LCD refactoring - saves 6 bytes on 9x stock

This commit is contained in:
bsongis
2014-08-20 22:29:45 +02:00
parent 749afc103e
commit 4d84ba4c19
19 changed files with 349 additions and 334 deletions
+84 -80
View File
@@ -40,7 +40,8 @@
#if defined(PCBTARANIS)
#define LCD_W 212
#define LCD_H 64
#define xcoord_t uint16_t
#define coord_t int
#define scoord_t int
#define CENTER "\015"
#define CENTER_OFS (7*FW-FW/2)
#define CONTRAST_MIN 0
@@ -48,7 +49,8 @@
#else
#define LCD_W 128
#define LCD_H 64
#define xcoord_t uint8_t
#define coord_t uint8_t
#define scoord_t int8_t
#define CENTER
#define CENTER_OFS 0
#define CONTRAST_MIN 10
@@ -67,6 +69,9 @@
#define FWNUM 5
#define FH 8
#define MENU_TITLE_HEIGHT FH
#define MENU_NAVIG_HEIGHT 0
#define LCD_LINES (LCD_H/FH)
#define LCD_COLS (LCD_W/FW)
@@ -75,7 +80,6 @@
/* lcd text flags */
#define INVERS 0x02
#define DBLSIZE 0x04
#ifdef BOLD_FONT
#define BOLD 0x40
#else
@@ -111,51 +115,56 @@
#define NO_UNIT 0x40
#if defined(CPUARM)
#define MIDSIZE 0x0100
#define FONTSIZE(x) ((x) & 0x0F00)
#define TINSIZE 0x0100
#define SMLSIZE 0x0200
#define TINSIZE 0x0400
#define XXLSIZE 0x0800
#define MIDSIZE 0x0300
#define DBLSIZE 0x0400
#define XXLSIZE 0x0500
#define ERASEBG 0x8000
#else
#define DBLSIZE 0x04
#define MIDSIZE DBLSIZE
#define SMLSIZE 0x00
#define TINSIZE 0x00
#define XXLSIZE 0x00
#endif
#if defined(PCBTARANIS)
#define GREY(x) ((x) * 0x1000)
#define GREY_DEFAULT GREY(11)
#define GREY_MASK(x) ((x) & 0xF000)
#define ERASEBG 0x00
#endif
#if defined(CPUARM)
#define TIMEBLINK 0x010000
#define TIMEHOUR 0x020000
#define STREXPANDED 0x040000
#define TIMEBLINK 0x1000
#define TIMEHOUR 0x2000
#define STREXPANDED 0x4000
#else
#define STREXPANDED 0x00
#endif
#if defined(CPUARM)
#define LcdFlags uint32_t
#else
#define LcdFlags uint8_t
#if defined(PCBTARANIS)
#define GREY(x) ((x) * 0x010000)
#define GREY_DEFAULT GREY(11)
#define COLOUR_MASK(x) ((x) & 0x0F0000)
#endif
#define DISPLAY_PLAN_SIZE (LCD_W*((LCD_H+7)/8))
#if defined(CPUARM)
#define LcdFlags uint32_t
#else
#define LcdFlags uint8_t
#endif
#if defined(PCBTARANIS)
#define DISPLAY_BUF_SIZE (4*DISPLAY_PLAN_SIZE)
#define display_t uint8_t
#define DISPLAY_BUF_SIZE (LCD_W*LCD_H*4/8)
#else
#define DISPLAY_BUF_SIZE DISPLAY_PLAN_SIZE
#define display_t uint8_t
#define DISPLAY_BUF_SIZE (LCD_W*((LCD_H+7)/8))
#endif
extern uint8_t displayBuf[DISPLAY_BUF_SIZE];
extern uint8_t lcdLastPos;
extern uint8_t lcdNextPos;
extern display_t displayBuf[DISPLAY_BUF_SIZE];
extern coord_t lcdLastPos;
extern coord_t lcdNextPos;
#define DISPLAY_END (displayBuf + DISPLAY_BUF_SIZE)
#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END)
#define DISPLAY_END (displayBuf + DISPLAY_BUF_SIZE)
#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END)
#if defined(PCBSTD) && defined(VOICE)
extern volatile uint8_t LcdLock ;
@@ -172,42 +181,42 @@ typedef const unsigned char pm_uchar;
typedef const char pm_char;
#endif
void lcd_putc(xcoord_t x, uint8_t y, const unsigned char c);
void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags mode);
void lcd_putsAtt(xcoord_t x, uint8_t y, const pm_char * s, LcdFlags mode);
void lcd_putsiAtt(xcoord_t x, uint8_t y, const pm_char * s,uint8_t idx, LcdFlags mode);
void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s,unsigned char len, LcdFlags mode);
void lcd_puts(xcoord_t x, uint8_t y, const pm_char * s);
void lcd_putsn(xcoord_t x, uint8_t y, const pm_char * s, unsigned char len);
void lcd_putsLeft(uint8_t y, const pm_char * s);
void lcd_putc(coord_t x, coord_t y, const unsigned char c);
void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags mode);
void lcd_putsAtt(coord_t x, coord_t y, const pm_char * s, LcdFlags mode);
void lcd_putsiAtt(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags mode);
void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s,unsigned char len, LcdFlags mode);
void lcd_puts(coord_t x, coord_t y, const pm_char * s);
void lcd_putsn(coord_t x, coord_t y, const pm_char * s, unsigned char len);
void lcd_putsLeft(coord_t y, const pm_char * s);
#define lcd_putsCenter(y, s) lcd_puts((LCD_W-sizeof(TR_##s)*FW+FW-2)/2, y, STR_##s)
void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val);
void lcd_outdezAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags mode=0);
void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags mode=0, uint8_t len=0);
void lcd_outdez8(xcoord_t x, uint8_t y, int8_t val);
void lcd_outhex4(coord_t x, coord_t y, uint16_t val);
void lcd_outdezAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags mode=0);
void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags mode=0, uint8_t len=0);
void lcd_outdez8(coord_t x, coord_t y, int8_t val);
void putsStrIdx(xcoord_t x, uint8_t y, const pm_char *str, uint8_t idx, LcdFlags att=0);
void putsModelName(xcoord_t x, uint8_t y, char *name, uint8_t id, LcdFlags att);
void putsSwitches(xcoord_t x, uint8_t y, int8_t swtch, LcdFlags att=0);
void putsMixerSource(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags att=0);
void putsFlightMode(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
void putsStrIdx(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att=0);
void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
void putsSwitches(coord_t x, coord_t y, int8_t swtch, LcdFlags att=0);
void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
#if defined(PCBTARANIS) && !defined(BOOT)
void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att);
void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att);
#endif
void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att=0);
void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att=0);
void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att);
void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att=0);
void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att);
#if defined(ROTARY_ENCODERS)
void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att);
void putsRotaryEncoderMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att);
#endif
#define putsChn(x, y, idx, att) putsMixerSource(x, y, MIXSRC_CH1+idx-1, att)
void putsChnLetter(xcoord_t x, uint8_t y, uint8_t idx, LcdFlags attr);
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr);
void putsVolts(xcoord_t x, uint8_t y, uint16_t volts, LcdFlags att);
void putsVBat(xcoord_t x, uint8_t y, LcdFlags att);
void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val, LcdFlags att=0);
void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att);
void putsVBat(coord_t x, coord_t y, LcdFlags att);
void putsTelemetryChannel(coord_t x, coord_t y, uint8_t channel, lcdint_t val, LcdFlags att=0);
#if defined(CPUARM)
#define putstime_t int32_t
@@ -215,31 +224,33 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
#define putstime_t int16_t
#endif
void putsRtcTime(xcoord_t x, uint8_t y, LcdFlags att);
void putsTimer(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2);
void putsRtcTime(coord_t x, coord_t y, LcdFlags att);
void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2);
#define SOLID 0xff
#define DOTTED 0x55
void lcd_plot(xcoord_t x, uint8_t y, LcdFlags att=0);
void lcd_plot(coord_t x, coord_t y, LcdFlags att=0);
void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att=0);
void lcd_hline(xcoord_t x, uint8_t y, xcoord_t w, LcdFlags att=0);
void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att=0);
void lcd_vline(xcoord_t x, int8_t y, int8_t h);
void lcd_hline(coord_t x, coord_t y, coord_t w, LcdFlags att=0);
void lcd_hlineStip(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0);
void lcd_vline(coord_t x, scoord_t y, scoord_t h);
#if defined(CPUM64)
void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat);
void lcd_vlineStip(coord_t x, scoord_t y, int8_t h, uint8_t pat);
#else
void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att=0);
#endif
#if defined(CPUARM)
void lcd_line(xcoord_t x1, int8_t y1, xcoord_t x2, int8_t y2, uint8_t pat=SOLID, LcdFlags att=0);
void lcd_vlineStip(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0);
#endif
void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat=SOLID, LcdFlags att=0);
void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat=SOLID, LcdFlags att=0);
void lcd_invert_line(int8_t y);
#if defined(CPUARM)
void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0);
#endif
void lcd_filled_rect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0);
void lcd_rect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0);
void lcd_invert_line(int8_t line);
#define lcd_status_line() lcd_invert_line(LCD_LINES-1)
inline void lcd_square(xcoord_t x, uint8_t y, xcoord_t w, LcdFlags att=0) { lcd_rect(x, y, w, w, SOLID, att); }
inline void lcd_square(coord_t x, coord_t y, coord_t w, LcdFlags att=0) { lcd_rect(x, y, w, w, SOLID, att); }
void lcdDrawTelemetryTopBar();
@@ -251,16 +262,9 @@ void lcdDrawTelemetryTopBar();
lcd_vline(xx-1,yy-ll,ll); \
lcd_vline(xx ,yy-ll,ll); \
lcd_vline(xx+1,yy-ll,ll);
/*
#define LCD_2DOTS(x, y, att) \
lcd_putcAtt(x, y, ' ', att); \
lcd_vline(x+4, y+3, 2); \
lcd_vline(x+5, y+3, 2); \
lcd_vline(x+4, y+8, 2); \
lcd_vline(x+5, y+8, 2);
*/
void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags att=0);
void lcd_bmp(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t offset=0, uint8_t width=0);
void lcd_img(coord_t x, coord_t y, const pm_uchar * img, uint8_t idx, LcdFlags att=0);
void lcd_bmp(coord_t x, coord_t y, const pm_uchar * img, uint8_t offset=0, uint8_t width=0);
#define LCD_ICON(x, y, icon) lcd_bmp(x, y, icons, icon)
void lcdSetRefVolt(unsigned char val);
void lcdInit();
@@ -276,7 +280,7 @@ void lcdSetContrast();
#endif
#if defined(PCBTARANIS)
const pm_char * bmpLoad(uint8_t *dest, const char *filename, const xcoord_t width, const uint8_t height);
const pm_char * bmpLoad(uint8_t *dest, const char *filename, const unsigned int width, const unsigned int height);
#endif
#if defined(BOOT)
@@ -287,7 +291,7 @@ void lcdSetContrast();
#ifdef SIMU
extern bool lcd_refresh;
extern uint8_t lcd_buf[DISPLAY_BUF_SIZE];
extern display_t lcd_buf[DISPLAY_BUF_SIZE];
#endif
#if defined(LUA)