Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
25b4285c
Commit
25b4285c
authored
Apr 18, 2016
by
Arnim Läuger
Committed by
Marcel Stör
Apr 18, 2016
Browse files
update examples to task posting (#1249)
parent
4710f73c
Changes
3
Show whitespace changes
Inline
Side-by-side
lua_examples/u8glib/u8g_bitmaps.lua
View file @
25b4285c
...
@@ -25,12 +25,16 @@ function init_spi_display()
...
@@ -25,12 +25,16 @@ function init_spi_display()
-- Hardware SPI CLK = GPIO14
-- Hardware SPI CLK = GPIO14
-- Hardware SPI MOSI = GPIO13
-- Hardware SPI MOSI = GPIO13
-- Hardware SPI MISO = GPIO12 (not used)
-- Hardware SPI MISO = GPIO12 (not used)
-- Hardware SPI /CS = GPIO15 (not used)
-- CS, D/C, and RES can be assigned freely to available GPIOs
-- CS, D/C, and RES can be assigned freely to available GPIOs
local
cs
=
8
-- GPIO15, pull-down 10k to GND
local
cs
=
8
-- GPIO15, pull-down 10k to GND
local
dc
=
4
-- GPIO2
local
dc
=
4
-- GPIO2
local
res
=
0
-- GPIO16
local
res
=
0
-- GPIO16
spi
.
setup
(
1
,
spi
.
MASTER
,
spi
.
CPOL_LOW
,
spi
.
CPHA_LOW
,
8
,
8
)
spi
.
setup
(
1
,
spi
.
MASTER
,
spi
.
CPOL_LOW
,
spi
.
CPHA_LOW
,
8
,
8
)
-- we won't be using the HSPI /CS line, so disable it again
gpio
.
mode
(
8
,
gpio
.
INPUT
,
gpio
.
PULLUP
)
disp
=
u8g
.
ssd1306_128x64_hw_spi
(
cs
,
dc
,
res
)
disp
=
u8g
.
ssd1306_128x64_hw_spi
(
cs
,
dc
,
res
)
end
end
...
@@ -61,14 +65,22 @@ function draw(draw_state)
...
@@ -61,14 +65,22 @@ function draw(draw_state)
end
end
function
bitmap_test
()
function
draw_loop
()
dir
=
0
-- Draws one page and schedules the next page, if there is one
next_rotation
=
0
local
function
draw_pages
()
disp
:
firstPage
()
repeat
draw
(
draw_state
)
draw
(
draw_state
)
until
disp
:
nextPage
()
==
false
if
disp
:
nextPage
()
then
node
.
task
.
post
(
draw_pages
)
else
node
.
task
.
post
(
bitmap_test
)
end
end
-- Restart the draw loop and start drawing pages
disp
:
firstPage
()
node
.
task
.
post
(
draw_pages
)
end
function
bitmap_test
()
if
(
draw_state
<=
7
+
1
*
8
)
then
if
(
draw_state
<=
7
+
1
*
8
)
then
draw_state
=
draw_state
+
1
draw_state
=
draw_state
+
1
...
@@ -78,8 +90,8 @@ function bitmap_test()
...
@@ -78,8 +90,8 @@ function bitmap_test()
end
end
print
(
"Heap: "
..
node
.
heap
())
print
(
"Heap: "
..
node
.
heap
())
-- retrigger
timer to give room for system housekeeping
-- retrigger
draw_loop
tmr
.
start
(
0
)
node
.
task
.
post
(
draw_loop
)
end
end
...
@@ -99,8 +111,5 @@ bm_data = file.read()
...
@@ -99,8 +111,5 @@ 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 ---"
)
tmr
.
start
(
0
)
node
.
task
.
post
(
draw_loop
)
lua_examples/u8glib/u8g_graphics_test.lua
View file @
25b4285c
...
@@ -24,12 +24,16 @@ function init_spi_display()
...
@@ -24,12 +24,16 @@ function init_spi_display()
-- Hardware SPI CLK = GPIO14
-- Hardware SPI CLK = GPIO14
-- Hardware SPI MOSI = GPIO13
-- Hardware SPI MOSI = GPIO13
-- Hardware SPI MISO = GPIO12 (not used)
-- Hardware SPI MISO = GPIO12 (not used)
-- Hardware SPI /CS = GPIO15 (not used)
-- CS, D/C, and RES can be assigned freely to available GPIOs
-- CS, D/C, and RES can be assigned freely to available GPIOs
local
cs
=
8
-- GPIO15, pull-down 10k to GND
local
cs
=
8
-- GPIO15, pull-down 10k to GND
local
dc
=
4
-- GPIO2
local
dc
=
4
-- GPIO2
local
res
=
0
-- GPIO16
local
res
=
0
-- GPIO16
spi
.
setup
(
1
,
spi
.
MASTER
,
spi
.
CPOL_LOW
,
spi
.
CPHA_LOW
,
8
,
8
)
spi
.
setup
(
1
,
spi
.
MASTER
,
spi
.
CPOL_LOW
,
spi
.
CPHA_LOW
,
8
,
8
)
-- we won't be using the HSPI /CS line, so disable it again
gpio
.
mode
(
8
,
gpio
.
INPUT
,
gpio
.
PULLUP
)
disp
=
u8g
.
ssd1306_128x64_hw_spi
(
cs
,
dc
,
res
)
disp
=
u8g
.
ssd1306_128x64_hw_spi
(
cs
,
dc
,
res
)
end
end
...
@@ -134,12 +138,22 @@ function draw(draw_state)
...
@@ -134,12 +138,22 @@ function draw(draw_state)
end
end
end
end
function
graphics_test
()
function
draw_loop
()
-- Draws one page and schedules the next page, if there is one
disp
:
firstPage
()
local
function
draw_pages
()
repeat
draw
(
draw_state
)
draw
(
draw_state
)
until
disp
:
nextPage
()
==
false
if
disp
:
nextPage
()
then
node
.
task
.
post
(
draw_pages
)
else
node
.
task
.
post
(
graphics_test
)
end
end
-- Restart the draw loop and start drawing pages
disp
:
firstPage
()
node
.
task
.
post
(
draw_pages
)
end
function
graphics_test
()
if
(
draw_state
<=
7
+
8
*
8
)
then
if
(
draw_state
<=
7
+
8
*
8
)
then
draw_state
=
draw_state
+
1
draw_state
=
draw_state
+
1
...
@@ -149,8 +163,9 @@ function graphics_test()
...
@@ -149,8 +163,9 @@ function graphics_test()
end
end
print
(
"Heap: "
..
node
.
heap
())
print
(
"Heap: "
..
node
.
heap
())
-- retrigger timer to give room for system housekeeping
-- retrigger draw_loop
tmr
.
start
(
0
)
node
.
task
.
post
(
draw_loop
)
end
end
draw_state
=
0
draw_state
=
0
...
@@ -158,8 +173,5 @@ draw_state = 0
...
@@ -158,8 +173,5 @@ draw_state = 0
init_i2c_display
()
init_i2c_display
()
--init_spi_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 ---"
)
print
(
"--- Starting Graphics Test ---"
)
tmr
.
start
(
0
)
node
.
task
.
post
(
draw_loop
)
lua_examples/u8glib/u8g_rotation.lua
View file @
25b4285c
...
@@ -25,12 +25,16 @@ function init_spi_display()
...
@@ -25,12 +25,16 @@ function init_spi_display()
-- Hardware SPI CLK = GPIO14
-- Hardware SPI CLK = GPIO14
-- Hardware SPI MOSI = GPIO13
-- Hardware SPI MOSI = GPIO13
-- Hardware SPI MISO = GPIO12 (not used)
-- Hardware SPI MISO = GPIO12 (not used)
-- Hardware SPI /CS = GPIO15 (not used)
-- CS, D/C, and RES can be assigned freely to available GPIOs
-- CS, D/C, and RES can be assigned freely to available GPIOs
local
cs
=
8
-- GPIO15, pull-down 10k to GND
local
cs
=
8
-- GPIO15, pull-down 10k to GND
local
dc
=
4
-- GPIO2
local
dc
=
4
-- GPIO2
local
res
=
0
-- GPIO16
local
res
=
0
-- GPIO16
spi
.
setup
(
1
,
spi
.
MASTER
,
spi
.
CPOL_LOW
,
spi
.
CPHA_LOW
,
8
,
8
)
spi
.
setup
(
1
,
spi
.
MASTER
,
spi
.
CPOL_LOW
,
spi
.
CPHA_LOW
,
8
,
8
)
-- we won't be using the HSPI /CS line, so disable it again
gpio
.
mode
(
8
,
gpio
.
INPUT
,
gpio
.
PULLUP
)
disp
=
u8g
.
ssd1306_128x64_hw_spi
(
cs
,
dc
,
res
)
disp
=
u8g
.
ssd1306_128x64_hw_spi
(
cs
,
dc
,
res
)
end
end
...
...
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