Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
esp8266-oled-ssd1306
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
Container Registry
Model registry
Operate
Environments
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
c3pb
esp8266-oled-ssd1306
Commits
23e8f775
Commit
23e8f775
authored
8 years ago
by
Daniel Eichhorn
Browse files
Options
Downloads
Patches
Plain Diff
Added more demos
parent
57e2ff32
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/SimpleSSD1306Demo/SimpleSSD1306Demo.ino
+28
-15
28 additions, 15 deletions
examples/SimpleSSD1306Demo/SimpleSSD1306Demo.ino
with
28 additions
and
15 deletions
examples/SimpleSSD1306Demo/SimpleSSD1306Demo.ino
+
28
−
15
View file @
23e8f775
...
...
@@ -27,8 +27,7 @@
#include
"SSD1306.h"
#include
"images.h"
#define DEMO_SPEED 500
#define NUMBER_OF_DEMOS 5
#define DEMO_DURATION 3000
typedef
void
(
*
Demo
)(
void
);
// Initialize the OLED display on address 0x3c
...
...
@@ -54,7 +53,7 @@ void setup() {
}
void
f
ontFaceDemo
()
{
void
drawF
ontFaceDemo
()
{
// Font Demo1
// create more fonts at http://oleddisplay.squix.ch/
display
.
setTextAlignment
(
TEXT_ALIGN_LEFT
);
...
...
@@ -66,13 +65,14 @@ void fontFaceDemo() {
display
.
drawString
(
0
,
26
,
"Hello world"
);
}
void
t
extFlowDemo
()
{
void
drawT
extFlowDemo
()
{
display
.
setFont
(
ArialMT_Plain_10
);
display
.
setTextAlignment
(
TEXT_ALIGN_LEFT
);
display
.
drawStringMaxWidth
(
0
,
0
,
128
,
"Lorem ipsum
\n
dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore."
);
}
void
t
extAlignmentDemo
()
{
void
drawT
extAlignmentDemo
()
{
// Text alignment demo
display
.
setFont
(
ArialMT_Plain_10
);
...
...
@@ -105,12 +105,9 @@ void drawRectDemo() {
// Draw a line horizontally
display
.
drawVerticalLine
(
40
,
0
,
20
);
// this demo is too fast otherwise
delay
(
10
);
}
void
c
ircleDemo
()
{
void
drawC
ircleDemo
()
{
for
(
int
i
=
1
;
i
<
8
;
i
++
)
{
display
.
setColor
(
WHITE
);
display
.
drawCircle
(
32
,
32
,
i
*
3
);
...
...
@@ -119,28 +116,44 @@ void circleDemo() {
}
display
.
fillCircle
(
96
,
32
,
32
-
i
*
3
);
}
delay
(
25
);
}
void
progressBarDemo
()
{
display
.
drawProgressBar
(
0
,
32
,
120
,
16
,
(
counter
/
5
)
%
100
);
void
drawProgressBarDemo
()
{
int
progress
=
(
counter
/
5
)
%
100
;
// draw the progress bar
display
.
drawProgressBar
(
0
,
32
,
120
,
10
,
progress
);
// draw the percentage as String
display
.
setTextAlignment
(
TEXT_ALIGN_CENTER
);
display
.
drawString
(
64
,
15
,
String
(
progress
)
+
"%"
);
}
Demo
demos
[]
=
{
progressBarDemo
,
/*fontFaceDemo, textFlowDemo, textAlignmentDemo, drawRectDemo, circleDemo*/
};
void
drawImageDemo
()
{
// see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
// on how to create xbm files
display
.
drawXbm
(
34
,
14
,
WiFi_Logo_width
,
WiFi_Logo_height
,
WiFi_Logo_bits
);
}
Demo
demos
[]
=
{
drawFontFaceDemo
,
drawTextFlowDemo
,
drawTextAlignmentDemo
,
drawRectDemo
,
drawCircleDemo
,
drawProgressBarDemo
,
drawImageDemo
};
int
demoLength
=
(
sizeof
(
demos
)
/
sizeof
(
Demo
));
long
timeSinceLastModeSwitch
=
0
;
void
loop
()
{
// clear the display
display
.
clear
();
// draw the current demo method
demos
[
demoMode
]();
display
.
setTextAlignment
(
TEXT_ALIGN_RIGHT
);
display
.
drawString
(
10
,
128
,
String
(
millis
()));
// write the buffer to the display
display
.
display
();
if
(
counter
%
DEMO_SPEED
==
0
)
{
if
(
millis
()
-
timeSinceLastModeSwitch
>
DEMO_DURATION
)
{
demoMode
=
(
demoMode
+
1
)
%
demoLength
;
Serial
.
println
(
String
(
counter
)
+
": "
+
String
(
demoMode
)
);
timeSinceLastModeSwitch
=
millis
(
);
}
counter
++
;
delay
(
10
);
}
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