Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ch32v003fun
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Horn
ch32v003fun
Commits
8350bccf
Commit
8350bccf
authored
1 year ago
by
Eric Brombaugh
Browse files
Options
Downloads
Patches
Plain Diff
Cycle through graphic test modes
parent
f971695d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/i2c_oled/i2c_oled.c
+64
-42
64 additions, 42 deletions
examples/i2c_oled/i2c_oled.c
with
64 additions
and
42 deletions
examples/i2c_oled/i2c_oled.c
+
64
−
42
View file @
8350bccf
...
...
@@ -13,8 +13,7 @@
int
main
()
{
uint32_t
count
=
0
;
// 48MHz internal clock
SystemInit48HSI
();
// start serial @ default 115200bps
...
...
@@ -27,49 +26,72 @@ int main()
printf
(
"initializing i2c oled..."
);
if
(
!
oled_init
())
{
//memset(oled_buffer, 0, sizeof(oled_buffer));
//for(int i=0;i<sizeof(oled_buffer);i++)
// oled_buffer[i] = i;
//for(int i=0;i<OLED_W;i++)
//{
// oled_drawPixel(i, i>>2, 1);
// oled_drawPixel(i, OLED_H-1-(i>>2), 1);
//}
//uint8_t y= 0;
//for(uint8_t x=0;x<OLED_W;x+=16)
//{
// oled_drawLine(x, 0, OLED_W, y, 1);
// oled_drawLine(OLED_W-x, OLED_H, 0, OLED_H-y, 1);
// y+= 4;
//}
//for(uint8_t x=0;x<OLED_W;x+=16)
// if(x<64)
// oled_drawCircle(x,16, 15, 1);
// else
// oled_fillCircle(x,16, 15, 1);
oled_drawstr
(
0
,
0
,
"This is a test"
,
1
);
oled_drawstr
(
0
,
8
,
"of the emergency"
,
1
);
oled_drawstr
(
0
,
16
,
"broadcasting"
,
1
);
oled_drawstr
(
0
,
24
,
"system."
,
1
);
oled_xorrect
(
64
,
0
,
64
,
32
);
oled_refresh
();
printf
(
"done.
\n\r
"
);
printf
(
"Looping on test modes..."
);
while
(
1
)
{
for
(
uint8_t
mode
=
0
;
mode
<
5
;
mode
++
)
{
// clear buffer for next mode
oled_setbuf
(
0
);
switch
(
mode
)
{
case
0
:
for
(
int
i
=
0
;
i
<
sizeof
(
oled_buffer
);
i
++
)
oled_buffer
[
i
]
=
i
;
break
;
case
1
:
for
(
int
i
=
0
;
i
<
OLED_W
;
i
++
)
{
oled_drawPixel
(
i
,
i
>>
2
,
1
);
oled_drawPixel
(
i
,
OLED_H
-
1
-
(
i
>>
2
),
1
);
}
break
;
case
2
:
{
uint8_t
y
=
0
;
for
(
uint8_t
x
=
0
;
x
<
OLED_W
;
x
+=
16
)
{
oled_drawLine
(
x
,
0
,
OLED_W
,
y
,
1
);
oled_drawLine
(
OLED_W
-
x
,
OLED_H
,
0
,
OLED_H
-
y
,
1
);
y
+=
4
;
}
}
break
;
case
3
:
for
(
uint8_t
x
=
0
;
x
<
OLED_W
;
x
+=
16
)
if
(
x
<
64
)
oled_drawCircle
(
x
,
16
,
15
,
1
);
else
oled_fillCircle
(
x
,
16
,
15
,
1
);
break
;
case
4
:
oled_drawstr
(
0
,
0
,
"This is a test"
,
1
);
oled_drawstr
(
0
,
8
,
"of the emergency"
,
1
);
oled_drawstr
(
0
,
16
,
"broadcasting"
,
1
);
oled_drawstr
(
0
,
24
,
"system."
,
1
);
oled_xorrect
(
64
,
0
,
64
,
32
);
break
;
default:
break
;
}
oled_refresh
();
Delay_Ms
(
2000
);
}
}
}
else
printf
(
"failed.
\n\r
"
);
printf
(
"looping...
\n\r
"
);
while
(
1
)
{
count
++
;
count
&=
255
;
Delay_Ms
(
5
);
}
printf
(
"Stuck here forever...
\n\r
"
);
while
(
1
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment