implement drawBitmap
This commit is contained in:
parent
a287020096
commit
8e42631a81
|
@ -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()
|
||||||
|
|
|
@ -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[] =
|
||||||
{ 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 ) },
|
||||||
|
|
|
@ -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:drawXBM( 0, 20, 38, 24, bitmap_data )
|
disp:drawBitmap( 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()
|
||||||
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)
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue