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
8e42631a
Commit
8e42631a
authored
Feb 19, 2015
by
devsaurus
Browse files
implement drawBitmap
parent
a2870200
Changes
4
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
8e42631a
...
@@ -368,9 +368,9 @@ They'll be available as `u8g.<font_name>` in Lua.
...
@@ -368,9 +368,9 @@ They'll be available as `u8g.<font_name>` in Lua.
-
[ ] setCursorFont()
-
[ ] setCursorFont()
-
[ ] setCursorPos()
-
[ ] setCursorPos()
-
[ ] setCursorStyle()
-
[ ] setCursorStyle()
-
[
] Bitmaps
-
[
x
] Bitmaps
-
[
] drawBitmap()
-
[
x
] drawBitmap()
-
[
] drawXBM()
-
[
x
] drawXBM()
-
[ ] General functions
-
[ ] General functions
-
[x] begin()
-
[x] begin()
-
[ ] print()
-
[ ] print()
...
...
app/modules/u8g.c
View file @
8e42631a
...
@@ -596,6 +596,26 @@ static int lu8g_drawXBM( lua_State *L )
...
@@ -596,6 +596,26 @@ static int lu8g_drawXBM( lua_State *L )
return
0
;
return
0
;
}
}
// Lua: u8g.drawBitmap( self, x, y, count, height, data )
static
int
lu8g_drawBitmap
(
lua_State
*
L
)
{
lu8g_userdata_t
*
lud
;
if
((
lud
=
get_lud
(
L
))
==
NULL
)
return
0
;
u8g_uint_t
args
[
4
];
lu8g_get_int_args
(
L
,
2
,
4
,
args
);
const
char
*
bm_data
=
luaL_checkstring
(
L
,
(
1
+
4
)
+
1
);
if
(
bm_data
==
NULL
)
return
0
;
u8g_DrawBitmap
(
lud
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
(
const
uint8_t
*
)
bm_data
);
return
0
;
}
// Lua: u8g.setScale2x2( self )
// Lua: u8g.setScale2x2( self )
static
int
lu8g_setScale2x2
(
lua_State
*
L
)
static
int
lu8g_setScale2x2
(
lua_State
*
L
)
{
{
...
@@ -951,6 +971,7 @@ static const LUA_REG_TYPE lu8g_display_map[] =
...
@@ -951,6 +971,7 @@ static const LUA_REG_TYPE lu8g_display_map[] =
{
LSTRKEY
(
"drawPixel"
),
LFUNCVAL
(
lu8g_drawPixel
)
},
{
LSTRKEY
(
"drawPixel"
),
LFUNCVAL
(
lu8g_drawPixel
)
},
{
LSTRKEY
(
"drawHLine"
),
LFUNCVAL
(
lu8g_drawHLine
)
},
{
LSTRKEY
(
"drawHLine"
),
LFUNCVAL
(
lu8g_drawHLine
)
},
{
LSTRKEY
(
"drawVLine"
),
LFUNCVAL
(
lu8g_drawVLine
)
},
{
LSTRKEY
(
"drawVLine"
),
LFUNCVAL
(
lu8g_drawVLine
)
},
{
LSTRKEY
(
"drawBitmap"
),
LFUNCVAL
(
lu8g_drawBitmap
)
},
{
LSTRKEY
(
"drawXBM"
),
LFUNCVAL
(
lu8g_drawXBM
)
},
{
LSTRKEY
(
"drawXBM"
),
LFUNCVAL
(
lu8g_drawXBM
)
},
{
LSTRKEY
(
"setScale2x2"
),
LFUNCVAL
(
lu8g_setScale2x2
)
},
{
LSTRKEY
(
"setScale2x2"
),
LFUNCVAL
(
lu8g_setScale2x2
)
},
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lu8g_undoScale
)
},
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lu8g_undoScale
)
},
...
...
lua_examples/u8g_bitmaps.lua
View file @
8e42631a
...
@@ -15,11 +15,11 @@ function xbm_picture()
...
@@ -15,11 +15,11 @@ function xbm_picture()
disp
:
drawXBM
(
0
,
20
,
38
,
24
,
xbm_data
)
disp
:
drawXBM
(
0
,
20
,
38
,
24
,
xbm_data
)
end
end
function
bitmap_picture
()
function
bitmap_picture
(
state
)
disp
:
setFont
(
u8g
.
font_6x10
)
disp
:
setFont
(
u8g
.
font_6x10
)
disp
:
drawStr
(
0
,
10
,
"Bitmap picture"
)
disp
:
drawStr
(
0
,
10
,
"Bitmap picture"
)
--
disp:draw
XBM( 0, 20, 38, 24, bitmap
_data )
disp
:
draw
Bitmap
(
0
+
(
state
*
10
),
20
+
(
state
*
4
),
1
,
8
,
bm
_data
)
end
end
-- the draw() routine
-- the draw() routine
...
@@ -42,12 +42,17 @@ function bitmap_test()
...
@@ -42,12 +42,17 @@ function bitmap_test()
xbm_data
=
file
.
read
()
xbm_data
=
file
.
read
()
file
.
close
()
file
.
close
()
-- read Bitmap picture
file
.
open
(
"u8g_rook.bm"
,
"r"
)
bm_data
=
file
.
read
()
file
.
close
()
print
(
"--- Starting Bitmap Test ---"
)
print
(
"--- Starting Bitmap Test ---"
)
dir
=
0
dir
=
0
next_rotation
=
0
next_rotation
=
0
local
draw_state
local
draw_state
for
draw_state
=
1
,
7
+
0
*
8
,
1
do
for
draw_state
=
1
,
7
+
1
*
8
,
1
do
disp
:
firstPage
()
disp
:
firstPage
()
repeat
repeat
draw
(
draw_state
)
draw
(
draw_state
)
...
...
lua_examples/u8g_rook.bm
0 → 100644
View file @
8e42631a
File added
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