further reduce RAM usage, consolidate font memory and "PROGMEM"
This commit is contained in:
parent
bf53ba9754
commit
d7f04a1de8
|
@ -339,7 +339,6 @@ static int lu8g_nextPage( lua_State *L )
|
||||||
// ------------------------------------------------------------
|
// ------------------------------------------------------------
|
||||||
// comm functions
|
// comm functions
|
||||||
//
|
//
|
||||||
#define I2C_SLA 0x3c
|
|
||||||
#define I2C_CMD_MODE 0x000
|
#define I2C_CMD_MODE 0x000
|
||||||
#define I2C_DATA_MODE 0x040
|
#define I2C_DATA_MODE 0x040
|
||||||
|
|
||||||
|
@ -530,7 +529,6 @@ const LUA_REG_TYPE lu8g_map[] =
|
||||||
{
|
{
|
||||||
{ LSTRKEY( "ssd1306_128x64_i2c" ), LFUNCVAL ( lu8g_ssd1306_128x64_i2c ) },
|
{ LSTRKEY( "ssd1306_128x64_i2c" ), LFUNCVAL ( lu8g_ssd1306_128x64_i2c ) },
|
||||||
#if LUA_OPTIMIZE_MEMORY > 0
|
#if LUA_OPTIMIZE_MEMORY > 0
|
||||||
//{ LSTRKEY( "font_6x10" ), LNUMVAL( LU8G_FONT_6X10 ) },
|
|
||||||
|
|
||||||
// Register fonts
|
// Register fonts
|
||||||
#undef U8G_FONT_TABLE_ENTRY
|
#undef U8G_FONT_TABLE_ENTRY
|
||||||
|
|
103
app/u8glib/u8g.h
103
app/u8glib/u8g.h
|
@ -93,7 +93,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef U8G_FONT_SECTION
|
#ifndef U8G_FONT_SECTION
|
||||||
# define U8G_FONT_SECTION(name) U8G_SECTION(".font_data." name)
|
# define U8G_FONT_SECTION(name) U8G_SECTION(".u8g_progmem." name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ typedef uint8_t u8g_fntpgm_uint8_t;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define U8G_PROGMEM
|
#define U8G_PROGMEM
|
||||||
#define PROGMEM
|
#define PROGMEM U8G_SECTION(".u8g_progmem.data")
|
||||||
typedef uint8_t u8g_pgm_uint8_t;
|
typedef uint8_t u8g_pgm_uint8_t;
|
||||||
typedef uint8_t u8g_fntpgm_uint8_t;
|
typedef uint8_t u8g_fntpgm_uint8_t;
|
||||||
//#define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
|
//#define u8g_pgm_read(adr) (*(const u8g_pgm_uint8_t *)(adr))
|
||||||
|
@ -153,6 +153,7 @@ typedef struct _u8g_dev_arg_bbx_t u8g_dev_arg_bbx_t;
|
||||||
typedef struct _u8g_box_t u8g_box_t;
|
typedef struct _u8g_box_t u8g_box_t;
|
||||||
typedef struct _u8g_dev_arg_irgb_t u8g_dev_arg_irgb_t;
|
typedef struct _u8g_dev_arg_irgb_t u8g_dev_arg_irgb_t;
|
||||||
|
|
||||||
|
typedef struct _pg_struct pg_struct;
|
||||||
|
|
||||||
/*===============================================================*/
|
/*===============================================================*/
|
||||||
/* generic */
|
/* generic */
|
||||||
|
@ -1054,49 +1055,6 @@ typedef void (*u8g_state_cb)(uint8_t msg);
|
||||||
#define U8G_FONT_HEIGHT_MODE_XTEXT 1
|
#define U8G_FONT_HEIGHT_MODE_XTEXT 1
|
||||||
#define U8G_FONT_HEIGHT_MODE_ALL 2
|
#define U8G_FONT_HEIGHT_MODE_ALL 2
|
||||||
|
|
||||||
struct _u8g_t
|
|
||||||
{
|
|
||||||
u8g_uint_t width;
|
|
||||||
u8g_uint_t height;
|
|
||||||
|
|
||||||
|
|
||||||
u8g_dev_t *dev; /* first device in the device chain */
|
|
||||||
const u8g_pgm_uint8_t *font; /* regular font for all text procedures */
|
|
||||||
const u8g_pgm_uint8_t *cursor_font; /* special font for cursor procedures */
|
|
||||||
uint8_t cursor_fg_color, cursor_bg_color;
|
|
||||||
uint8_t cursor_encoding;
|
|
||||||
uint8_t mode; /* display mode, one of U8G_MODE_xxx */
|
|
||||||
u8g_uint_t cursor_x;
|
|
||||||
u8g_uint_t cursor_y;
|
|
||||||
u8g_draw_cursor_fn cursor_fn;
|
|
||||||
|
|
||||||
int8_t glyph_dx;
|
|
||||||
int8_t glyph_x;
|
|
||||||
int8_t glyph_y;
|
|
||||||
uint8_t glyph_width;
|
|
||||||
uint8_t glyph_height;
|
|
||||||
|
|
||||||
u8g_font_calc_vref_fnptr font_calc_vref;
|
|
||||||
uint8_t font_height_mode;
|
|
||||||
int8_t font_ref_ascent;
|
|
||||||
int8_t font_ref_descent;
|
|
||||||
uint8_t font_line_spacing_factor; /* line_spacing = factor * (ascent - descent) / 64 */
|
|
||||||
uint8_t line_spacing;
|
|
||||||
|
|
||||||
u8g_dev_arg_pixel_t arg_pixel;
|
|
||||||
/* uint8_t color_index; */
|
|
||||||
|
|
||||||
#ifdef U8G_WITH_PINLIST
|
|
||||||
uint8_t pin_list[U8G_PIN_LIST_LEN];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
u8g_state_cb state_cb;
|
|
||||||
|
|
||||||
u8g_box_t current_page; /* current box of the visible page */
|
|
||||||
|
|
||||||
uint8_t i2c_addr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define u8g_GetFontAscent(u8g) ((u8g)->font_ref_ascent)
|
#define u8g_GetFontAscent(u8g) ((u8g)->font_ref_ascent)
|
||||||
#define u8g_GetFontDescent(u8g) ((u8g)->font_ref_descent)
|
#define u8g_GetFontDescent(u8g) ((u8g)->font_ref_descent)
|
||||||
#define u8g_GetFontLineSpacing(u8g) ((u8g)->line_spacing)
|
#define u8g_GetFontLineSpacing(u8g) ((u8g)->line_spacing)
|
||||||
|
@ -1354,8 +1312,6 @@ struct pg_point_struct
|
||||||
pg_word_t y;
|
pg_word_t y;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _pg_struct pg_struct; /* forward declaration */
|
|
||||||
|
|
||||||
struct pg_edge_struct
|
struct pg_edge_struct
|
||||||
{
|
{
|
||||||
pg_word_t x_direction; /* 1, if x2 is greater than x1, -1 otherwise */
|
pg_word_t x_direction; /* 1, if x2 is greater than x1, -1 otherwise */
|
||||||
|
@ -1395,7 +1351,7 @@ struct _pg_struct
|
||||||
void pg_ClearPolygonXY(pg_struct *pg);
|
void pg_ClearPolygonXY(pg_struct *pg);
|
||||||
void pg_AddPolygonXY(pg_struct *pg, u8g_t *u8g, int16_t x, int16_t y);
|
void pg_AddPolygonXY(pg_struct *pg, u8g_t *u8g, int16_t x, int16_t y);
|
||||||
void pg_DrawPolygon(pg_struct *pg, u8g_t *u8g);
|
void pg_DrawPolygon(pg_struct *pg, u8g_t *u8g);
|
||||||
void u8g_ClearPolygonXY(void);
|
void u8g_ClearPolygonXY(u8g_t *u8g);
|
||||||
void u8g_AddPolygonXY(u8g_t *u8g, int16_t x, int16_t y);
|
void u8g_AddPolygonXY(u8g_t *u8g, int16_t x, int16_t y);
|
||||||
void u8g_DrawPolygon(u8g_t *u8g);
|
void u8g_DrawPolygon(u8g_t *u8g);
|
||||||
void u8g_DrawTriangle(u8g_t *u8g, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
|
void u8g_DrawTriangle(u8g_t *u8g, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
|
||||||
|
@ -1470,6 +1426,57 @@ void chess_Init(u8g_t *u8g, uint8_t empty_body_color);
|
||||||
void chess_Draw(void);
|
void chess_Draw(void);
|
||||||
void chess_Step(uint8_t keycode);
|
void chess_Step(uint8_t keycode);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct _u8g_t
|
||||||
|
{
|
||||||
|
u8g_uint_t width;
|
||||||
|
u8g_uint_t height;
|
||||||
|
|
||||||
|
|
||||||
|
u8g_dev_t *dev; /* first device in the device chain */
|
||||||
|
const u8g_pgm_uint8_t *font; /* regular font for all text procedures */
|
||||||
|
const u8g_pgm_uint8_t *cursor_font; /* special font for cursor procedures */
|
||||||
|
uint8_t cursor_fg_color, cursor_bg_color;
|
||||||
|
uint8_t cursor_encoding;
|
||||||
|
uint8_t mode; /* display mode, one of U8G_MODE_xxx */
|
||||||
|
u8g_uint_t cursor_x;
|
||||||
|
u8g_uint_t cursor_y;
|
||||||
|
u8g_draw_cursor_fn cursor_fn;
|
||||||
|
|
||||||
|
int8_t glyph_dx;
|
||||||
|
int8_t glyph_x;
|
||||||
|
int8_t glyph_y;
|
||||||
|
uint8_t glyph_width;
|
||||||
|
uint8_t glyph_height;
|
||||||
|
|
||||||
|
u8g_font_calc_vref_fnptr font_calc_vref;
|
||||||
|
uint8_t font_height_mode;
|
||||||
|
int8_t font_ref_ascent;
|
||||||
|
int8_t font_ref_descent;
|
||||||
|
uint8_t font_line_spacing_factor; /* line_spacing = factor * (ascent - descent) / 64 */
|
||||||
|
uint8_t line_spacing;
|
||||||
|
|
||||||
|
u8g_dev_arg_pixel_t arg_pixel;
|
||||||
|
/* uint8_t color_index; */
|
||||||
|
|
||||||
|
#ifdef U8G_WITH_PINLIST
|
||||||
|
uint8_t pin_list[U8G_PIN_LIST_LEN];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
u8g_state_cb state_cb;
|
||||||
|
|
||||||
|
u8g_box_t current_page; /* current box of the visible page */
|
||||||
|
|
||||||
|
uint8_t i2c_addr;
|
||||||
|
|
||||||
|
/* global variables from u8g_polygon.c */
|
||||||
|
pg_struct pg;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*===============================================================*/
|
/*===============================================================*/
|
||||||
/* font definitions */
|
/* font definitions */
|
||||||
extern const u8g_fntpgm_uint8_t u8g_font_m2icon_5[] U8G_FONT_SECTION("u8g_font_m2icon_5");
|
extern const u8g_fntpgm_uint8_t u8g_font_m2icon_5[] U8G_FONT_SECTION("u8g_font_m2icon_5");
|
||||||
|
|
|
@ -384,29 +384,28 @@ uint8_t u8g_dev_sh1106_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, voi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//U8G_PB_DEV(u8g_dev_ssd1306_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SW_SPI);
|
U8G_PB_DEV(u8g_dev_ssd1306_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SW_SPI);
|
||||||
//U8G_PB_DEV(u8g_dev_ssd1306_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_HW_SPI);
|
U8G_PB_DEV(u8g_dev_ssd1306_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_HW_SPI);
|
||||||
U8G_PB_DEV(u8g_dev_ssd1306_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SSD_I2C);
|
U8G_PB_DEV(u8g_dev_ssd1306_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SSD_I2C);
|
||||||
|
|
||||||
//U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SW_SPI);
|
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SW_SPI);
|
||||||
//U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_HW_SPI);
|
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_HW_SPI);
|
||||||
//U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SSD_I2C);
|
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SSD_I2C);
|
||||||
//
|
|
||||||
//
|
|
||||||
//uint8_t u8g_dev_ssd1306_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
|
||||||
//u8g_pb_t u8g_dev_ssd1306_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x64_2x_buf};
|
|
||||||
//u8g_dev_t u8g_dev_ssd1306_128x64_2x_sw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SW_SPI };
|
|
||||||
//u8g_dev_t u8g_dev_ssd1306_128x64_2x_hw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_HW_SPI };
|
|
||||||
//u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SSD_I2C };
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//U8G_PB_DEV(u8g_dev_sh1106_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SW_SPI);
|
|
||||||
//U8G_PB_DEV(u8g_dev_sh1106_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_HW_SPI);
|
|
||||||
//U8G_PB_DEV(u8g_dev_sh1106_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SSD_I2C);
|
|
||||||
//
|
|
||||||
//uint8_t u8g_dev_sh1106_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
|
||||||
//u8g_pb_t u8g_dev_sh1106_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_buf};
|
|
||||||
//u8g_dev_t u8g_dev_sh1106_128x64_2x_sw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SW_SPI };
|
|
||||||
//u8g_dev_t u8g_dev_sh1106_128x64_2x_hw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_HW_SPI };
|
|
||||||
//u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SSD_I2C };
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t u8g_dev_ssd1306_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||||
|
u8g_pb_t u8g_dev_ssd1306_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x64_2x_buf};
|
||||||
|
u8g_dev_t u8g_dev_ssd1306_128x64_2x_sw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SW_SPI };
|
||||||
|
u8g_dev_t u8g_dev_ssd1306_128x64_2x_hw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_HW_SPI };
|
||||||
|
u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SSD_I2C };
|
||||||
|
|
||||||
|
|
||||||
|
U8G_PB_DEV(u8g_dev_sh1106_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SW_SPI);
|
||||||
|
U8G_PB_DEV(u8g_dev_sh1106_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_HW_SPI);
|
||||||
|
U8G_PB_DEV(u8g_dev_sh1106_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SSD_I2C);
|
||||||
|
|
||||||
|
uint8_t u8g_dev_sh1106_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||||
|
u8g_pb_t u8g_dev_sh1106_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_buf};
|
||||||
|
u8g_dev_t u8g_dev_sh1106_128x64_2x_sw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SW_SPI };
|
||||||
|
u8g_dev_t u8g_dev_sh1106_128x64_2x_hw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_HW_SPI };
|
||||||
|
u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SSD_I2C };
|
||||||
|
|
|
@ -306,26 +306,26 @@ void pg_DrawPolygon(pg_struct *pg, u8g_t *u8g)
|
||||||
pg_exec(pg, u8g);
|
pg_exec(pg, u8g);
|
||||||
}
|
}
|
||||||
|
|
||||||
pg_struct u8g_pg;
|
//pg_struct u8g_pg;
|
||||||
|
|
||||||
void u8g_ClearPolygonXY(void)
|
void u8g_ClearPolygonXY(u8g_t *u8g)
|
||||||
{
|
{
|
||||||
pg_ClearPolygonXY(&u8g_pg);
|
pg_ClearPolygonXY(&(u8g->pg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void u8g_AddPolygonXY(u8g_t *u8g, int16_t x, int16_t y)
|
void u8g_AddPolygonXY(u8g_t *u8g, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
pg_AddPolygonXY(&u8g_pg, u8g, x, y);
|
pg_AddPolygonXY(&(u8g->pg), u8g, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void u8g_DrawPolygon(u8g_t *u8g)
|
void u8g_DrawPolygon(u8g_t *u8g)
|
||||||
{
|
{
|
||||||
pg_DrawPolygon(&u8g_pg, u8g);
|
pg_DrawPolygon(&(u8g->pg), u8g);
|
||||||
}
|
}
|
||||||
|
|
||||||
void u8g_DrawTriangle(u8g_t *u8g, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2)
|
void u8g_DrawTriangle(u8g_t *u8g, int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2)
|
||||||
{
|
{
|
||||||
u8g_ClearPolygonXY();
|
u8g_ClearPolygonXY(u8g);
|
||||||
u8g_AddPolygonXY(u8g, x0, y0);
|
u8g_AddPolygonXY(u8g, x0, y0);
|
||||||
u8g_AddPolygonXY(u8g, x1, y1);
|
u8g_AddPolygonXY(u8g, x1, y1);
|
||||||
u8g_AddPolygonXY(u8g, x2, y2);
|
u8g_AddPolygonXY(u8g, x2, y2);
|
||||||
|
|
|
@ -73,8 +73,8 @@ SECTIONS
|
||||||
*(.literal.* .text.*)
|
*(.literal.* .text.*)
|
||||||
*(.rodata2.text)
|
*(.rodata2.text)
|
||||||
|
|
||||||
/* put font data into irom0 */
|
/* put font and progmem data into irom0 */
|
||||||
*(.font_data.*)
|
*(.u8g_progmem.*)
|
||||||
|
|
||||||
_irom0_text_end = ABSOLUTE(.);
|
_irom0_text_end = ABSOLUTE(.);
|
||||||
_flash_used_end = ABSOLUTE(.);
|
_flash_used_end = ABSOLUTE(.);
|
||||||
|
|
Loading…
Reference in New Issue