Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
a2bca463
Commit
a2bca463
authored
Aug 09, 2015
by
devsaurus
Browse files
establish parametrization via ucg_config.h
parent
fde4843a
Changes
2
Show whitespace changes
Inline
Side-by-side
app/include/ucg_config.h
0 → 100644
View file @
a2bca463
#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__ */
app/modules/ucg.c
View file @
a2bca463
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include "ucg.h"
#include "ucg.h"
//
#include "u
8
g_config.h"
#include "u
c
g_config.h"
struct
_lucg_userdata_t
struct
_lucg_userdata_t
{
{
...
@@ -825,44 +825,53 @@ static int lucg_close_display( lua_State *L )
...
@@ -825,44 +825,53 @@ static int lucg_close_display( lua_State *L )
}
}
static
int
lucg_ili9341_18x240x320_hw_spi
(
lua_State
*
L
)
// ***************************************************************************
{
// Device constructors
unsigned
cs
=
luaL_checkinteger
(
L
,
1
);
//
if
(
cs
==
0
)
//
return
luaL_error
(
L
,
"CS pin required"
);
#undef UCG_DISPLAY_TABLE_ENTRY
unsigned
dc
=
luaL_checkinteger
(
L
,
2
);
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) \
if
(
dc
==
0
)
static int lucg_ ## binding( lua_State *L ) \
return
luaL_error
(
L
,
"D/C pin required"
);
{ \
unsigned
res
=
luaL_optinteger
(
L
,
3
,
UCG_PIN_VAL_NONE
);
unsigned cs = luaL_checkinteger( L, 1 ); \
if (cs == 0) \
lucg_userdata_t
*
lud
=
(
lucg_userdata_t
*
)
lua_newuserdata
(
L
,
sizeof
(
lucg_userdata_t
)
);
return luaL_error( L, "CS pin required" ); \
unsigned dc = luaL_checkinteger( L, 2 ); \
// do a dummy init so that something usefull is part of the ucg structure
if (dc == 0) \
ucg_Init
(
LUCG
,
ucg_dev_default_cb
,
ucg_ext_none
,
(
ucg_com_fnptr
)
0
);
return luaL_error( L, "D/C pin required" ); \
unsigned res = luaL_optinteger( L, 3, UCG_PIN_VAL_NONE ); \
// reset cursor position
\
lud
->
tx
=
0
;
lucg_userdata_t *lud = (lucg_userdata_t *) lua_newuserdata( L, sizeof( lucg_userdata_t ) ); \
lud
->
ty
=
0
;
\
lud
->
tdir
=
0
;
// default direction
/* 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 ); \
uint8_t
i
;
\
for
(
i
=
0
;
i
<
UCG_PIN_COUNT
;
i
++
)
/* reset cursor position */
\
lud
->
ucg
.
pin_list
[
i
]
=
UCG_PIN_VAL_NONE
;
lud->tx = 0; \
lud->ty = 0; \
lud->tdir = 0;
/* default direction */
\
lud
->
dev_cb
=
ucg_dev_ili9341_18x240x320
;
\
lud
->
ext_cb
=
ucg_ext_ili9341_18
;
uint8_t i; \
lud
->
ucg
.
pin_list
[
UCG_PIN_RST
]
=
res
;
for( i = 0; i < UCG_PIN_COUNT; i++ ) \
lud
->
ucg
.
pin_list
[
UCG_PIN_CD
]
=
dc
;
lud->ucg.pin_list[i] = UCG_PIN_VAL_NONE; \
lud
->
ucg
.
pin_list
[
UCG_PIN_CS
]
=
cs
;
\
lud->dev_cb = device; \
lud->ext_cb = extension; \
/* set its metatable */
lud->ucg.pin_list[UCG_PIN_RST] = res; \
luaL_getmetatable
(
L
,
"ucg.display"
);
lud->ucg.pin_list[UCG_PIN_CD] = dc; \
lua_setmetatable
(
L
,
-
2
);
lud->ucg.pin_list[UCG_PIN_CS] = cs; \
\
return
1
;
/* 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[] =
...
@@ -925,19 +934,16 @@ static const LUA_REG_TYPE lucg_display_map[] =
const
LUA_REG_TYPE
lucg_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
#if LUA_OPTIMIZE_MEMORY > 0
// Register fonts
// Register fonts
{
LSTRKEY
(
"font_7x13B_tr"
),
LUDATA
(
(
void
*
)(
ucg_font_7x13B_tr
)
)
},
#undef UCG_FONT_TABLE_ENTRY
{
LSTRKEY
(
"font_helvB08_hr"
),
LUDATA
(
(
void
*
)(
ucg_font_helvB08_hr
)
)
},
#define UCG_FONT_TABLE_ENTRY(font) { LSTRKEY( #font ), LUDATA( (void *)(ucg_ ## font) ) },
{
LSTRKEY
(
"font_helvB10_hr"
),
LUDATA
(
(
void
*
)(
ucg_font_helvB10_hr
)
)
},
UCG_FONT_TABLE
{
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
)
)
},
// Font modes
// Font modes
{
LSTRKEY
(
"FONT_MODE_TRANSPARENT"
),
LNUMVAL
(
UCG_FONT_MODE_TRANSPARENT
)
},
{
LSTRKEY
(
"FONT_MODE_TRANSPARENT"
),
LNUMVAL
(
UCG_FONT_MODE_TRANSPARENT
)
},
...
@@ -971,14 +977,9 @@ LUALIB_API int luaopen_ucg( lua_State *L )
...
@@ -971,14 +977,9 @@ LUALIB_API int luaopen_ucg( lua_State *L )
// Module constants
// Module constants
// Register fonts
// Register fonts
MOD_REG_LUDATA
(
L
,
"font_7x13B_tr"
,
(
void
*
)(
ucg_font_7x13B_tr
)
);
#undef UCG_FONT_TABLE_ENTRY
MOD_REG_LUDATA
(
L
,
"font_helvB08_hr"
,
(
void
*
)(
ucg_font_helvB08_hr
)
);
#define UCG_FONT_TABLE_ENTRY(font) MOD_REG_LUDATA( L, #font, (void *)(ucg_ ## font) );
MOD_REG_LUDATA
(
L
,
"font_helvB10_hr"
,
(
void
*
)(
ucg_font_helvB10_hr
)
);
UCG_FONT_TABLE
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
)
);
// Font modes
// Font modes
MOD_REG_NUMBER
(
L
,
"FONT_MODE_TRANSPARENT"
,
UCG_FONT_MODE_TRANSPARENT
);
MOD_REG_NUMBER
(
L
,
"FONT_MODE_TRANSPARENT"
,
UCG_FONT_MODE_TRANSPARENT
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment