refactor: FLASH size optimisations for B&W (#4827)

This commit is contained in:
philmoz
2024-04-01 09:43:50 +10:00
committed by GitHub
parent 46f484e6e5
commit 6c5eada23a
36 changed files with 608 additions and 655 deletions
+22
View File
@@ -21,6 +21,28 @@
#include "opentx.h"
const MenuHandler menuTabModel[MENU_MODEL_PAGES_COUNT] = {
{ menuModelSelect, nullptr },
{ menuModelSetup, nullptr },
#if defined(HELI)
{ menuModelHeli, modelHeliEnabled },
#endif
#if defined(FLIGHT_MODES)
{ menuModelFlightModesAll, modelFMEnabled },
#endif
{ menuModelExposAll, nullptr },
{ menuModelMixAll, nullptr },
{ menuModelLimits, nullptr },
{ menuModelCurvesAll, modelCurvesEnabled },
{ menuModelLogicalSwitches, modelLSEnabled },
{ menuModelSpecialFunctions, modelSFEnabled },
#if defined(LUA_MODEL_SCRIPTS)
{ menuModelCustomScripts, modelCustomScriptsEnabled },
#endif
{ menuModelTelemetry, modelTelemetryEnabled },
{ menuModelDisplay, nullptr }
};
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint8_t delay, uint8_t prec)
{
lcdDrawTextAlignedLeft(y, str);
+14
View File
@@ -21,6 +21,20 @@
#include "opentx.h"
const MenuHandler menuTabGeneral[MENU_RADIO_PAGES_COUNT] = {
#if defined(RADIO_TOOLS)
{ menuRadioTools, nullptr },
#endif
#if defined(SDCARD)
{ menuRadioSdManager, nullptr },
#endif
{ menuRadioSetup, nullptr },
{ menuRadioSpecialFunctions, radioGFEnabled },
{ menuRadioTrainer, radioTrainerEnabled },
{ menuRadioHardware, nullptr },
{ menuRadioVersion, nullptr }
};
void menuRadioSpecialFunctions(event_t event)
{
#if defined(NAVIGATION_X7)
+3 -38
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _MENUS_H_
#define _MENUS_H_
#pragma once
#include "keys.h"
#include "common/stdlcd/menus.h"
@@ -82,19 +81,7 @@ void menuGhostModuleConfig(event_t event);
extern bool radioGFEnabled();
extern bool radioTrainerEnabled();
static const MenuHandler menuTabGeneral[MENU_RADIO_PAGES_COUNT] = {
#if defined(RADIO_TOOLS)
{ menuRadioTools, nullptr },
#endif
#if defined(SDCARD)
{ menuRadioSdManager, nullptr },
#endif
{ menuRadioSetup, nullptr },
{ menuRadioSpecialFunctions, radioGFEnabled },
{ menuRadioTrainer, radioTrainerEnabled },
{ menuRadioHardware, nullptr },
{ menuRadioVersion, nullptr }
};
extern const MenuHandler menuTabGeneral[MENU_RADIO_PAGES_COUNT];
enum MenuModelIndexes {
MENU_MODEL_SELECT,
@@ -150,31 +137,9 @@ extern bool modelSFEnabled();
extern bool modelCustomScriptsEnabled();
extern bool modelTelemetryEnabled();
static const MenuHandler menuTabModel[] = {
{ menuModelSelect, nullptr },
{ menuModelSetup, nullptr },
#if defined(HELI)
{ menuModelHeli, modelHeliEnabled },
#endif
#if defined(FLIGHT_MODES)
{ menuModelFlightModesAll, modelFMEnabled },
#endif
{ menuModelExposAll, nullptr },
{ menuModelMixAll, nullptr },
{ menuModelLimits, nullptr },
{ menuModelCurvesAll, modelCurvesEnabled },
{ menuModelLogicalSwitches, modelLSEnabled },
{ menuModelSpecialFunctions, modelSFEnabled },
#if defined(LUA_MODEL_SCRIPTS)
{ menuModelCustomScripts, modelCustomScriptsEnabled },
#endif
{ menuModelTelemetry, modelTelemetryEnabled },
{ menuModelDisplay, nullptr }
};
extern const MenuHandler menuTabModel[MENU_MODEL_PAGES_COUNT];
void menuStatisticsView(event_t event);
void menuStatisticsDebug(event_t event);
void menuStatisticsDebug2(event_t event);
void menuAboutView(event_t event);
#endif // _MENUS_H_
+1 -4
View File
@@ -154,10 +154,7 @@ void menuModelCurveOne(event_t event)
case EVT_KEY_LONG(KEY_ENTER):
if (menuVerticalPosition > 1) {
killEvents(event);
POPUP_MENU_ADD_ITEM(STR_CURVE_PRESET);
POPUP_MENU_ADD_ITEM(STR_MIRROR);
POPUP_MENU_ADD_ITEM(STR_CLEAR);
POPUP_MENU_START(onCurveOneMenu);
POPUP_MENU_START(onCurveOneMenu, 3, STR_CURVE_PRESET, STR_MIRROR, STR_CLEAR);
}
break;
+1 -5
View File
@@ -66,11 +66,7 @@ void menuModelFailsafe(event_t event)
if (sub == k && !READ_ONLY() && event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
POPUP_MENU_ADD_ITEM(STR_NONE);
POPUP_MENU_ADD_ITEM(STR_HOLD);
POPUP_MENU_ADD_ITEM(STR_CHANNEL2FAILSAFE);
POPUP_MENU_ADD_ITEM(STR_CHANNELS2FAILSAFE);
POPUP_MENU_START(onFailsafeMenu);
POPUP_MENU_START(onFailsafeMenu, 4, STR_NONE, STR_HOLD, STR_CHANNEL2FAILSAFE, STR_CHANNELS2FAILSAFE);
}
// Channel
+1 -6
View File
@@ -234,12 +234,7 @@ void menuModelLimits(event_t event)
if (sub==k && event==EVT_KEY_FIRST(KEY_ENTER) && !READ_ONLY() && (k != MAX_OUTPUT_CHANNELS) ) {
killEvents(event);
s_editMode = 0;
POPUP_MENU_ADD_ITEM(STR_EDIT);
POPUP_MENU_ADD_ITEM(STR_RESET);
POPUP_MENU_ADD_ITEM(STR_COPY_TRIMS_TO_OFS);
POPUP_MENU_ADD_ITEM(STR_COPY_STICKS_TO_OFS);
POPUP_MENU_ADD_ITEM(STR_COPY_MIN_MAX_TO_OUTPUTS);
POPUP_MENU_START(onLimitsMenu);
POPUP_MENU_START(onLimitsMenu, 5, STR_EDIT, STR_RESET, STR_COPY_TRIMS_TO_OFS, STR_COPY_STICKS_TO_OFS, STR_COPY_MIN_MAX_TO_OUTPUTS);
}
if (k == MAX_OUTPUT_CHANNELS) {
+1 -4
View File
@@ -174,10 +174,7 @@ void menuModelTelemetry(event_t event)
s_currIdx = index;
if (event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
POPUP_MENU_ADD_ITEM(STR_EDIT);
POPUP_MENU_ADD_ITEM(STR_COPY);
POPUP_MENU_ADD_ITEM(STR_DELETE);
POPUP_MENU_START(onSensorMenu);
POPUP_MENU_START(onSensorMenu, 3, STR_EDIT, STR_COPY, STR_DELETE);
}
else if (event == EVT_KEY_BREAK(KEY_ENTER)) {
pushMenu(menuModelSensor);
+1 -1
View File
@@ -28,7 +28,7 @@ const unsigned char ASTERISK_BITMAP[] = {
void drawAlertBox(const char * title, const char * text, const char * action)
{
lcdClear();
lcdDraw1bitBitmap(2, 0, ASTERISK_BITMAP, 0, 0);
lcdDraw1bitBitmap(2, 2, ASTERISK_BITMAP, 0, 0);
#define MESSAGE_LCD_OFFSET 6*FW
+2 -2
View File
@@ -22,8 +22,8 @@
#include "opentx.h"
#define SLEEP_BITMAP_WIDTH 60
#define SLEEP_BITMAP_HEIGHT 60
#define SLEEP_BITMAP_WIDTH 42
#define SLEEP_BITMAP_HEIGHT 47
const unsigned char bmp_sleep[] = {
#include "sleep.lbm"
+44 -69
View File
@@ -49,10 +49,10 @@
#define TRIM_LV_X 3
#define TRIM_RV_X (LCD_W-4)
#define TRIM_RH_X (LCD_W-TRIM_LEN-5)
#define TRIM_LH_NEG (TRIM_LH_X+1*FW)
#define TRIM_LH_POS (TRIM_LH_X-4*FW)
#define TRIM_RH_NEG (TRIM_RH_X+1*FW)
#define TRIM_RH_POS (TRIM_RH_X-4*FW)
#define TRIM_LH_NEG (TRIM_LH_X+3*FW+1)
#define TRIM_LH_POS (TRIM_LH_X-4*FW+3)
#define TRIM_RH_NEG (TRIM_RH_X+3*FW+1)
#define TRIM_RH_POS (TRIM_RH_X-4*FW+3)
#define RSSSI_X (30)
#define RSSSI_Y (31)
#define RSSI_MAX 105
@@ -148,43 +148,48 @@ void doMainScreenGraphics()
void displayTrims(uint8_t phase)
{
for (uint8_t i = 0; i < keysGetMaxTrims(); i++) {
#if defined(SURFACE_RADIO)
static coord_t x[] = {TRIM_RH_X, TRIM_LH_X, TRIM_RV_X, TRIM_LV_X, TRIM_LV_X};
static uint8_t vert[] = {0, 0, 1, 1, 1};
static uint8_t x[] = {TRIM_RH_X, TRIM_LH_X, TRIM_RV_X, TRIM_LV_X, TRIM_LV_X};
static uint8_t vert[] = {0, 0, 1, 1, 1};
#else
static coord_t x[] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X, TRIM_LH_X, TRIM_LV_X, TRIM_RH_X, TRIM_RV_X};
static uint8_t vert[] = {0, 1, 1, 0, 0, 1, 0, 1};
static uint8_t x[] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X, TRIM_LH_X, TRIM_LV_X, TRIM_RH_X, TRIM_RV_X};
static uint8_t vert[] = {0, 1, 1, 0, 0, 1, 0, 1};
#endif
coord_t xm, ym;
uint8_t stickIndex = inputMappingConvertMode(i);
xm = x[stickIndex];
uint8_t att = ROUND;
int16_t val = getTrimValue(phase, i);
bool squareMarker = (keysGetMaxTrims() <= 4);
for (uint8_t i = 0; i < keysGetMaxTrims(); i++) {
if (getRawTrimValue(phase, i).mode == TRIM_MODE_NONE || getRawTrimValue(phase, i).mode == TRIM_MODE_3POS)
continue;
coord_t ym;
uint8_t stickIndex = inputMappingConvertMode(i);
coord_t xm = x[stickIndex];
uint8_t att = ROUND;
int16_t val = getTrimValue(phase, i);
int16_t dir = val;
bool exttrim = false;
if (val < TRIM_MIN || val > TRIM_MAX) {
exttrim = true;
}
if (val < -(TRIM_LEN + 1) * 4) {
val = -(TRIM_LEN + 1);
val = (val * TRIM_LEN) / TRIM_MAX;
if (val < -TRIM_LEN) {
val = -TRIM_LEN;
}
else if (val > (TRIM_LEN + 1) * 4) {
val = TRIM_LEN + 1;
}
else {
val /= 4;
else if (val > TRIM_LEN) {
val = TRIM_LEN;
}
uint8_t nx, ny;
LcdFlags nFlg = TINSIZE;
if (vert[i]) {
ym = 31;
if (!getPixel(xm, ym))
lcdDrawSolidVerticalLine(xm, ym - TRIM_LEN, TRIM_LEN * 2 + 1);
if (keysGetMaxTrims() <= 4) {
if (squareMarker) {
if (i != 2 || !g_model.thrTrim) {
lcdDrawSolidVerticalLine(xm - 1, ym - 1, 3);
lcdDrawSolidVerticalLine(xm + 1, ym - 1, 3);
@@ -200,14 +205,6 @@ void displayTrims(uint8_t phase)
if (exttrim) {
lcdDrawSolidHorizontalLine(xm - 1, ym, 3);
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS ||
(trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber(dir > 0 ? 12 : 40, xm - 2, -abs(dir),
TINSIZE | VERTICAL);
}
}
lcdDrawSquare(xm - 3, ym - 3, 7, att);
}
else {
ym -= val;
@@ -221,20 +218,16 @@ void displayTrims(uint8_t phase)
lcdDrawSolidVerticalLine(xm + 2, ym - 1, 3);
lcdDrawSolidVerticalLine(xm + 3, ym - 2, 5);
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0 && i < 4) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS ||
(trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber(dir > 0 ? 12 : 40, xm - 2, -abs(dir),
TINSIZE | VERTICAL);
}
}
}
nx = dir > 0 ? 12 : 52;
ny = xm - 2;
nFlg |= VERTICAL;
}
else {
ym = 60;
if (!getPixel(xm, ym))
lcdDrawSolidHorizontalLine(xm - TRIM_LEN, ym, TRIM_LEN * 2 + 1);
if (keysGetMaxTrims() <= 4) {
if (squareMarker) {
lcdDrawSolidHorizontalLine(xm - 1, ym - 1, 3);
lcdDrawSolidHorizontalLine(xm - 1, ym + 1, 3);
xm += val;
@@ -248,16 +241,6 @@ void displayTrims(uint8_t phase)
if (exttrim) {
lcdDrawSolidVerticalLine(xm, ym - 1, 3);
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS ||
(trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber(
(stickIndex == 0 ? (dir > 0 ? TRIM_LH_POS : TRIM_LH_NEG)
: (dir > 0 ? TRIM_RH_POS : TRIM_RH_NEG)),
ym - 2, -abs(dir), TINSIZE);
}
}
lcdDrawSquare(xm - 3, ym - 3, 7, att);
}
else {
xm += val;
@@ -271,18 +254,19 @@ void displayTrims(uint8_t phase)
lcdDrawSolidHorizontalLine(xm - 1, ym - 2, 3);
lcdDrawSolidHorizontalLine(xm - 2, ym - 3, 5);
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0 && i < 4) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS ||
(trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber(
(xm < LCD_W / 2 ? (dir > 0 ? TRIM_LH_POS : TRIM_LH_NEG)
: (dir > 0 ? TRIM_RH_POS : TRIM_RH_NEG)),
ym - 2, -abs(dir), TINSIZE);
}
}
}
nx = xm < LCD_W / 2 ? (dir > 0 ? TRIM_LH_POS : TRIM_LH_NEG)
: (dir > 0 ? TRIM_RH_POS : TRIM_RH_NEG);
ny = ym - 2;
}
if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && dir != 0 && i < 4) {
if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS ||
(trimsDisplayTimer > 0 && (trimsDisplayMask & (1 << i)))) {
lcdDrawNumber(nx, ny, -abs(dir), nFlg | (dir < 0 ? RIGHT : 0));
}
}
if (squareMarker)
lcdDrawSquare(xm - 3, ym - 3, 7, att);
}
}
@@ -388,12 +372,7 @@ void onMainViewMenu(const char * result)
pushModelNotes();
}
else if (result == STR_RESET_SUBMENU) {
POPUP_MENU_ADD_ITEM(STR_RESET_FLIGHT);
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER1);
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER2);
POPUP_MENU_ADD_ITEM(STR_RESET_TIMER3);
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
POPUP_MENU_START(onMainViewMenu);
POPUP_MENU_START(onMainViewMenu, 5, STR_RESET_FLIGHT, STR_RESET_TIMER1, STR_RESET_TIMER2, STR_RESET_TIMER3, STR_RESET_TELEMETRY);
}
else if (result == STR_RESET_TELEMETRY) {
telemetryReset();
@@ -474,11 +453,7 @@ void menuMainView(event_t event)
POPUP_MENU_ADD_ITEM(STR_VIEW_NOTES);
}
POPUP_MENU_ADD_ITEM(STR_RESET_SUBMENU);
POPUP_MENU_ADD_ITEM(STR_STATISTICS);
POPUP_MENU_ADD_ITEM(STR_ABOUT_US);
POPUP_MENU_START(onMainViewMenu);
POPUP_MENU_START(onMainViewMenu, 3, STR_RESET_SUBMENU, STR_STATISTICS, STR_ABOUT_US);
break;
#if defined(EVT_KEY_LAST_MENU)