Skip to content

Commit

Permalink
refactor: FLASH size optimisations for B&W (EdgeTX#4827)
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz authored and ThomasKuehne committed Apr 5, 2024
1 parent 22b1207 commit f0809d1
Show file tree
Hide file tree
Showing 36 changed files with 607 additions and 654 deletions.
Binary file modified radio/src/bitmaps/128x64/asterisk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified radio/src/bitmaps/128x64/sleep.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions radio/src/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@
#define PACK(__Declaration__) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
#endif

#if defined(SIMU)
#define PACK_NOT_SIMU(__Declaration__) __Declaration__
#else
#define PACK_NOT_SIMU(__Declaration__) PACK(__Declaration__)
#endif

#if defined(SIMU)
#define CONVERT_PTR_UINT(x) ((uint32_t)(uint64_t)(x))
#define CONVERT_UINT_PTR(x) ((uint32_t*)(uint64_t)(x))
Expand Down
22 changes: 22 additions & 0 deletions radio/src/gui/128x64/menu_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions radio/src/gui/128x64/menu_radio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
41 changes: 3 additions & 38 deletions radio/src/gui/128x64/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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_
5 changes: 1 addition & 4 deletions radio/src/gui/128x64/model_curve_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 1 addition & 5 deletions radio/src/gui/128x64/model_failsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions radio/src/gui/128x64/model_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions radio/src/gui/128x64/model_telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion radio/src/gui/128x64/popups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/128x64/startup_shutdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
113 changes: 44 additions & 69 deletions radio/src/gui/128x64/view_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
else if (val > (TRIM_LEN + 1) * 4) {
val = TRIM_LEN + 1;
val = (val * TRIM_LEN) / TRIM_MAX;
if (val < -TRIM_LEN) {
val = -TRIM_LEN;
}
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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit f0809d1

Please sign in to comment.