Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
4e235d84
Commit
4e235d84
authored
Sep 24, 2015
by
devsaurus
Browse files
improve u8g lua examples
parent
f5ae0ed7
Changes
2
Show whitespace changes
Inline
Side-by-side
lua_examples/u8glib/u8g_bitmaps.lua
View file @
4e235d84
...
@@ -61,35 +61,46 @@ function draw(draw_state)
...
@@ -61,35 +61,46 @@ function draw(draw_state)
end
end
function
bitmap_test
(
delay
)
function
bitmap_test
()
-- read XBM picture
file
.
open
(
"u8glib_logo.xbm"
,
"r"
)
xbm_data
=
file
.
read
()
file
.
close
()
-- read Bitmap picture
file
.
open
(
"u8g_rook.bm"
,
"r"
)
bm_data
=
file
.
read
()
file
.
close
()
print
(
"--- Starting Bitmap Test ---"
)
dir
=
0
dir
=
0
next_rotation
=
0
next_rotation
=
0
local
draw_state
for
draw_state
=
1
,
7
+
1
*
8
,
1
do
disp
:
firstPage
()
disp
:
firstPage
()
repeat
repeat
draw
(
draw_state
)
draw
(
draw_state
)
until
disp
:
nextPage
()
==
false
until
disp
:
nextPage
()
==
false
tmr
.
delay
(
delay
)
if
(
draw_state
<=
7
+
1
*
8
)
then
tmr
.
wdclr
()
draw_state
=
draw_state
+
1
else
print
(
"--- Restarting Bitmap Test ---"
)
draw_state
=
1
end
end
print
(
"--- Bitmap Test done ---"
)
print
(
"Heap: "
..
node
.
heap
())
-- retrigger timer to give room for system housekeeping
tmr
.
start
(
0
)
end
end
--init_i2c_display()
draw_state
=
1
init_spi_display
()
bitmap_test
(
50000
)
init_i2c_display
()
--init_spi_display()
-- read XBM picture
file
.
open
(
"u8glib_logo.xbm"
,
"r"
)
xbm_data
=
file
.
read
()
file
.
close
()
-- read Bitmap picture
file
.
open
(
"u8g_rook.bm"
,
"r"
)
bm_data
=
file
.
read
()
file
.
close
()
-- set up timer 0 with short interval, will be retriggered in graphics_test()
tmr
.
register
(
0
,
100
,
tmr
.
ALARM_SEMI
,
function
()
bitmap_test
()
end
)
print
(
"--- Starting Bitmap Test ---"
)
tmr
.
start
(
0
)
lua_examples/u8glib/u8g_graphics_test.lua
View file @
4e235d84
...
@@ -134,25 +134,32 @@ function draw(draw_state)
...
@@ -134,25 +134,32 @@ function draw(draw_state)
end
end
end
end
function
graphics_test
(
delay
)
function
graphics_test
()
print
(
"--- Starting Graphics Test ---"
)
-- cycle through all components
local
draw_state
for
draw_state
=
0
,
7
+
8
*
8
,
1
do
disp
:
firstPage
()
disp
:
firstPage
()
repeat
repeat
draw
(
draw_state
)
draw
(
draw_state
)
until
disp
:
nextPage
()
==
false
until
disp
:
nextPage
()
==
false
--print(node.heap())
tmr
.
delay
(
delay
)
if
(
draw_state
<=
7
+
8
*
8
)
then
-- re-trigger Watchdog!
draw_state
=
draw_state
+
1
tmr
.
wdclr
()
else
print
(
"--- Restarting Graphics Test ---"
)
draw_state
=
0
end
end
print
(
"--- Graphics Test done ---"
)
print
(
"Heap: "
..
node
.
heap
())
-- retrigger timer to give room for system housekeeping
tmr
.
start
(
0
)
end
end
--init_i2c_display()
draw_state
=
0
init_spi_display
()
graphics_test
(
50000
)
init_i2c_display
()
--init_spi_display()
-- set up timer 0 with short interval, will be retriggered in graphics_test()
tmr
.
register
(
0
,
100
,
tmr
.
ALARM_SEMI
,
function
()
graphics_test
()
end
)
print
(
"--- Starting Graphics Test ---"
)
tmr
.
start
(
0
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment