establish parametrization via ucg_config.h
This commit is contained in:
parent
fde4843a75
commit
a2bca463a0
|
@ -0,0 +1,48 @@
|
|||
#ifndef __UCG_CONFIG_H__
|
||||
#define __UCG_CONFIG_H__
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Configure Ucglib fonts
|
||||
//
|
||||
// Add a UCG_FONT_TABLE_ENTRY for each font you want to compile into the image
|
||||
#define UCG_FONT_TABLE_ENTRY(font)
|
||||
#define UCG_FONT_TABLE \
|
||||
UCG_FONT_TABLE_ENTRY(font_7x13B_tr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_helvB08_hr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_helvB10_hr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_helvB12_hr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_helvB18_hr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_ncenB24_tr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_ncenR12_tr) \
|
||||
UCG_FONT_TABLE_ENTRY(font_ncenR14_hr)
|
||||
#undef UCG_FONT_TABLE_ENTRY
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Enable display drivers
|
||||
//
|
||||
// Uncomment the UCG_DISPLAY_TABLE_ENTRY for the device(s) you want to
|
||||
// compile into the firmware.
|
||||
//
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ili9163_18x128x128_hw_spi, ucg_dev_ili9163_18x128x128, ucg_ext_ili9163_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ili9341_18x240x320_hw_spi, ucg_dev_ili9341_18x240x320, ucg_ext_ili9341_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(pcf8833_16x132x132_hw_spi, ucg_dev_pcf8833_16x132x132, ucg_ext_pcf8833_16) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(seps225_16x128x128_univision_hw_spi, ucg_dev_seps225_16x128x128_univision, ucg_ext_seps225_16) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ssd1351_18x128x128_hw_spi, ucg_dev_ssd1351_18x128x128_ilsoft, ucg_ext_ssd1351_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ssd1351_18x128x128_ft_hw_spi, ucg_dev_ssd1351_18x128x128_ft, ucg_ext_ssd1351_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(ssd1331_18x96x64_univision_hw_spi, ucg_dev_ssd1331_18x96x64_univision, ucg_ext_ssd1331_18) \
|
||||
// UCG_DISPLAY_TABLE_ENTRY(st7735_18x128x160_hw_spi, ucg_dev_st7735_18x128x160, ucg_ext_st7735_18) \
|
||||
|
||||
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension)
|
||||
#define UCG_DISPLAY_TABLE \
|
||||
UCG_DISPLAY_TABLE_ENTRY(ili9341_18x240x320_hw_spi, ucg_dev_ili9341_18x240x320, ucg_ext_ili9341_18) \
|
||||
|
||||
#undef UCG_DISPLAY_TABLE_ENTRY
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
#endif /* __UCG_CONFIG_H__ */
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "ucg.h"
|
||||
|
||||
//#include "u8g_config.h"
|
||||
#include "ucg_config.h"
|
||||
|
||||
struct _lucg_userdata_t
|
||||
{
|
||||
|
@ -825,44 +825,53 @@ static int lucg_close_display( lua_State *L )
|
|||
}
|
||||
|
||||
|
||||
static int lucg_ili9341_18x240x320_hw_spi( lua_State *L )
|
||||
{
|
||||
unsigned cs = luaL_checkinteger( L, 1 );
|
||||
if (cs == 0)
|
||||
return luaL_error( L, "CS pin required" );
|
||||
unsigned dc = luaL_checkinteger( L, 2 );
|
||||
if (dc == 0)
|
||||
return luaL_error( L, "D/C pin required" );
|
||||
unsigned res = luaL_optinteger( L, 3, UCG_PIN_VAL_NONE );
|
||||
|
||||
lucg_userdata_t *lud = (lucg_userdata_t *) lua_newuserdata( L, sizeof( lucg_userdata_t ) );
|
||||
|
||||
// do a dummy init so that something usefull is part of the ucg structure
|
||||
ucg_Init( LUCG, ucg_dev_default_cb, ucg_ext_none, (ucg_com_fnptr)0 );
|
||||
|
||||
// reset cursor position
|
||||
lud->tx = 0;
|
||||
lud->ty = 0;
|
||||
lud->tdir = 0; // default direction
|
||||
|
||||
uint8_t i;
|
||||
for( i = 0; i < UCG_PIN_COUNT; i++ )
|
||||
lud->ucg.pin_list[i] = UCG_PIN_VAL_NONE;
|
||||
|
||||
|
||||
lud->dev_cb = ucg_dev_ili9341_18x240x320;
|
||||
lud->ext_cb = ucg_ext_ili9341_18;
|
||||
lud->ucg.pin_list[UCG_PIN_RST] = res;
|
||||
lud->ucg.pin_list[UCG_PIN_CD] = dc;
|
||||
lud->ucg.pin_list[UCG_PIN_CS] = cs;
|
||||
|
||||
|
||||
/* set its metatable */
|
||||
luaL_getmetatable(L, "ucg.display");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
// ***************************************************************************
|
||||
// Device constructors
|
||||
//
|
||||
//
|
||||
#undef UCG_DISPLAY_TABLE_ENTRY
|
||||
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) \
|
||||
static int lucg_ ## binding( lua_State *L ) \
|
||||
{ \
|
||||
unsigned cs = luaL_checkinteger( L, 1 ); \
|
||||
if (cs == 0) \
|
||||
return luaL_error( L, "CS pin required" ); \
|
||||
unsigned dc = luaL_checkinteger( L, 2 ); \
|
||||
if (dc == 0) \
|
||||
return luaL_error( L, "D/C pin required" ); \
|
||||
unsigned res = luaL_optinteger( L, 3, UCG_PIN_VAL_NONE ); \
|
||||
\
|
||||
lucg_userdata_t *lud = (lucg_userdata_t *) lua_newuserdata( L, sizeof( lucg_userdata_t ) ); \
|
||||
\
|
||||
/* do a dummy init so that something usefull is part of the ucg structure */ \
|
||||
ucg_Init( LUCG, ucg_dev_default_cb, ucg_ext_none, (ucg_com_fnptr)0 ); \
|
||||
\
|
||||
/* reset cursor position */ \
|
||||
lud->tx = 0; \
|
||||
lud->ty = 0; \
|
||||
lud->tdir = 0; /* default direction */ \
|
||||
\
|
||||
uint8_t i; \
|
||||
for( i = 0; i < UCG_PIN_COUNT; i++ ) \
|
||||
lud->ucg.pin_list[i] = UCG_PIN_VAL_NONE; \
|
||||
\
|
||||
lud->dev_cb = device; \
|
||||
lud->ext_cb = extension; \
|
||||
lud->ucg.pin_list[UCG_PIN_RST] = res; \
|
||||
lud->ucg.pin_list[UCG_PIN_CD] = dc; \
|
||||
lud->ucg.pin_list[UCG_PIN_CS] = cs; \
|
||||
\
|
||||
/* set its metatable */ \
|
||||
luaL_getmetatable(L, "ucg.display"); \
|
||||
lua_setmetatable(L, -2); \
|
||||
\
|
||||
return 1; \
|
||||
}
|
||||
//
|
||||
// Unroll the display table and insert binding functions.
|
||||
UCG_DISPLAY_TABLE
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
|
||||
|
@ -925,19 +934,16 @@ static const LUA_REG_TYPE lucg_display_map[] =
|
|||
|
||||
const LUA_REG_TYPE lucg_map[] =
|
||||
{
|
||||
{ LSTRKEY( "ili9341_18x240x320_hw_spi" ), LFUNCVAL( lucg_ili9341_18x240x320_hw_spi ) },
|
||||
#undef UCG_DISPLAY_TABLE_ENTRY
|
||||
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) { LSTRKEY( #binding ), LFUNCVAL ( lucg_ ##binding ) },
|
||||
UCG_DISPLAY_TABLE
|
||||
|
||||
#if LUA_OPTIMIZE_MEMORY > 0
|
||||
|
||||
// Register fonts
|
||||
{ LSTRKEY( "font_7x13B_tr" ), LUDATA( (void *)(ucg_font_7x13B_tr) ) },
|
||||
{ LSTRKEY( "font_helvB08_hr" ), LUDATA( (void *)(ucg_font_helvB08_hr) ) },
|
||||
{ LSTRKEY( "font_helvB10_hr" ), LUDATA( (void *)(ucg_font_helvB10_hr) ) },
|
||||
{ LSTRKEY( "font_helvB12_hr" ), LUDATA( (void *)(ucg_font_helvB12_hr) ) },
|
||||
{ LSTRKEY( "font_helvB18_hr" ), LUDATA( (void *)(ucg_font_helvB18_hr) ) },
|
||||
{ LSTRKEY( "font_ncenB24_tr" ), LUDATA( (void *)(ucg_font_ncenB24_tr) ) },
|
||||
{ LSTRKEY( "font_ncenR12_tr" ), LUDATA( (void *)(ucg_font_ncenR12_tr) ) },
|
||||
{ LSTRKEY( "font_ncenR14_hr" ), LUDATA( (void *)(ucg_font_ncenR14_hr) ) },
|
||||
#undef UCG_FONT_TABLE_ENTRY
|
||||
#define UCG_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(ucg_ ## font) ) },
|
||||
UCG_FONT_TABLE
|
||||
|
||||
// Font modes
|
||||
{ LSTRKEY( "FONT_MODE_TRANSPARENT" ), LNUMVAL( UCG_FONT_MODE_TRANSPARENT ) },
|
||||
|
@ -971,14 +977,9 @@ LUALIB_API int luaopen_ucg( lua_State *L )
|
|||
// Module constants
|
||||
|
||||
// Register fonts
|
||||
MOD_REG_LUDATA( L, "font_7x13B_tr", (void *)(ucg_font_7x13B_tr) );
|
||||
MOD_REG_LUDATA( L, "font_helvB08_hr", (void *)(ucg_font_helvB08_hr) );
|
||||
MOD_REG_LUDATA( L, "font_helvB10_hr", (void *)(ucg_font_helvB10_hr) );
|
||||
MOD_REG_LUDATA( L, "font_helvB12_hr", (void *)(ucg_font_helvB12_hr) );
|
||||
MOD_REG_LUDATA( L, "font_helvB18_hr", (void *)(ucg_font_helvB18_hr) );
|
||||
MOD_REG_LUDATA( L, "font_ncenB24_tr", (void *)(ucg_font_ncenB24_tr) );
|
||||
MOD_REG_LUDATA( L, "font_ncenR12_tr", (void *)(ucg_font_ncenR12_tr) );
|
||||
MOD_REG_LUDATA( L, "font_ncenR14_hr", (void *)(ucg_font_ncenR14_hr) );
|
||||
#undef UCG_FONT_TABLE_ENTRY
|
||||
#define UCG_FONT_TABLE_ENTRY(font) MOD_REG_LUDATA( L, #font, (void *)(ucg_ ## font) );
|
||||
UCG_FONT_TABLE
|
||||
|
||||
// Font modes
|
||||
MOD_REG_NUMBER( L, "FONT_MODE_TRANSPARENT", UCG_FONT_MODE_TRANSPARENT );
|
||||
|
|
Loading…
Reference in New Issue