UcgLogo example - fix drawGlyph and drawString
This commit is contained in:
parent
5c93ba017e
commit
f0d581223f
|
@ -117,6 +117,38 @@ static int lucg_drawBox( lua_State *L )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lua: ucg.drawCircle( self, x0, y0, rad, option )
|
||||||
|
static int lucg_drawCircle( lua_State *L )
|
||||||
|
{
|
||||||
|
lucg_userdata_t *lud;
|
||||||
|
|
||||||
|
if ((lud = get_lud( L )) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ucg_int_t args[4];
|
||||||
|
lucg_get_int_args( L, 2, 4, args );
|
||||||
|
|
||||||
|
ucg_DrawCircle( LUCG, args[0], args[1], args[2], args[3] );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lua: ucg.drawDisc( self, x0, y0, rad, option )
|
||||||
|
static int lucg_drawDisc( lua_State *L )
|
||||||
|
{
|
||||||
|
lucg_userdata_t *lud;
|
||||||
|
|
||||||
|
if ((lud = get_lud( L )) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ucg_int_t args[4];
|
||||||
|
lucg_get_int_args( L, 2, 4, args );
|
||||||
|
|
||||||
|
ucg_DrawDisc( LUCG, args[0], args[1], args[2], args[3] );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Lua: ucg.drawFrame( self, x, y, w, h )
|
// Lua: ucg.drawFrame( self, x, y, w, h )
|
||||||
static int lucg_drawFrame( lua_State *L )
|
static int lucg_drawFrame( lua_State *L )
|
||||||
{
|
{
|
||||||
|
@ -149,6 +181,42 @@ static int lucg_drawGradientBox( lua_State *L )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lua: width = ucg.drawGlyph( self, x, y, dir, encoding )
|
||||||
|
static int lucg_drawGlyph( lua_State *L )
|
||||||
|
{
|
||||||
|
lucg_userdata_t *lud;
|
||||||
|
|
||||||
|
if ((lud = get_lud( L )) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ucg_int_t args[3];
|
||||||
|
lucg_get_int_args( L, 2, 3, args );
|
||||||
|
|
||||||
|
const char *c = luaL_checkstring( L, (1+3) + 1 );
|
||||||
|
if (c == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
lua_pushinteger( L, ucg_DrawGlyph( LUCG, args[0], args[1], args[2], *c ) );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lua: ucg.drawGradientLine( self, x, y, len, dir )
|
||||||
|
static int lucg_drawGradientLine( lua_State *L )
|
||||||
|
{
|
||||||
|
lucg_userdata_t *lud;
|
||||||
|
|
||||||
|
if ((lud = get_lud( L )) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ucg_int_t args[4];
|
||||||
|
lucg_get_int_args( L, 2, 4, args );
|
||||||
|
|
||||||
|
ucg_DrawGradientLine( LUCG, args[0], args[1], args[2], args[3] );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Lua: ucg.drawHLine( self, x, y, len )
|
// Lua: ucg.drawHLine( self, x, y, len )
|
||||||
static int lucg_drawHLine( lua_State *L )
|
static int lucg_drawHLine( lua_State *L )
|
||||||
{
|
{
|
||||||
|
@ -197,7 +265,7 @@ static int lucg_drawPixel( lua_State *L )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ucg.drawString( self, x, y, dir, str )
|
// Lua: width = ucg.drawString( self, x, y, dir, str )
|
||||||
static int lucg_drawString( lua_State *L )
|
static int lucg_drawString( lua_State *L )
|
||||||
{
|
{
|
||||||
lucg_userdata_t *lud;
|
lucg_userdata_t *lud;
|
||||||
|
@ -208,13 +276,13 @@ static int lucg_drawString( lua_State *L )
|
||||||
ucg_int_t args[3];
|
ucg_int_t args[3];
|
||||||
lucg_get_int_args( L, 2, 3, args );
|
lucg_get_int_args( L, 2, 3, args );
|
||||||
|
|
||||||
const char *s = luaL_checkstring( L, 2 );
|
const char *s = luaL_checkstring( L, (1+3) + 1 );
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ucg_DrawString( LUCG, args[0], args[1], args[2], s );
|
lua_pushinteger( L, ucg_DrawString( LUCG, args[0], args[1], args[2], s ) );
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ucg.drawTriangle( self, x0, y0, x1, y1, x2, y2 )
|
// Lua: ucg.drawTriangle( self, x0, y0, x1, y1, x2, y2 )
|
||||||
|
@ -249,7 +317,7 @@ static int lucg_drawVLine( lua_State *L )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ucg.getHeight( self )
|
// Lua: height = ucg.getHeight( self )
|
||||||
static int lucg_getHeight( lua_State *L )
|
static int lucg_getHeight( lua_State *L )
|
||||||
{
|
{
|
||||||
lucg_userdata_t *lud;
|
lucg_userdata_t *lud;
|
||||||
|
@ -262,7 +330,7 @@ static int lucg_getHeight( lua_State *L )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lua: ucg.getWidth( self )
|
// Lua: width = ucg.getWidth( self )
|
||||||
static int lucg_getWidth( lua_State *L )
|
static int lucg_getWidth( lua_State *L )
|
||||||
{
|
{
|
||||||
lucg_userdata_t *lud;
|
lucg_userdata_t *lud;
|
||||||
|
@ -454,6 +522,19 @@ static int lucg_setRotate270( lua_State *L )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lua: ucg.setScale2x2( self )
|
||||||
|
static int lucg_setScale2x2( lua_State *L )
|
||||||
|
{
|
||||||
|
lucg_userdata_t *lud;
|
||||||
|
|
||||||
|
if ((lud = get_lud( L )) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ucg_SetScale2x2( LUCG );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Lua: ucg.undoRotate( self )
|
// Lua: ucg.undoRotate( self )
|
||||||
static int lucg_undoRotate( lua_State *L )
|
static int lucg_undoRotate( lua_State *L )
|
||||||
{
|
{
|
||||||
|
@ -467,6 +548,19 @@ static int lucg_undoRotate( lua_State *L )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lua: ucg.undoScale( self )
|
||||||
|
static int lucg_undoScale( lua_State *L )
|
||||||
|
{
|
||||||
|
lucg_userdata_t *lud;
|
||||||
|
|
||||||
|
if ((lud = get_lud( L )) == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ucg_UndoScale( LUCG );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int16_t ucg_com_esp8266_hw_spi(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data)
|
static int16_t ucg_com_esp8266_hw_spi(ucg_t *ucg, int16_t msg, uint16_t arg, uint8_t *data)
|
||||||
|
@ -639,8 +733,12 @@ static const LUA_REG_TYPE lucg_display_map[] =
|
||||||
{ LSTRKEY( "clearScreen" ), LFUNCVAL( lucg_clearScreen ) },
|
{ LSTRKEY( "clearScreen" ), LFUNCVAL( lucg_clearScreen ) },
|
||||||
{ LSTRKEY( "draw90Line" ), LFUNCVAL( lucg_draw90Line ) },
|
{ LSTRKEY( "draw90Line" ), LFUNCVAL( lucg_draw90Line ) },
|
||||||
{ LSTRKEY( "drawBox" ), LFUNCVAL( lucg_drawBox ) },
|
{ LSTRKEY( "drawBox" ), LFUNCVAL( lucg_drawBox ) },
|
||||||
|
{ LSTRKEY( "drawCircle" ), LFUNCVAL( lucg_drawCircle ) },
|
||||||
|
{ LSTRKEY( "drawDisc" ), LFUNCVAL( lucg_drawDisc ) },
|
||||||
{ LSTRKEY( "drawFrame" ), LFUNCVAL( lucg_drawFrame ) },
|
{ LSTRKEY( "drawFrame" ), LFUNCVAL( lucg_drawFrame ) },
|
||||||
|
{ LSTRKEY( "drawGlyph" ), LFUNCVAL( lucg_drawGlyph ) },
|
||||||
{ LSTRKEY( "drawGradientBox" ), LFUNCVAL( lucg_drawGradientBox ) },
|
{ LSTRKEY( "drawGradientBox" ), LFUNCVAL( lucg_drawGradientBox ) },
|
||||||
|
{ LSTRKEY( "drawGradientLine" ), LFUNCVAL( lucg_drawGradientLine ) },
|
||||||
{ LSTRKEY( "drawHLine" ), LFUNCVAL( lucg_drawHLine ) },
|
{ LSTRKEY( "drawHLine" ), LFUNCVAL( lucg_drawHLine ) },
|
||||||
{ LSTRKEY( "drawLine" ), LFUNCVAL( lucg_drawLine ) },
|
{ LSTRKEY( "drawLine" ), LFUNCVAL( lucg_drawLine ) },
|
||||||
{ LSTRKEY( "drawPixel" ), LFUNCVAL( lucg_drawPixel ) },
|
{ LSTRKEY( "drawPixel" ), LFUNCVAL( lucg_drawPixel ) },
|
||||||
|
@ -660,7 +758,10 @@ static const LUA_REG_TYPE lucg_display_map[] =
|
||||||
{ LSTRKEY( "setRotate90" ), LFUNCVAL( lucg_setRotate90 ) },
|
{ LSTRKEY( "setRotate90" ), LFUNCVAL( lucg_setRotate90 ) },
|
||||||
{ LSTRKEY( "setRotate180" ), LFUNCVAL( lucg_setRotate180 ) },
|
{ LSTRKEY( "setRotate180" ), LFUNCVAL( lucg_setRotate180 ) },
|
||||||
{ LSTRKEY( "setRotate270" ), LFUNCVAL( lucg_setRotate270 ) },
|
{ LSTRKEY( "setRotate270" ), LFUNCVAL( lucg_setRotate270 ) },
|
||||||
|
{ LSTRKEY( "setScale2x2" ), LFUNCVAL( lucg_setScale2x2 ) },
|
||||||
|
{ LSTRKEY( "undoClipRange" ), LFUNCVAL( lucg_setMaxClipRange ) },
|
||||||
{ LSTRKEY( "undoRotate" ), LFUNCVAL( lucg_undoRotate ) },
|
{ LSTRKEY( "undoRotate" ), LFUNCVAL( lucg_undoRotate ) },
|
||||||
|
{ LSTRKEY( "undoScale" ), LFUNCVAL( lucg_undoScale ) },
|
||||||
|
|
||||||
{ LSTRKEY( "__gc" ), LFUNCVAL( lucg_close_display ) },
|
{ LSTRKEY( "__gc" ), LFUNCVAL( lucg_close_display ) },
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
|
@ -676,10 +777,12 @@ const LUA_REG_TYPE lucg_map[] =
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
|
|
||||||
// Register fonts
|
// Register fonts
|
||||||
|
{ LSTRKEY( "font_7x13B_tr" ), LUDATA( (void *)(ucg_font_7x13B_tr) ) },
|
||||||
{ LSTRKEY( "font_helvB08_hr" ), LUDATA( (void *)(ucg_font_helvB08_hr) ) },
|
{ LSTRKEY( "font_helvB08_hr" ), LUDATA( (void *)(ucg_font_helvB08_hr) ) },
|
||||||
{ LSTRKEY( "font_helvB10_hr" ), LUDATA( (void *)(ucg_font_helvB10_hr) ) },
|
{ LSTRKEY( "font_helvB10_hr" ), LUDATA( (void *)(ucg_font_helvB10_hr) ) },
|
||||||
{ LSTRKEY( "font_helvB12_hr" ), LUDATA( (void *)(ucg_font_helvB12_hr) ) },
|
{ LSTRKEY( "font_helvB12_hr" ), LUDATA( (void *)(ucg_font_helvB12_hr) ) },
|
||||||
{ LSTRKEY( "font_helvB18_hr" ), LUDATA( (void *)(ucg_font_helvB18_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_ncenR12_tr" ), LUDATA( (void *)(ucg_font_ncenR12_tr) ) },
|
||||||
{ LSTRKEY( "font_ncenR14_hr" ), LUDATA( (void *)(ucg_font_ncenR14_hr) ) },
|
{ LSTRKEY( "font_ncenR14_hr" ), LUDATA( (void *)(ucg_font_ncenR14_hr) ) },
|
||||||
|
|
||||||
|
@ -687,6 +790,13 @@ const LUA_REG_TYPE lucg_map[] =
|
||||||
{ LSTRKEY( "FONT_MODE_TRANSPARENT" ), LNUMVAL( UCG_FONT_MODE_TRANSPARENT ) },
|
{ LSTRKEY( "FONT_MODE_TRANSPARENT" ), LNUMVAL( UCG_FONT_MODE_TRANSPARENT ) },
|
||||||
{ LSTRKEY( "FONT_MODE_SOLID" ), LNUMVAL( UCG_FONT_MODE_SOLID ) },
|
{ LSTRKEY( "FONT_MODE_SOLID" ), LNUMVAL( UCG_FONT_MODE_SOLID ) },
|
||||||
|
|
||||||
|
// Options for circle/ disc drawing
|
||||||
|
{ LSTRKEY( "DRAW_UPPER_RIGHT" ), LNUMVAL( UCG_DRAW_UPPER_RIGHT ) },
|
||||||
|
{ LSTRKEY( "DRAW_UPPER_LEFT" ), LNUMVAL( UCG_DRAW_UPPER_LEFT ) },
|
||||||
|
{ LSTRKEY( "DRAW_LOWER_RIGHT" ), LNUMVAL( UCG_DRAW_LOWER_RIGHT ) },
|
||||||
|
{ LSTRKEY( "DRAW_LOWER_LEFT" ), LNUMVAL( UCG_DRAW_LOWER_LEFT ) },
|
||||||
|
{ LSTRKEY( "DRAW_ALL" ), LNUMVAL( UCG_DRAW_ALL ) },
|
||||||
|
|
||||||
{ LSTRKEY( "__metatable" ), LROVAL( lucg_map ) },
|
{ LSTRKEY( "__metatable" ), LROVAL( lucg_map ) },
|
||||||
#endif
|
#endif
|
||||||
{ LNILKEY, LNILVAL }
|
{ LNILKEY, LNILVAL }
|
||||||
|
@ -708,10 +818,12 @@ 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) );
|
||||||
MOD_REG_LUDATA( L, "font_helvB08_hr", (void *)(ucg_font_helvB08_hr) );
|
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_helvB10_hr", (void *)(ucg_font_helvB10_hr) );
|
||||||
MOD_REG_LUDATA( L, "font_helvB12_hr", (void *)(ucg_font_helvB12_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_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_ncenR12_tr", (void *)(ucg_font_ncenR12_tr) );
|
||||||
MOD_REG_LUDATA( L, "font_ncenR14_hr", (void *)(ucg_font_ncenR14_hr) );
|
MOD_REG_LUDATA( L, "font_ncenR14_hr", (void *)(ucg_font_ncenR14_hr) );
|
||||||
|
|
||||||
|
@ -719,6 +831,13 @@ LUALIB_API int luaopen_ucg( lua_State *L )
|
||||||
MOD_REG_NUMBER( L, "FONT_MODE_TRANSPARENT", UCG_FONT_MODE_TRANSPARENT );
|
MOD_REG_NUMBER( L, "FONT_MODE_TRANSPARENT", UCG_FONT_MODE_TRANSPARENT );
|
||||||
MOD_REG_NUMBER( L, "FONT_MODE_SOLID", UCG_FONT_MODE_SOLID );
|
MOD_REG_NUMBER( L, "FONT_MODE_SOLID", UCG_FONT_MODE_SOLID );
|
||||||
|
|
||||||
|
// Options for circle/ disc drawing
|
||||||
|
MOD_REG_NUMBER( L, "DRAW_UPPER_RIGHT", UCG_DRAW_UPPER_RIGHT );
|
||||||
|
MOD_REG_NUMBER( L, "DRAW_UPPER_LEFT", UCG_DRAW_UPPER_LEFT );
|
||||||
|
MOD_REG_NUMBER( L, "DRAW_LOWER_RIGHT", UCG_DRAW_LOWER_RIGHT );
|
||||||
|
MOD_REG_NUMBER( L, "DRAW_LOWER_LEFT", UCG_DRAW_LOWER_LEFT );
|
||||||
|
MOD_REG_NUMBER( L, "DRAW_ALL", UCG_DRAW_ALL );
|
||||||
|
|
||||||
// create metatable
|
// create metatable
|
||||||
luaL_newmetatable(L, "ucg.display");
|
luaL_newmetatable(L, "ucg.display");
|
||||||
// metatable.__index = metatable
|
// metatable.__index = metatable
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
-- setup SPI and connect display
|
||||||
|
function init_spi_display()
|
||||||
|
-- Hardware SPI CLK = GPIO14
|
||||||
|
-- Hardware SPI MOSI = GPIO13
|
||||||
|
-- Hardware SPI MISO = GPIO12 (not used)
|
||||||
|
-- CS, D/C, and RES can be assigned freely to available GPIOs
|
||||||
|
local cs = 8 -- GPIO15, pull-down 10k to GND
|
||||||
|
local dc = 4 -- GPIO2
|
||||||
|
local res = 0 -- GPIO16
|
||||||
|
|
||||||
|
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, spi.DATABITS_8, 0)
|
||||||
|
disp = ucg.ili9341_18x240x320_hw_spi(cs, dc, res)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function upper_pin(x, y)
|
||||||
|
local w = 7
|
||||||
|
local h = 6
|
||||||
|
disp:setColor(0, 212, 212, 212)
|
||||||
|
disp:setColor(1, 200, 200, 200)
|
||||||
|
disp:setColor(2, 200, 200, 200)
|
||||||
|
disp:setColor(3, 188, 188, 188)
|
||||||
|
disp:drawGradientBox(x, y, w, h)
|
||||||
|
|
||||||
|
--disp:drawVLine(x+w, y+1, len)
|
||||||
|
disp:setColor(0, 220, 220, 220)
|
||||||
|
disp:setColor(1, 232, 232, 232)
|
||||||
|
disp:drawGradientLine(x+w, y, h, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function lower_pin(x, y)
|
||||||
|
local w = 7
|
||||||
|
local h = 5
|
||||||
|
disp:setColor(0, 212, 212, 212)
|
||||||
|
disp:setColor(1, 200, 200, 200)
|
||||||
|
disp:setColor(2, 200, 200, 200)
|
||||||
|
disp:setColor(3, 188, 188, 188)
|
||||||
|
disp:drawGradientBox(x, y, w, h)
|
||||||
|
|
||||||
|
--disp:drawVLine(x+w, y+1, len)
|
||||||
|
disp:setColor(0, 220, 220, 220)
|
||||||
|
disp:setColor(1, 232, 232, 232)
|
||||||
|
disp:drawGradientLine(x+w, y, h, 1)
|
||||||
|
disp:setColor(0, 220, 220, 220)
|
||||||
|
disp:setColor(1, 232, 232, 232)
|
||||||
|
disp:drawGradientLine(x, y+h, w, 0)
|
||||||
|
disp:setColor(0, 240, 240, 240)
|
||||||
|
disp:drawPixel(x+w, y+h)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ic_body(x, y)
|
||||||
|
local w = 4*14+4
|
||||||
|
local h = 31
|
||||||
|
disp:setColor(0, 60, 60, 60)
|
||||||
|
disp:setColor(1, 40, 40, 40)
|
||||||
|
disp:setColor(2, 48, 48, 48)
|
||||||
|
disp:setColor(3, 30, 30, 30)
|
||||||
|
disp:drawGradientBox(x, y, w, h)
|
||||||
|
|
||||||
|
disp:setColor(0, 255, 168, 0)
|
||||||
|
--disp:setColor(0, 225, 168, 30)
|
||||||
|
disp:drawDisc(x+w-1, y+h/2-1, 7, bit.bor(ucg.DRAW_UPPER_LEFT, ucg.DRAW_LOWER_LEFT))
|
||||||
|
|
||||||
|
disp:setColor(0, 60, 30, 0)
|
||||||
|
--disp:drawDisc(x+w-1, y+h/2+1, 7, bit.bor(ucg.DRAW_UPPER_LEFT, ucg.DRAW_LOWER_LEFT))
|
||||||
|
|
||||||
|
disp:setColor(0, 50, 50, 50)
|
||||||
|
disp:setColor(0, 25, 25, 25)
|
||||||
|
disp:drawDisc(x+w-1, y+h/2+1, 7, bit.bor(ucg.DRAW_UPPER_LEFT, ucg.DRAW_LOWER_LEFT))
|
||||||
|
end
|
||||||
|
|
||||||
|
function draw_ucg_logo()
|
||||||
|
local a, b
|
||||||
|
|
||||||
|
--ucg_Init(ucg, ucg_sdl_dev_cb, ucg_ext_none, (ucg_com_fnptr)0)
|
||||||
|
disp:setFont(ucg.font_ncenB24_tr)
|
||||||
|
|
||||||
|
--disp:setRotate270()
|
||||||
|
--disp:setClipRange(10,5,40,20)
|
||||||
|
|
||||||
|
a = 2
|
||||||
|
b = 3
|
||||||
|
|
||||||
|
disp:setColor(0, 135*a/b,206*a/b,250*a/b)
|
||||||
|
disp:setColor(1, 176*a/b,226*a/b,255*a/b)
|
||||||
|
disp:setColor(2, 25*a/b,25*a/b,112*a/b)
|
||||||
|
disp:setColor(3, 85*a/b,26*a/b,139*a/b)
|
||||||
|
disp:drawGradientBox(0, 0, disp:getWidth()/4, disp:getHeight())
|
||||||
|
|
||||||
|
disp:setColor(1, 135*a/b,206*a/b,250*a/b)
|
||||||
|
disp:setColor(0, 176*a/b,226*a/b,255*a/b)
|
||||||
|
disp:setColor(3, 25*a/b,25*a/b,112*a/b)
|
||||||
|
disp:setColor(2, 85*a/b,26*a/b,139*a/b)
|
||||||
|
disp:drawGradientBox(disp:getWidth()/4, 0, disp:getWidth()/4, disp:getHeight())
|
||||||
|
|
||||||
|
disp:setColor(0, 135*a/b,206*a/b,250*a/b)
|
||||||
|
disp:setColor(1, 176*a/b,226*a/b,255*a/b)
|
||||||
|
disp:setColor(2, 25*a/b,25*a/b,112*a/b)
|
||||||
|
disp:setColor(3, 85*a/b,26*a/b,139*a/b)
|
||||||
|
disp:drawGradientBox(disp:getWidth()*2/4, 0, disp:getWidth()/4, disp:getHeight())
|
||||||
|
|
||||||
|
disp:setColor(1, 135*a/b,206*a/b,250*a/b)
|
||||||
|
disp:setColor(0, 176*a/b,226*a/b,255*a/b)
|
||||||
|
disp:setColor(3, 25*a/b,25*a/b,112*a/b)
|
||||||
|
disp:setColor(2, 85*a/b,26*a/b,139*a/b)
|
||||||
|
disp:drawGradientBox(disp:getWidth()*3/4, 0, disp:getWidth()/4, disp:getHeight())
|
||||||
|
|
||||||
|
|
||||||
|
upper_pin(7+0*14, 4)
|
||||||
|
upper_pin(7+1*14, 4)
|
||||||
|
upper_pin(7+2*14, 4)
|
||||||
|
upper_pin(7+3*14, 4)
|
||||||
|
|
||||||
|
ic_body(2, 10)
|
||||||
|
|
||||||
|
lower_pin(7+0*14, 41)
|
||||||
|
lower_pin(7+1*14, 41)
|
||||||
|
lower_pin(7+2*14, 41)
|
||||||
|
lower_pin(7+3*14, 41)
|
||||||
|
|
||||||
|
disp:setColor(0, 135*a/b, 206*a/b, 250*a/b)
|
||||||
|
disp:drawString(63+1, 33+1, 0, "glib")
|
||||||
|
|
||||||
|
disp:setColor(0, 255, 168, 0)
|
||||||
|
disp:drawGlyph(26, 38, 0, 'U')
|
||||||
|
disp:drawString(63, 33, 0, "glib")
|
||||||
|
|
||||||
|
disp:setColor(0, 135*a/b, 206*a/b, 250*a/b)
|
||||||
|
disp:setColor(1, 135*a/b, 206*a/b, 250*a/b)
|
||||||
|
disp:setColor(2, 135*a/b, 206*a/b, 250*a/b)
|
||||||
|
disp:setColor(3, 135*a/b, 206*a/b, 250*a/b)
|
||||||
|
disp:drawGradientBox(84+1, 42+1-6, 42, 4)
|
||||||
|
|
||||||
|
disp:setColor(0, 255, 180, 40)
|
||||||
|
disp:setColor(1, 235, 148, 0)
|
||||||
|
--disp:drawGradientLine(79, 42, 20, 0)
|
||||||
|
disp:setColor(2, 245, 158, 0)
|
||||||
|
disp:setColor(3, 220, 138, 0)
|
||||||
|
disp:drawGradientBox(84, 42-6, 42, 4)
|
||||||
|
|
||||||
|
disp:setColor(0, 255, 168, 0)
|
||||||
|
--disp:setFont(ucg.font_5x8_tr)
|
||||||
|
disp:setFont(ucg.font_7x13B_tr)
|
||||||
|
--disp:setFont(ucg.font_courB08_tr)
|
||||||
|
--disp:setFont(ucg.font_timR08_tr)
|
||||||
|
disp:drawString(2, 54+5, 0, "http://github.com")
|
||||||
|
disp:drawString(2, 61+10, 0, "/olikraus/ucglib")
|
||||||
|
--disp:drawString(1, 61, 0, "code.google.com/p/ucglib/")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
init_spi_display()
|
||||||
|
|
||||||
|
disp:begin(ucg.FONT_MODE_TRANSPARENT)
|
||||||
|
disp:clearScreen()
|
||||||
|
|
||||||
|
|
||||||
|
disp:setRotate180()
|
||||||
|
draw_ucg_logo()
|
Loading…
Reference in New Issue