From 4d84ba4c195660380c0a4fe01afa6ee0342baa34 Mon Sep 17 00:00:00 2001 From: bsongis Date: Wed, 20 Aug 2014 21:36:00 +0200 Subject: [PATCH] LCD refactoring - saves 6 bytes on 9x stock --- radio/src/Makefile | 2 +- radio/src/bmp.cpp | 2 +- radio/src/gui/menu_general.cpp | 62 +++---- radio/src/gui/menu_model.cpp | 127 +++++++------- radio/src/gui/menus.cpp | 56 +++--- radio/src/gui/menus.h | 22 +-- radio/src/gui/view_main.cpp | 12 +- radio/src/gui/view_telemetry.cpp | 4 +- radio/src/lcd.h | 164 +++++++++--------- radio/src/lcd_common.cpp | 134 +++++++------- radio/src/lcd_default.cpp | 18 +- radio/src/lcd_taranis.cpp | 22 +-- radio/src/opentx.cpp | 18 +- radio/src/opentx.h | 8 +- radio/src/simu.cpp | 22 +-- .../targets/mega2560/lcd_driver_ST7565R.cpp | 2 +- radio/src/targets/simu/simpgmspace.cpp | 4 +- radio/src/targets/stock/lcd_driver.cpp | 2 +- radio/src/telemetry/frsky.h | 2 +- 19 files changed, 349 insertions(+), 334 deletions(-) diff --git a/radio/src/Makefile b/radio/src/Makefile index 4f18f3555..b6bb91ff8 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -1278,7 +1278,7 @@ bitmaps/sticks.lbm: bitmaps/sticks_4x1.xbm bitmaps/splash_9x.xbm bitmaps/splash_ lua_exports.cpp: myeeprom.h ../util/luaexport.py @echo "Generating a list of Lua exported constants in lua_exports.txt" - @$(CPP) -DPCBTARANIS -DCPUARM -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports.txt + @$(CPP) -DPCBTARANIS -DCPUARM -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports.txt @echo "Parsing and generating C Lua exports in lua_exports.cpp" @python ../util/luaexport.py lua_exports.txt lua_exports.cpp diff --git a/radio/src/bmp.cpp b/radio/src/bmp.cpp index f76fc279d..a20e07ab6 100644 --- a/radio/src/bmp.cpp +++ b/radio/src/bmp.cpp @@ -36,7 +36,7 @@ #include "opentx.h" -const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const xcoord_t width, const uint8_t height) +const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const unsigned int width, const unsigned int height) { FIL bmpFile; UINT read; diff --git a/radio/src/gui/menu_general.cpp b/radio/src/gui/menu_general.cpp index 34f9cb124..e4e5adaf5 100644 --- a/radio/src/gui/menu_general.cpp +++ b/radio/src/gui/menu_general.cpp @@ -108,7 +108,7 @@ const MenuFuncP_PROGMEM menuTabDiag[] PROGMEM = { #else #define RADIO_SETUP_2ND_COLUMN (LCD_W-6*FW-1-MENUS_SCROLLBAR_WIDTH) #define RADIO_SETUP_TIME_COLUMN (FW*15+9) - #define RADIO_SETUP_DATE_COLUMN (FW*15+5) + #define RADIO_SETUP_DATE_COLUMN (FW*15+7) #endif #if !defined(CPUM64) @@ -220,7 +220,7 @@ void menuGeneralSetup(uint8_t event) uint8_t sub = m_posVert - 1; for (uint8_t i=0; i0) ? BLINK|INVERS : INVERS); uint8_t attr = (sub == k ? blink : 0); @@ -1096,7 +1096,7 @@ void menuGeneralSdManager(uint8_t _event) reusableBuffer.sdmanager.offset = s_pgOfs; for (uint8_t i=0; i0) ? BLINK|INVERS : INVERS); - lcd_puts(3*FW, 1 + 1*FH, STR_MODESRC); + lcd_puts(3*FW, MENU_TITLE_HEIGHT+1, STR_MODESRC); - y = 1 + 2*FH; + y = MENU_TITLE_HEIGHT + 1 + FH; for (uint8_t i=1; i<=NUM_STICKS; i++) { uint8_t chan = channel_order(i); @@ -1183,19 +1183,19 @@ void menuGeneralTrainer(uint8_t event) } attr = (m_posVert==5) ? blink : 0; - lcd_putsLeft(6*FH+1, STR_MULTIPLIER); - lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, 6*FH+1, g_eeGeneral.PPM_Multiplier+10, attr|PREC1); + lcd_putsLeft(MENU_TITLE_HEIGHT+1+5*FH, STR_MULTIPLIER); + lcd_outdezAtt(LEN_MULTIPLIER*FW+3*FW, MENU_TITLE_HEIGHT+1+5*FH, g_eeGeneral.PPM_Multiplier+10, attr|PREC1); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40); attr = (m_posVert==6) ? INVERS : 0; if (attr) s_editMode = 0; - lcd_putsAtt(0*FW, 1+7*FH, STR_CAL, attr); + lcd_putsAtt(0*FW, MENU_TITLE_HEIGHT+1+6*FH, STR_CAL, attr); for (uint8_t i=0; i<4; i++) { uint8_t x = (i*TRAINER_CALIB_POS+16)*FW/2; #if defined (PPM_UNIT_PERCENT_PREC1) - lcd_outdezAtt(x, 1+7*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])*2, PREC1); + lcd_outdezAtt(x, MENU_TITLE_HEIGHT+1+6*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])*2, PREC1); #else - lcd_outdezAtt(x, 1+7*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])/5, 0); + lcd_outdezAtt(x, MENU_TITLE_HEIGHT+1+6*FH, (g_ppmIns[i]-g_eeGeneral.trainer.calib[i])/5, 0); #endif } @@ -1213,7 +1213,7 @@ void menuGeneralVersion(uint8_t event) { SIMPLE_MENU(STR_MENUVERSION, menuTabDiag, e_Vers, 1); - lcd_putsLeft(2*FH, vers_stamp); + lcd_putsLeft(MENU_TITLE_HEIGHT+FH, vers_stamp); #if defined(COPROCESSOR) if (Coproc_valid == 1) { @@ -1226,7 +1226,7 @@ void menuGeneralVersion(uint8_t event) #endif #if defined(PCBTARANIS) - lcd_putsLeft(7*FH, STR_EEBACKUP); + lcd_putsLeft(MENU_TITLE_HEIGHT+6*FH, STR_EEBACKUP); if (event == EVT_KEY_LONG(KEY_ENTER)) { backupEeprom(); } @@ -1243,26 +1243,26 @@ void menuGeneralDiagKeys(uint8_t event) { SIMPLE_MENU(STR_MENUDIAG, menuTabDiag, e_Keys, 1); - lcd_puts(14*FW, 3*FH, STR_VTRIM); + lcd_puts(14*FW, MENU_TITLE_HEIGHT+2*FH, STR_VTRIM); for(uint8_t i=0; i<9; i++) { - uint8_t y; + coord_t y; if (i<8) { - y = i/2*FH+FH*4; + y = MENU_TITLE_HEIGHT + FH*3 + FH*(i/2); lcd_img(14*FW, y, sticks, i/2, 0); displayKeyState(i&1? 20*FW : 18*FW, y, (EnumKeys)(TRM_BASE+i)); } if (i<6) { - y = (5-i)*FH+2*FH; + y = (5-i)*FH+MENU_TITLE_HEIGHT+FH; lcd_putsiAtt(0, y, STR_VKEYS, i, 0); displayKeyState(5*FW+2, y, (EnumKeys)(KEY_MENU+i)); } #if !defined(PCBTARANIS) if (i != SW_ID0-SW_BASE) { - y = i*FH-FH; + y = MENU_TITLE_HEIGHT+i*FH-2*FH; putsSwitches(8*FW, y, i+1, 0); //ohne off,on displayKeyState(11*FW+2, y, (EnumKeys)(SW_BASE+i)); } @@ -1271,7 +1271,7 @@ void menuGeneralDiagKeys(uint8_t event) #if defined(ROTARY_ENCODERS) || defined(ROTARY_ENCODER_NAVIGATION) for(uint8_t i=0; i>= 11; batCalV += 2; // because of the diode - putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 6*FH+1, batCalV, (m_posVert==1 ? INVERS : 0)); + putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_TITLE_HEIGHT+1+5*FH, batCalV, (m_posVert==1 ? INVERS : 0)); #elif defined(PCBSKY9X) - lcd_putsLeft(5*FH+1, STR_BATT_CALIB); + lcd_putsLeft(MENU_TITLE_HEIGHT+1+4*FH, STR_BATT_CALIB); static int32_t adcBatt; adcBatt = ((adcBatt * 7) + anaIn(TX_VOLTAGE)) / 8; uint32_t batCalV = (adcBatt + adcBatt*(g_eeGeneral.vBatCalib)/128) * 4191; batCalV /= 55296; - putsVolts(LEN_CALIB_FIELDS*FW+4*FW, 5*FH+1, batCalV, (m_posVert==1 ? INVERS : 0)); + putsVolts(LEN_CALIB_FIELDS*FW+4*FW, MENU_TITLE_HEIGHT+1+4*FH, batCalV, (m_posVert==1 ? INVERS : 0)); #elif defined(PCBGRUVIN9X) lcd_putsLeft(6*FH-2, STR_BATT_CALIB); // Gruvin wants 2 decimal places and instant update of volts calib field when button pressed @@ -1367,7 +1367,7 @@ void menuGeneralHardware(uint8_t event) uint8_t sub = m_posVert - 1; for (uint8_t i=0; i0) ? BLINK|INVERS : INVERS) : 0); switch(i) { case ITEM_SETUP_HW_POT1: @@ -1422,7 +1422,7 @@ void menuGeneralHardware(uint8_t event) uint8_t sub = m_posVert - 1; for (uint8_t i=0; i0) ? BLINK|INVERS : INVERS); uint8_t attr = (sub == k ? blink : 0); @@ -1539,14 +1539,14 @@ void menuCommonCalib(uint8_t event) case 0: // START CALIBRATION if (!READ_ONLY()) { - lcd_putsLeft(3*FH, STR_MENUTOSTART); + lcd_putsLeft(MENU_TITLE_HEIGHT+2*FH, STR_MENUTOSTART); } break; case 1: // SET MIDPOINT - lcd_putsAtt(0*FW, 2*FH, STR_SETMIDPOINT, INVERS); - lcd_putsLeft(3*FH, STR_MENUWHENDONE); + lcd_putsAtt(0*FW, MENU_TITLE_HEIGHT+FH, STR_SETMIDPOINT, INVERS); + lcd_putsLeft(MENU_TITLE_HEIGHT+2*FH, STR_MENUWHENDONE); for (uint8_t i=0; i 50) { diff --git a/radio/src/gui/menu_model.cpp b/radio/src/gui/menu_model.cpp index 185a71d4d..62f223baf 100644 --- a/radio/src/gui/menu_model.cpp +++ b/radio/src/gui/menu_model.cpp @@ -591,11 +591,11 @@ void menuModelSelect(uint8_t event) lcd_outdezAtt(17*FW, 0, reusableBuffer.modelsel.eepromfree, 0); #endif -#if defined(ROTARY_ENCODER_NAVIGATION) - displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? ((IS_RE_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0); -#elif defined(PCBTARANIS) +#if defined(PCBTARANIS) displayScreenIndex(e_ModelSelect, DIM(menuTabModel), 0); lcd_filled_rect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT); +#elif defined(ROTARY_ENCODER_NAVIGATION) + displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? ((IS_RE_NAVIGATION_ENABLE() && s_editMode < 0) ? INVERS|BLINK : INVERS) : 0); #else displayScreenIndex(e_ModelSelect, DIM(menuTabModel), (sub == g_eeGeneral.currModel) ? INVERS : 0); #endif @@ -603,8 +603,8 @@ void menuModelSelect(uint8_t event) TITLE(STR_MENUMODELSEL); for (uint8_t i=0; i= 0)) { @@ -702,11 +702,11 @@ void menuModelFailsafe(uint8_t event) uint8_t col = 0; #endif { - uint8_t x = col*COL_W+1; + coord_t x = col*COL_W+1; // Channels for (uint8_t line=0; line<8; line++) { - uint8_t y = 9+line*7; + coord_t y = 9+line*7; int32_t val; uint8_t ofs = (col ? 0 : 1); @@ -754,7 +754,7 @@ void menuModelFailsafe(uint8_t event) lcd_rect(x+COL_W-3-wbar-ofs, y, wbar+1, 6); uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2; uint8_t len = limit((uint8_t)1, uint8_t((abs(val) * wbar/2 + lim/2) / lim), uint8_t(wbar/2)); - uint8_t x0 = (val>0) ? x+COL_W-ofs-3-wbar/2 : x+COL_W-ofs-2-wbar/2-len; + coord_t x0 = (val>0) ? x+COL_W-ofs-3-wbar/2 : x+COL_W-ofs-2-wbar/2-len; lcd_hline(x0, y+1, len); lcd_hline(x0, y+2, len); lcd_hline(x0, y+3, len); @@ -774,7 +774,7 @@ void menuModelFailsafe(uint8_t event) static uint8_t editNameCursorPos = 0; #endif -void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, uint8_t active) +void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active) { #if defined(CPUM64) // in order to save flash @@ -788,6 +788,7 @@ void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, uin else mode = FIXEDWIDTH; } + lcd_putsnAtt(x, y, name, size, ZCHAR | mode); if (active) { @@ -851,7 +852,8 @@ void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, uin name[cur] = v; eeDirty(EE_MODEL); } - lcd_putcAtt(x+editNameCursorPos*FW, y, idx2char(v), INVERS+FIXEDWIDTH); + + lcd_putcAtt(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH); } else { cur = 0; @@ -863,7 +865,7 @@ void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, uin #if defined(CPUM64) #define editSingleName(x, y, label, name, size, event, active) editName(x, y, name, size, event, active) #else -void editSingleName(uint8_t x, uint8_t y, const pm_char *label, char *name, uint8_t size, uint8_t event, uint8_t active) +void editSingleName(coord_t x, coord_t y, const pm_char *label, char *name, uint8_t size, uint8_t event, uint8_t active) { lcd_putsLeft(y, label); editName(x, y, name, size, event, active); @@ -1055,7 +1057,7 @@ void menuModelSetup(uint8_t event) int8_t editMode = s_editMode; for (uint8_t i=0; i 1 -uint8_t editDelay(const xcoord_t x, const uint8_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay) +uint8_t editDelay(const coord_t x, const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay) { lcd_puts(x, y, str); lcd_outdezAtt(x+MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT); @@ -1847,7 +1849,7 @@ uint8_t editDelay(const xcoord_t x, const uint8_t y, const uint8_t event, const } #define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(x, y, event, attr, str, delay) #else -uint8_t editDelay(const uint8_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay) +uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay) { lcd_putsLeft(y, str); lcd_outdezAtt(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT); @@ -1866,7 +1868,7 @@ uint8_t editDelay(const uint8_t y, const uint8_t event, const uint8_t attr, cons #endif #if defined(PCBTARANIS) -void displayFlightModes(uint8_t x, uint8_t y, FlightModesType value) +void displayFlightModes(coord_t x, coord_t y, FlightModesType value) { lcd_puts(x, y, STR_FP); x = lcdNextPos + 1; @@ -1876,7 +1878,7 @@ void displayFlightModes(uint8_t x, uint8_t y, FlightModesType value) } } #else -void displayFlightModes(uint8_t x, uint8_t y, FlightModesType value) +void displayFlightModes(coord_t x, coord_t y, FlightModesType value) { uint8_t p = MAX_FLIGHT_MODES; do { @@ -1888,7 +1890,7 @@ void displayFlightModes(uint8_t x, uint8_t y, FlightModesType value) } #endif -FlightModesType editFlightModes(uint8_t x, uint8_t y, uint8_t event, FlightModesType value, uint8_t attr) +FlightModesType editFlightModes(coord_t x, coord_t y, uint8_t event, FlightModesType value, uint8_t attr) { lcd_putsColumnLeft(x, y, STR_FLMODE); @@ -1964,7 +1966,7 @@ void menuModelFlightModesAll(uint8_t event) } for (uint8_t i=0; i=ITEM_MODEL_PHASE_SWITCH) sub += ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH; for (uint8_t k=0; k=ITEM_MODEL_PHASE_SWITCH) i += ITEM_MODEL_PHASE_FADE_IN-ITEM_MODEL_PHASE_SWITCH; uint8_t attr = (sub==i ? (editMode>0 ? BLINK|INVERS : INVERS) : 0); @@ -2239,10 +2241,10 @@ void menuModelFlightModesAll(uint8_t event) uint8_t att; for (uint8_t i=0; i(LCD_LINES-1)*FH+1) continue; + coord_t y = MENU_TITLE_HEIGHT + 1 + (i-s_pgOfs)*FH; + if (y(LCD_LINES-1)*FH+MENU_TITLE_HEIGHT-FH) continue; #else - uint8_t y = 1 + (i+1)*FH; + coord_t y = MENU_TITLE_HEIGHT + 1 + i*FH; #endif att = (i==sub ? INVERS : 0); FlightModeData *p = flightModeAddress(i); @@ -2312,7 +2314,7 @@ void menuModelHeli(uint8_t event) uint8_t sub = m_posVert - 1; for (uint8_t i=0; i<6; i++) { - uint8_t y = 1 + 1*FH + i*FH; + coord_t y = MENU_TITLE_HEIGHT + 1 + i*FH; uint8_t attr = (sub == i ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0); switch(i) { case ITEM_HELI_SWASHTYPE: @@ -2374,7 +2376,7 @@ void DrawFunction(FnFuncP fn, uint8_t offset=0) uint8_t prev_yv = 255; for (int8_t xv=-WCHART; xv<=WCHART; xv++) { - uint8_t yv = (LCD_H-1) - (((uint16_t)RESX + fn(xv * (RESX/WCHART))) / 2 * (LCD_H-1) / RESX); + coord_t yv = (LCD_H-1) - (((uint16_t)RESX + fn(xv * (RESX/WCHART))) / 2 * (LCD_H-1) / RESX); if (prev_yv != 255) { if (abs((int8_t)yv-prev_yv) <= 1) { lcd_plot(X0+xv-offset-1, prev_yv, FORCE); @@ -2396,8 +2398,8 @@ int16_t curveFn(int16_t x) } struct point_t { - uint8_t x; - uint8_t y; + coord_t x; + coord_t y; }; point_t getPoint(uint8_t i) @@ -2772,7 +2774,7 @@ void menuModelCurveOne(uint8_t event) #endif #if defined(PCBTARANIS) && defined(CURVES) -void editCurveRef(uint8_t x, uint8_t y, CurveRef & curve, uint8_t event, uint8_t attr) +void editCurveRef(coord_t x, coord_t y, CurveRef & curve, uint8_t event, uint8_t attr) { lcd_putsiAtt(x, y, "\004DiffExpoFuncCstm", curve.type, m_posHorz==0 ? attr : 0); if (attr && m_posHorz==0) { @@ -3041,7 +3043,7 @@ void menuModelExpoOne(uint8_t event) int8_t sub = m_posVert; - uint8_t y = FH+1; + coord_t y = MENU_TITLE_HEIGHT + 1; #if defined(PCBTARANIS) for (uint8_t k=0; k 1 - uint8_t y; + coord_t y; uint8_t COLUMN_X; if (k >= LCD_LINES-1) { y = 1 + (k-LCD_LINES+2)*FH; @@ -3265,7 +3267,7 @@ void menuModelMixOne(uint8_t event) } int8_t i = k; #else - uint8_t y = 1 + (k+1)*FH; + coord_t y = MENU_TITLE_HEIGHT + 1 + k*FH; int8_t i = k + s_pgOfs; #endif @@ -3494,7 +3496,7 @@ void displayHeaderChannelName(uint8_t ch) } #endif -void displayMixInfos(uint8_t y, MixData *md) +void displayMixInfos(coord_t y, MixData *md) { #if defined(PCBTARANIS) putsCurveRef(MIX_LINE_CURVE_POS, y, md->curve, 0); @@ -3513,7 +3515,7 @@ void displayMixInfos(uint8_t y, MixData *md) } #if defined(PCBTARANIS) -void displayMixLine(uint8_t y, MixData *md) +void displayMixLine(coord_t y, MixData *md) { if (md->name[0]) { lcd_putsnAtt(EXPO_LINE_NAME_POS, y, md->name, sizeof(md->name), ZCHAR); @@ -3525,7 +3527,7 @@ void displayMixLine(uint8_t y, MixData *md) displayFlightModes(MIX_LINE_FM_POS, y, md->flightModes); } #elif defined(CPUARM) -void displayMixLine(uint8_t y, MixData *md) +void displayMixLine(coord_t y, MixData *md) { if (md->name[0]) { lcd_putsnAtt(EXPO_LINE_NAME_POS, y, md->name, sizeof(md->name), ZCHAR); @@ -3538,7 +3540,7 @@ void displayMixLine(uint8_t y, MixData *md) #define displayMixLine(y, md) displayMixInfos(y, md) #endif -void displayExpoInfos(uint8_t y, ExpoData *ed) +void displayExpoInfos(coord_t y, ExpoData *ed) { #if defined(PCBTARANIS) putsCurveRef(EXPO_LINE_CURVE_POS, y, ed->curve, 0); @@ -3553,7 +3555,7 @@ void displayExpoInfos(uint8_t y, ExpoData *ed) } #if defined(PCBTARANIS) -void displayExpoLine(uint8_t y, ExpoData *ed) +void displayExpoLine(coord_t y, ExpoData *ed) { putsMixerSource(EXPO_LINE_SRC_POS, y, ed->srcRaw, 0); @@ -3571,7 +3573,7 @@ void displayExpoLine(uint8_t y, ExpoData *ed) } } #elif defined(CPUARM) -void displayExpoLine(uint8_t y, ExpoData *ed) +void displayExpoLine(coord_t y, ExpoData *ed) { displayExpoInfos(y, ed); @@ -3751,7 +3753,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) for (uint8_t ch=1; ch<=(expo ? NUM_INPUTS : NUM_CHNOUT); ch++) { void *pointer = NULL; MixData * &md = (MixData * &)pointer; ExpoData * &ed = (ExpoData * &)pointer; - uint8_t y = 1+(cur-s_pgOfs)*FH; + coord_t y = MENU_TITLE_HEIGHT-FH+1+(cur-s_pgOfs)*FH; if (expo ? (ichn+1 == ch && EXPO_VALID(ed)) : (isrcRaw && md->destCh+1 == ch)) { if (s_pgOfs < cur && cur-s_pgOfs < LCD_LINES) { if (expo) { @@ -4028,7 +4030,7 @@ void menuModelLimits(uint8_t event) } for (uint8_t i=0; i= 212 || !defined(PPM_CENTER_ADJUSTABLE) int16_t v = (ld->revert) ? -LIMIT_OFS(ld) : LIMIT_OFS(ld); char swVal = '-'; // '-', '<', '>' - if((channelOutputs[k] - v) > 50) swVal = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim! - if((channelOutputs[k] - v) < -50) swVal = (ld->revert ? 126 : 127); + if ((channelOutputs[k] - v) > 50) swVal = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim! + if ((channelOutputs[k] - v) < -50) swVal = (ld->revert ? 126 : 127); +#if !defined(PCBTARANIS) putsChn(0, y, k+1, 0); +#endif lcd_putc(LIMITS_DIRECTION_POS, y, swVal); #endif @@ -4228,7 +4232,7 @@ void menuModelCurvesAll(uint8_t event) } for (uint8_t i=0; i 6 for (uint8_t l=0; l0) ? BLINK|INVERS : INVERS) : 0); - xcoord_t x = GVARS_FM_COLUMN(j-1); + coord_t x = GVARS_FM_COLUMN(j-1); #if MAX_GVARS == 6 if (i==0 && j!=9) putsStrIdx(x+2, FH+1, STR_FP, j, SMLSIZE); @@ -4448,7 +4452,7 @@ void menuModelLogicalSwitchOne(uint8_t event) int v1_val = cs->v1; for (uint8_t k=0; k0 ? BLINK|INVERS : INVERS) : 0); uint8_t cstate = lswFamily(cs->func); @@ -4587,7 +4591,7 @@ void menuModelLogicalSwitches(uint8_t event) { SIMPLE_MENU(STR_MENULOGICALSWITCHES, menuTabModel, e_LogicalSwitches, NUM_LOGICAL_SWITCH+1); - uint8_t y = 0; + coord_t y = 0; uint8_t k = 0; int8_t sub = m_posVert - 1; @@ -4706,7 +4710,6 @@ void menuModelLogicalSwitches(uint8_t event) MENU(STR_MENULOGICALSWITCHES, menuTabModel, e_LogicalSwitches, NUM_LOGICAL_SWITCH+1, {0, NAVIGATION_LINE_BY_LINE|LS_FIELD_LAST/*repeated...*/}); - uint8_t y = 0; uint8_t k = 0; int8_t sub = m_posVert - 1; horzpos_t horz = m_posHorz; @@ -4732,7 +4735,7 @@ void menuModelLogicalSwitches(uint8_t event) #endif for (uint8_t i=0; i0) ? BLINK|INVERS : INVERS) : 0); uint8_t attr1 = (horz==1 ? attr : 0); @@ -5068,8 +5071,6 @@ void menuModelCustomFunctions(uint8_t event) { MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN+1, {0, NAVIGATION_LINE_BY_LINE|4/*repeated*/}); - uint8_t y; - uint8_t k = 0; int8_t sub = m_posVert - 1; #if defined(PCBTARANIS) @@ -5095,8 +5096,8 @@ void menuModelCustomFunctions(uint8_t event) #endif for (uint8_t i=0; i= 212 putsStrIdx(0, y, STR_CF, k+1, (sub==k && m_posHorz<0) ? INVERS : 0); @@ -5216,9 +5217,9 @@ void menuModelCustomFunctions(uint8_t event) #if defined(CPUARM) && defined(SDCARD) else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC || func == FUNC_PLAY_SCRIPT) { #if LCD_W >= 212 - xcoord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN; + coord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN; #else - xcoord_t x = (func == FUNC_PLAY_TRACK ? MODEL_CUSTOM_FUNC_2ND_COLUMN + FW + FW*strlen(TR_PLAY_TRACK) : MODEL_CUSTOM_FUNC_3RD_COLUMN); + coord_t x = (func == FUNC_PLAY_TRACK ? MODEL_CUSTOM_FUNC_2ND_COLUMN + FW + FW*strlen(TR_PLAY_TRACK) : MODEL_CUSTOM_FUNC_3RD_COLUMN); #endif if (ZEXIST(sd->play.name)) lcd_putsnAtt(x, y, sd->play.name, sizeof(sd->play.name), attr); @@ -5438,7 +5439,7 @@ void menuModelCustomScriptOne(uint8_t event) int8_t sub = m_posVert; for (uint8_t k=0; k0 ? BLINK|INVERS : INVERS) : 0); @@ -5503,7 +5504,7 @@ void menuModelCustomScripts(uint8_t event) MENU(STR_MENUCUSTOMSCRIPTS, menuTabModel, e_CustomScripts, MAX_SCRIPTS+1, {0, NAVIGATION_LINE_BY_LINE|3/*repeated*/}); - uint8_t y; + coord_t y; int8_t sub = m_posVert - 1; switch (event) { @@ -5708,7 +5709,7 @@ void menuModelTelemetry(uint8_t event) #endif for (uint8_t i=0; i9 ? 3 : 2); + coord_t x = 1+LCD_W-FW*(count>9 ? 3 : 2); lcd_putcAtt(x, 0, '/', attr); lcd_outdezAtt(x, 0, index+1, attr); } #if !defined(CPUM64) -void displayScrollbar(xcoord_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_t count, uint8_t visible) +void displayScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible) { lcd_vlineStip(x, y, h, SOLID, ERASE); lcd_vlineStip(x, y, h, DOTTED); - uint8_t yofs = (h * offset) / count; - uint8_t yhgt = (h * visible) / count; + coord_t yofs = (h * offset) / count; + coord_t yhgt = (h * visible) / count; if (yhgt + yofs > h) yhgt = h - yofs; lcd_vlineStip(x, y + yofs, yhgt, SOLID, FORCE); @@ -335,7 +335,7 @@ void title(const pm_char * s) #define DEC(val, min, max) if (val>min) {val--;} else {val=max;} #if LCD_W >= 212 -uint8_t scrollbar_X = LCD_W-1; +coord_t scrollbar_X = LCD_W-1; #endif #if defined(CPUARM) @@ -386,8 +386,6 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t if (p2valdiff || scrollUD || p1valdiff) backlightOn(); // on keypress turn the light on if (menuTab) { - uint8_t attr = 0; - int8_t cc = curr; switch (event) { case EVT_KEY_LONG(KEY_MENU): @@ -427,10 +425,10 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t } if (!(flags&CHECK_FLAG_NO_SCREEN_INDEX)) { - displayScreenIndex(curr, menuTabSize, attr); + displayScreenIndex(curr, menuTabSize, 0); } - lcd_filled_rect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT); + lcd_filled_rect(0, 0, LCD_W, MENU_TITLE_HEIGHT, SOLID, FILL_WHITE|GREY_DEFAULT); } DISPLAY_PROGRESS_BAR(menuTab ? lcdLastPos-2*FW-((curr+1)/10*FWNUM)-2 : 20*FW+1); @@ -631,7 +629,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t } if (maxrow > LCD_LINES-1 && scrollbar_X) { - displayScrollbar(scrollbar_X, FH, LCD_H-FH, s_pgOfs, menuTab ? maxrow : maxrow+1, LCD_LINES-1); + displayScrollbar(scrollbar_X, MENU_TITLE_HEIGHT, LCD_H-MENU_TITLE_HEIGHT-MENU_NAVIG_HEIGHT, s_pgOfs, menuTab ? maxrow : maxrow+1, LCD_LINES-1); } m_posVert = l_posVert; @@ -1095,7 +1093,7 @@ void displayWarning(uint8_t event) } } -select_menu_value_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event) +select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event) { lcd_putsColumnLeft(x, y, label); if (values) lcd_putsiAtt(x, y, values, value-min, attr); @@ -1103,7 +1101,7 @@ select_menu_value_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, c return value; } -uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, LcdFlags attr, uint8_t event ) +uint8_t onoffMenuItem(uint8_t value, coord_t x, coord_t y, const pm_char *label, LcdFlags attr, uint8_t event ) { #if defined(GRAPHICS) menu_lcd_onoff(x, y, value, attr); @@ -1113,7 +1111,7 @@ uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, #endif } -int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t event) +int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event) { lcd_putsColumnLeft(x, y, STR_SWITCH); putsSwitches(x, y, value, attr); @@ -1122,26 +1120,26 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t } #if !defined(CPUM64) - void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr) - { - lcd_putc(x+(value*4*FW)/max, y, '$'); - lcd_hline(x, y+3, 5*FW-1, SOLID); - if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(x, y, 5*FW-1, FH-1); - } +void displaySlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr) +{ + lcd_putc(x+(value*4*FW)/max, y, '$'); + lcd_hline(x, y+3, 5*FW-1, FORCE); + if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(x, y, 5*FW-1, FH-1); +} #elif defined(GRAPHICS) - void display5posSlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr) - { - lcd_putc(x+2*FW+(value*FW), y, '$'); - lcd_hline(x, y+3, 5*FW-1, SOLID); - if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(x, y, 5*FW-1, FH-1); - } +void display5posSlider(coord_t x, coord_t y, uint8_t value, uint8_t attr) +{ + lcd_putc(x+2*FW+(value*FW), y, '$'); + lcd_hline(x, y+3, 5*FW-1, SOLID); + if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcd_filled_rect(x, y, 5*FW-1, FH-1); +} #endif #if defined(GVARS) #if defined(CPUARM) -int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event) +int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event) #else -int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event) +int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event) #endif { uint16_t delta = GV_GET_GV1_VALUE(max); @@ -1198,7 +1196,7 @@ int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t m return value; } #else -int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event) +int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event) { lcd_outdezAtt(x, y, value, attr); if (attr&INVERS) value = checkIncDec(event, value, min, max, EE_MODEL); diff --git a/radio/src/gui/menus.h b/radio/src/gui/menus.h index f29c2ea20..dad886430 100644 --- a/radio/src/gui/menus.h +++ b/radio/src/gui/menus.h @@ -46,11 +46,11 @@ inline void displayColumnHeader(const char **headers, uint8_t index) } #if !defined(CPUM64) - void displayScrollbar(xcoord_t x, uint8_t y, uint8_t h, uint16_t offset, uint16_t count, uint8_t visible); + void displayScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible); #endif #if LCD_W >= 212 - extern uint8_t scrollbar_X; + extern coord_t scrollbar_X; #define SET_SCROLLBAR_X(x) scrollbar_X = (x); #else #define SET_SCROLLBAR_X(x) @@ -98,7 +98,7 @@ extern vertpos_t s_pgOfs; extern uint8_t s_noHi; extern uint8_t calibrationState; -void menu_lcd_onoff(uint8_t x, uint8_t y, uint8_t value, LcdFlags attr); +void menu_lcd_onoff(coord_t x, coord_t y, uint8_t value, LcdFlags attr); typedef void (*MenuFuncP)(uint8_t event); typedef void (*MenuFuncP_PROGMEM)(uint8_t event); @@ -139,9 +139,9 @@ void menuStatisticsDebug(uint8_t event); void menuAboutView(uint8_t event); #if !defined(CPUM64) - void displaySlider(uint8_t x, uint8_t y, uint8_t value, uint8_t max, uint8_t attr); + void displaySlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr); #elif defined(GRAPHICS) - void display5posSlider(uint8_t x, uint8_t y, uint8_t value, uint8_t attr); + void display5posSlider(coord_t x, coord_t y, uint8_t value, uint8_t attr); #define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT) #else #define displaySlider(x, y, value, max, attr) lcd_outdezAtt(x, y, value, attr|LEFT) @@ -329,9 +329,9 @@ void title(const pm_char * s); typedef int8_t select_menu_value_t; #endif -select_menu_value_t selectMenuItem(uint8_t x, uint8_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event); -uint8_t onoffMenuItem(uint8_t value, uint8_t x, uint8_t y, const pm_char *label, LcdFlags attr, uint8_t event ); -int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t event); +select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event); +uint8_t onoffMenuItem(uint8_t value, coord_t x, coord_t y, const pm_char *label, LcdFlags attr, uint8_t event ); +int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t event); #if defined(CPUARM) && defined(GVARS) #define GVAR_MENU_ITEM(x, y, v, min, max, lcdattr, editflags, event) gvarMenuItem(x, y, v, min, max, lcdattr, editflags, event) @@ -341,13 +341,13 @@ int8_t switchMenuItem(uint8_t x, uint8_t y, int8_t value, LcdFlags attr, uint8_t #if defined(GVARS) #if defined(CPUARM) - int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event); + int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, uint8_t event); #else - int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event); // @@@ open.20.fsguruh + int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event); // @@@ open.20.fsguruh #endif #define displayGVar(x, y, v, min, max) GVAR_MENU_ITEM(x, y, v, min, max, 0, 0, 0) #else - int16_t gvarMenuItem(uint8_t x, uint8_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event); + int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t event); #define displayGVar(x, y, v, min, max) lcd_outdez8(x, y, v) #endif diff --git a/radio/src/gui/view_main.cpp b/radio/src/gui/view_main.cpp index f119fd8ba..6f637d948 100644 --- a/radio/src/gui/view_main.cpp +++ b/radio/src/gui/view_main.cpp @@ -129,7 +129,7 @@ void drawPotsBars() } } -void drawStick(uint8_t centrex, int16_t xval, int16_t yval) +void drawStick(coord_t centrex, int16_t xval, int16_t yval) { lcd_square(centrex-BOX_WIDTH/2, BOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH); DO_CROSS(centrex, BOX_CENTERY, 3); @@ -156,9 +156,9 @@ void doMainScreenGraphics() void displayTrims(uint8_t phase) { for (uint8_t i=0; i<4; i++) { - static xcoord_t x[4] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X}; + static coord_t x[4] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X}; static uint8_t vert[4] = {0,1,1,0}; - uint8_t xm, ym; + coord_t xm, ym; xm = x[CONVERT_MODE(i)]; uint8_t att = ROUND; @@ -232,7 +232,7 @@ void displaySliders() if (i == POT3) { continue; } - xcoord_t x = ((i==POT1 || i==SLIDER1) ? 3 : LCD_W-5); + coord_t x = ((i==POT1 || i==SLIDER1) ? 3 : LCD_W-5); int8_t y = (i>=SLIDER1 ? LCD_H/2+1 : 1); lcd_vline(x, y, LCD_H/2-2); lcd_vline(x+1, y, LCD_H/2-2); @@ -251,7 +251,7 @@ void displaySliders() #define BAR_VOLUME_X BAR_X+147 #define BAR_TIME_X BAR_X+159 -void displayTopBarGauge(xcoord_t x, int count, bool blinking=false) +void displayTopBarGauge(coord_t x, int count, bool blinking=false) { if (!blinking || BLINK_ON_PHASE) lcd_filled_rect(x+1, BAR_Y+2, 11, 5, SOLID, ERASE); @@ -311,7 +311,7 @@ void displayTopBar() } /* Notifs icons */ - xcoord_t x = BAR_NOTIFS_X; + coord_t x = BAR_NOTIFS_X; if (unexpectedShutdown) { LCD_NOTIF_ICON(x, ICON_REBOOT); x -= 12; diff --git a/radio/src/gui/view_telemetry.cpp b/radio/src/gui/view_telemetry.cpp index c64f768b9..dd473f6ed 100644 --- a/radio/src/gui/view_telemetry.cpp +++ b/radio/src/gui/view_telemetry.cpp @@ -393,9 +393,9 @@ bool displayNumbersTelemetryScreen(FrSkyScreenData & screen) getvalue_t value = getValue(MIXSRC_FIRST_TELEM+field-1); uint8_t att = (i==3 ? NO_UNIT : DBLSIZE|NO_UNIT); #if LCD_W >= 212 - xcoord_t pos[] = {0, 71, 143, 214}; + coord_t pos[] = {0, 71, 143, 214}; #else - xcoord_t pos[] = {0, 65, 130}; + coord_t pos[] = {0, 65, 130}; #endif putsTelemetryChannel(pos[j+1]-2, FH+2*FH*i, field-1, value, att); diff --git a/radio/src/lcd.h b/radio/src/lcd.h index f32dafea9..aa0212909 100644 --- a/radio/src/lcd.h +++ b/radio/src/lcd.h @@ -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) diff --git a/radio/src/lcd_common.cpp b/radio/src/lcd_common.cpp index 005327e4b..8cb854bfc 100644 --- a/radio/src/lcd_common.cpp +++ b/radio/src/lcd_common.cpp @@ -36,7 +36,7 @@ #include "opentx.h" -uint8_t displayBuf[DISPLAY_BUF_SIZE]; +display_t displayBuf[DISPLAY_BUF_SIZE]; #if defined(LUA) bool lcd_locked = false; @@ -47,11 +47,11 @@ void lcd_clear() memset(displayBuf, 0, sizeof(displayBuf)); } -uint8_t lcdLastPos; -uint8_t lcdNextPos; +coord_t lcdLastPos; +coord_t lcdNextPos; #if defined(CPUARM) -void lcdPutPattern(xcoord_t x, uint8_t y, const uint8_t * pattern, uint8_t width, uint8_t height, LcdFlags flags) +void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width, uint8_t height, LcdFlags flags) { bool blink = false; bool inv = false; @@ -114,6 +114,7 @@ void lcdPutPattern(xcoord_t x, uint8_t y, const uint8_t * pattern, uint8_t width plot = false; if (height >= 12) continue; if (j<0 && !inv) continue; + if (y+j < 0) continue; } else { uint8_t line = (j / 8); @@ -132,16 +133,17 @@ void lcdPutPattern(xcoord_t x, uint8_t y, const uint8_t * pattern, uint8_t width } } -void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags) +void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags flags) { const pm_uchar * q; + uint32_t fontsize = FONTSIZE(flags); lcdNextPos = x-1; #if !defined(BOOT) unsigned char c_remapped = 0; - if (flags & (DBLSIZE+BOLD)) { + 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<=':') @@ -156,7 +158,7 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags) flags &= ~BOLD; } - if (flags & DBLSIZE) { + if (fontsize == DBLSIZE) { if (c >= 0xC0) { q = &font_10x14_extra[((uint16_t)(c-0xC0))*20]; } @@ -167,19 +169,19 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags) } lcdPutPattern(x, y, q, 10, 16, flags); } - else if (flags & XXLSIZE) { + else if (fontsize == XXLSIZE) { q = &font_22x38_num[((uint16_t)c-'0'+5)*110]; lcdPutPattern(x, y, q, 22, 38, flags); } - else if (flags & MIDSIZE) { + else if (fontsize == MIDSIZE) { q = &font_8x10[((uint16_t)c-0x20)*16]; lcdPutPattern(x, y, q, 8, 12, flags); } - else if (flags & SMLSIZE) { + else if (fontsize == SMLSIZE) { q = (c < 0xc0 ? &font_4x6[(c-0x20)*5] : &font_4x6_extra[(c-0xc0)*5]); lcdPutPattern(x, y, q, 5, 7, flags); } - else if (flags & TINSIZE) { + else if (fontsize == TINSIZE) { q = &font_3x5[((uint16_t)c-0x2d)*3]; lcdPutPattern(x, y, q, 3, 5, flags); } @@ -202,21 +204,22 @@ void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags) } #endif -void lcd_putc(xcoord_t x, uint8_t y, const unsigned char c) +void lcd_putc(coord_t x, coord_t y, const unsigned char c) { lcd_putcAtt(x, y, c, 0); } -void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlags mode) +void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags flags) { - const xcoord_t orig_x = x; + const coord_t orig_x = x; #if defined(CPUARM) const uint8_t orig_len = len; + uint32_t fontsize = FONTSIZE(flags); #endif bool setx = false; while (len--) { unsigned char c; - switch (mode & (BSS+ZCHAR)) { + switch (flags & (BSS+ZCHAR)) { case BSS: c = *s; break; @@ -238,7 +241,7 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag break; } else if (c >= 0x20) { - lcd_putcAtt(x, y, c, mode); + lcd_putcAtt(x, y, c, flags); x = lcdNextPos; } else if (setx) { @@ -255,9 +258,12 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag x = orig_x; y += FH; #if defined(CPUARM) - if (mode & DBLSIZE) y += FH; - else if (mode & MIDSIZE) y += 4; - else if (mode & SMLSIZE) y--; + if (fontsize == DBLSIZE) + y += FH; + else if (fontsize == MIDSIZE) + y += 4; + else if (fontsize == SMLSIZE) + y--; #endif if (y >= LCD_H) break; } @@ -275,40 +281,40 @@ void lcd_putsnAtt(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len, LcdFlag lcdLastPos = x; lcdNextPos = x; #if defined(CPUARM) - if (mode&MIDSIZE) + if (fontsize == MIDSIZE) lcdLastPos += 1; #endif } -void lcd_putsn(xcoord_t x, uint8_t y, const pm_char * s, uint8_t len) +void lcd_putsn(coord_t x, coord_t y, const pm_char * s, uint8_t len) { lcd_putsnAtt(x, y, s, len, 0); } -void lcd_putsAtt(xcoord_t x, uint8_t y, const pm_char * s, LcdFlags flags) +void lcd_putsAtt(coord_t x, coord_t y, const pm_char * s, LcdFlags flags) { lcd_putsnAtt(x, y, s, 255, flags); } -void lcd_puts(xcoord_t x, uint8_t y, const pm_char * s) +void lcd_puts(coord_t x, coord_t y, const pm_char * s) { lcd_putsAtt(x, y, s, 0); } -void lcd_putsLeft(uint8_t y, const pm_char * s) +void lcd_putsLeft(coord_t y, const pm_char * s) { lcd_puts(0, y, s); } #if !defined(BOOT) -void lcd_putsiAtt(xcoord_t x, uint8_t y,const pm_char * s,uint8_t idx, LcdFlags flags) +void lcd_putsiAtt(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags flags) { uint8_t length; length = pgm_read_byte(s++); lcd_putsnAtt(x, y, s+length*idx, length, flags & ~(BSS|ZCHAR)); } -void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val) +void lcd_outhex4(coord_t x, coord_t y, uint16_t val) { x += FWNUM*4+1; for(int i=0; i<4; i++) { @@ -320,28 +326,30 @@ void lcd_outhex4(xcoord_t x, uint8_t y, uint16_t val) } } -void lcd_outdez8(xcoord_t x, uint8_t y, int8_t val) +void lcd_outdez8(coord_t x, coord_t y, int8_t val) { lcd_outdezAtt(x, y, val); } -void lcd_outdezAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags) +void lcd_outdezAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags) { lcd_outdezNAtt(x, y, val, flags); } -void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t len) +void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t len) { uint8_t fw = FWNUM; int8_t mode = MODE(flags); flags &= ~LEADING0; - bool dblsize = flags & DBLSIZE; #if defined(CPUARM) - bool xxlsize = flags & XXLSIZE; - bool midsize = flags & MIDSIZE; - bool smlsize = flags & SMLSIZE; - bool tinsize = flags & TINSIZE; + uint32_t fontsize = FONTSIZE(flags); + bool dblsize = (fontsize == DBLSIZE); + bool xxlsize = (fontsize == XXLSIZE); + bool midsize = (fontsize == MIDSIZE); + bool smlsize = (fontsize == SMLSIZE); + bool tinsize = (fontsize == TINSIZE); #else + bool dblsize = flags & DBLSIZE; #define xxlsize 0 #define midsize 0 #define smlsize 0 @@ -357,7 +365,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t val = -val; } - xcoord_t xn = 0; + coord_t xn = 0; uint8_t ln = 2; if (mode != MODE(LEADING0)) { @@ -412,7 +420,7 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t #if !defined(PCBTARANIS) if (dblsize) { if (c=='1' && i==len && xn>x+10) { x+=1; } - if ((lcduint_t)val >= 1000) { x+=FWNUM; f&=~DBLSIZE; } + if ((lcduint_t)val >= 1000) { x+=FWNUM; f &= ~DBLSIZE; } } #endif lcd_putcAtt(x, y, c, f); @@ -488,13 +496,13 @@ void lcd_outdezNAtt(xcoord_t x, uint8_t y, lcdint_t val, LcdFlags flags, uint8_t } #endif -void lcd_hline(xcoord_t x, uint8_t y, xcoord_t w, LcdFlags att) +void lcd_hline(coord_t x, coord_t y, coord_t w, LcdFlags att) { lcd_hlineStip(x, y, w, 0xff, att); } #if defined(CPUARM) -void lcd_line(xcoord_t x1, int8_t y1, xcoord_t x2, int8_t y2, uint8_t pat, LcdFlags att) +void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att) { int dx = x2-x1; /* the horizontal distance of the line */ int dy = y2-y1; /* the vertical distance of the line */ @@ -536,12 +544,12 @@ void lcd_line(xcoord_t x1, int8_t y1, xcoord_t x2, int8_t y2, uint8_t pat, LcdFl } #endif -void lcd_vline(xcoord_t x, int8_t y, int8_t h) +void lcd_vline(coord_t x, scoord_t y, scoord_t h) { lcd_vlineStip(x, y, h, SOLID); } -void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlags att) +void lcd_rect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att) { lcd_vlineStip(x, y, h, pat); lcd_vlineStip(x+w-1, y, h, pat); @@ -551,15 +559,15 @@ void lcd_rect(xcoord_t x, uint8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlag } #if !defined(BOOT) -void lcd_filled_rect(xcoord_t x, int8_t y, xcoord_t w, uint8_t h, uint8_t pat, LcdFlags att) +void lcd_filled_rect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att) { #if defined(CPUM64) - for (int8_t i=y; i> 1) + ((pat & 1) << 7); } #else - for (int8_t i=y; i0 && !name[len-1]) --len; @@ -759,7 +767,7 @@ 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 idx, LcdFlags att) +void putsSwitches(coord_t x, coord_t y, int8_t idx, LcdFlags att) { if (idx == SWSRC_OFF) return lcd_putsiAtt(x, y, STR_OFFON, 0, att); @@ -776,7 +784,7 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) } #if defined(FLIGHT_MODES) -void putsFlightMode(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) +void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att) { if (idx==0) { lcd_putsiAtt(x, y, STR_MMMINV, 0, att); return; } if (idx < 0) { lcd_putcAtt(x-2, y, '!', att); idx = -idx; } @@ -788,7 +796,7 @@ void putsFlightMode(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) #endif #if defined(PCBTARANIS) -void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att) +void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att) { if (curve.value != 0) { switch (curve.type) { @@ -813,7 +821,7 @@ void putsCurveRef(xcoord_t x, uint8_t y, CurveRef &curve, LcdFlags att) } } -void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) +void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att) { if (idx == 0) { return lcd_putsiAtt(x, y, STR_MMMINV, 0, att); @@ -827,7 +835,7 @@ void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) putsStrIdx(x, y, STR_CV, idx, att); } #else -void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) +void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att) { if (idx < 0) { lcd_putcAtt(x-1*FW, y, '!', att); @@ -840,7 +848,7 @@ void putsCurve(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att) } #endif -void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att) +void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att) { if (mode >= 0) { if (mode < TMRMODE_COUNT) @@ -852,7 +860,7 @@ void putsTimerMode(xcoord_t x, uint8_t y, int8_t mode, LcdFlags att) } #if defined(PCBTARANIS) -void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att) +void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att) { trim_t v = getRawTrimValue(phase, idx); unsigned int mode = v.mode; @@ -870,7 +878,7 @@ void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags at } } #else -void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags att) +void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att) { trim_t v = getRawTrimValue(phase, idx); @@ -886,7 +894,7 @@ void putsTrimMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, LcdFlags at #endif #if ROTARY_ENCODERS > 0 -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) { int16_t v = flightModeAddress(phase)->rotaryEncoders[idx]; @@ -902,7 +910,7 @@ void putsRotaryEncoderMode(xcoord_t x, uint8_t y, uint8_t phase, uint8_t idx, Lc #endif #if defined(FRSKY) || defined(CPUARM) -void putsTelemetryValue(xcoord_t x, uint8_t y, lcdint_t val, uint8_t unit, LcdFlags att) +void putsTelemetryValue(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att) { convertUnit(val, unit); lcd_outdezAtt(x, y, val, att & (~NO_UNIT)); @@ -922,7 +930,7 @@ const pm_uint8_t bchunit_ar[] PROGMEM = { UNIT_DIST, // GPS Alt }; -void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val, LcdFlags att) +void putsTelemetryChannel(coord_t x, coord_t y, uint8_t channel, lcdint_t val, LcdFlags att) { switch (channel) { #if defined(CPUARM) && defined(RTCLOCK) @@ -1064,7 +1072,7 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val, } } #else // defined(FRSKY) -void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val, uint8_t att) +void putsTelemetryChannel(coord_t x, coord_t y, uint8_t channel, lcdint_t val, uint8_t att) { switch (channel) { case TELEM_TIMER1-1: diff --git a/radio/src/lcd_default.cpp b/radio/src/lcd_default.cpp index 69a1c73c6..f4777abb4 100755 --- a/radio/src/lcd_default.cpp +++ b/radio/src/lcd_default.cpp @@ -39,7 +39,7 @@ #define LCD_BYTE_FILTER(p, keep, add) *(p) = (*(p) & (keep)) | (add) #if !defined(CPUARM) -void lcd_putcAtt(xcoord_t x, uint8_t y, const unsigned char c, LcdFlags flags) +void lcd_putcAtt(coord_t x, uint8_t y, const unsigned char c, LcdFlags flags) { uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ]; const pm_uchar *q = &font_5x7[(c-0x20)*5]; @@ -202,14 +202,14 @@ void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att) *p ^= mask; } -void lcd_plot(xcoord_t x, uint8_t y, LcdFlags att) +void lcd_plot(coord_t x, coord_t y, LcdFlags att) { uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ]; if (p= LCD_H) return; if (x+w > LCD_W) { w = LCD_W - x; } @@ -229,7 +229,7 @@ void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att) } #if defined(CPUM64) -void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat) +void lcd_vlineStip(coord_t x, int8_t y, int8_t h, uint8_t pat) { if (x >= LCD_W) return; if (h<0) { y+=h; h=-h; } @@ -262,7 +262,7 @@ void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat) } #else // allows the att parameter... -void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att) +void lcd_vlineStip(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att) { if (x >= LCD_W) return; #if defined(CPUARM) @@ -304,18 +304,18 @@ void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att) void lcd_invert_line(int8_t y) { uint8_t *p = &displayBuf[y * LCD_W]; - for (xcoord_t x=0; x= 260 - xcoord_t w = pgm_read_byte(q++); + coord_t w = pgm_read_byte(q++); if (w == 255) w += pgm_read_byte(q++); #else uint8_t w = pgm_read_byte(q++); @@ -325,7 +325,7 @@ void lcd_img(xcoord_t x, uint8_t y, const pm_uchar * img, uint8_t idx, LcdFlags q += idx*w*hb; for (uint8_t yb = 0; yb < hb; yb++) { uint8_t *p = &displayBuf[ (y / 8 + yb) * LCD_W + x ]; - for (xcoord_t i=0; i> 8)) : (0x0F - (GREY_MASK(att) >> 12))) +#define PIXEL_GREY_MASK(y, att) (((y) & 1) ? (0xF0 - (COLOUR_MASK(att) >> 12)) : (0x0F - (COLOUR_MASK(att) >> 16))) -void lcd_plot(xcoord_t x, uint8_t y, LcdFlags att) +void lcd_plot(coord_t x, coord_t y, LcdFlags att) { uint8_t *p = &displayBuf[ y / 2 * LCD_W + x ]; uint8_t mask = PIXEL_GREY_MASK(y, att); @@ -68,7 +68,7 @@ void lcd_plot(xcoord_t x, uint8_t y, LcdFlags att) } } -void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att) +void lcd_hlineStip(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; } @@ -87,7 +87,7 @@ void lcd_hlineStip(xcoord_t x, uint8_t y, xcoord_t w, uint8_t pat, LcdFlags att) } } -void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att) +void lcd_vlineStip(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att) { if (x >= LCD_W) return; if (y >= LCD_H) return; @@ -111,17 +111,17 @@ void lcd_vlineStip(xcoord_t x, int8_t y, int8_t h, uint8_t pat, LcdFlags att) } } -void lcd_invert_line(int8_t y) +void lcd_invert_line(int8_t line) { - uint8_t *p = &displayBuf[y * 4 * LCD_W]; - for (xcoord_t x=0; x= 212 lcd_bmp(0, 0, asterisk_lbm); - #define TITLE_LCD_OFFSET 60 - #define MESSAGE_LCD_OFFSET 60 + #define MESSAGE_LCD_OFFSET 60 #else lcd_img(2, 0, asterisk_lbm, 0, 0); - #define TITLE_LCD_OFFSET 6*FW - #define MESSAGE_LCD_OFFSET 0 + #define MESSAGE_LCD_OFFSET 6*FW #endif #if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ) - lcd_putsAtt(TITLE_LCD_OFFSET, 0, STR_WARNING, DBLSIZE); - lcd_putsAtt(TITLE_LCD_OFFSET, 2*FH, title, DBLSIZE); + lcd_putsAtt(MESSAGE_LCD_OFFSET, 0, STR_WARNING, DBLSIZE); + lcd_putsAtt(MESSAGE_LCD_OFFSET, 2*FH, title, DBLSIZE); #else - lcd_putsAtt(TITLE_LCD_OFFSET, 0, title, DBLSIZE); - lcd_putsAtt(TITLE_LCD_OFFSET, 2*FH, STR_WARNING, DBLSIZE); + lcd_putsAtt(MESSAGE_LCD_OFFSET, 0, title, DBLSIZE); + lcd_putsAtt(MESSAGE_LCD_OFFSET, 2*FH, STR_WARNING, DBLSIZE); #endif #if LCD_W >= 212 - lcd_filled_rect(60, 0, LCD_W-MESSAGE_LCD_OFFSET, 32); + lcd_filled_rect(MESSAGE_LCD_OFFSET, 0, LCD_W-MESSAGE_LCD_OFFSET, 32); if (t) lcd_puts(MESSAGE_LCD_OFFSET, 5*FH, t); if (last) { lcd_puts(MESSAGE_LCD_OFFSET, 7*FH, last); AUDIO_ERROR_MESSAGE(sound); } #else - lcd_filled_rect(0, 0, LCD_W-MESSAGE_LCD_OFFSET, 32); + lcd_filled_rect(0, 0, LCD_W, 32); if (t) lcd_putsLeft(5*FH, t); if (last) { lcd_putsLeft(7*FH, last); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index ecd60c986..2c26fef44 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -42,6 +42,12 @@ #include #include +#if defined(SIMU) + #define SWITCH_SIMU(a, b) (a) +#else + #define SWITCH_SIMU(a, b) (b) +#endif + #if defined(PCBSKY9X) #define IS_PCBSKY9X true #define CASE_PCBSKY9X(x) x, @@ -1568,7 +1574,7 @@ void checkFlashOnBeep(); #if defined(FRSKY) || defined(CPUARM) void convertUnit(getvalue_t & val, uint8_t & unit); // TODO check FORCEINLINE on stock -void putsTelemetryValue(xcoord_t x, uint8_t y, lcdint_t val, uint8_t unit, LcdFlags att); +void putsTelemetryValue(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att); #else #define convertUnit(...) #endif diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 969f2e254..61b0f011a 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -70,30 +70,29 @@ class Open9xSim: public FXMainWindow FXSlider *sliders[8]; FXKnob *knobs[NUM_POTS]; }; -// Message Map -FXDEFMAP(Open9xSim) Open9xSimMap[]={ - //________Message_Type_________ID_____________________Message_Handler_______ +// Message Map +FXDEFMAP(Open9xSim) Open9xSimMap[] = { +//Message_Type _________ ID____Message_Handler_______ FXMAPFUNC(SEL_TIMEOUT, 2, Open9xSim::onTimeout), FXMAPFUNC(SEL_KEYPRESS, 0, Open9xSim::onKeypress), - }; +}; FXIMPLEMENT(Open9xSim,FXMainWindow,Open9xSimMap,ARRAYNUMBER(Open9xSimMap)) Open9xSim::Open9xSim(FXApp* a): FXMainWindow(a, "OpenTX Simu", NULL, NULL, DECOR_ALL, 20, 90, 0, 0) { - firstTime=true; - for(int i=0; i<(LCD_W*LCD_H/8); i++) displayBuf[i]=0;//rand(); + firstTime = true; + memset(displayBuf, 0, sizeof(displayBuf)); bmp = new FXPPMImage(getApp(),NULL,IMAGE_OWNED|IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP, W2, H2); FXHorizontalFrame *hf11=new FXHorizontalFrame(this,LAYOUT_CENTER_X); FXHorizontalFrame *hf1=new FXHorizontalFrame(this,LAYOUT_FILL_X); //rh lv rv lh - for(int i=0; i<4; i++){ - switch(i) - { + for (int i=0; i<4; i++) { + switch (i) { #define L LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FIX_X|LAYOUT_FIX_Y #undef X0 #define X0 10 @@ -164,6 +163,7 @@ void Open9xSim::makeSnapshot(const FXDrawable* drawable) printf("Cannot create snapshot %s\n", buf); } } + void Open9xSim::doEvents() { getApp()->runOneEvent(false); @@ -302,10 +302,10 @@ void Open9xSim::refreshDisplay() #if !defined(PCBTARANIS) FXColor onColor = FXRGB(0,0,0); #endif - for (int x=0;x> 4) : (*p & 0x0F); if (z) { FXColor color; diff --git a/radio/src/targets/mega2560/lcd_driver_ST7565R.cpp b/radio/src/targets/mega2560/lcd_driver_ST7565R.cpp index 33050fbeb..b0be5999c 100644 --- a/radio/src/targets/mega2560/lcd_driver_ST7565R.cpp +++ b/radio/src/targets/mega2560/lcd_driver_ST7565R.cpp @@ -119,7 +119,7 @@ void lcdRefresh() #endif PORTC_LCD_CTRL |= (1<0; --x) { + for (coord_t x=LCD_W; x>0; --x) { PORTA_LCD_DAT = *p++; PORTC_LCD_CTRL |= (1<0; --x) { + for (coord_t x=LCD_W; x>0; --x) { PORTA_LCD_DAT = *p++; PORTC_LCD_CTRL |= (1<