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
a2870200
Commit
a2870200
authored
Feb 18, 2015
by
devsaurus
Browse files
implement drawXBM
parent
4fd11fdf
Changes
3
Show whitespace changes
Inline
Side-by-side
app/modules/u8g.c
View file @
a2870200
...
@@ -576,6 +576,26 @@ static int lu8g_drawVLine( lua_State *L )
...
@@ -576,6 +576,26 @@ static int lu8g_drawVLine( lua_State *L )
return
0
;
return
0
;
}
}
// Lua: u8g.drawXBM( self, x, y, width, height, data )
static
int
lu8g_drawXBM
(
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
*
xbm_data
=
luaL_checkstring
(
L
,
(
1
+
4
)
+
1
);
if
(
xbm_data
==
NULL
)
return
0
;
u8g_DrawXBM
(
lud
,
args
[
0
],
args
[
1
],
args
[
2
],
args
[
3
],
(
const
uint8_t
*
)
xbm_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
)
{
{
...
@@ -931,6 +951,7 @@ static const LUA_REG_TYPE lu8g_display_map[] =
...
@@ -931,6 +951,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
(
"drawXBM"
),
LFUNCVAL
(
lu8g_drawXBM
)
},
{
LSTRKEY
(
"setScale2x2"
),
LFUNCVAL
(
lu8g_setScale2x2
)
},
{
LSTRKEY
(
"setScale2x2"
),
LFUNCVAL
(
lu8g_setScale2x2
)
},
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lu8g_undoScale
)
},
{
LSTRKEY
(
"undoScale"
),
LFUNCVAL
(
lu8g_undoScale
)
},
{
LSTRKEY
(
"firstPage"
),
LFUNCVAL
(
lu8g_firstPage
)
},
{
LSTRKEY
(
"firstPage"
),
LFUNCVAL
(
lu8g_firstPage
)
},
...
...
lua_examples/u8g_bitmaps.lua
0 → 100644
View file @
a2870200
-- 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
function
xbm_picture
()
disp
:
setFont
(
u8g
.
font_6x10
)
disp
:
drawStr
(
0
,
10
,
"XBM picture"
)
disp
:
drawXBM
(
0
,
20
,
38
,
24
,
xbm_data
)
end
function
bitmap_picture
()
disp
:
setFont
(
u8g
.
font_6x10
)
disp
:
drawStr
(
0
,
10
,
"Bitmap picture"
)
--disp:drawXBM( 0, 20, 38, 24, bitmap_data )
end
-- the draw() routine
function
draw
(
draw_state
)
local
component
=
bit
.
rshift
(
draw_state
,
3
)
if
(
component
==
0
)
then
xbm_picture
(
bit
.
band
(
draw_state
,
7
))
elseif
(
component
==
1
)
then
bitmap_picture
(
bit
.
band
(
draw_state
,
7
))
end
end
function
bitmap_test
()
init_i2c_display
()
-- read XBM picture
file
.
open
(
"u8glib_logo.xbm"
,
"r"
)
xbm_data
=
file
.
read
()
file
.
close
()
print
(
"--- Starting Bitmap Test ---"
)
dir
=
0
next_rotation
=
0
local
draw_state
for
draw_state
=
1
,
7
+
0
*
8
,
1
do
disp
:
firstPage
()
repeat
draw
(
draw_state
)
until
disp
:
nextPage
()
==
false
tmr
.
wdclr
()
end
print
(
"--- Bitmap Test done ---"
)
end
bitmap_test
()
lua_examples/u8glib_logo.xbm
0 → 100644
View file @
a2870200
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