Merge pull request #667 from devsaurus/dev

Improve u8g Lua examples
This commit is contained in:
devsaurus 2015-09-24 23:27:22 +02:00
commit cb0f32d677
2 changed files with 142 additions and 124 deletions

View File

@ -61,7 +61,33 @@ function draw(draw_state)
end end
function bitmap_test(delay) function bitmap_test()
dir = 0
next_rotation = 0
disp:firstPage()
repeat
draw(draw_state)
until disp:nextPage() == false
if (draw_state <= 7 + 1*8) then
draw_state = draw_state + 1
else
print("--- Restarting Bitmap Test ---")
draw_state = 1
end
print("Heap: " .. node.heap())
-- retrigger timer to give room for system housekeeping
tmr.start(0)
end
draw_state = 1
init_i2c_display()
--init_spi_display()
-- read XBM picture -- read XBM picture
file.open("u8glib_logo.xbm", "r") file.open("u8glib_logo.xbm", "r")
xbm_data = file.read() xbm_data = file.read()
@ -72,24 +98,9 @@ function bitmap_test(delay)
bm_data = file.read() bm_data = file.read()
file.close() 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 ---") print("--- Starting Bitmap Test ---")
dir = 0 tmr.start(0)
next_rotation = 0
local draw_state
for draw_state = 1, 7 + 1*8, 1 do
disp:firstPage()
repeat
draw(draw_state)
until disp:nextPage() == false
tmr.delay(delay)
tmr.wdclr()
end
print("--- Bitmap Test done ---")
end
--init_i2c_display()
init_spi_display()
bitmap_test(50000)

View File

@ -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)