refactor: FLASH size optimisations for B&W (#4827)
This commit is contained in:
@@ -319,13 +319,7 @@ void menuModelExposAll(event_t event)
|
||||
else {
|
||||
event = 0;
|
||||
s_copyMode = 0;
|
||||
POPUP_MENU_ADD_ITEM(STR_EDIT);
|
||||
POPUP_MENU_ADD_ITEM(STR_INSERT_BEFORE);
|
||||
POPUP_MENU_ADD_ITEM(STR_INSERT_AFTER);
|
||||
POPUP_MENU_ADD_ITEM(STR_COPY);
|
||||
POPUP_MENU_ADD_ITEM(STR_MOVE);
|
||||
POPUP_MENU_ADD_ITEM(STR_DELETE);
|
||||
POPUP_MENU_START(onExposMenu);
|
||||
POPUP_MENU_START(onExposMenu, 6, STR_EDIT, STR_INSERT_BEFORE, STR_INSERT_AFTER, STR_COPY, STR_MOVE, STR_DELETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,13 +236,7 @@ void menuModelMixAll(event_t event)
|
||||
else {
|
||||
event = 0;
|
||||
s_copyMode = 0;
|
||||
POPUP_MENU_ADD_ITEM(STR_EDIT);
|
||||
POPUP_MENU_ADD_ITEM(STR_INSERT_BEFORE);
|
||||
POPUP_MENU_ADD_ITEM(STR_INSERT_AFTER);
|
||||
POPUP_MENU_ADD_ITEM(STR_COPY);
|
||||
POPUP_MENU_ADD_ITEM(STR_MOVE);
|
||||
POPUP_MENU_ADD_ITEM(STR_DELETE);
|
||||
POPUP_MENU_START(onMixesMenu);
|
||||
POPUP_MENU_START(onMixesMenu, 6, STR_EDIT, STR_INSERT_BEFORE, STR_INSERT_AFTER, STR_COPY, STR_MOVE, STR_DELETE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,9 +72,7 @@ void onPXX2BindMenu(const char * result)
|
||||
}
|
||||
else if (isModuleR9MAccess(moduleIdx) && reusableBuffer.moduleSetup.pxx2.moduleInformation.information.variant == PXX2_VARIANT_FLEX) {
|
||||
reusableBuffer.moduleSetup.bindInformation.step = BIND_RX_NAME_SELECTED;
|
||||
POPUP_MENU_ADD_ITEM(STR_FLEX_868);
|
||||
POPUP_MENU_ADD_ITEM(STR_FLEX_915);
|
||||
POPUP_MENU_START(onPXX2R9MBindModeMenu);
|
||||
POPUP_MENU_START(onPXX2R9MBindModeMenu, 2, STR_FLEX_868, STR_FLEX_915);
|
||||
}
|
||||
else {
|
||||
#if defined(SIMU)
|
||||
@@ -332,11 +330,6 @@ void modelSetupModulePxx2ReceiverLine(uint8_t moduleIdx, uint8_t receiverIdx, co
|
||||
}
|
||||
|
||||
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
POPUP_MENU_ADD_ITEM(STR_BIND);
|
||||
POPUP_MENU_ADD_ITEM(STR_OPTIONS);
|
||||
POPUP_MENU_ADD_ITEM(STR_SHARE);
|
||||
POPUP_MENU_ADD_ITEM(STR_DELETE);
|
||||
POPUP_MENU_ADD_ITEM(STR_RESET);
|
||||
POPUP_MENU_START(onPXX2ReceiverMenu);
|
||||
POPUP_MENU_START(onPXX2ReceiverMenu, 5, STR_BIND, STR_OPTIONS, STR_SHARE, STR_DELETE, STR_RESET);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,3 +247,117 @@ void drawProgressScreen(const char * title, const char * message, int num, int d
|
||||
}
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
void CLEAR_POPUP()
|
||||
{
|
||||
warningText = nullptr;
|
||||
warningInfoText = nullptr;
|
||||
popupMenuTitle = nullptr;
|
||||
popupMenuHandler = nullptr;
|
||||
popupMenuItemsCount = 0;
|
||||
}
|
||||
|
||||
void POPUP_WAIT(const char * s)
|
||||
{
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningType = WARNING_TYPE_WAIT;
|
||||
popupFunc = runPopupWarning;
|
||||
}
|
||||
|
||||
void POPUP_INFORMATION(const char * s)
|
||||
{
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningType = WARNING_TYPE_INFO;
|
||||
popupFunc = runPopupWarning;
|
||||
}
|
||||
|
||||
void POPUP_WARNING(const char * message, const char * info, bool waitForClose)
|
||||
{
|
||||
(void)waitForClose;
|
||||
|
||||
warningText = message;
|
||||
warningInfoText = info;
|
||||
warningInfoLength = info ? strlen(info) : 0;
|
||||
warningInfoFlags = 0;
|
||||
warningType = WARNING_TYPE_ASTERISK;
|
||||
popupFunc = runPopupWarning;
|
||||
}
|
||||
|
||||
void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags)
|
||||
{
|
||||
warningInfoText = info;
|
||||
warningInfoLength = length;
|
||||
warningInfoFlags = flags;
|
||||
}
|
||||
|
||||
void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler)
|
||||
{
|
||||
if (s != warningText) {
|
||||
killAllEvents();
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningType = WARNING_TYPE_CONFIRM;
|
||||
popupFunc = runPopupWarning;
|
||||
popupMenuHandler = handler;
|
||||
}
|
||||
}
|
||||
|
||||
void POPUP_INPUT(const char * s, PopupFunc func)
|
||||
{
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningType = WARNING_TYPE_INPUT;
|
||||
popupFunc = func;
|
||||
}
|
||||
|
||||
bool isEventCaughtByPopup()
|
||||
{
|
||||
if (warningText && warningType != WARNING_TYPE_WAIT)
|
||||
return true;
|
||||
|
||||
if (popupMenuItemsCount > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void POPUP_MENU_ADD_ITEM(const char * s)
|
||||
{
|
||||
popupMenuOffsetType = MENU_OFFSET_INTERNAL;
|
||||
if (popupMenuItemsCount < POPUP_MENU_MAX_LINES) {
|
||||
popupMenuItems[popupMenuItemsCount++] = s;
|
||||
}
|
||||
}
|
||||
|
||||
void POPUP_MENU_SELECT_ITEM(uint8_t index)
|
||||
{
|
||||
popupMenuSelectedItem = (index > 0 ? (index < popupMenuItemsCount ? index : popupMenuItemsCount) : 0);
|
||||
}
|
||||
|
||||
void POPUP_MENU_TITLE(const char * s)
|
||||
{
|
||||
popupMenuTitle = s;
|
||||
}
|
||||
|
||||
void POPUP_MENU_START(PopupMenuHandler handler)
|
||||
{
|
||||
if (handler != popupMenuHandler) {
|
||||
killAllEvents();
|
||||
AUDIO_KEY_PRESS();
|
||||
popupMenuHandler = handler;
|
||||
}
|
||||
}
|
||||
|
||||
void POPUP_MENU_START(PopupMenuHandler handler, int count, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, count);
|
||||
for(int i = 0; i < count; i += 1) {
|
||||
const char* s = va_arg(ap, const char*);
|
||||
POPUP_MENU_ADD_ITEM(s);
|
||||
}
|
||||
va_end(ap);
|
||||
POPUP_MENU_START(handler);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _STDLCD_POPUPS_H_
|
||||
#define _STDLCD_POPUPS_H_
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "audio.h"
|
||||
@@ -80,89 +79,17 @@ enum
|
||||
inline void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags) { }
|
||||
#else
|
||||
#define DISPLAY_WARNING(evt) (*popupFunc)(evt)
|
||||
inline void CLEAR_POPUP()
|
||||
{
|
||||
warningText = nullptr;
|
||||
warningInfoText = nullptr;
|
||||
popupMenuTitle = nullptr;
|
||||
popupMenuHandler = nullptr;
|
||||
popupMenuItemsCount = 0;
|
||||
}
|
||||
|
||||
inline void POPUP_WAIT(const char * s)
|
||||
{
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningType = WARNING_TYPE_WAIT;
|
||||
popupFunc = runPopupWarning;
|
||||
}
|
||||
|
||||
inline void POPUP_INFORMATION(const char * s)
|
||||
{
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningType = WARNING_TYPE_INFO;
|
||||
popupFunc = runPopupWarning;
|
||||
}
|
||||
|
||||
inline void POPUP_WARNING(const char * message, const char * info = nullptr, bool waitForClose = true)
|
||||
{
|
||||
(void)waitForClose;
|
||||
|
||||
warningText = message;
|
||||
warningInfoText = info;
|
||||
warningInfoLength = info ? strlen(info) : 0;
|
||||
warningInfoFlags = 0;
|
||||
warningType = WARNING_TYPE_ASTERISK;
|
||||
popupFunc = runPopupWarning;
|
||||
}
|
||||
|
||||
inline void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags)
|
||||
{
|
||||
warningInfoText = info;
|
||||
warningInfoLength = length;
|
||||
warningInfoFlags = flags;
|
||||
}
|
||||
|
||||
inline void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler)
|
||||
{
|
||||
if (s != warningText) {
|
||||
killAllEvents();
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningType = WARNING_TYPE_CONFIRM;
|
||||
popupFunc = runPopupWarning;
|
||||
popupMenuHandler = handler;
|
||||
}
|
||||
}
|
||||
|
||||
inline void POPUP_INPUT(const char * s, PopupFunc func)
|
||||
{
|
||||
warningText = s;
|
||||
warningInfoText = nullptr;
|
||||
warningType = WARNING_TYPE_INPUT;
|
||||
popupFunc = func;
|
||||
}
|
||||
|
||||
inline bool isEventCaughtByPopup()
|
||||
{
|
||||
if (warningText && warningType != WARNING_TYPE_WAIT)
|
||||
return true;
|
||||
|
||||
if (popupMenuItemsCount > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
extern void CLEAR_POPUP();
|
||||
extern void POPUP_WAIT(const char * s);
|
||||
extern void POPUP_INFORMATION(const char * s);
|
||||
extern void POPUP_WARNING(const char * message, const char * info = nullptr, bool waitForClose = true);
|
||||
extern void SET_WARNING_INFO(const char * info, uint8_t length, uint8_t flags);
|
||||
extern void POPUP_CONFIRMATION(const char * s, PopupMenuHandler handler);
|
||||
extern void POPUP_INPUT(const char * s, PopupFunc func);
|
||||
extern bool isEventCaughtByPopup();
|
||||
#endif
|
||||
|
||||
inline void POPUP_MENU_ADD_ITEM(const char * s)
|
||||
{
|
||||
popupMenuOffsetType = MENU_OFFSET_INTERNAL;
|
||||
if (popupMenuItemsCount < POPUP_MENU_MAX_LINES) {
|
||||
popupMenuItems[popupMenuItemsCount++] = s;
|
||||
}
|
||||
}
|
||||
extern void POPUP_MENU_ADD_ITEM(const char * s);
|
||||
|
||||
#if defined(SDCARD)
|
||||
#define POPUP_MENU_ADD_SD_ITEM(s) POPUP_MENU_ADD_ITEM(s)
|
||||
@@ -170,26 +97,12 @@ inline void POPUP_MENU_ADD_ITEM(const char * s)
|
||||
#define POPUP_MENU_ADD_SD_ITEM(s)
|
||||
#endif
|
||||
|
||||
inline void POPUP_MENU_SELECT_ITEM(uint8_t index)
|
||||
{
|
||||
popupMenuSelectedItem = (index > 0 ? (index < popupMenuItemsCount ? index : popupMenuItemsCount) : 0);
|
||||
}
|
||||
extern void POPUP_MENU_SELECT_ITEM(uint8_t index);
|
||||
|
||||
inline void POPUP_MENU_TITLE(const char * s)
|
||||
{
|
||||
popupMenuTitle = s;
|
||||
}
|
||||
extern void POPUP_MENU_TITLE(const char * s);
|
||||
|
||||
inline void POPUP_MENU_START(PopupMenuHandler handler)
|
||||
{
|
||||
if (handler != popupMenuHandler) {
|
||||
killAllEvents();
|
||||
AUDIO_KEY_PRESS();
|
||||
popupMenuHandler = handler;
|
||||
}
|
||||
}
|
||||
extern void POPUP_MENU_START(PopupMenuHandler handler);
|
||||
extern void POPUP_MENU_START(PopupMenuHandler handler, int count, ...);
|
||||
|
||||
// For compatability with color LCD code base, not (currently) required for B&W
|
||||
#define POPUP_WARNING_ON_UI_TASK POPUP_WARNING
|
||||
|
||||
#endif // _STDLCD_POPUPS_H_
|
||||
|
||||
@@ -73,9 +73,7 @@ void menuViewTelemetry(event_t event)
|
||||
}
|
||||
else if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
killEvents(event);
|
||||
POPUP_MENU_ADD_ITEM(STR_RESET_TELEMETRY);
|
||||
POPUP_MENU_ADD_ITEM(STR_RESET_FLIGHT);
|
||||
POPUP_MENU_START(onMainViewMenu);
|
||||
POPUP_MENU_START(onMainViewMenu, 2, STR_RESET_TELEMETRY, STR_RESET_FLIGHT);
|
||||
}
|
||||
|
||||
for (int i=0; i<=TELEMETRY_SCREEN_TYPE_MAX; i++) {
|
||||
|
||||
Reference in New Issue
Block a user