introduce lua_api_name parameter when building the display table
keeps the API as before and gets rid of hw_spi vs sw_spi topics
This commit is contained in:
parent
1bc156e4d1
commit
8bd3d7d2bf
|
@ -23,14 +23,14 @@
|
||||||
// Stick to the assignments to *_I2C and *_SPI tables.
|
// Stick to the assignments to *_I2C and *_SPI tables.
|
||||||
//
|
//
|
||||||
// I2C based displays go into here:
|
// I2C based displays go into here:
|
||||||
#define U8G_DISPLAY_TABLE_ENTRY(device, display)
|
#define U8G_DISPLAY_TABLE_ENTRY(device, display, lua_api_name)
|
||||||
#define U8G_DISPLAY_TABLE_I2C \
|
#define U8G_DISPLAY_TABLE_I2C \
|
||||||
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c, ssd1306_128x64)
|
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c, ssd1306_128x64, ssd1306_128x64_i2c)
|
||||||
|
|
||||||
// SPI based displays go into here:
|
// SPI based displays go into here:
|
||||||
#define U8G_DISPLAY_TABLE_SPI \
|
#define U8G_DISPLAY_TABLE_SPI \
|
||||||
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi, ssd1306_128x64) \
|
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi, ssd1306_128x64, ssd1306_128x64_spi) \
|
||||||
// U8G_DISPLAY_TABLE_ENTRY(pcd8544_84x48_hw_spi, pcd8544_84x48)
|
// U8G_DISPLAY_TABLE_ENTRY(pcd8544_84x48_hw_spi, pcd8544_84x48, pcd8544_84x48_spi)
|
||||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||||
//
|
//
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
|
@ -986,9 +986,9 @@ static int lu8g_close_display( lua_State *L )
|
||||||
//
|
//
|
||||||
// I2C based devices will use this function template to implement the Lua binding.
|
// I2C based devices will use this function template to implement the Lua binding.
|
||||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||||
#define U8G_DISPLAY_TABLE_ENTRY(device, display) \
|
#define U8G_DISPLAY_TABLE_ENTRY(device, display, lua_api_name) \
|
||||||
uint8_t u8g_dev_ ## display ## _fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg); \
|
uint8_t u8g_dev_ ## display ## _fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg); \
|
||||||
static int lu8g_ ## device( lua_State *L ) \
|
static int lu8g_ ## lua_api_name( lua_State *L ) \
|
||||||
{ \
|
{ \
|
||||||
unsigned addr = luaL_checkinteger( L, 1 ); \
|
unsigned addr = luaL_checkinteger( L, 1 ); \
|
||||||
\
|
\
|
||||||
|
@ -1015,9 +1015,9 @@ U8G_DISPLAY_TABLE_I2C
|
||||||
//
|
//
|
||||||
// SPI based devices will use this function template to implement the Lua binding.
|
// SPI based devices will use this function template to implement the Lua binding.
|
||||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||||
#define U8G_DISPLAY_TABLE_ENTRY(device, display) \
|
#define U8G_DISPLAY_TABLE_ENTRY(device, display, lua_api_name) \
|
||||||
uint8_t u8g_dev_ ## display ## _fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg); \
|
uint8_t u8g_dev_ ## display ## _fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg); \
|
||||||
static int lu8g_ ## device( lua_State *L ) \
|
static int lu8g_ ## lua_api_name( lua_State *L ) \
|
||||||
{ \
|
{ \
|
||||||
unsigned cs = luaL_checkinteger( L, 1 ); \
|
unsigned cs = luaL_checkinteger( L, 1 ); \
|
||||||
if (cs == 0) \
|
if (cs == 0) \
|
||||||
|
@ -1110,7 +1110,7 @@ static const LUA_REG_TYPE lu8g_display_map[] =
|
||||||
const LUA_REG_TYPE lu8g_map[] =
|
const LUA_REG_TYPE lu8g_map[] =
|
||||||
{
|
{
|
||||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||||
#define U8G_DISPLAY_TABLE_ENTRY(device, display) { LSTRKEY( #device ), LFUNCVAL ( lu8g_ ##device ) },
|
#define U8G_DISPLAY_TABLE_ENTRY(device, display, lua_api_name) { LSTRKEY( #lua_api_name ), LFUNCVAL ( lu8g_ ##lua_api_name ) },
|
||||||
U8G_DISPLAY_TABLE_I2C
|
U8G_DISPLAY_TABLE_I2C
|
||||||
U8G_DISPLAY_TABLE_SPI
|
U8G_DISPLAY_TABLE_SPI
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
-- ***************************************************************************
|
||||||
|
-- Bitmaps Test
|
||||||
|
--
|
||||||
|
-- This script executes the bitmap features of u8glib to test their Lua
|
||||||
|
-- integration.
|
||||||
|
--
|
||||||
|
-- Note: It is prepared for SSD1306-based displays. Select your connectivity
|
||||||
|
-- type by calling either init_i2c_display() or init_spi_display() at
|
||||||
|
-- the bottom of this file.
|
||||||
|
--
|
||||||
|
-- ***************************************************************************
|
||||||
|
|
||||||
-- setup I2c and connect display
|
-- setup I2c and connect display
|
||||||
function init_i2c_display()
|
function init_i2c_display()
|
||||||
|
@ -20,7 +31,7 @@ function init_spi_display()
|
||||||
local res = 0 -- GPIO16
|
local res = 0 -- GPIO16
|
||||||
|
|
||||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||||
disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res)
|
disp = u8g.ssd1306_128x64_spi(cs, dc, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
-- ***************************************************************************
|
||||||
|
-- Graphics Test
|
||||||
|
--
|
||||||
|
-- This script executes several features of u8glib to test their Lua bindings.
|
||||||
|
--
|
||||||
|
-- Note: It is prepared for SSD1306-based displays. Select your connectivity
|
||||||
|
-- type by calling either init_i2c_display() or init_spi_display() at
|
||||||
|
-- the bottom of this file.
|
||||||
|
--
|
||||||
|
-- ***************************************************************************
|
||||||
|
|
||||||
-- setup I2c and connect display
|
-- setup I2c and connect display
|
||||||
function init_i2c_display()
|
function init_i2c_display()
|
||||||
|
@ -20,7 +30,7 @@ function init_spi_display()
|
||||||
local res = 0 -- GPIO16
|
local res = 0 -- GPIO16
|
||||||
|
|
||||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||||
disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res)
|
disp = u8g.ssd1306_128x64_spi(cs, dc, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
-- ***************************************************************************
|
||||||
|
-- Rotation Test
|
||||||
|
--
|
||||||
|
-- This script executes the rotation features of u8glib to test their Lua
|
||||||
|
-- integration.
|
||||||
|
--
|
||||||
|
-- Note: It is prepared for SSD1306-based displays. Select your connectivity
|
||||||
|
-- type by calling either init_i2c_display() or init_spi_display() at
|
||||||
|
-- the bottom of this file.
|
||||||
|
--
|
||||||
|
-- ***************************************************************************
|
||||||
|
|
||||||
-- setup I2c and connect display
|
-- setup I2c and connect display
|
||||||
function init_i2c_display()
|
function init_i2c_display()
|
||||||
|
@ -20,7 +31,7 @@ function init_spi_display()
|
||||||
local res = 0 -- GPIO16
|
local res = 0 -- GPIO16
|
||||||
|
|
||||||
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||||
disp = u8g.ssd1306_128x64_hw_spi(cs, dc, res)
|
disp = u8g.ssd1306_128x64_spi(cs, dc, res)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue