Refactoring
This commit is contained in:
@@ -39,21 +39,38 @@ extern const pm_uchar sticks[] PROGMEM;
|
||||
#define X0 (LCD_W-WCHART-2)
|
||||
#define Y0 (LCD_H/2)
|
||||
|
||||
#if LCD_W >= 212
|
||||
#define MIXES_2ND_COLUMN (18*FW)
|
||||
#else
|
||||
#define MIXES_2ND_COLUMN (12*FW)
|
||||
#endif
|
||||
#define MIXES_2ND_COLUMN (12*FW)
|
||||
|
||||
void drawSplash();
|
||||
void drawScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
|
||||
void drawStick(coord_t centrex, int16_t xval, int16_t yval);
|
||||
void drawProgressBar(const char * label)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
void updateProgressBar(int num, int den)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
void drawSleepBitmap()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
#if !defined(CPUM64)
|
||||
void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible);
|
||||
#endif
|
||||
|
||||
|
||||
#define SET_SCROLLBAR_X(x)
|
||||
#define LOAD_MODEL_BITMAP()
|
||||
|
||||
#define IS_MAIN_VIEW_DISPLAYED() menuHandlers[0] == menuMainView
|
||||
#if defined(FRSKY)
|
||||
#define IS_TELEMETRY_VIEW_DISPLAYED() menuHandlers[0] == menuTelemetryFrsky
|
||||
#else
|
||||
#define IS_TELEMETRY_VIEW_DISPLAYED() false
|
||||
#endif
|
||||
#define IS_OTHER_VIEW_DISPLAYED() false
|
||||
|
||||
#endif // _GUI_H_
|
||||
@@ -268,4 +268,6 @@ uint8_t lcdRefresh_ST7920(uint8_t full);
|
||||
#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6))
|
||||
#endif
|
||||
|
||||
const char * writeScreenshot();
|
||||
|
||||
#endif // _LCD_H_
|
||||
|
||||
@@ -445,7 +445,7 @@ extern uint8_t s_curveChan;
|
||||
#define WARNING_LINE_X 16
|
||||
#define WARNING_LINE_Y 3*FH
|
||||
|
||||
void displayBox();
|
||||
void drawMessageBox();
|
||||
void displayPopup(const pm_char * pstr);
|
||||
void displayWarning(uint8_t event);
|
||||
|
||||
@@ -496,7 +496,7 @@ void displayWarning(uint8_t event);
|
||||
extern uint16_t popupMenuNoItems;
|
||||
extern uint8_t popupMenuFlags;
|
||||
extern uint16_t popupMenuOffset;
|
||||
const char * displayPopupMenu(uint8_t event);
|
||||
const char * runPopupMenu(uint8_t event);
|
||||
extern void (*popupMenuHandler)(const char *result);
|
||||
#else
|
||||
#define popupMenuNoItems 0
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "../../opentx.h"
|
||||
#include "opentx.h"
|
||||
|
||||
const pm_char * warningText = NULL;
|
||||
const pm_char * warningInfoText;
|
||||
@@ -33,7 +33,7 @@ int16_t warningInputValueMin;
|
||||
int16_t warningInputValueMax;
|
||||
#endif
|
||||
|
||||
void displayBox()
|
||||
void drawMessageBox()
|
||||
{
|
||||
lcdDrawFilledRect(10, 16, LCD_W-20, 40, SOLID, ERASE);
|
||||
lcdDrawRect(10, 16, LCD_W-20, 40);
|
||||
@@ -48,7 +48,7 @@ void displayBox()
|
||||
void displayPopup(const pm_char * pstr)
|
||||
{
|
||||
warningText = pstr;
|
||||
displayBox();
|
||||
drawMessageBox();
|
||||
warningText = NULL;
|
||||
lcdRefresh();
|
||||
}
|
||||
@@ -89,7 +89,7 @@ void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SO
|
||||
void displayWarning(uint8_t event)
|
||||
{
|
||||
warningResult = false;
|
||||
displayBox();
|
||||
drawMessageBox();
|
||||
if (warningInfoText) {
|
||||
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y+FH, warningInfoText, warningInfoLength, WARNING_INFO_FLAGS);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ uint16_t popupMenuNoItems = 0;
|
||||
uint8_t popupMenuFlags = 0;
|
||||
uint16_t popupMenuOffset = 0;
|
||||
void (*popupMenuHandler)(const char *result);
|
||||
const char * displayPopupMenu(uint8_t event)
|
||||
const char * runPopupMenu(uint8_t event)
|
||||
{
|
||||
const char * result = NULL;
|
||||
|
||||
|
||||
@@ -554,7 +554,7 @@ void menuMainView(uint8_t event)
|
||||
if (gvarDisplayTimer > 0) {
|
||||
gvarDisplayTimer--;
|
||||
warningText = STR_GLOBAL_VAR;
|
||||
displayBox();
|
||||
drawMessageBox();
|
||||
lcdDrawSizedText(16, 5*FH, g_model.gvars[gvarLastChanged].name, LEN_GVAR_NAME, ZCHAR);
|
||||
lcdDrawText(16+7*FW, 5*FH, PSTR("[\010]"), BOLD);
|
||||
|
||||
|
||||
@@ -188,65 +188,21 @@ uint8_t * lcdLoadBitmap(uint8_t * bmp, const char * filename, uint16_t width, ui
|
||||
return bmp;
|
||||
}
|
||||
|
||||
const uint8_t bmpHeader[] = {
|
||||
0x42, 0x4d, 0xF8, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00,
|
||||
0x00, 0x00, 212, 0x00, 0x00, 0x00, 64, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0xbc, 0x38, 0x00, 0x00, 0xbc, 0x38, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xee, 0xee, 0xee, 0x00, 0xdd, 0xdd,
|
||||
0xdd, 0x00, 0xcc, 0xcc, 0xcc, 0x00, 0xbb, 0xbb, 0xbb, 0x00, 0xaa, 0xaa, 0xaa, 0x00, 0x99, 0x99,
|
||||
0x99, 0x00, 0x88, 0x88, 0x88, 0x00, 0x77, 0x77, 0x77, 0x00, 0x66, 0x66, 0x66, 0x00, 0x55, 0x55,
|
||||
0x55, 0x00, 0x44, 0x44, 0x44, 0x00, 0x33, 0x33, 0x33, 0x00, 0x22, 0x22, 0x22, 0x00, 0x11, 0x11,
|
||||
0x11, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
uint8_t modelBitmap[MODEL_BITMAP_SIZE] __DMA;
|
||||
|
||||
inline display_t getPixel(unsigned int x, unsigned int y)
|
||||
bool loadModelBitmap(char * name, uint8_t * bitmap)
|
||||
{
|
||||
if (x>=LCD_W || y>=LCD_H)
|
||||
return 0;
|
||||
display_t * p = &displayBuf[y / 2 * LCD_W + x];
|
||||
return (y & 1) ? (*p >> 4) : (*p & 0x0F);
|
||||
}
|
||||
|
||||
const char * writeScreenshot()
|
||||
{
|
||||
FIL bmpFile;
|
||||
UINT written;
|
||||
char filename[42]; // /SCREENSHOTS/screen-2013-01-01-123540.bmp
|
||||
|
||||
// check and create folder here
|
||||
strcpy_P(filename, SCREENSHOTS_PATH);
|
||||
const char * error = sdCheckAndCreateDirectory(filename);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
char * tmp = strAppend(&filename[sizeof(SCREENSHOTS_PATH)-1], "/screen");
|
||||
tmp = strAppendDate(tmp, true);
|
||||
strcpy(tmp, BMP_EXT);
|
||||
|
||||
FRESULT result = f_open(&bmpFile, filename, FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (result != FR_OK) {
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
result = f_write(&bmpFile, bmpHeader, sizeof(bmpHeader), &written);
|
||||
if (result != FR_OK || written != sizeof(bmpHeader)) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
|
||||
for (int y=LCD_H-1; y>=0; y-=1) {
|
||||
for (int x=0; x<8*((LCD_W+7)/8); x+=2) {
|
||||
uint8_t byte = getPixel(x+1, y) + (getPixel(x, y) << 4);
|
||||
f_write(&bmpFile, &byte, 1, &written);
|
||||
if (result != FR_OK || written != 1) {
|
||||
f_close(&bmpFile);
|
||||
return SDCARD_ERROR(result);
|
||||
}
|
||||
uint8_t len = zlen(name, LEN_BITMAP_NAME);
|
||||
if (len > 0) {
|
||||
char lfn[] = BITMAPS_PATH "/xxxxxxxxxx.bmp";
|
||||
strncpy(lfn+sizeof(BITMAPS_PATH), name, len);
|
||||
strcpy(lfn+sizeof(BITMAPS_PATH)+len, BMP_EXT);
|
||||
if (lcdLoadBitmap(bitmap, lfn, MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
f_close(&bmpFile);
|
||||
|
||||
return NULL;
|
||||
// In all error cases, we set the default logo
|
||||
memcpy(bitmap, logo_taranis, MODEL_BITMAP_SIZE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ struct MenuItem {
|
||||
void drawSplash();
|
||||
void drawScreenIndex(uint8_t index, uint8_t count, uint8_t attr);
|
||||
void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible);
|
||||
void displayMenuBar(const MenuItem *menu, int index);
|
||||
void drawProgressBar(const char *label);
|
||||
void displayMenuBar(const MenuItem * menu, int index);
|
||||
void drawProgressBar(const char * label);
|
||||
void updateProgressBar(int num, int den);
|
||||
void drawGauge(coord_t x, coord_t y, coord_t w, coord_t h, int32_t val, int32_t max);
|
||||
void drawColumnHeader(const char * const * headers, uint8_t index);
|
||||
@@ -80,4 +80,8 @@ FlightModesType editFlightModes(coord_t x, coord_t y, uint8_t event, FlightModes
|
||||
#define displayFlightModes(...)
|
||||
#endif
|
||||
|
||||
#define IS_MAIN_VIEW_DISPLAYED() menuHandlers[0] == menuMainView
|
||||
#define IS_TELEMETRY_VIEW_DISPLAYED() menuHandlers[0] == menuTelemetryFrsky
|
||||
#define IS_OTHER_VIEW_DISPLAYED() (menuHandlers[0] == menuMainViewChannelsMonitor || menuHandlers[0] == menuChannelsView)
|
||||
|
||||
#endif // _GUI_H_
|
||||
@@ -218,4 +218,14 @@ const char * writeScreenshot();
|
||||
#define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6))
|
||||
#endif
|
||||
|
||||
inline display_t getPixel(unsigned int x, unsigned int y)
|
||||
{
|
||||
if (x>=LCD_W || y>=LCD_H) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
display_t * p = &displayBuf[y / 2 * LCD_W + x];
|
||||
return (y & 1) ? (*p >> 4) : (*p & 0x0F);
|
||||
}
|
||||
|
||||
#endif // _LCD_H_
|
||||
|
||||
@@ -362,8 +362,8 @@ void insertMix(uint8_t idx);
|
||||
#define WARNING_LINE_X 16
|
||||
#define WARNING_LINE_Y 3*FH
|
||||
|
||||
void displayBox(const char *title);
|
||||
void displayPopup(const char *title);
|
||||
void drawMessageBox(const char * title);
|
||||
void displayPopup(const char * title);
|
||||
void displayWarning(uint8_t event);
|
||||
|
||||
extern void (*popupFunc)(uint8_t event);
|
||||
@@ -395,7 +395,7 @@ enum {
|
||||
MENU_OFFSET_EXTERNAL
|
||||
};
|
||||
extern uint8_t popupMenuOffsetType;
|
||||
const char * displayPopupMenu(uint8_t event);
|
||||
const char * runPopupMenu(uint8_t event);
|
||||
extern void (*popupMenuHandler)(const char *result);
|
||||
|
||||
#define STATUS_LINE_LENGTH 32
|
||||
|
||||
@@ -20,24 +20,24 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
const char *warningText = NULL;
|
||||
const char *warningInfoText;
|
||||
uint8_t warningInfoLength;
|
||||
uint8_t warningType;
|
||||
uint8_t warningResult = 0;
|
||||
uint8_t warningInfoFlags = ZCHAR;
|
||||
int16_t warningInputValue;
|
||||
int16_t warningInputValueMin;
|
||||
int16_t warningInputValueMax;
|
||||
void (*popupFunc)(uint8_t event) = NULL;
|
||||
const char *popupMenuItems[POPUP_MENU_MAX_LINES];
|
||||
uint8_t s_menu_item = 0;
|
||||
uint16_t popupMenuNoItems = 0;
|
||||
uint16_t popupMenuOffset = 0;
|
||||
uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL;
|
||||
void (*popupMenuHandler)(const char * result);
|
||||
const char * warningText = NULL;
|
||||
const char * warningInfoText;
|
||||
uint8_t warningInfoLength;
|
||||
uint8_t warningType;
|
||||
uint8_t warningResult = 0;
|
||||
uint8_t warningInfoFlags = ZCHAR;
|
||||
int16_t warningInputValue;
|
||||
int16_t warningInputValueMin;
|
||||
int16_t warningInputValueMax;
|
||||
void (*popupFunc)(uint8_t event) = NULL;
|
||||
const char * popupMenuItems[POPUP_MENU_MAX_LINES];
|
||||
uint8_t s_menu_item = 0;
|
||||
uint16_t popupMenuNoItems = 0;
|
||||
uint16_t popupMenuOffset = 0;
|
||||
uint8_t popupMenuOffsetType = MENU_OFFSET_INTERNAL;
|
||||
void (*popupMenuHandler)(const char * result);
|
||||
|
||||
void displayBox(const char * title)
|
||||
void drawMessageBox(const char * title)
|
||||
{
|
||||
lcdDrawFilledRect(10, 16, LCD_W-20, 40, SOLID, ERASE);
|
||||
lcdDrawRect(10, 16, LCD_W-20, 40);
|
||||
@@ -47,7 +47,7 @@ void displayBox(const char * title)
|
||||
|
||||
void displayPopup(const char * title)
|
||||
{
|
||||
displayBox(title);
|
||||
drawMessageBox(title);
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ void message(const pm_char * title, const pm_char * text, const char * action, u
|
||||
void displayWarning(uint8_t event)
|
||||
{
|
||||
warningResult = false;
|
||||
displayBox(warningText);
|
||||
drawMessageBox(warningText);
|
||||
if (warningInfoText) {
|
||||
lcdDrawSizedText(WARNING_LINE_X, WARNING_LINE_Y+FH, warningInfoText, warningInfoLength, WARNING_INFO_FLAGS);
|
||||
}
|
||||
@@ -119,11 +119,11 @@ void displayWarning(uint8_t event)
|
||||
}
|
||||
}
|
||||
|
||||
const char * displayPopupMenu(uint8_t event)
|
||||
const char * runPopupMenu(uint8_t event)
|
||||
{
|
||||
const char * result = NULL;
|
||||
|
||||
uint8_t display_count = min<unsigned int>(popupMenuNoItems, MENU_MAX_DISPLAY_LINES);
|
||||
uint8_t display_count = min<uint8_t>(popupMenuNoItems, MENU_MAX_DISPLAY_LINES);
|
||||
uint8_t y = (display_count >= 5 ? MENU_Y - FH - 1 : MENU_Y);
|
||||
lcdDrawFilledRect(MENU_X, y, MENU_W, display_count * (FH+1) + 2, SOLID, ERASE);
|
||||
lcdDrawRect(MENU_X, y, MENU_W, display_count * (FH+1) + 2);
|
||||
|
||||
@@ -91,4 +91,8 @@ void drawCurvePoint(int x, int y, LcdFlags color);
|
||||
extern Layout * customScreens[MAX_CUSTOM_SCREENS];
|
||||
extern Topbar * topbar;
|
||||
|
||||
#define IS_MAIN_VIEW_DISPLAYED() menuHandlers[0] == menuMainView
|
||||
#define IS_TELEMETRY_VIEW_DISPLAYED() false
|
||||
#define IS_OTHER_VIEW_DISPLAYED() false
|
||||
|
||||
#endif // _GUI_H_
|
||||
|
||||
@@ -503,7 +503,7 @@ enum {
|
||||
MENU_OFFSET_EXTERNAL
|
||||
};
|
||||
extern uint8_t popupMenuOffsetType;
|
||||
const char * displayPopupMenu(evt_t event);
|
||||
const char * runPopupMenu(evt_t event);
|
||||
extern void (*popupMenuHandler)(const char * result);
|
||||
|
||||
#define TEXT_FILENAME_MAXLEN 40
|
||||
|
||||
@@ -99,7 +99,7 @@ void displayWarning(evt_t event)
|
||||
}
|
||||
}
|
||||
|
||||
const char * displayPopupMenu(evt_t event)
|
||||
const char * runPopupMenu(evt_t event)
|
||||
{
|
||||
const char * result = NULL;
|
||||
|
||||
|
||||
@@ -62,6 +62,12 @@ bool modelHasNotes();
|
||||
|
||||
#if defined(COLORLCD)
|
||||
bool isSwitchWarningStateAvailable(int state);
|
||||
#endif // #if defined(COLORLCD)
|
||||
#endif
|
||||
|
||||
#if defined(GUI)
|
||||
#define IS_INSTANT_TRIM_ALLOWED() (IS_MAIN_VIEW_DISPLAYED() || IS_TELEMETRY_VIEW_DISPLAYED() || IS_OTHER_VIEW_DISPLAYED())
|
||||
#else
|
||||
#define IS_INSTANT_TRIM_ALLOWED() true
|
||||
#endif
|
||||
|
||||
#endif // _GUI_HELPERS_H_
|
||||
|
||||
Reference in New Issue
Block a user