2015-08-05 21:46:24 +02:00
|
|
|
// Module for Ucglib
|
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
// Do not use the code from ucg submodule and skip the complete source here
|
|
|
|
// if the ucg module is not selected.
|
|
|
|
// Reason: The whole ucg submodule code tree might not even exist in this case.
|
|
|
|
#include "user_modules.h"
|
|
|
|
#ifdef LUA_USE_MODULES_UCG
|
|
|
|
|
2015-12-16 06:04:58 +01:00
|
|
|
#include "module.h"
|
2015-08-05 21:46:24 +02:00
|
|
|
#include "lauxlib.h"
|
|
|
|
|
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
#define USE_PIN_LIST
|
2015-08-05 21:46:24 +02:00
|
|
|
#include "ucg.h"
|
2018-10-19 22:18:50 +02:00
|
|
|
#include "ucg_nodemcu_hal.h"
|
|
|
|
|
2015-08-05 21:46:24 +02:00
|
|
|
|
2015-08-09 16:28:49 +02:00
|
|
|
#include "ucg_config.h"
|
2015-08-05 21:46:24 +02:00
|
|
|
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
#ifdef ESP_PLATFORM
|
|
|
|
// ESP32
|
|
|
|
#include "spi_common.h"
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
#include "sdkconfig.h"
|
|
|
|
#endif
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
#ifndef CONFIG_LUA_MODULE_U8G2
|
|
|
|
// ignore unused functions if u8g2 module will be skipped anyhow
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
|
|
|
#endif
|
2015-08-08 12:02:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ucg_nodemcu_t ucg;
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_dev_fnptr dev_cb;
|
2019-02-17 19:26:29 +01:00
|
|
|
ucg_dev_fnptr ext_cb;
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
// For Print() function
|
|
|
|
ucg_int_t tx, ty;
|
|
|
|
uint8_t tdir;
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
int font_ref;
|
|
|
|
int host_ref;
|
|
|
|
} ucg_ud_t;
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2015-08-05 21:46:24 +02:00
|
|
|
|
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
|
|
|
|
// shorthand macro for the ucg structure inside the userdata
|
|
|
|
#define GET_UCG() \
|
|
|
|
ucg_ud_t *ud = (ucg_ud_t *)luaL_checkudata( L, 1, "ucg.display" ); \
|
|
|
|
ucg_t *ucg = (ucg_t *)(&(ud->ucg));
|
|
|
|
|
2015-08-05 21:46:24 +02:00
|
|
|
|
|
|
|
// helper function: retrieve given number of integer arguments
|
2015-08-09 01:38:16 +02:00
|
|
|
static void lucg_get_int_args( lua_State *L, uint8_t stack, uint8_t num, ucg_int_t *args)
|
2015-08-05 21:46:24 +02:00
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
while (num-- > 0) {
|
|
|
|
*args++ = luaL_checkinteger( L, stack++ );
|
|
|
|
}
|
2015-08-05 21:46:24 +02:00
|
|
|
}
|
|
|
|
|
2015-08-08 12:02:52 +02:00
|
|
|
// Lua: ucg.begin( self, fontmode )
|
|
|
|
static int lucg_begin( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_Init( ucg, ud->dev_cb, ud->ext_cb, ucg_com_nodemcu_hw_spi );
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t fontmode = luaL_checkinteger( L, 2 );
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetFontMode( ucg, fontmode );
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-08 12:02:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.clearScreen( self )
|
|
|
|
static int lucg_clearScreen( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_ClearScreen( ucg );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-08 12:02:52 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 01:38:16 +02:00
|
|
|
// Lua: ucg.draw90Line( self, x, y, len, dir, col_idx )
|
|
|
|
static int lucg_draw90Line( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[5];
|
|
|
|
lucg_get_int_args( L, 2, 5, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_Draw90Line( ucg, args[0], args[1], args[2], args[3], args[4] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.drawBox( self, x, y, w, h )
|
|
|
|
static int lucg_drawBox( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[4];
|
|
|
|
lucg_get_int_args( L, 2, 4, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawBox( ucg, args[0], args[1], args[2], args[3] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 13:57:33 +02:00
|
|
|
// Lua: ucg.drawCircle( self, x0, y0, rad, option )
|
|
|
|
static int lucg_drawCircle( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[4];
|
|
|
|
lucg_get_int_args( L, 2, 4, args );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawCircle( ucg, args[0], args[1], args[2], args[3] );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 13:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.drawDisc( self, x0, y0, rad, option )
|
|
|
|
static int lucg_drawDisc( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[4];
|
|
|
|
lucg_get_int_args( L, 2, 4, args );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawDisc( ucg, args[0], args[1], args[2], args[3] );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 13:57:33 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 12:54:35 +02:00
|
|
|
// Lua: ucg.drawFrame( self, x, y, w, h )
|
|
|
|
static int lucg_drawFrame( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 12:54:35 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[4];
|
|
|
|
lucg_get_int_args( L, 2, 4, args );
|
2015-08-09 12:54:35 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawFrame( ucg, args[0], args[1], args[2], args[3] );
|
2015-08-09 12:54:35 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 12:54:35 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 01:38:16 +02:00
|
|
|
// Lua: ucg.drawGradientBox( self, x, y, w, h )
|
|
|
|
static int lucg_drawGradientBox( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[4];
|
|
|
|
lucg_get_int_args( L, 2, 4, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawGradientBox( ucg, args[0], args[1], args[2], args[3] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 13:57:33 +02:00
|
|
|
// Lua: width = ucg.drawGlyph( self, x, y, dir, encoding )
|
|
|
|
static int lucg_drawGlyph( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[3];
|
|
|
|
lucg_get_int_args( L, 2, 3, args );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
const char *c = luaL_checkstring( L, (1+3) + 1 );
|
|
|
|
if (c == NULL)
|
|
|
|
return 0;
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
lua_pushinteger( L, ucg_DrawGlyph( ucg, args[0], args[1], args[2], *c ) );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 1;
|
2015-08-09 13:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.drawGradientLine( self, x, y, len, dir )
|
|
|
|
static int lucg_drawGradientLine( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[4];
|
|
|
|
lucg_get_int_args( L, 2, 4, args );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawGradientLine( ucg, args[0], args[1], args[2], args[3] );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 13:57:33 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 01:38:16 +02:00
|
|
|
// Lua: ucg.drawHLine( self, x, y, len )
|
|
|
|
static int lucg_drawHLine( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[3];
|
|
|
|
lucg_get_int_args( L, 2, 3, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawHLine( ucg, args[0], args[1], args[2] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.drawLine( self, x1, y1, x2, y2 )
|
|
|
|
static int lucg_drawLine( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[4];
|
|
|
|
lucg_get_int_args( L, 2, 4, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawLine( ucg, args[0], args[1], args[2], args[3] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.drawPixel( self, x, y )
|
|
|
|
static int lucg_drawPixel( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[2];
|
|
|
|
lucg_get_int_args( L, 2, 2, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawPixel( ucg, args[0], args[1] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 14:15:17 +02:00
|
|
|
// Lua: ucg.drawRBox( self, x, y, w, h, r )
|
|
|
|
static int lucg_drawRBox( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[5];
|
|
|
|
lucg_get_int_args( L, 2, 5, args );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawRBox( ucg, args[0], args[1], args[2], args[3], args[4] );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.drawRFrame( self, x, y, w, h, r )
|
|
|
|
static int lucg_drawRFrame( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[5];
|
|
|
|
lucg_get_int_args( L, 2, 5, args );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawRFrame( ucg, args[0], args[1], args[2], args[3], args[4] );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 13:57:33 +02:00
|
|
|
// Lua: width = ucg.drawString( self, x, y, dir, str )
|
2015-08-09 01:38:16 +02:00
|
|
|
static int lucg_drawString( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[3];
|
|
|
|
lucg_get_int_args( L, 2, 3, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
const char *s = luaL_checkstring( L, (1+3) + 1 );
|
|
|
|
if (s == NULL)
|
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
lua_pushinteger( L, ucg_DrawString( ucg, args[0], args[1], args[2], s ) );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 1;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 14:15:17 +02:00
|
|
|
// Lua: ucg.drawTetragon( self, x0, y0, x1, y1, x2, y2, x3, y3 )
|
|
|
|
static int lucg_drawTetragon( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[8];
|
|
|
|
lucg_get_int_args( L, 2, 8, args );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawTetragon( ucg, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 01:38:16 +02:00
|
|
|
// Lua: ucg.drawTriangle( self, x0, y0, x1, y1, x2, y2 )
|
|
|
|
static int lucg_drawTriangle( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[6];
|
|
|
|
lucg_get_int_args( L, 2, 6, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawTriangle( ucg, args[0], args[1], args[2], args[3], args[4], args[5] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.drawVLine( self, x, y, len )
|
|
|
|
static int lucg_drawVLine( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[3];
|
|
|
|
lucg_get_int_args( L, 2, 3, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_DrawVLine( ucg, args[0], args[1], args[2] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 14:15:17 +02:00
|
|
|
// Lua: height = ucg.getFontAscent( self )
|
|
|
|
static int lucg_getFontAscent( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
lua_pushinteger( L, ucg_GetFontAscent( ucg ) );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 1;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: height = ucg.getFontDescent( self )
|
|
|
|
static int lucg_getFontDescent( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
lua_pushinteger( L, ucg_GetFontDescent( ucg ) );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 1;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 13:57:33 +02:00
|
|
|
// Lua: height = ucg.getHeight( self )
|
2015-08-09 01:38:16 +02:00
|
|
|
static int lucg_getHeight( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
lua_pushinteger( L, ucg_GetHeight( ucg ) );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 1;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-12-28 15:22:09 +01:00
|
|
|
// Lua: width = ucg.getStrWidth( self, string )
|
2015-08-09 14:15:17 +02:00
|
|
|
static int lucg_getStrWidth( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
const char *s = luaL_checkstring( L, 2 );
|
|
|
|
if (s == NULL)
|
|
|
|
return 0;
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
lua_pushinteger( L, ucg_GetStrWidth( ucg, s ) );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 1;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 13:57:33 +02:00
|
|
|
// Lua: width = ucg.getWidth( self )
|
2015-08-09 01:38:16 +02:00
|
|
|
static int lucg_getWidth( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
lua_pushinteger( L, ucg_GetWidth( ucg ) );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 1;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.setClipRange( self, x, y, w, h )
|
|
|
|
static int lucg_setClipRange( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[4];
|
|
|
|
lucg_get_int_args( L, 2, 4, args );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetClipRange( ucg, args[0], args[1], args[2], args[3] );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-08 12:02:52 +02:00
|
|
|
// Lua: ucg.setColor( self, [idx], r, g, b )
|
|
|
|
static int lucg_setColor( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[3];
|
|
|
|
lucg_get_int_args( L, 2, 3, args );
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t opt = luaL_optint( L, (1+3) + 1, -1 );
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
if (opt < 0) {
|
|
|
|
ucg_SetColor( ucg, 0, args[0], args[1], args[2] );
|
|
|
|
} else {
|
|
|
|
ucg_SetColor( ucg, args[0], args[1], args[2], opt );
|
|
|
|
}
|
2015-08-08 12:02:52 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.setFont( self, font )
|
|
|
|
static int lucg_setFont( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_fntpgm_uint8_t *font = (ucg_fntpgm_uint8_t *)lua_touserdata( L, 2 );
|
|
|
|
if (font != NULL)
|
|
|
|
ucg_SetFont( ucg, font );
|
|
|
|
else
|
|
|
|
luaL_argerror(L, 2, "font data expected");
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-08 12:02:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.print( self, str )
|
|
|
|
static int lucg_print( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
const char *s = luaL_checkstring( L, 2 );
|
|
|
|
if (s == NULL)
|
2015-08-08 12:02:52 +02:00
|
|
|
return 0;
|
2018-10-19 22:18:50 +02:00
|
|
|
|
|
|
|
while (*s)
|
|
|
|
{
|
|
|
|
ucg_int_t delta;
|
|
|
|
delta = ucg_DrawGlyph(ucg, ud->tx, ud->ty, ud->tdir, *(s++));
|
|
|
|
switch(ud->tdir) {
|
|
|
|
case 0: ud->tx += delta; break;
|
|
|
|
case 1: ud->ty += delta; break;
|
|
|
|
case 2: ud->tx -= delta; break;
|
|
|
|
default: case 3: ud->ty -= delta; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2015-08-08 12:02:52 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 01:38:16 +02:00
|
|
|
// Lua: ucg.setFontMode( self, fontmode )
|
|
|
|
static int lucg_setFontMode( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t fontmode = luaL_checkinteger( L, 2 );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetFontMode( ucg, fontmode );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 14:15:17 +02:00
|
|
|
// Lua: ucg.setFontPosBaseline( self )
|
|
|
|
static int lucg_setFontPosBaseline( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetFontPosBaseline( ucg );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.setFontPosBottom( self )
|
|
|
|
static int lucg_setFontPosBottom( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetFontPosBottom( ucg );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.setFontPosCenter( self )
|
|
|
|
static int lucg_setFontPosCenter( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetFontPosCenter( ucg );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.setFontPosTop( self )
|
|
|
|
static int lucg_setFontPosTop( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetFontPosTop( ucg );
|
2015-08-09 14:15:17 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 14:15:17 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 12:54:35 +02:00
|
|
|
// Lua: ucg.setMaxClipRange( self )
|
|
|
|
static int lucg_setMaxClipRange( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 12:54:35 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetMaxClipRange( ucg );
|
2015-08-09 12:54:35 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 12:54:35 +02:00
|
|
|
}
|
|
|
|
|
2015-08-08 12:02:52 +02:00
|
|
|
// Lua: ucg.setPrintPos( self, x, y )
|
|
|
|
static int lucg_setPrintPos( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
|
|
|
(void)ucg;
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_int_t args[2];
|
|
|
|
lucg_get_int_args( L, 2, 2, args );
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ud->tx = args[0];
|
|
|
|
ud->ty = args[1];
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-08 12:02:52 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 01:38:16 +02:00
|
|
|
// Lua: ucg.setPrintDir( self, dir )
|
|
|
|
static int lucg_setPrintDir( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
|
|
|
(void)ucg;
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ud->tdir = luaL_checkinteger( L, 2 );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.setRotate90( self )
|
|
|
|
static int lucg_setRotate90( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetRotate90( ucg );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.setRotate180( self )
|
|
|
|
static int lucg_setRotate180( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetRotate180( ucg );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lua: ucg.setRotate270( self )
|
|
|
|
static int lucg_setRotate270( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetRotate270( ucg );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 13:57:33 +02:00
|
|
|
// Lua: ucg.setScale2x2( self )
|
|
|
|
static int lucg_setScale2x2( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_SetScale2x2( ucg );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 13:57:33 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 01:38:16 +02:00
|
|
|
// Lua: ucg.undoRotate( self )
|
|
|
|
static int lucg_undoRotate( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_UndoRotate( ucg );
|
2015-08-09 01:38:16 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 01:38:16 +02:00
|
|
|
}
|
|
|
|
|
2015-08-09 13:57:33 +02:00
|
|
|
// Lua: ucg.undoScale( self )
|
|
|
|
static int lucg_undoScale( lua_State *L )
|
|
|
|
{
|
2018-10-19 22:18:50 +02:00
|
|
|
GET_UCG();
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
ucg_UndoScale( ucg );
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
return 0;
|
2015-08-09 13:57:33 +02:00
|
|
|
}
|
|
|
|
|
2015-08-08 12:02:52 +02:00
|
|
|
|
2015-08-05 21:46:24 +02:00
|
|
|
// device destructor
|
|
|
|
static int lucg_close_display( lua_State *L )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-09 16:28:49 +02:00
|
|
|
// ***************************************************************************
|
|
|
|
// Device constructors
|
|
|
|
//
|
|
|
|
//
|
2018-10-19 22:18:50 +02:00
|
|
|
static int ldisplay_hw_spi( lua_State *L, ucg_dev_fnptr device, ucg_dev_fnptr extension )
|
|
|
|
{
|
|
|
|
int stack = 0;
|
|
|
|
|
|
|
|
#ifndef ESP_PLATFORM
|
|
|
|
// ESP8266
|
|
|
|
typedef struct {
|
|
|
|
int host;
|
|
|
|
} lspi_host_t;
|
|
|
|
lspi_host_t host_elem;
|
|
|
|
lspi_host_t *host = &host_elem;
|
|
|
|
#else
|
|
|
|
// ESP32
|
|
|
|
lspi_host_t *host = NULL;
|
|
|
|
#endif
|
|
|
|
int host_ref = LUA_NOREF;
|
|
|
|
int cs = -1;
|
|
|
|
int dc = -1;
|
|
|
|
int res = -1;
|
|
|
|
int get_spi_pins;
|
|
|
|
|
|
|
|
if (lua_type( L, ++stack ) == LUA_TUSERDATA) {
|
|
|
|
host = (lspi_host_t *)luaL_checkudata( L, stack, "spi.master" );
|
|
|
|
/* reference host object to avoid automatic gc */
|
|
|
|
lua_pushvalue( L, stack );
|
|
|
|
host_ref = luaL_ref( L, LUA_REGISTRYINDEX );
|
|
|
|
get_spi_pins = 1;
|
|
|
|
} else if (lua_type( L, stack ) == LUA_TNUMBER) {
|
|
|
|
host->host = luaL_checkint( L, stack );
|
|
|
|
get_spi_pins = 1;
|
|
|
|
} else {
|
|
|
|
get_spi_pins = 0;
|
|
|
|
stack--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_spi_pins) {
|
|
|
|
cs = luaL_checkint( L, ++stack );
|
|
|
|
dc = luaL_checkint( L, ++stack );
|
|
|
|
res = luaL_optint( L, ++stack, -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
ucg_ud_t *ud = (ucg_ud_t *) lua_newuserdata( L, sizeof( ucg_ud_t ) );
|
|
|
|
ucg_nodemcu_t *ext_ucg = &(ud->ucg);
|
|
|
|
ud->font_ref = LUA_NOREF;
|
|
|
|
ud->host_ref = host_ref;
|
|
|
|
ext_ucg->hal = host ? (void *)(host->host) : NULL;
|
|
|
|
|
|
|
|
ucg_t *ucg = (ucg_t *)ext_ucg;
|
|
|
|
|
|
|
|
/* do a dummy init so that something usefull is part of the ucg structure */
|
|
|
|
ucg_Init( ucg, ucg_dev_default_cb, ucg_ext_none, (ucg_com_fnptr)0 );
|
|
|
|
|
|
|
|
/* reset cursor position */
|
|
|
|
ud->tx = 0;
|
|
|
|
ud->ty = 0;
|
|
|
|
ud->tdir = 0; /* default direction */
|
|
|
|
|
|
|
|
uint8_t i;
|
|
|
|
for( i = 0; i < UCG_PIN_COUNT; i++ )
|
|
|
|
ucg->pin_list[i] = UCG_PIN_VAL_NONE;
|
|
|
|
|
|
|
|
ud->dev_cb = device;
|
|
|
|
ud->ext_cb = extension;
|
|
|
|
if (res >= 0)
|
|
|
|
ucg->pin_list[UCG_PIN_RST] = res;
|
|
|
|
ucg->pin_list[UCG_PIN_CD] = dc;
|
|
|
|
ucg->pin_list[UCG_PIN_CS] = cs;
|
|
|
|
|
|
|
|
/* set its metatable */
|
|
|
|
luaL_getmetatable(L, "ucg.display");
|
|
|
|
lua_setmetatable(L, -2);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2015-08-09 16:28:49 +02:00
|
|
|
#undef UCG_DISPLAY_TABLE_ENTRY
|
2018-10-19 22:18:50 +02:00
|
|
|
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) \
|
|
|
|
static int l ## binding( lua_State *L ) \
|
|
|
|
{ \
|
|
|
|
return ldisplay_hw_spi( L, device, extension ); \
|
|
|
|
}
|
2015-08-09 16:28:49 +02:00
|
|
|
//
|
|
|
|
// Unroll the display table and insert binding functions.
|
|
|
|
UCG_DISPLAY_TABLE
|
|
|
|
//
|
|
|
|
// ***************************************************************************
|
2015-08-08 12:02:52 +02:00
|
|
|
|
|
|
|
|
2015-08-05 21:46:24 +02:00
|
|
|
|
|
|
|
// Module function map
|
2020-04-27 02:13:38 +02:00
|
|
|
LROT_BEGIN(lucg_display, NULL, LROT_MASK_GC_INDEX)
|
|
|
|
LROT_FUNCENTRY( __gc, lucg_close_display )
|
|
|
|
LROT_TABENTRY( __index, lucg_display )
|
2019-05-08 13:08:20 +02:00
|
|
|
LROT_FUNCENTRY( begin, lucg_begin )
|
|
|
|
LROT_FUNCENTRY( clearScreen, lucg_clearScreen )
|
|
|
|
LROT_FUNCENTRY( draw90Line, lucg_draw90Line )
|
|
|
|
LROT_FUNCENTRY( drawBox, lucg_drawBox )
|
|
|
|
LROT_FUNCENTRY( drawCircle, lucg_drawCircle )
|
|
|
|
LROT_FUNCENTRY( drawDisc, lucg_drawDisc )
|
|
|
|
LROT_FUNCENTRY( drawFrame, lucg_drawFrame )
|
|
|
|
LROT_FUNCENTRY( drawGlyph, lucg_drawGlyph )
|
|
|
|
LROT_FUNCENTRY( drawGradientBox, lucg_drawGradientBox )
|
|
|
|
LROT_FUNCENTRY( drawGradientLine, lucg_drawGradientLine )
|
|
|
|
LROT_FUNCENTRY( drawHLine, lucg_drawHLine )
|
|
|
|
LROT_FUNCENTRY( drawLine, lucg_drawLine )
|
|
|
|
LROT_FUNCENTRY( drawPixel, lucg_drawPixel )
|
|
|
|
LROT_FUNCENTRY( drawRBox, lucg_drawRBox )
|
|
|
|
LROT_FUNCENTRY( drawRFrame, lucg_drawRFrame )
|
|
|
|
LROT_FUNCENTRY( drawString, lucg_drawString )
|
|
|
|
LROT_FUNCENTRY( drawTetragon, lucg_drawTetragon )
|
|
|
|
LROT_FUNCENTRY( drawTriangle, lucg_drawTriangle )
|
|
|
|
LROT_FUNCENTRY( drawVLine, lucg_drawVLine )
|
|
|
|
LROT_FUNCENTRY( getFontAscent, lucg_getFontAscent )
|
|
|
|
LROT_FUNCENTRY( getFontDescent, lucg_getFontDescent )
|
|
|
|
LROT_FUNCENTRY( getHeight, lucg_getHeight )
|
|
|
|
LROT_FUNCENTRY( getStrWidth, lucg_getStrWidth )
|
|
|
|
LROT_FUNCENTRY( getWidth, lucg_getWidth )
|
|
|
|
LROT_FUNCENTRY( print, lucg_print )
|
|
|
|
LROT_FUNCENTRY( setClipRange, lucg_setClipRange )
|
|
|
|
LROT_FUNCENTRY( setColor, lucg_setColor )
|
|
|
|
LROT_FUNCENTRY( setFont, lucg_setFont )
|
|
|
|
LROT_FUNCENTRY( setFontMode, lucg_setFontMode )
|
|
|
|
LROT_FUNCENTRY( setFontPosBaseline, lucg_setFontPosBaseline )
|
|
|
|
LROT_FUNCENTRY( setFontPosBottom, lucg_setFontPosBottom )
|
|
|
|
LROT_FUNCENTRY( setFontPosCenter, lucg_setFontPosCenter )
|
|
|
|
LROT_FUNCENTRY( setFontPosTop, lucg_setFontPosTop )
|
|
|
|
LROT_FUNCENTRY( setMaxClipRange, lucg_setMaxClipRange )
|
|
|
|
LROT_FUNCENTRY( setPrintDir, lucg_setPrintDir )
|
|
|
|
LROT_FUNCENTRY( setPrintPos, lucg_setPrintPos )
|
|
|
|
LROT_FUNCENTRY( setRotate90, lucg_setRotate90 )
|
|
|
|
LROT_FUNCENTRY( setRotate180, lucg_setRotate180 )
|
|
|
|
LROT_FUNCENTRY( setRotate270, lucg_setRotate270 )
|
|
|
|
LROT_FUNCENTRY( setScale2x2, lucg_setScale2x2 )
|
|
|
|
LROT_FUNCENTRY( undoClipRange, lucg_setMaxClipRange )
|
|
|
|
LROT_FUNCENTRY( undoRotate, lucg_undoRotate )
|
|
|
|
LROT_FUNCENTRY( undoScale, lucg_undoScale )
|
2020-04-27 02:13:38 +02:00
|
|
|
LROT_END(lucg_display, NULL, LROT_MASK_GC_INDEX)
|
2019-05-08 13:08:20 +02:00
|
|
|
|
|
|
|
|
2020-04-27 02:13:38 +02:00
|
|
|
LROT_BEGIN(lucg, NULL , 0)
|
2015-08-09 16:28:49 +02:00
|
|
|
#undef UCG_DISPLAY_TABLE_ENTRY
|
2019-05-08 13:08:20 +02:00
|
|
|
#define UCG_DISPLAY_TABLE_ENTRY(binding, device, extension) LROT_FUNCENTRY(binding,l ## binding)
|
2018-10-19 22:18:50 +02:00
|
|
|
UCG_DISPLAY_TABLE
|
2015-08-05 21:46:24 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
// Register fonts
|
2015-08-09 16:28:49 +02:00
|
|
|
#undef UCG_FONT_TABLE_ENTRY
|
2019-05-08 13:08:20 +02:00
|
|
|
#define UCG_FONT_TABLE_ENTRY(font) LROT_LUDENTRY(font, ucg_ ## font )
|
2018-10-19 22:18:50 +02:00
|
|
|
UCG_FONT_TABLE
|
2015-08-05 21:46:24 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
// Font modes
|
2019-05-08 13:08:20 +02:00
|
|
|
LROT_NUMENTRY( FONT_MODE_TRANSPARENT, UCG_FONT_MODE_TRANSPARENT )
|
|
|
|
LROT_NUMENTRY( FONT_MODE_SOLID, UCG_FONT_MODE_SOLID )
|
2015-08-05 21:46:24 +02:00
|
|
|
|
2018-10-19 22:18:50 +02:00
|
|
|
// Options for circle/ disc drawing
|
2019-05-08 13:08:20 +02:00
|
|
|
LROT_NUMENTRY( DRAW_UPPER_RIGHT, UCG_DRAW_UPPER_RIGHT )
|
|
|
|
LROT_NUMENTRY( DRAW_UPPER_LEFT, UCG_DRAW_UPPER_LEFT )
|
|
|
|
LROT_NUMENTRY( DRAW_LOWER_RIGHT, UCG_DRAW_LOWER_RIGHT )
|
|
|
|
LROT_NUMENTRY( DRAW_LOWER_LEFT, UCG_DRAW_LOWER_LEFT )
|
|
|
|
LROT_NUMENTRY( DRAW_ALL, UCG_DRAW_ALL )
|
2020-04-27 02:13:38 +02:00
|
|
|
LROT_END(lucg, NULL, 0)
|
2015-08-09 13:57:33 +02:00
|
|
|
|
2015-08-05 21:46:24 +02:00
|
|
|
|
2015-12-16 06:04:58 +01:00
|
|
|
int luaopen_ucg( lua_State *L )
|
2015-08-05 21:46:24 +02:00
|
|
|
{
|
2019-05-08 13:08:20 +02:00
|
|
|
luaL_rometatable(L, "ucg.display", LROT_TABLEREF(lucg_display));
|
2015-08-05 21:46:24 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2015-12-16 06:04:58 +01:00
|
|
|
|
2019-05-08 13:08:20 +02:00
|
|
|
NODEMCU_MODULE(UCG, "ucg", lucg, luaopen_ucg);
|
2018-10-19 22:18:50 +02:00
|
|
|
|
|
|
|
#endif /* LUA_USE_MODULES_UCG */
|