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
a6f6a1e3
Commit
a6f6a1e3
authored
Feb 08, 2015
by
devsaurus
Browse files
add rotation and aspect ration functions for rotation test
parent
145a0f01
Changes
2
Hide whitespace changes
Inline
Side-by-side
lua_examples/graphics_test.lua
→
lua_examples/
u8g_
graphics_test.lua
View file @
a6f6a1e3
File moved
lua_examples/u8g_rotation.lua
0 → 100644
View file @
a6f6a1e3
-- setup I2c and connect display
function
init_i2c_display
()
sda
=
5
scl
=
6
sla
=
0x3c
i2c
.
setup
(
0
,
sda
,
scl
,
i2c
.
SLOW
)
disp
=
u8g
.
ssd1306_128x64_i2c
(
sla
)
end
-- the draw() routine
function
draw
()
disp
:
setFont
(
u8g
.
font_6x10
)
disp
:
drawStr
(
0
+
0
,
20
+
0
,
"Hello!"
)
disp
:
drawStr
(
0
+
2
,
20
+
16
,
"Hello!"
)
disp
:
drawBox
(
0
,
0
,
3
,
3
)
disp
:
drawBox
(
disp
:
getWidth
()
-
6
,
0
,
6
,
6
)
disp
:
drawBox
(
disp
:
getWidth
()
-
9
,
disp
:
getHeight
()
-
9
,
9
,
9
)
disp
:
drawBox
(
0
,
disp
:
getHeight
()
-
12
,
12
,
12
)
end
function
rotate
()
if
(
next_rotation
<
tmr
.
now
()
/
1000
)
then
if
(
dir
==
0
)
then
disp
:
undoRotation
()
elseif
(
dir
==
1
)
then
disp
:
setRot90
()
elseif
(
dir
==
2
)
then
disp
:
setRot180
()
elseif
(
dir
==
3
)
then
disp
:
setRot270
()
end
dir
=
dir
+
1
dir
=
bit
.
band
(
dir
,
3
)
next_rotation
=
tmr
.
now
()
/
1000
+
1000
end
end
function
rotation_test
()
init_i2c_display
()
print
(
"--- Starting Rotation Test ---"
)
dir
=
0
next_rotation
=
0
local
loopcnt
for
loopcnt
=
1
,
100
,
1
do
rotate
()
disp
:
firstPage
()
repeat
draw
(
draw_state
)
until
disp
:
nextPage
()
==
false
tmr
.
wdclr
()
end
print
(
"--- Rotation Test done ---"
)
end
rotation_test
()
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