* increase irom0_0_seg size to accomodate u8glib code

* implement first functions for graphics test
This commit is contained in:
devsaurus 2015-01-31 23:08:06 +01:00
parent a2672113aa
commit 6b3abb004a
5 changed files with 297 additions and 38 deletions

View File

@ -19,22 +19,264 @@ typedef struct lu8g_userdata
} lu8g_userdata_t;
// Font look-up array
#define LU8G_FONT_6X10 0
// Lua: u8g.setup( self, id )
static int lu8g_setup( lua_State *L )
const static u8g_fntpgm_uint8_t *font_array[] =
{
unsigned id = luaL_checkinteger( L, 2 );
u8g_font_6x10
};
//MOD_CHECK_ID( u8g, id );
if (id == 0)
return luaL_error( L, "ID 0 not supported!" );
// Lua: u8g.setFont( self, font )
static int lu8g_setFont( lua_State *L )
{
lu8g_userdata_t *lud;
uint8_t stack = 1;
return 0;
lud = (lu8g_userdata_t *)luaL_checkudata(L, stack, "u8g.display");
luaL_argcheck(L, lud, stack, "u8g.display expected");
stack++;
if (lud == NULL)
return 0;
unsigned fontnr = luaL_checkinteger( L, stack );
stack++;
u8g_SetFont( &(lud->u8g), font_array[fontnr] );
return 0;
}
// Lua: u8g.setFontRefHeightExtendedText( self )
static int lu8g_setFontRefHeightExtendedText( lua_State *L )
{
lu8g_userdata_t *lud;
lud = (lu8g_userdata_t *)luaL_checkudata(L, 1, "u8g.display");
luaL_argcheck(L, lud, 1, "u8g.display expected");
if (lud == NULL)
return 0;
u8g_SetFontRefHeightExtendedText( &(lud->u8g) );
return 0;
}
// Lua: u8g.setDefaultForegroundColor( self )
static int lu8g_setDefaultForegroundColor( lua_State *L )
{
lu8g_userdata_t *lud;
lud = (lu8g_userdata_t *)luaL_checkudata(L, 1, "u8g.display");
luaL_argcheck(L, lud, 1, "u8g.display expected");
if (lud == NULL)
return 0;
u8g_SetDefaultForegroundColor( &(lud->u8g) );
return 0;
}
// Lua: u8g.setFontPosTop( self )
static int lu8g_setFontPosTop( lua_State *L )
{
lu8g_userdata_t *lud;
lud = (lu8g_userdata_t *)luaL_checkudata(L, 1, "u8g.display");
luaL_argcheck(L, lud, 1, "u8g.display expected");
if (lud == NULL)
return 0;
u8g_SetFontPosTop( &(lud->u8g) );
return 0;
}
// Lua: pix_len = u8g.drawStr( self, x, y, string )
static int lu8g_drawStr( lua_State *L )
{
lu8g_userdata_t *lud;
uint8_t stack = 1;
lud = (lu8g_userdata_t *)luaL_checkudata(L, stack, "u8g.display");
luaL_argcheck(L, lud, stack, "u8g.display expected");
stack++;
if (lud == NULL)
return 0;
u8g_uint_t x = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t y = luaL_checkinteger( L, stack );
stack++;
const char *s = luaL_checkstring( L, stack );
stack++;
if (s == NULL)
return 0;
lua_pushinteger( L, u8g_DrawStr( &(lud->u8g), x, y, s ) );
return 1;
}
// Lua: u8g.drawBox( self, x, y, width, height )
static int lu8g_drawBox( lua_State *L )
{
lu8g_userdata_t *lud;
uint8_t stack = 1;
lud = (lu8g_userdata_t *)luaL_checkudata(L, stack, "u8g.display");
luaL_argcheck(L, lud, stack, "u8g.display expected");
stack++;
if (lud == NULL)
return 0;
u8g_uint_t x = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t y = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t w = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t h = luaL_checkinteger( L, stack );
stack++;
u8g_DrawBox( &(lud->u8g), x, y, w, h );
return 0;
}
// Lua: u8g.drawFrame( self, x, y, width, height )
static int lu8g_drawFrame( lua_State *L )
{
lu8g_userdata_t *lud;
uint8_t stack = 1;
lud = (lu8g_userdata_t *)luaL_checkudata(L, stack, "u8g.display");
luaL_argcheck(L, lud, stack, "u8g.display expected");
stack++;
if (lud == NULL)
return 0;
u8g_uint_t x = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t y = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t w = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t h = luaL_checkinteger( L, stack );
stack++;
u8g_DrawFrame( &(lud->u8g), x, y, w, h );
return 0;
}
// Lua: u8g.drawDisc( self, x0, y0, rad, opt = U8G_DRAW_ALL )
static int lu8g_drawDisc( lua_State *L )
{
lu8g_userdata_t *lud;
uint8_t stack = 1;
lud = (lu8g_userdata_t *)luaL_checkudata(L, stack, "u8g.display");
luaL_argcheck(L, lud, stack, "u8g.display expected");
stack++;
if (lud == NULL)
return 0;
u8g_uint_t x0 = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t y0 = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t rad = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t opt = luaL_optinteger( L, stack, U8G_DRAW_ALL );
stack++;
u8g_DrawDisc( &(lud->u8g), x0, y0, rad, opt );
return 0;
}
// Lua: u8g.drawCircle( self, x0, y0, rad, opt = U8G_DRAW_ALL )
static int lu8g_drawCircle( lua_State *L )
{
lu8g_userdata_t *lud;
uint8_t stack = 1;
lud = (lu8g_userdata_t *)luaL_checkudata(L, stack, "u8g.display");
luaL_argcheck(L, lud, stack, "u8g.display expected");
stack++;
if (lud == NULL)
return 0;
u8g_uint_t x0 = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t y0 = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t rad = luaL_checkinteger( L, stack );
stack++;
u8g_uint_t opt = luaL_optinteger( L, stack, U8G_DRAW_ALL );
stack++;
u8g_DrawCircle( &(lud->u8g), x0, y0, rad, opt );
return 0;
}
// Lua: u8g.firstPage( self )
static int lu8g_firstPage( lua_State *L )
{
lu8g_userdata_t *lud;
lud = (lu8g_userdata_t *)luaL_checkudata(L, 1, "u8g.display");
luaL_argcheck(L, lud, 1, "u8g.display expected");
if (lud == NULL)
return 0;
u8g_FirstPage( &(lud->u8g) );
return 0;
}
// Lua: bool = u8g.nextPage( self )
static int lu8g_nextPage( lua_State *L )
{
lu8g_userdata_t *lud;
lud = (lu8g_userdata_t *)luaL_checkudata(L, 1, "u8g.display");
luaL_argcheck(L, lud, 1, "u8g.display expected");
if (lud == NULL)
return 0;
lua_pushboolean( L, u8g_NextPage( &(lud->u8g) ) );
return 1;
}
// ------------------------------------------------------------
// comm functions
@ -68,7 +310,8 @@ static uint8_t u8g_com_esp8266_ssd_start_sequence(u8g_t *u8g)
if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 )
{
// ignore return value -> tolerate missing ACK
platform_i2c_send_byte( ESP_I2C_ID, I2C_CMD_MODE );
if ( platform_i2c_send_byte( ESP_I2C_ID, I2C_CMD_MODE ) == 0 )
; //return 0;
}
else
{
@ -116,8 +359,9 @@ uint8_t u8g_com_esp8266_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, voi
//u8g->pin_list[U8G_PI_SET_A0] = 1;
if ( u8g_com_esp8266_ssd_start_sequence(u8g) == 0 )
return platform_i2c_stop( ESP_I2C_ID ), 0;
// ignore return value -> tolerate missing ACK
if ( platform_i2c_send_byte( ESP_I2C_ID, arg_val) == 0 )
return platform_i2c_send_stop( ESP_I2C_ID ), 0;
; //return platform_i2c_send_stop( ESP_I2C_ID ), 0;
// platform_i2c_send_stop( ESP_I2C_ID );
break;
@ -200,7 +444,17 @@ static int lu8g_ssd1306_128x64_i2c( lua_State *L )
static const LUA_REG_TYPE lu8g_display_map[] =
{
{ LSTRKEY( "setup" ), LFUNCVAL( lu8g_setup ) },
{ LSTRKEY( "setFont" ), LFUNCVAL( lu8g_setFont ) },
{ LSTRKEY( "setFontRefHeightExtendedText" ), LFUNCVAL( lu8g_setFontRefHeightExtendedText ) },
{ LSTRKEY( "setDefaultForegroundColor" ), LFUNCVAL( lu8g_setDefaultForegroundColor ) },
{ LSTRKEY( "setFontPosTop" ), LFUNCVAL( lu8g_setFontPosTop ) },
{ LSTRKEY( "drawStr" ), LFUNCVAL( lu8g_drawStr ) },
{ LSTRKEY( "drawBox" ), LFUNCVAL( lu8g_drawBox ) },
{ LSTRKEY( "drawFrame" ), LFUNCVAL( lu8g_drawFrame ) },
{ LSTRKEY( "drawDisc" ), LFUNCVAL( lu8g_drawDisc ) },
{ LSTRKEY( "drawCircle" ), LFUNCVAL( lu8g_drawCircle ) },
{ LSTRKEY( "firstPage" ), LFUNCVAL( lu8g_firstPage ) },
{ LSTRKEY( "nextPage" ), LFUNCVAL( lu8g_nextPage ) },
#if LUA_OPTIMIZE_MEMORY > 0
{ LSTRKEY( "__index" ), LROVAL ( lu8g_display_map ) },
#endif
@ -211,6 +465,7 @@ const LUA_REG_TYPE lu8g_map[] =
{
{ LSTRKEY( "ssd1306_128x64_i2c" ), LFUNCVAL ( lu8g_ssd1306_128x64_i2c ) },
#if LUA_OPTIMIZE_MEMORY > 0
{ LSTRKEY( "font_6x10" ), LNUMVAL( LU8G_FONT_6X10 ) },
{ LSTRKEY( "__metatable" ), LROVAL( lu8g_map ) },
#endif
{ LNILKEY, LNILVAL }
@ -230,7 +485,8 @@ LUALIB_API int ICACHE_FLASH_ATTR luaopen_u8g( lua_State *L )
lua_setmetatable( L, -2 );
// Module constants
// MOD_REG_NUMBER( L, "TCP", TCP );
// Register fonts
MOD_REG_NUMBER( L, "font_6x10", LU8G_FONT_6X10 );
// create metatable
luaL_newmetatable(L, "u8g.display");
@ -240,7 +496,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaopen_u8g( lua_State *L )
lua_rawset(L,-3);
// Setup the methods inside metatable
luaL_register( L, NULL, u8g_display_map );
return 1;
#endif // #if LUA_OPTIMIZE_MEMORY > 0
}

View File

@ -90,7 +90,6 @@ extern "C" {
# define U8G_PURE
# define U8G_NOCOMMON
# define U8G_SECTION(name)
# define U8G_FONT_SECTION(name)
#endif
#ifndef U8G_FONT_SECTION

View File

@ -384,29 +384,29 @@ uint8_t u8g_dev_sh1106_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, voi
U8G_PB_DEV(u8g_dev_ssd1306_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SW_SPI);
U8G_PB_DEV(u8g_dev_ssd1306_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_HW_SPI);
//U8G_PB_DEV(u8g_dev_ssd1306_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SW_SPI);
//U8G_PB_DEV(u8g_dev_ssd1306_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_HW_SPI);
U8G_PB_DEV(u8g_dev_ssd1306_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SSD_I2C);
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SW_SPI);
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_HW_SPI);
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SSD_I2C);
uint8_t u8g_dev_ssd1306_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
u8g_pb_t u8g_dev_ssd1306_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x64_2x_buf};
u8g_dev_t u8g_dev_ssd1306_128x64_2x_sw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SW_SPI };
u8g_dev_t u8g_dev_ssd1306_128x64_2x_hw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_HW_SPI };
u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SSD_I2C };
U8G_PB_DEV(u8g_dev_sh1106_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SW_SPI);
U8G_PB_DEV(u8g_dev_sh1106_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_HW_SPI);
U8G_PB_DEV(u8g_dev_sh1106_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SSD_I2C);
uint8_t u8g_dev_sh1106_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
u8g_pb_t u8g_dev_sh1106_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_buf};
u8g_dev_t u8g_dev_sh1106_128x64_2x_sw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SW_SPI };
u8g_dev_t u8g_dev_sh1106_128x64_2x_hw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_HW_SPI };
u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SSD_I2C };
//U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SW_SPI);
//U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_HW_SPI);
//U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SSD_I2C);
//
//
//uint8_t u8g_dev_ssd1306_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
//u8g_pb_t u8g_dev_ssd1306_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x64_2x_buf};
//u8g_dev_t u8g_dev_ssd1306_128x64_2x_sw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SW_SPI };
//u8g_dev_t u8g_dev_ssd1306_128x64_2x_hw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_HW_SPI };
//u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SSD_I2C };
//
//
//U8G_PB_DEV(u8g_dev_sh1106_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SW_SPI);
//U8G_PB_DEV(u8g_dev_sh1106_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_HW_SPI);
//U8G_PB_DEV(u8g_dev_sh1106_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SSD_I2C);
//
//uint8_t u8g_dev_sh1106_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
//u8g_pb_t u8g_dev_sh1106_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_buf};
//u8g_dev_t u8g_dev_sh1106_128x64_2x_sw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SW_SPI };
//u8g_dev_t u8g_dev_sh1106_128x64_2x_hw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_HW_SPI };
//u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SSD_I2C };

View File

@ -1,3 +1,4 @@
#if 0
/*
Fontname: -FreeType-04b03b-Medium-R-Normal--8-80-72-72-P-39-ISO10646-1
Copyright: 19992003 / yuji oshimoÿo / 04@dsg4.com / www.04.jp.org
@ -1860,6 +1861,7 @@ const u8g_fntpgm_uint8_t u8g_font_5x8r[805] U8G_FONT_SECTION("u8g_font_5x8r") =
64,240,2,71,87,48,64,32,192,32,64,48,34,22,86,128,
128,128,128,128,128,2,71,87,192,32,64,48,64,32,192,6,
66,82,80,160,255};
#endif
/*
Fontname: -Misc-Fixed-Medium-R-Normal--10-100-75-75-C-60-ISO10646-1
Copyright: Public domain terminal emulator font. Share and enjoy.
@ -1990,6 +1992,7 @@ const u8g_fntpgm_uint8_t u8g_font_6x10[1866] U8G_FONT_SECTION("u8g_font_6x10") =
80,0,136,136,136,152,104,0,89,105,16,32,136,136,152,104,
8,136,112,0,88,104,128,240,136,136,136,240,128,128,0,89,
105,80,0,136,136,152,104,8,136,112};
#if 0
/*
Fontname: -Misc-Fixed-Medium-R-Normal--10-100-75-75-C-60-ISO10646-1
Copyright: Public domain terminal emulator font. Share and enjoy.
@ -88462,3 +88465,4 @@ const u8g_fntpgm_uint8_t u8g_font_unifontr[1485] U8G_FONT_SECTION("u8g_font_unif
3,8,1,8,98,146,140,16,16,32,16,0,254,170,170,0,
1,128,0,0,1,128,0,115,209,202,16,75,209,202,16,115,
223,128,0,0,1,128,0,0,1,128,0,85,85};
#endif

View File

@ -5,7 +5,7 @@ MEMORY
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x51000
irom0_0_seg : org = 0x40210000, len = 0x52000
}
PHDRS