res optional

This commit is contained in:
devsaurus 2015-03-13 22:22:57 +01:00
parent 429bf57d67
commit 3b37f0920c
1 changed files with 4 additions and 3 deletions

View File

@ -1037,7 +1037,7 @@ static int lu8g_ssd1306_128x64_i2c( lua_State *L )
return 1;
}
// Lua: object = u8g.ssd1306_128x64_spi( cs, dc )
// Lua: object = u8g.ssd1306_128x64_spi( cs, dc, [res] )
static int lu8g_ssd1306_128x64_spi( lua_State *L )
{
unsigned cs = luaL_checkinteger( L, 1 );
@ -1046,6 +1046,7 @@ static int lu8g_ssd1306_128x64_spi( lua_State *L )
unsigned dc = luaL_checkinteger( L, 2 );
if (dc == 0)
return luaL_error( L, "D/C pin required" );
unsigned res = luaL_optinteger( L, 3, U8G_PIN_NONE );
lu8g_userdata_t *lud = (lu8g_userdata_t *) lua_newuserdata( L, sizeof( lu8g_userdata_t ) );
@ -1069,9 +1070,9 @@ static int lu8g_ssd1306_128x64_spi( lua_State *L )
return luaL_error( L, "out of memory" );
// and finally init device using specific interface init function
u8g_InitHWSPI( LU8G, &(lud->dev), cs, dc, U8G_PIN_NONE );
u8g_InitHWSPI( LU8G, &(lud->dev), cs, dc, res );
#else
u8g_InitHWSPI( LU8G, &u8g_dev_ssd1306_128x64_spi, cs, dc, U8G_PIN_NONE );
u8g_InitHWSPI( LU8G, &u8g_dev_ssd1306_128x64_spi, cs, dc, res );
#endif