Bsongis/gui refactoring for x7 d (#3701)

* [X7D] New board added
* Cosmetics
This commit is contained in:
Bertrand Songis
2016-08-18 11:49:16 +02:00
committed by GitHub
parent 282b856309
commit d3ae3c035d
233 changed files with 7472 additions and 4560 deletions
+366 -115
View File
@@ -116,6 +116,103 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
}
}
#if defined(CPUARM) && !defined(BOOT)
struct PatternData
{
uint8_t width;
uint8_t height;
const uint8_t * data;
};
uint8_t getPatternWidth(const PatternData * pattern)
{
uint8_t result = 0;
uint8_t lines = (pattern->height+7)/8;
const uint8_t * data = pattern->data;
for (int8_t i=0; i<pattern->width; i++) {
for (uint8_t j=0; j<lines; j++) {
if (data[j] != 0xff) {
result += 1;
break;
}
}
data += lines;
}
return result;
}
void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
{
uint32_t fontsize = FONTSIZE(flags);
unsigned char c_remapped = 0;
if (fontsize == DBLSIZE || (flags&BOLD)) {
// To save space only some DBLSIZE and BOLD chars are available
// c has to be remapped. All non existing chars mapped to 0 (space)
if (c>=',' && c<=':')
c_remapped = c - ',' + 1;
else if (c>='A' && c<='Z')
c_remapped = c - 'A' + 16;
else if (c>='a' && c<='z')
c_remapped = c - 'a' + 42;
else if (c=='_')
c_remapped = 4;
else if (c!=' ')
flags &= ~BOLD;
}
if (fontsize == DBLSIZE) {
pattern->width = 10;
pattern->height = 16;
if (c >= 0xC0) {
pattern->data = &font_10x14_extra[((uint16_t)(c-0xC0))*20];
}
else {
if (c >= 128)
c_remapped = c - 60;
pattern->data = &font_10x14[((uint16_t)c_remapped)*20];
}
}
else if (fontsize == XXLSIZE) {
pattern->width = 22;
pattern->height = 38;
pattern->data = &font_22x38_num[((uint16_t)c-'0'+5)*110];
}
else if (fontsize == MIDSIZE) {
pattern->width = 8;
pattern->height = 12;
pattern->data = &font_8x10[((uint16_t)c-0x20)*16];
}
else if (fontsize == SMLSIZE) {
pattern->width = 5;
pattern->height = 6;
pattern->data = (c < 0xc0 ? &font_4x6[(c-0x20)*5] : &font_4x6_extra[(c-0xc0)*5]);
}
else if (fontsize == TINSIZE) {
pattern->width = 3;
pattern->height = 5;
pattern->data = &font_3x5[((uint16_t)c-0x20)*3];
}
else if (flags & BOLD) {
pattern->width = 5;
pattern->height = 7;
pattern->data = &font_5x7_B[c_remapped*5];
}
else {
pattern->width = 5;
pattern->height = 7;
pattern->data = (c < 0xC0) ? &font_5x7[(c-0x20)*5] : &font_5x7_extra[(c-0xC0)*5];
}
}
uint8_t getCharWidth(char c, LcdFlags flags)
{
PatternData pattern;
getCharPattern(&pattern, c, flags);
return getPatternWidth(&pattern);
}
#endif
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
{
const pm_uchar * q;
@@ -192,13 +289,39 @@ void lcdDrawChar(coord_t x, coord_t y, const unsigned char c)
lcdDrawChar(x, y, c, 0);
}
#if defined(CPUARM) && !defined(BOOT)
uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
{
uint8_t width = 0;
while (len--) {
unsigned char c = (flags & ZCHAR) ? idx2char(*s) : *s;
if (!c) {
break;
}
width += getCharWidth(c, flags) + 1;
s++;
}
return width;
}
#endif
void lcdDrawSizedText(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags flags)
{
const coord_t orig_x = x;
#if defined(CPUARM)
const uint8_t orig_len = len;
uint32_t fontsize = FONTSIZE(flags);
#endif
#if defined(CPUARM) && !defined(BOOT)
uint8_t width = 0;
if (flags & RIGHT) {
width = getTextWidth(s, len, flags);
x -= width;
}
#endif
bool setx = false;
while (len--) {
unsigned char c;
@@ -259,9 +382,14 @@ void lcdDrawSizedText(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdF
}
lcdLastPos = x;
lcdNextPos = x;
#if defined(CPUARM)
if (fontsize == MIDSIZE)
#if defined(CPUARM) && !defined(BOOT)
if (fontsize == MIDSIZE) {
lcdLastPos += 1;
}
if (flags & RIGHT) {
lcdLastPos -= width;
lcdNextPos -= width;
}
#endif
}
@@ -334,6 +462,7 @@ void lcdDrawNumber(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t l
uint8_t fw = FWNUM;
int8_t mode = MODE(flags);
flags &= ~LEADING0;
#if defined(CPUARM)
uint32_t fontsize = FONTSIZE(flags);
bool dblsize = (fontsize == DBLSIZE);
@@ -386,16 +515,17 @@ void lcdDrawNumber(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t l
fw -= 1;
}
else {
if (flags & LEFT) {
if (mode > 0)
if (IS_LEFT_ALIGNED(flags)) {
if (mode > 0) {
x += 2;
}
}
#if defined(BOLD_FONT) && !defined(CPUM64) || defined(TELEMETRY_NONE)
if (flags & BOLD) fw += 1;
#endif
}
if (flags & LEFT) {
if (IS_LEFT_ALIGNED(flags)) {
x += len * fw;
if (neg) {
x += ((xxlsize|dblsize|midsize) ? 7 : FWNUM);
@@ -568,30 +698,31 @@ void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat,
#endif
}
void lcdDrawTelemetryTopBar()
void drawTelemetryTopBar()
{
putsModelName(0, 0, g_model.header.name, g_eeGeneral.currModel, 0);
uint8_t att = (IS_TXBATT_WARNING() ? BLINK : 0);
putsVBat(14*FW,0,att);
if (g_model.timers[0].mode) {
att = (timersStates[0].val<0 ? BLINK : 0);
putsTimer(17*FW+5*FWNUM+1, 0, timersStates[0].val, att, att);
drawTimer(17*FW+5*FWNUM+1, 0, timersStates[0].val, att, att);
}
lcdInvertLine(0);
}
#if defined(CPUARM) && defined(RTCLOCK)
void putsRtcTime(coord_t x, coord_t y, LcdFlags att)
void drawRtcTime(coord_t x, coord_t y, LcdFlags att)
{
putsTimer(x, y, getValue(MIXSRC_TX_TIME), att, att);
drawTimer(x, y, getValue(MIXSRC_TX_TIME), att, att);
}
#endif
void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2)
void drawTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2)
{
div_t qr;
if (!(att & LEFT)) {
if (IS_RIGHT_ALIGNED(att)) {
att -= RIGHT;
if (att & DBLSIZE)
x -= 5*(2*FWNUM)-4;
else if (att & MIDSIZE)
@@ -622,12 +753,12 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2
att &= ~DBLSIZE;
#endif
#if defined(CPUARM) && defined(RTCLOCK)
if (att&TIMEBLINK)
if (att & TIMEBLINK)
lcdDrawChar(lcdLastPos, y, separator, BLINK);
else
#endif
lcdDrawChar(lcdLastPos, y, separator, att&att2);
lcdDrawNumber(lcdNextPos, y, qr.rem, att2|LEADING0|LEFT, 2);
lcdDrawNumber(lcdNextPos, y, qr.rem, (att2|LEADING0|LEFT) & (~RIGHT), 2);
}
// TODO to be optimized with putsValueWithUnit
@@ -642,20 +773,97 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att)
putsVolts(x, y, g_vbat100mV, att);
}
void drawStringWithIndex(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att)
#if defined(CPUARM)
void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
{
lcdDrawText(x, y, str, att & ~LEADING0);
lcdDrawNumber(lcdNextPos, y, idx, att|LEFT, 2);
if (idx == MIXSRC_NONE) {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, 0, att); // TODO macro
}
else if (idx <= MIXSRC_LAST_INPUT) {
lcdDrawChar(x+2, y+1, CHR_INPUT, TINSIZE);
lcdDrawFilledRect(x, y, 7, 7);
if (ZEXIST(g_model.inputNames[idx-MIXSRC_FIRST_INPUT]))
lcdDrawSizedText(x+8, y, g_model.inputNames[idx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, ZCHAR|att);
else
lcdDrawNumber(x+8, y, idx, att|LEADING0|LEFT, 2);
}
#if defined(LUA_INPUTS)
else if (idx <= MIXSRC_LAST_LUA) {
div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS);
#if defined(LUA_MODEL_SCRIPTS)
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
lcdDrawChar(x+2, y+1, '1'+qr.quot, TINSIZE);
lcdDrawFilledRect(x, y, 7, 7);
lcdDrawSizedText(x+8, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
}
else
#endif
{
drawStringWithIndex(x, y, "LUA", qr.quot+1, att);
lcdDrawChar(lcdLastPos, y, 'a'+qr.rem, att);
}
}
#endif
else if (idx < MIXSRC_LAST_POT) {
idx = idx - MIXSRC_Rud;
if (ZEXIST(g_eeGeneral.anaNames[idx])) {
if (idx < MIXSRC_FIRST_POT-MIXSRC_Rud )
lcdDrawChar(x, y, '\307', att); // stick symbol
else if (idx <= MIXSRC_LAST_POT-MIXSRC_Rud )
lcdDrawChar(x, y, '\310', att); // pot symbol
else
lcdDrawChar(x, y, '\311', att); // slider symbol
lcdDrawSizedText(lcdNextPos, y, g_eeGeneral.anaNames[idx], LEN_ANA_NAME, ZCHAR|att);
}
else {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx + 1, att);
}
}
else if (idx >= MIXSRC_FIRST_SWITCH && idx <= MIXSRC_LAST_SWITCH) {
idx = idx-MIXSRC_FIRST_SWITCH;
if (ZEXIST(g_eeGeneral.switchNames[idx])) {
lcdDrawChar(x, y, '\312', att); //switch symbol
lcdDrawSizedText(lcdNextPos, y, g_eeGeneral.switchNames[idx], LEN_SWITCH_NAME, ZCHAR|att);
}
else {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx + MIXSRC_FIRST_SWITCH - MIXSRC_Rud + 1, att);
}
}
else if (idx < MIXSRC_SW1)
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1, att);
else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH)
drawSwitch(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att);
else if (idx < MIXSRC_CH1)
drawStringWithIndex(x, y, STR_PPM_TRAINER, idx-MIXSRC_FIRST_TRAINER+1, att);
else if (idx <= MIXSRC_LAST_CH) {
drawStringWithIndex(x, y, STR_CH, idx-MIXSRC_CH1+1, att);
if (ZEXIST(g_model.limitData[idx-MIXSRC_CH1].name) && (att & STREXPANDED)) {
lcdDrawChar(lcdLastPos, y, ' ', att|SMLSIZE);
lcdDrawSizedText(lcdLastPos+3, y, g_model.limitData[idx-MIXSRC_CH1].name, LEN_CHANNEL_NAME, ZCHAR|att|SMLSIZE);
}
}
else if (idx <= MIXSRC_LAST_GVAR) {
drawStringWithIndex(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att);
}
else if (idx < MIXSRC_FIRST_TELEM) {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-MAX_LOGICAL_SWITCHES-MAX_TRAINER_CHANNELS-MAX_OUTPUT_CHANNELS-MAX_GVARS, att);
}
else {
idx -= MIXSRC_FIRST_TELEM;
div_t qr = div(idx, 3);
lcdDrawSizedText(x, y, g_model.telemetrySensors[qr.quot].label, TELEM_LABEL_LEN, ZCHAR|att);
if (qr.rem) lcdDrawChar(lcdLastPos, y, qr.rem==2 ? '+' : '-', att);
}
}
void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
#else
void drawSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
{
if (idx < MIXSRC_THR)
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx, att);
else if (idx < MIXSRC_SW1)
putsSwitches(x, y, idx-MIXSRC_THR+1+3*(1), att);
drawSwitch(x, y, idx-MIXSRC_THR+1+3*(1), att);
else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH)
putsSwitches(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att);
drawSwitch(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att);
else if (idx < MIXSRC_CH1)
drawStringWithIndex(x, y, STR_PPM_TRAINER, idx-MIXSRC_FIRST_TRAINER+1, att);
else if (idx <= MIXSRC_LAST_CH) {
@@ -666,7 +874,7 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
drawStringWithIndex(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att);
#endif
else if (idx < MIXSRC_FIRST_TELEM) {
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-(MIXSRC_SW1-MIXSRC_THR)-NUM_LOGICAL_SWITCH-NUM_TRAINER-NUM_CHNOUT-MAX_GVARS, att);
lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-(MIXSRC_SW1-MIXSRC_THR)-MAX_LOGICAL_SWITCHES-MAX_TRAINER_CHANNELS-MAX_OUTPUT_CHANNELS-MAX_GVARS, att);
}
#if defined(CPUARM)
else {
@@ -680,6 +888,7 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
lcdDrawTextAtIndex(x, y, STR_VTELEMCHNS, idx-MIXSRC_FIRST_TELEM+1, att);
#endif
}
#endif
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
{
@@ -698,7 +907,15 @@ 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 idx, LcdFlags att)
#if defined(CPUARM)
void drawSwitch(coord_t x, coord_t y, swsrc_t idx, LcdFlags flags)
{
char s[8];
getSwitchString(s, idx);
lcdDrawText(x, y, s, flags);
}
#else
void drawSwitch(coord_t x, coord_t y, swsrc_t idx, LcdFlags att)
{
if (idx == SWSRC_OFF)
return lcdDrawTextAtIndex(x, y, STR_OFFON, 0, att);
@@ -713,17 +930,6 @@ void putsSwitches(coord_t x, coord_t y, int8_t idx, LcdFlags att)
#endif
return lcdDrawTextAtIndex(x, y, STR_VSWITCHES, idx, att);
}
#if defined(FLIGHT_MODES)
void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att)
{
if (idx==0) { lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, att); return; }
if (idx < 0) { lcdDrawChar(x-2, y, '!', att); idx = -idx; }
if (att & CONDENSED)
lcdDrawNumber(x+FW*1, y, idx-1, (att & ~CONDENSED), 1);
else
drawStringWithIndex(x, y, STR_FP, idx-1, att);
}
#endif
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att)
@@ -738,7 +944,7 @@ void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att)
drawStringWithIndex(x, y, STR_CV, idx-CURVE_BASE+1, att);
}
void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att)
void drawTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att)
{
if (mode >= 0) {
if (mode < TMRMODE_COUNT)
@@ -746,22 +952,52 @@ void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att)
else
mode -= (TMRMODE_COUNT-1);
}
putsSwitches(x, y, mode, att);
drawSwitch(x, y, mode, att);
}
void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att)
#if defined(CPUARM)
void drawTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags att)
{
trim_t v = getRawTrimValue(phase, idx);
trim_t v = getRawTrimValue(fm, idx);
uint8_t mode = v.mode;
uint8_t p = mode >> 1;
char s[] = "--";
if (mode != TRIM_MODE_NONE) {
if (mode % 2 == 0)
s[0] = ':';
else
s[0] = '+';
s[1] = '0'+p;
}
lcdDrawText(x, y, s, att);
}
void drawShortTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags att)
{
trim_t v = getRawTrimValue(fm, idx);
uint8_t mode = v.mode;
uint8_t p = v.mode >> 1;
if (mode == TRIM_MODE_NONE) {
putsChnLetter(x, y, idx+1, att);
}
else {
lcdDrawChar(x, y, '0'+p, att);
}
}
#else
void drawTrimMode(coord_t x, coord_t y, uint8_t fm, uint8_t idx, LcdFlags att)
{
trim_t v = getRawTrimValue(fm, idx);
if (v > TRIM_EXTENDED_MAX) {
uint8_t p = v - TRIM_EXTENDED_MAX - 1;
if (p >= phase) p++;
if (p >= fm) p++;
lcdDrawChar(x, y, '0'+p, att);
}
else {
putsChnLetter(x, y, idx+1, att);
}
}
#endif
#if ROTARY_ENCODERS > 0
void putsRotaryEncoderMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att)
@@ -870,7 +1106,7 @@ void displayGpsCoords(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFl
void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t value, LcdFlags att)
{
if (channel >= MAX_SENSORS) return;
if (channel >= MAX_TELEMETRY_SENSORS) return;
TelemetryItem & telemetryItem = telemetryItems[channel];
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[channel];
if (telemetrySensor.unit == UNIT_DATETIME) {
@@ -896,7 +1132,7 @@ void putsChannelValue(coord_t x, coord_t y, source_t channel, lcdint_t value, Lc
putsTelemetryChannelValue(x, y, channel, value, att);
}
else if (channel >= MIXSRC_FIRST_TIMER || channel == MIXSRC_TX_TIME) {
putsTimer(x, y, value, att, att);
drawTimer(x, y, value, att, att);
}
else if (channel == MIXSRC_TX_VOLTAGE) {
lcdDrawNumber(x, y, value, att|PREC1);
@@ -941,10 +1177,8 @@ void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t v
switch (channel) {
#if defined(CPUARM) && defined(RTCLOCK)
case TELEM_TX_TIME-1:
{
putsRtcTime(x, y, att);
drawRtcTime(x, y, att);
break;
}
#endif
case TELEM_TIMER1-1:
case TELEM_TIMER2-1:
@@ -952,7 +1186,7 @@ void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t v
case TELEM_TIMER3-1:
#endif
att &= ~NO_UNIT;
putsTimer(x, y, val, att, att);
drawTimer(x, y, val, att, att);
break;
#if defined(TELEMETRY_FRSKY)
case TELEM_MIN_A1-1:
@@ -1080,7 +1314,7 @@ void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t v
case TELEM_TIMER1-1:
case TELEM_TIMER2-1:
att &= ~NO_UNIT;
putsTimer(x, y, val, att, att);
drawTimer(x, y, val, att, att);
break;
case TELEM_TX_VOLTAGE-1:
@@ -1251,44 +1485,6 @@ void lcdDrawChar(coord_t x, uint8_t y, const unsigned char c, LcdFlags flags)
}
#endif
void lcdMaskPoint(uint8_t *p, uint8_t mask, LcdFlags att)
{
ASSERT_IN_DISPLAY(p);
if (att & FORCE)
*p |= mask;
else if (att & ERASE)
*p &= ~mask;
else
*p ^= mask;
}
void lcdDrawPoint(coord_t x, coord_t y, LcdFlags att)
{
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
if (p<DISPLAY_END)
lcdMaskPoint(p, BITMASK(y%8), att);
}
void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att)
{
if (y >= LCD_H) return;
if (x+w > LCD_W) { w = LCD_W - x; }
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
uint8_t msk = BITMASK(y%8);
while (w--) {
if(pat&1) {
lcdMaskPoint(p, msk, att);
pat = (pat >> 1) | 0x80;
}
else {
pat = pat >> 1;
}
p++;
}
}
#if defined(CPUM64)
void lcdDrawVerticalLine(coord_t x, int8_t y, int8_t h, uint8_t pat)
{
@@ -1323,6 +1519,84 @@ void lcdDrawVerticalLine(coord_t x, int8_t y, int8_t h, uint8_t pat)
}
#else
// allows the att parameter...
#endif
#define LCD_IMG_FUNCTION(NAME, TYPE, READ_BYTE) \
void NAME(coord_t x, coord_t y, TYPE img, uint8_t idx, LcdFlags att) \
{ \
TYPE q = img; \
uint8_t w = READ_BYTE(q++); \
uint8_t hb = (READ_BYTE(q++)+7)/8; \
bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false); \
q += idx*w*hb; \
for (uint8_t yb = 0; yb < hb; yb++) { \
uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ]; \
for (coord_t i=0; i<w; i++){ \
uint8_t b = READ_BYTE(q); \
q++; \
ASSERT_IN_DISPLAY(p); \
*p++ = inv ? ~b : b; \
} \
} \
}
#if defined(PCBMEGA2560) && !defined(SIMU)
LCD_IMG_FUNCTION(lcd_imgfar, uint_farptr_t, pgm_read_byte_far)
#endif
LCD_IMG_FUNCTION(lcd_img, const pm_uchar *, pgm_read_byte)
#endif
void lcdMaskPoint(uint8_t * p, uint8_t mask, LcdFlags att)
{
ASSERT_IN_DISPLAY(p);
if (att & FORCE)
*p |= mask;
else if (att & ERASE)
*p &= ~mask;
else
*p ^= mask;
}
void lcdDrawPoint(coord_t x, coord_t y, LcdFlags att)
{
uint8_t * p = &displayBuf[ y / 8 * LCD_W + x ];
if (p < DISPLAY_END) {
lcdMaskPoint(p, BITMASK(y % 8), att);
}
}
void lcdInvertLine(int8_t y)
{
uint8_t *p = &displayBuf[y * LCD_W];
for (coord_t x=0; x<LCD_W; x++) {
ASSERT_IN_DISPLAY(p);
*p++ ^= 0xff;
}
}
void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att)
{
if (y >= LCD_H) return;
if (x+w > LCD_W) { w = LCD_W - x; }
uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ];
uint8_t msk = BITMASK(y%8);
while (w--) {
if(pat&1) {
lcdMaskPoint(p, msk, att);
pat = (pat >> 1) | 0x80;
}
else {
pat = pat >> 1;
}
p++;
}
}
void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att)
{
if (x >= LCD_W) return;
@@ -1360,40 +1634,17 @@ void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlag
lcdMaskPoint(p, (BITMASK(h)-1) & pat, att);
}
}
#endif
void lcdInvertLine(int8_t y)
#if defined(PWR_PRESS_BUTTON)
void drawShutdownAnimation(uint32_t index)
{
uint8_t *p = &displayBuf[y * LCD_W];
for (coord_t x=0; x<LCD_W; x++) {
ASSERT_IN_DISPLAY(p);
*p++ ^= 0xff;
lcdClear();
int quarter = index / (PWR_PRESS_SHUTDOWN / 5);
for (int i=1; i<=4; i++) {
if (quarter >= i) {
lcdDrawFilledRect(LCD_W / 2 - 28 + 10 * i, LCD_H / 2 - 3, 6, 6, SOLID, 0);
}
}
lcdRefresh();
}
#define LCD_IMG_FUNCTION(NAME, TYPE, READ_BYTE) \
void NAME(coord_t x, coord_t y, TYPE img, uint8_t idx, LcdFlags att) \
{ \
TYPE q = img; \
uint8_t w = READ_BYTE(q++); \
uint8_t hb = (READ_BYTE(q++)+7)/8; \
bool inv = (att & INVERS) ? true : (att & BLINK ? BLINK_ON_PHASE : false); \
q += idx*w*hb; \
for (uint8_t yb = 0; yb < hb; yb++) { \
uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ]; \
for (coord_t i=0; i<w; i++){ \
uint8_t b = READ_BYTE(q); \
q++; \
ASSERT_IN_DISPLAY(p); \
*p++ = inv ? ~b : b; \
} \
} \
}
#if defined(PCBMEGA2560) && !defined(SIMU)
LCD_IMG_FUNCTION(lcd_imgfar, uint_farptr_t, pgm_read_byte_far)
#endif
LCD_IMG_FUNCTION(lcd_img, const pm_uchar *, pgm_read_byte)
#endif