diff --git a/radio/src/curves.cpp b/radio/src/curves.cpp index 5d4643888..ee23e2212 100644 --- a/radio/src/curves.cpp +++ b/radio/src/curves.cpp @@ -84,7 +84,7 @@ bool moveCurve(uint8_t index, int8_t shift) int8_t getCurveX(int noPoints, int point) { - return -100 + div_and_round((point*2000) / (noPoints-1), 10); + return -100 + divRoundClosest((point*2000) / (noPoints-1), 10); } void resetCustomCurveX(int8_t * points, int noPoints) diff --git a/radio/src/functions.cpp b/radio/src/functions.cpp index 59df7764f..60eff9536 100644 --- a/radio/src/functions.cpp +++ b/radio/src/functions.cpp @@ -55,16 +55,16 @@ PLAY_FUNCTION(playValue, source_t idx) if (telemetrySensor.prec > 0) { if (telemetrySensor.prec == 2) { if (val >= 5000) { - val = div_and_round(val, 100); + val = divRoundClosest(val, 100); } else { - val = div_and_round(val, 10); + val = divRoundClosest(val, 10); attr = PREC1; } } else { if (val >= 500) { - val = div_and_round(val, 10); + val = divRoundClosest(val, 10); } else { attr = PREC1; diff --git a/radio/src/gui/128x64/model_curve_edit.cpp b/radio/src/gui/128x64/model_curve_edit.cpp index d3f7d4b85..d12c94e78 100644 --- a/radio/src/gui/128x64/model_curve_edit.cpp +++ b/radio/src/gui/128x64/model_curve_edit.cpp @@ -56,7 +56,7 @@ void runPopupCurvePreset(event_t event) int dx = 2000 / (5+crv.points-1); for (uint8_t i=0; i<5+crv.points; i++) { int x = -1000 + i * dx; - points[i] = div_and_round(div_and_round(k * x, 100), 10); + points[i] = divRoundClosest(divRoundClosest(k * x, 100), 10); } if (crv.type == CURVE_TYPE_CUSTOM) { resetCustomCurveX(points, 5+crv.points); diff --git a/radio/src/gui/212x64/model_curve_edit.cpp b/radio/src/gui/212x64/model_curve_edit.cpp index 0b76153ab..25ca49d11 100644 --- a/radio/src/gui/212x64/model_curve_edit.cpp +++ b/radio/src/gui/212x64/model_curve_edit.cpp @@ -58,7 +58,7 @@ void runPopupCurvePreset(event_t event) int dx = 2000 / (5+crv.points-1); for (uint8_t i=0; i<5+crv.points; i++) { int x = -1000 + i * dx; - points[i] = div_and_round(div_and_round(k * x, 100), 10); + points[i] = divRoundClosest(divRoundClosest(k * x, 100), 10); } if (crv.type == CURVE_TYPE_CUSTOM) { resetCustomCurveX(points, 5+crv.points); diff --git a/radio/src/gui/colorlcd/model_curves.cpp b/radio/src/gui/colorlcd/model_curves.cpp index ea6ed8189..9b7e9397d 100644 --- a/radio/src/gui/colorlcd/model_curves.cpp +++ b/radio/src/gui/colorlcd/model_curves.cpp @@ -287,7 +287,7 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex) int dx = 2000 / (5 + curve.points - 1); for (uint8_t i = 0; i < 5 + curve.points; i++) { int x = -1000 + i * dx; - points[i] = div_and_round(angle * x, 450); + points[i] = divRoundClosest(angle * x, 450); } if (curve.type == CURVE_TYPE_CUSTOM) { resetCustomCurveX(points, 5 + curve.points); diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index 48869b577..052031dee 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -180,11 +180,11 @@ void applyExpos(int16_t * anas, uint8_t mode, uint8_t ovwrIdx, int16_t ovwrValue //========== WEIGHT =============== int32_t weight = GET_GVAR_PREC1(ed->weight, -100, 100, mixerCurrentFlightMode); - v = div_and_round((int32_t)v * weight, 1000); + v = divRoundClosest((int32_t)v * weight, 1000); //========== OFFSET =============== int32_t offset = GET_GVAR_PREC1(ed->offset, -100, 100, mixerCurrentFlightMode); - if (offset) v += div_and_round(calc100toRESX(offset), 10); + if (offset) v += divRoundClosest(calc100toRESX(offset), 10); //========== TRIMS ================ if (ed->carryTrim < TRIM_ON) @@ -794,12 +794,12 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms) //========== WEIGHT =============== int32_t dv = (int32_t)v * weight; - dv = div_and_round(dv, 10); + dv = divRoundClosest(dv, 10); //========== OFFSET / AFTER =============== if (applyOffsetAndCurve) { int32_t offset = GET_GVAR_PREC1(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode); - if (offset) dv += div_and_round(calc100toRESX_16Bits(offset), 10) << 8; + if (offset) dv += divRoundClosest(calc100toRESX_16Bits(offset), 10) << 8; } //========== DIFFERENTIAL ========= diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 411b483ee..9f801b19b 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1249,25 +1249,11 @@ inline getvalue_t convertTelemValue(source_t channel, ls_telemetry_value_t value return convert16bitsTelemValue(channel, value); } -inline int div_and_round(int num, int den) -{ - if (den == 0) { - return 0; - } - else if (num >= 0) { - num += den / 2; - } - else { - num -= den / 2; - } - return num / den; -} - extern uint8_t g_vbat100mV; inline uint8_t GET_TXBATT_BARS(uint8_t barsMax) { - return limit(0, div_and_round(barsMax * (g_vbat100mV - g_eeGeneral.vBatMin - 90), 30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin), barsMax); + return limit(0, divRoundClosest(barsMax * (g_vbat100mV - g_eeGeneral.vBatMin - 90), 30 + g_eeGeneral.vBatMax - g_eeGeneral.vBatMin), barsMax); } inline bool IS_TXBATT_WARNING() diff --git a/radio/src/storage/conversions/CMakeLists.txt b/radio/src/storage/conversions/CMakeLists.txt index e6df47a87..ac912cd5b 100644 --- a/radio/src/storage/conversions/CMakeLists.txt +++ b/radio/src/storage/conversions/CMakeLists.txt @@ -1,35 +1,35 @@ if(PCB STREQUAL X9D OR PCB STREQUAL X9D+ OR PCB STREQUAL SKY9X OR PCB STREQUAL AR9X) - set(EEPROM_CONVERSIONS 216) + set(STORAGE_CONVERSIONS 216) endif() if(PCB STREQUAL SKY9X OR PCB STREQUAL AR9X OR PCB STREQUAL 9XRPRO) - set(EEPROM_CONVERSIONS 216) + set(STORAGE_CONVERSIONS 216) endif() if(PCB STREQUAL X7 OR PCB STREQUAL XLITE OR PCB STREQUAL X9E) - set(EEPROM_CONVERSIONS 218) + set(STORAGE_CONVERSIONS 218) endif() if(PCB STREQUAL X12S OR PCB STREQUAL X10) - set(EEPROM_CONVERSIONS 218) + set(STORAGE_CONVERSIONS 218) endif() -if(EEPROM_CONVERSIONS) - add_definitions(-DEEPROM_CONVERSIONS=${EEPROM_CONVERSIONS}) +if(STORAGE_CONVERSIONS) + add_definitions(-DSTORAGE_CONVERSIONS=${STORAGE_CONVERSIONS}) set(SRC ${SRC} storage/conversions/conversions.cpp ) endif() -if(EEPROM_CONVERSIONS LESS 218) +if(STORAGE_CONVERSIONS LESS 218) set(SRC ${SRC} storage/conversions/conversions_216_218.cpp ) endif() -if(EEPROM_CONVERSIONS LESS 219) +if(STORAGE_CONVERSIONS LESS 219) set(SRC ${SRC} storage/conversions/conversions_218_219.cpp diff --git a/radio/src/storage/conversions/conversions.cpp b/radio/src/storage/conversions/conversions.cpp index fa97a4edf..842321043 100644 --- a/radio/src/storage/conversions/conversions.cpp +++ b/radio/src/storage/conversions/conversions.cpp @@ -25,21 +25,21 @@ void convertRadioData(int version) { TRACE("convertRadioData(%d)", version); -#if EEPROM_CONVERSIONS < 217 +#if STORAGE_CONVERSIONS < 217 if (version == 216) { version = 217; convertRadioData_216_to_217(g_eeGeneral); } #endif -#if EEPROM_CONVERSIONS < 218 +#if STORAGE_CONVERSIONS < 218 if (version == 217) { version = 218; convertRadioData_217_to_218(g_eeGeneral); } #endif -#if EEPROM_CONVERSIONS < 219 +#if STORAGE_CONVERSIONS < 219 if (version == 218) { version = 219; convertRadioData_218_to_219(g_eeGeneral); @@ -51,21 +51,21 @@ void convertModelData(int version) { TRACE("convertModelData(%d)", version); -#if EEPROM_CONVERSIONS < 217 +#if STORAGE_CONVERSIONS < 217 if (version == 216) { version = 217; convertModelData_216_to_217(g_model); } #endif -#if EEPROM_CONVERSIONS < 218 +#if STORAGE_CONVERSIONS < 218 if (version == 217) { version = 218; convertModelData_217_to_218(g_model); } #endif -#if EEPROM_CONVERSIONS < 219 +#if STORAGE_CONVERSIONS < 219 if (version == 218) { version = 219; convertModelData_218_to_219(g_model); @@ -121,21 +121,21 @@ bool eeConvert() eeLoadGeneralSettingsData(); int version = conversionVersionStart; -#if EEPROM_CONVERSIONS < 217 +#if STORAGE_CONVERSIONS < 217 if (version == 216) { version = 217; convertRadioData_216_to_217(g_eeGeneral); } #endif -#if EEPROM_CONVERSIONS < 218 +#if STORAGE_CONVERSIONS < 218 if (version == 217) { version = 218; convertRadioData_217_to_218(g_eeGeneral); } #endif -#if EEPROM_CONVERSIONS < 219 +#if STORAGE_CONVERSIONS < 219 if (version == 218) { version = 219; convertRadioData_218_to_219(g_eeGeneral); diff --git a/radio/src/storage/eeprom_raw.cpp b/radio/src/storage/eeprom_raw.cpp index 71af9d436..9c657edce 100644 --- a/radio/src/storage/eeprom_raw.cpp +++ b/radio/src/storage/eeprom_raw.cpp @@ -584,7 +584,7 @@ const char * eeRestoreModel(uint8_t i_fileDst, char *model_name) eeLoadModelHeader(i_fileDst, &modelHeaders[i_fileDst]); -#if defined(EEPROM_CONVERSIONS) +#if defined(STORAGE_CONVERSIONS) if (version < EEPROM_VER) { eeConvertModel(i_fileDst, version); eeLoadModel(g_eeGeneral.currModel); diff --git a/radio/src/storage/eeprom_rlc.cpp b/radio/src/storage/eeprom_rlc.cpp index 33f561e6c..3864ebb34 100644 --- a/radio/src/storage/eeprom_rlc.cpp +++ b/radio/src/storage/eeprom_rlc.cpp @@ -596,7 +596,7 @@ const char * eeRestoreModel(uint8_t i_fileDst, char *model_name) f_close(&g_oLogFile); -#if defined(EEPROM_CONVERSIONS) +#if defined(STORAGE_CONVERSIONS) if (version < EEPROM_VER) { storageCheck(true); eeConvertModel(i_fileDst, version); @@ -795,7 +795,7 @@ bool eeLoadGeneral(bool allowFixes) } #endif -#if defined(EEPROM_CONVERSIONS) +#if defined(STORAGE_CONVERSIONS) if (g_eeGeneral.version != EEPROM_VER) { TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER); if (!allowFixes) diff --git a/radio/src/storage/sdcard_common.cpp b/radio/src/storage/sdcard_common.cpp index ac433f7ac..79f2c2317 100644 --- a/radio/src/storage/sdcard_common.cpp +++ b/radio/src/storage/sdcard_common.cpp @@ -122,9 +122,12 @@ const char * loadModel(const char * filename, bool alarms) storageCheck(true); alarms = false; } - else if (version < EEPROM_VER) { + +#if defined(STORAGE_CONVERSIONS) + if (version < EEPROM_VER) { convertModelData(version); } +#endif postModelLoad(alarms); diff --git a/radio/src/storage/sdcard_raw.cpp b/radio/src/storage/sdcard_raw.cpp index 1c4980ae8..710fcc44a 100644 --- a/radio/src/storage/sdcard_raw.cpp +++ b/radio/src/storage/sdcard_raw.cpp @@ -136,7 +136,7 @@ const char * loadRadioSettings(const char * path) return error; } -#if defined(EEPROM_CONVERSIONS) +#if defined(STORAGE_CONVERSIONS) if (version < EEPROM_VER) { convertRadioData(version); } diff --git a/radio/src/targets/horus/libopenui_config.h b/radio/src/targets/horus/libopenui_config.h index e2a310438..deb2ad09a 100644 --- a/radio/src/targets/horus/libopenui_config.h +++ b/radio/src/targets/horus/libopenui_config.h @@ -22,7 +22,7 @@ #define _LIBOPENUI_CONFIG_H_ #include "debug.h" -#include "libopenui_types.h" +#include "libopenui_defines.h" #include "colors.h" #include "board.h" #include "keys.h" @@ -32,7 +32,6 @@ typedef uint16_t pixel_t; constexpr uint32_t MENU_HEADER_BUTTON_WIDTH = 33; constexpr uint32_t MENU_HEADER_BUTTONS_LEFT = 47; -#define MENU_TOOLTIPS constexpr uint32_t MENU_HEADER_HEIGHT = 45; constexpr uint32_t MENU_TITLE_TOP = 48; constexpr uint32_t MENU_TITLE_HEIGHT = 21; @@ -58,10 +57,6 @@ constexpr uint32_t NUM_BODY_LINES = MENU_BODY_HEIGHT / PAGE_LINE_ constexpr uint32_t FIELD_PADDING_LEFT = 3; constexpr uint32_t FIELD_PADDING_TOP = 0; -constexpr uint32_t INVERT_HORZ_MARGIN = 2; -constexpr uint32_t INVERT_VERT_MARGIN = 1; -constexpr uint32_t INVERT_LINE_HEIGHT = 20; - constexpr uint32_t CURVE_SIDE_WIDTH = 100; constexpr uint32_t CURVE_CENTER_X = LCD_W - CURVE_SIDE_WIDTH - 7; constexpr uint32_t CURVE_CENTER_Y = 151; @@ -130,7 +125,10 @@ enum LcdColorIndex BARGRAPH2_COLOR_INDEX, BARGRAPH_BGCOLOR_INDEX, SCROLLBOX_COLOR_INDEX, - LCD_COLOR_COUNT + LCD_COLOR_COUNT, + + TABLE_HEADER_BGCOLOR_INDEX, + TABLE_BGCOLOR_INDEX, }; enum FontIndex @@ -160,6 +158,10 @@ constexpr coord_t MENUS_FOOTER_HEIGHT = 0; constexpr coord_t MENUS_MIN_HEIGHT = 2 * MENUS_LINE_HEIGHT - 1; constexpr coord_t MENUS_MAX_HEIGHT = 7 * MENUS_LINE_HEIGHT - 1; constexpr coord_t MODEL_SELECT_FOOTER_HEIGHT = 24; +constexpr coord_t SCROLLBAR_WIDTH = 3; + +constexpr LcdFlags TABLE_HEADER_FONT = FONT(STD); +constexpr LcdFlags TABLE_BODY_FONT = FONT(STD); constexpr int CJK_FIRST_LETTER_INDEX = 187; diff --git a/radio/src/targets/nv14/CMakeLists.txt b/radio/src/targets/nv14/CMakeLists.txt index e9948fa32..e75a7bcb1 100644 --- a/radio/src/targets/nv14/CMakeLists.txt +++ b/radio/src/targets/nv14/CMakeLists.txt @@ -7,7 +7,9 @@ set(PWR_BUTTON "PRESS" CACHE STRING "Pwr button type (PRESS/SWITCH)") set(CPU_TYPE STM32F4) set(HSE_VALUE 12000000) set(SDCARD YES) -set(EEPROM SDCARD) +set(SDCARD YES) +set(STORAGE SDCARD) +set(STORAGE_FORMAT BIN) set(HAPTIC YES) set(GUI_DIR colorlcd) # set(NAVIGATION_TYPE touch) diff --git a/radio/src/targets/nv14/libopenui_config.h b/radio/src/targets/nv14/libopenui_config.h index fed37dc71..d49bd1750 100644 --- a/radio/src/targets/nv14/libopenui_config.h +++ b/radio/src/targets/nv14/libopenui_config.h @@ -22,7 +22,7 @@ #define _LIBOPENUI_CONFIG_H_ #include "debug.h" -#include "libopenui_types.h" +#include "libopenui_defines.h" #include "colors.h" #include "board.h" #include "keys.h" @@ -32,7 +32,6 @@ typedef uint16_t pixel_t; constexpr uint32_t MENU_HEADER_BUTTON_WIDTH = 60; constexpr uint32_t MENU_HEADER_BUTTONS_LEFT = MENU_HEADER_BUTTON_WIDTH; -#define MENU_TOOLTIPS constexpr uint32_t MENU_HEADER_HEIGHT = 60; constexpr uint32_t MENU_TITLE_TOP = 61; constexpr uint32_t MENU_TITLE_HEIGHT = 22; @@ -73,8 +72,6 @@ constexpr uint32_t MENUS_TOOLBAR_BUTTON_WIDTH = 50; constexpr uint32_t MENUS_TOOLBAR_BUTTON_PADDING = 11; constexpr rect_t MENUS_TOOLBAR_RECT = { 35, 95, 50, 370 }; -//constexpr uint32_t SUBMENU_LINE_WIDTH = 230; - constexpr uint32_t ALERT_FRAME_TOP = 70; constexpr uint32_t ALERT_FRAME_HEIGHT = (LCD_H - 2 * ALERT_FRAME_TOP); constexpr uint32_t ALERT_BITMAP_TOP = ALERT_FRAME_TOP + 15; @@ -128,7 +125,10 @@ enum LcdColorIndex BARGRAPH2_COLOR_INDEX, BARGRAPH_BGCOLOR_INDEX, SCROLLBOX_COLOR_INDEX, - LCD_COLOR_COUNT + LCD_COLOR_COUNT, + + TABLE_HEADER_BGCOLOR_INDEX, + TABLE_BGCOLOR_INDEX, }; enum FontIndex @@ -157,8 +157,11 @@ constexpr coord_t MENUS_HEADER_HEIGHT = 40; constexpr coord_t MENUS_FOOTER_HEIGHT = 0; constexpr coord_t MENUS_MIN_HEIGHT = 2 * MENUS_LINE_HEIGHT - 1; constexpr coord_t MENUS_MAX_HEIGHT = 7 * MENUS_LINE_HEIGHT - 1; - constexpr coord_t MODEL_SELECT_FOOTER_HEIGHT = 24; +constexpr coord_t SCROLLBAR_WIDTH = 3; + +constexpr LcdFlags TABLE_HEADER_FONT = FONT(STD); +constexpr LcdFlags TABLE_BODY_FONT = FONT(STD); constexpr int CJK_FIRST_LETTER_INDEX = 187; diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index 385c51175..e8b739f76 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit 385c511755dd9ba5814a9bf46ceb0ce499efd162 +Subproject commit e8b739f765cb6ff0e4e00066d04ae6518a6f61dc