diff --git a/app/modules/u8g.c b/app/modules/u8g.c index f08bb416..a94639ce 100644 --- a/app/modules/u8g.c +++ b/app/modules/u8g.c @@ -310,6 +310,32 @@ static int lu8g_drawCircle( lua_State *L ) return 0; } +// Lua: u8g.setScale2x2( self ) +static int lu8g_setScale2x2( lua_State *L ) +{ + lu8g_userdata_t *lud; + + if ((lud = get_lud( L )) == NULL) + return 0; + + u8g_SetScale2x2( lud ); + + return 0; +} + +// Lua: u8g.undoScale( self ) +static int lu8g_undoScale( lua_State *L ) +{ + lu8g_userdata_t *lud; + + if ((lud = get_lud( L )) == NULL) + return 0; + + u8g_UndoScale( lud ); + + return 0; +} + // Lua: u8g.firstPage( self ) static int lu8g_firstPage( lua_State *L ) { @@ -517,6 +543,8 @@ static const LUA_REG_TYPE lu8g_display_map[] = { LSTRKEY( "drawRFrame" ), LFUNCVAL( lu8g_drawRFrame ) }, { LSTRKEY( "drawDisc" ), LFUNCVAL( lu8g_drawDisc ) }, { LSTRKEY( "drawCircle" ), LFUNCVAL( lu8g_drawCircle ) }, + { LSTRKEY( "setScale2x2" ), LFUNCVAL( lu8g_setScale2x2 ) }, + { LSTRKEY( "undoScale" ), LFUNCVAL( lu8g_undoScale ) }, { LSTRKEY( "firstPage" ), LFUNCVAL( lu8g_firstPage ) }, { LSTRKEY( "nextPage" ), LFUNCVAL( lu8g_nextPage ) }, #if LUA_OPTIMIZE_MEMORY > 0 diff --git a/lua_examples/graphics_test.lua b/lua_examples/graphics_test.lua index 5885fa08..edadf872 100644 --- a/lua_examples/graphics_test.lua +++ b/lua_examples/graphics_test.lua @@ -87,6 +87,13 @@ function ascii_2() end end +function extra_page(a) + disp:drawStr(0, 12, "setScale2x2") + disp:setScale2x2() + disp:drawStr(0, 6+a, "setScale2x2") + disp:undoScale() +end + -- the draw() routine function draw(draw_state) @@ -110,6 +117,8 @@ function draw(draw_state) ascii_1() elseif (component == 7) then ascii_2() + elseif (component == 8) then + extra_page(bit.band(draw_state, 7)) end end @@ -120,7 +129,7 @@ function graphics_test() -- cycle through all components local draw_state - for draw_state = 0, 7 + 7*8, 1 do + for draw_state = 0, 7 + 8*8, 1 do disp:firstPage() repeat draw(draw_state)