[Horus] Refactoring continued
This commit is contained in:
@@ -64,10 +64,18 @@ const uint8_t LBM_CURRENT_DOT[] = {
|
||||
* Main view bitmaps
|
||||
*/
|
||||
|
||||
const uint16_t LBM_MAINVIEW_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/background.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_TOPMENU_OPENTX[] = {
|
||||
#include "../../bitmaps/Horus/mask_topmenu_opentx.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_TOPMENU_USB[] = {
|
||||
#include "../../bitmaps/Horus/mask_topmenu_usb.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_HTRIM_FRAME[] = {
|
||||
#include "../../bitmaps/Horus/mask_htrim_frame.lbm"
|
||||
};
|
||||
@@ -80,6 +88,14 @@ const uint8_t LBM_TRIM_SHADOW[] = {
|
||||
#include "../../bitmaps/Horus/mask_trim_shadow.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_TIMER_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/mask_timer_bg.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_RSCALE[] = {
|
||||
#include "../../bitmaps/Horus/mask_rscale.lbm"
|
||||
};
|
||||
|
||||
/*
|
||||
* Radio menu bitmaps
|
||||
*/
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#define CURVE_CENTER_Y 159
|
||||
|
||||
#define MENU_TITLE_NEXT_POS (lcdNextPos + 10)
|
||||
#define MENU_INIT_VPOS -1
|
||||
|
||||
void displaySplash();
|
||||
void displayScreenIndex(uint8_t index, uint8_t count);
|
||||
@@ -82,12 +83,16 @@ extern const uint8_t LBM_CURRENT_SHADOW[];
|
||||
extern const uint8_t LBM_CURRENT_DOT[];
|
||||
|
||||
// Main view icons
|
||||
extern const uint16_t LBM_MAINVIEW_BACKGROUND[];
|
||||
extern const uint8_t LBM_TOPMENU_OPENTX[];
|
||||
extern const uint8_t LBM_TOPMENU_USB[];
|
||||
extern const uint8_t LBM_HTRIM_FRAME[];
|
||||
extern const uint8_t LBM_VTRIM_FRAME[];
|
||||
extern const uint8_t LBM_TRIM_SHADOW[];
|
||||
extern const uint8_t LBM_RADIO_ICON[];
|
||||
extern const uint8_t LBM_MODEL_ICON[];
|
||||
extern const uint8_t LBM_TIMER_BACKGROUND[];
|
||||
extern const uint8_t LBM_RSCALE[];
|
||||
|
||||
// Menu icons
|
||||
extern const uint8_t * const LBM_RADIO_ICONS[];
|
||||
|
||||
+53
-102
@@ -54,6 +54,7 @@ void lcdColorsInit()
|
||||
lcdColorTable[SCROLLBOX_COLOR_INDEX] = RED;
|
||||
lcdColorTable[MENU_TITLE_BGCOLOR_INDEX] = DARKGREY;
|
||||
lcdColorTable[MENU_TITLE_COLOR_INDEX] = WHITE;
|
||||
lcdColorTable[MENU_TITLE_DISABLE_COLOR_INDEX] = RGB(130, 1, 5);
|
||||
lcdColorTable[HEADER_COLOR_INDEX] = DARKGREY;
|
||||
lcdColorTable[ALARM_COLOR_INDEX] = RED;
|
||||
lcdColorTable[WARNING_COLOR_INDEX] = YELLOW;
|
||||
@@ -790,18 +791,18 @@ void lcdSetContrast()
|
||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
||||
}
|
||||
|
||||
void lcdDrawPixel(display_t * p, display_t value)
|
||||
inline void lcdDrawPixel(display_t * p, display_t value)
|
||||
{
|
||||
*p = value;
|
||||
}
|
||||
|
||||
void lcdDrawPixel(coord_t x, coord_t y, display_t value)
|
||||
inline void lcdDrawPixel(coord_t x, coord_t y, display_t value)
|
||||
{
|
||||
display_t * p = PIXEL_PTR(x, y);
|
||||
lcdDrawPixel(p, value);
|
||||
}
|
||||
|
||||
void lcdDrawTransparentPixel(coord_t x, coord_t y, uint8_t opacity, uint16_t color)
|
||||
inline void lcdDrawTransparentPixel(coord_t x, coord_t y, uint8_t opacity, uint16_t color)
|
||||
{
|
||||
display_t * p = PIXEL_PTR(x, y);
|
||||
lcdDrawTransparentPixel(p, opacity, color);
|
||||
@@ -938,56 +939,66 @@ void lcdDrawCircle(int x0, int y0, int radius)
|
||||
|
||||
#define PI 3.14159265
|
||||
|
||||
void lcdDrawPie(int x0, int y0, int radius, int startAngle, int endAngle)
|
||||
bool evalSlopes(int * slopes, int startAngle, int endAngle)
|
||||
{
|
||||
int slope1s, slope1e, slope2s, slope2e;
|
||||
|
||||
if (startAngle >= 360 || endAngle <= 0)
|
||||
return;
|
||||
|
||||
float angle1 = float(startAngle) * PI / 180;
|
||||
float angle2 = float(endAngle) * PI / 180;
|
||||
return false;
|
||||
|
||||
if (startAngle == 0) {
|
||||
slope1e = 100000;
|
||||
slope2s = -100000;
|
||||
}
|
||||
else if (startAngle >= 180) {
|
||||
slope1e = -100000;
|
||||
slope2s = cos(angle1)*100/sin(angle1);
|
||||
slopes[1] = 100000;
|
||||
slopes[2] = -100000;
|
||||
}
|
||||
else {
|
||||
slope1e = cos(angle1)*100/sin(angle1);
|
||||
slope2s = -100000;
|
||||
float angle1 = float(startAngle) * PI / 180;
|
||||
if (startAngle >= 180) {
|
||||
slopes[1] = -100000;
|
||||
slopes[2] = cos(angle1) * 100 / sin(angle1);
|
||||
}
|
||||
else {
|
||||
slopes[1] = cos(angle1) * 100 / sin(angle1);
|
||||
slopes[2] = -100000;
|
||||
}
|
||||
}
|
||||
|
||||
if (endAngle == 360) {
|
||||
slope1s = -100000;
|
||||
slope2e = 100000;
|
||||
}
|
||||
else if (endAngle >= 180) {
|
||||
slope1s = -100000;
|
||||
slope2e = -cos(angle2)*100/sin(angle2);
|
||||
slopes[0] = -100000;
|
||||
slopes[3] = 100000;
|
||||
}
|
||||
else {
|
||||
slope1s = cos(angle2)*100/sin(angle2);
|
||||
slope2e = -100000;
|
||||
float angle2 = float(endAngle) * PI / 180;
|
||||
if (endAngle >= 180) {
|
||||
slopes[0] = -100000;
|
||||
slopes[3] = -cos(angle2) * 100 / sin(angle2);
|
||||
}
|
||||
else {
|
||||
slopes[0] = cos(angle2) * 100 / sin(angle2);
|
||||
slopes[3] = -100000;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void lcdDrawPie(int x0, int y0, int radius, int startAngle, int endAngle)
|
||||
{
|
||||
int slopes[4];
|
||||
if (!evalSlopes(slopes, startAngle, endAngle))
|
||||
return;
|
||||
|
||||
for (int y=0; y<=radius; y++) {
|
||||
for (int x=0; x<=radius; x++) {
|
||||
if (x*x+y*y <= radius*radius) {
|
||||
int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x);
|
||||
if (slope >= slope1s && slope < slope1e) {
|
||||
if (slope >= slopes[0] && slope < slopes[1]) {
|
||||
lcdDrawPixel(x0+x, y0-y, WHITE);
|
||||
}
|
||||
if (-slope >= slope1s && -slope < slope1e) {
|
||||
if (-slope >= slopes[0] && -slope < slopes[1]) {
|
||||
lcdDrawPixel(x0+x, y0+y, WHITE);
|
||||
}
|
||||
if (slope >= slope2s && slope < slope2e) {
|
||||
if (slope >= slopes[2] && slope < slopes[3]) {
|
||||
lcdDrawPixel(x0-x, y0-y, WHITE);
|
||||
}
|
||||
if (-slope >= slope2s && -slope < slope2e) {
|
||||
if (-slope >= slopes[2] && -slope < slopes[3]) {
|
||||
lcdDrawPixel(x0-x, y0+y, WHITE);
|
||||
}
|
||||
}
|
||||
@@ -1001,56 +1012,26 @@ void lcdDrawBitmapPie(int x0, int y0, const uint16_t * img, int startAngle, int
|
||||
coord_t width = *q++;
|
||||
coord_t height = *q++;
|
||||
|
||||
int slope1s, slope1e, slope2s, slope2e;
|
||||
|
||||
if (startAngle >= 360 || endAngle <= 0)
|
||||
int slopes[4];
|
||||
if (!evalSlopes(slopes, startAngle, endAngle))
|
||||
return;
|
||||
|
||||
float angle1 = float(startAngle) * PI / 180;
|
||||
float angle2 = float(endAngle) * PI / 180;
|
||||
|
||||
if (startAngle == 0) {
|
||||
slope1e = 100000;
|
||||
slope2s = -100000;
|
||||
}
|
||||
else if (startAngle >= 180) {
|
||||
slope1e = -100000;
|
||||
slope2s = cos(angle1)*100/sin(angle1);
|
||||
}
|
||||
else {
|
||||
slope1e = cos(angle1)*100/sin(angle1);
|
||||
slope2s = -100000;
|
||||
}
|
||||
|
||||
if (endAngle == 360) {
|
||||
slope1s = -100000;
|
||||
slope2e = 100000;
|
||||
}
|
||||
else if (endAngle >= 180) {
|
||||
slope1s = -100000;
|
||||
slope2e = -cos(angle2)*100/sin(angle2);
|
||||
}
|
||||
else {
|
||||
slope1s = cos(angle2)*100/sin(angle2);
|
||||
slope2e = -100000;
|
||||
}
|
||||
|
||||
int w2 = width/2;
|
||||
int h2 = height/2;
|
||||
|
||||
for (int y=h2-1; y>=0; y--) {
|
||||
for (int x=w2-1; x>=0; x--) {
|
||||
int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x);
|
||||
if (slope >= slope1s && slope < slope1e) {
|
||||
if (slope >= slopes[0] && slope < slopes[1]) {
|
||||
displayBuf[(y0+h2-y)*LCD_W + x0+w2+x] = q[(h2-y)*width + w2+x];
|
||||
}
|
||||
if (-slope >= slope1s && -slope < slope1e) {
|
||||
if (-slope >= slopes[0] && -slope < slopes[1]) {
|
||||
displayBuf[(y0+h2+y)*LCD_W + x0+w2+x] = q[(h2+y)*width + w2+x];
|
||||
}
|
||||
if (slope >= slope2s && slope < slope2e) {
|
||||
if (slope >= slopes[2] && slope < slopes[3]) {
|
||||
displayBuf[(y0+h2-y)*LCD_W + x0+w2-x] = q[(h2-y)*width + w2-x];
|
||||
}
|
||||
if (-slope >= slope2s && -slope < slope2e) {
|
||||
if (-slope >= slopes[2] && -slope < slopes[3]) {
|
||||
displayBuf[(y0+h2+y)*LCD_W + x0+w2-x] = q[(h2+y)*width + w2-x];
|
||||
}
|
||||
}
|
||||
@@ -1063,58 +1044,28 @@ void lcdDrawBitmapPatternPie(coord_t x0, coord_t y0, const uint8_t * img, LcdFla
|
||||
coord_t height = *(((uint16_t *)img)+1);
|
||||
const uint8_t * q = img+4;
|
||||
|
||||
int slope1s, slope1e, slope2s, slope2e;
|
||||
|
||||
if (startAngle >= 360 || endAngle <= 0)
|
||||
int slopes[4];
|
||||
if (!evalSlopes(slopes, startAngle, endAngle))
|
||||
return;
|
||||
|
||||
display_t color = lcdColorTable[COLOR_IDX(flags)];
|
||||
|
||||
float angle1 = float(startAngle) * PI / 180;
|
||||
float angle2 = float(endAngle) * PI / 180;
|
||||
|
||||
if (startAngle == 0) {
|
||||
slope1e = 100000;
|
||||
slope2s = -100000;
|
||||
}
|
||||
else if (startAngle >= 180) {
|
||||
slope1e = -100000;
|
||||
slope2s = cos(angle1)*100/sin(angle1);
|
||||
}
|
||||
else {
|
||||
slope1e = cos(angle1)*100/sin(angle1);
|
||||
slope2s = -100000;
|
||||
}
|
||||
|
||||
if (endAngle == 360) {
|
||||
slope1s = -100000;
|
||||
slope2e = 100000;
|
||||
}
|
||||
else if (endAngle >= 180) {
|
||||
slope1s = -100000;
|
||||
slope2e = -cos(angle2)*100/sin(angle2);
|
||||
}
|
||||
else {
|
||||
slope1s = cos(angle2)*100/sin(angle2);
|
||||
slope2e = -100000;
|
||||
}
|
||||
|
||||
int w2 = width/2;
|
||||
int h2 = height/2;
|
||||
|
||||
for (int y=h2-1; y>=0; y--) {
|
||||
for (int x=w2-1; x>=0; x--) {
|
||||
int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x);
|
||||
if (slope >= slope1s && slope < slope1e) {
|
||||
if (slope >= slopes[0] && slope < slopes[1]) {
|
||||
lcdDrawTransparentPixel(x0+w2+x, y0+h2-y, q[(h2-y)*width + w2+x], color);
|
||||
}
|
||||
if (-slope >= slope1s && -slope < slope1e) {
|
||||
if (-slope >= slopes[0] && -slope < slopes[1]) {
|
||||
lcdDrawTransparentPixel(x0+w2+x, y0+h2+y, q[(h2+y)*width + w2+x], color);
|
||||
}
|
||||
if (slope >= slope2s && slope < slope2e) {
|
||||
if (slope >= slopes[2] && slope < slopes[3]) {
|
||||
lcdDrawTransparentPixel(x0+w2-x, y0+h2-y, q[(h2-y)*width + w2-x], color);
|
||||
}
|
||||
if (-slope >= slope2s && -slope < slope2e) {
|
||||
if (-slope >= slopes[2] && -slope < slopes[3]) {
|
||||
lcdDrawTransparentPixel(x0+w2-x, y0+h2+y, q[(h2+y)*width + w2-x], color);
|
||||
}
|
||||
}
|
||||
|
||||
+21
-19
@@ -123,6 +123,7 @@ enum LcdColorIndex
|
||||
SCROLLBOX_COLOR_INDEX,
|
||||
MENU_TITLE_BGCOLOR_INDEX,
|
||||
MENU_TITLE_COLOR_INDEX,
|
||||
MENU_TITLE_DISABLE_COLOR_INDEX,
|
||||
HEADER_COLOR_INDEX,
|
||||
ALARM_COLOR_INDEX,
|
||||
WARNING_COLOR_INDEX,
|
||||
@@ -141,25 +142,26 @@ void lcdColorsInit();
|
||||
#define OPACITY_MAX 0x0F
|
||||
#define OPACITY(x) ((x)<<24)
|
||||
|
||||
#define COLOR(index) ((index) << 16)
|
||||
#define TEXT_COLOR COLOR(TEXT_COLOR_INDEX)
|
||||
#define TEXT_BGCOLOR COLOR(TEXT_BGCOLOR_INDEX)
|
||||
#define TEXT_INVERTED_COLOR COLOR(TEXT_INVERTED_COLOR_INDEX)
|
||||
#define TEXT_INVERTED_BGCOLOR COLOR(TEXT_INVERTED_BGCOLOR_INDEX)
|
||||
#define LINE_COLOR COLOR(LINE_COLOR_INDEX)
|
||||
#define SCROLLBOX_COLOR COLOR(SCROLLBOX_COLOR_INDEX)
|
||||
#define HEADER_SEPARATOR_COLOR COLOR(HEADER_SEPARATOR_COLOR_INDEX)
|
||||
#define MENU_TITLE_BGCOLOR COLOR(MENU_TITLE_BGCOLOR_INDEX)
|
||||
#define MENU_TITLE_COLOR COLOR(MENU_TITLE_COLOR_INDEX)
|
||||
#define HEADER_COLOR COLOR(HEADER_COLOR_INDEX)
|
||||
#define ALARM_COLOR COLOR(ALARM_COLOR_INDEX)
|
||||
#define WARNING_COLOR COLOR(WARNING_COLOR_INDEX)
|
||||
#define TEXT_DISABLE_COLOR COLOR(TEXT_DISABLE_COLOR_INDEX)
|
||||
#define CURVE_AXIS_COLOR COLOR(CURVE_AXIS_COLOR_INDEX)
|
||||
#define CURVE_COLOR COLOR(CURVE_COLOR_INDEX)
|
||||
#define CURVE_CURSOR_COLOR COLOR(CURVE_CURSOR_COLOR_INDEX)
|
||||
#define TITLE_BGCOLOR COLOR(TITLE_BGCOLOR_INDEX)
|
||||
#define HEADER_BGCOLOR COLOR(HEADER_BGCOLOR_INDEX)
|
||||
#define COLOR(index) ((index) << 16)
|
||||
#define TEXT_COLOR COLOR(TEXT_COLOR_INDEX)
|
||||
#define TEXT_BGCOLOR COLOR(TEXT_BGCOLOR_INDEX)
|
||||
#define TEXT_INVERTED_COLOR COLOR(TEXT_INVERTED_COLOR_INDEX)
|
||||
#define TEXT_INVERTED_BGCOLOR COLOR(TEXT_INVERTED_BGCOLOR_INDEX)
|
||||
#define LINE_COLOR COLOR(LINE_COLOR_INDEX)
|
||||
#define SCROLLBOX_COLOR COLOR(SCROLLBOX_COLOR_INDEX)
|
||||
#define HEADER_SEPARATOR_COLOR COLOR(HEADER_SEPARATOR_COLOR_INDEX)
|
||||
#define MENU_TITLE_BGCOLOR COLOR(MENU_TITLE_BGCOLOR_INDEX)
|
||||
#define MENU_TITLE_COLOR COLOR(MENU_TITLE_COLOR_INDEX)
|
||||
#define MENU_TITLE_DISABLE_COLOR COLOR(MENU_TITLE_DISABLE_COLOR_INDEX)
|
||||
#define HEADER_COLOR COLOR(HEADER_COLOR_INDEX)
|
||||
#define ALARM_COLOR COLOR(ALARM_COLOR_INDEX)
|
||||
#define WARNING_COLOR COLOR(WARNING_COLOR_INDEX)
|
||||
#define TEXT_DISABLE_COLOR COLOR(TEXT_DISABLE_COLOR_INDEX)
|
||||
#define CURVE_AXIS_COLOR COLOR(CURVE_AXIS_COLOR_INDEX)
|
||||
#define CURVE_COLOR COLOR(CURVE_COLOR_INDEX)
|
||||
#define CURVE_CURSOR_COLOR COLOR(CURVE_CURSOR_COLOR_INDEX)
|
||||
#define TITLE_BGCOLOR COLOR(TITLE_BGCOLOR_INDEX)
|
||||
#define HEADER_BGCOLOR COLOR(HEADER_BGCOLOR_INDEX)
|
||||
|
||||
#define COLOR_IDX(att) uint8_t((att) >> 16)
|
||||
|
||||
|
||||
@@ -39,6 +39,36 @@
|
||||
#define XPOT_DELTA 10
|
||||
#define XPOT_DELAY 10 /* cycles */
|
||||
|
||||
#define BAR_HEIGHT (BOX_WIDTH-9)
|
||||
#define LBOX_CENTERX (BOX_WIDTH/2 + 17)
|
||||
#define RBOX_CENTERX (LCD_W-LBOX_CENTERX)
|
||||
|
||||
void drawPotsBars()
|
||||
{
|
||||
// Optimization by Mike Blandford
|
||||
uint8_t x, i, len ; // declare temporary variables
|
||||
for (x=LCD_W/2-9, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS; x+=9, i++) {
|
||||
if (IS_POT_AVAILABLE(i)) {
|
||||
len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
// TODO 220 constant
|
||||
lcdDrawSolidFilledRect(x, 220-FH-len, 5, len, TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawSticksPositions()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
||||
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
}
|
||||
|
||||
void menuCommonCalib(evt_t event)
|
||||
{
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS; i++) { // get low and high vals for sticks and trims
|
||||
@@ -172,7 +202,7 @@ void menuCommonCalib(evt_t event)
|
||||
break;
|
||||
}
|
||||
|
||||
doMainScreenGraphics();
|
||||
drawSticksPositions();
|
||||
drawPotsBars();
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -72,7 +72,6 @@ typedef void (*MenuFuncP)(evt_t event);
|
||||
typedef void (*MenuFuncP_PROGMEM)(evt_t event);
|
||||
extern const MenuFuncP_PROGMEM menuTabModel[];
|
||||
extern const MenuFuncP_PROGMEM menuTabGeneral[];
|
||||
extern const MenuFuncP_PROGMEM menuTabTelemetry[];
|
||||
|
||||
extern MenuFuncP g_menuStack[5];
|
||||
extern uint8_t g_menuPos[4];
|
||||
@@ -85,14 +84,7 @@ void chainMenu(MenuFuncP newMenu);
|
||||
void pushMenu(MenuFuncP newMenu);
|
||||
/// return to last menu in menustack
|
||||
void popMenu();
|
||||
///deliver address of last menu which was popped from
|
||||
inline MenuFuncP lastPopMenu()
|
||||
{
|
||||
return g_menuStack[g_menuStackPtr+1];
|
||||
}
|
||||
|
||||
void drawPotsBars();
|
||||
void doMainScreenGraphics();
|
||||
void menuFirstCalib(evt_t event);
|
||||
|
||||
void onMainViewMenu(const char *result);
|
||||
@@ -141,7 +133,6 @@ extern int8_t s_editMode; // global editmode
|
||||
#define TITLE_ROW ((uint8_t)-1)
|
||||
#define HIDDEN_ROW ((uint8_t)-2)
|
||||
|
||||
typedef bool (*IsValueAvailable)(int);
|
||||
struct CheckIncDecStops {
|
||||
const int count;
|
||||
const int stops[];
|
||||
@@ -345,9 +336,9 @@ void menuChannelsView(evt_t event);
|
||||
#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; }
|
||||
#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE()
|
||||
|
||||
#define POS_VERT_INIT (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0)
|
||||
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
|
||||
#define EDIT_MODE_INIT 0 // TODO enum
|
||||
#define MENU_FIRST_LINE_EDIT (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0)
|
||||
#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0)
|
||||
#define EDIT_MODE_INIT 0 // TODO enum
|
||||
|
||||
typedef int (*FnFuncP) (int x);
|
||||
void DrawFunction(FnFuncP fn, int offset=0);
|
||||
|
||||
@@ -243,7 +243,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
if (rowcount > 0) {
|
||||
l_posVert = POS_VERT_INIT;
|
||||
l_posVert = MENU_FIRST_LINE_EDIT;
|
||||
event = 0;
|
||||
}
|
||||
break;
|
||||
@@ -347,7 +347,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
case EVT_KEY_REPT(KEY_DOWN):
|
||||
do {
|
||||
INC(l_posVert, POS_VERT_INIT, rowcount-1);
|
||||
INC(l_posVert, MENU_FIRST_LINE_EDIT, rowcount-1);
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
s_editMode = 0; // if we go down, we must be in this mode
|
||||
l_posHorz = POS_HORZ_INIT(l_posVert);
|
||||
@@ -376,7 +376,7 @@ bool check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
case EVT_KEY_REPT(KEY_UP):
|
||||
do {
|
||||
DEC(l_posVert, POS_VERT_INIT, rowcount-1);
|
||||
DEC(l_posVert, MENU_FIRST_LINE_EDIT, rowcount-1);
|
||||
} while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert));
|
||||
|
||||
s_editMode = 0; // if we go up, we must be in this mode
|
||||
|
||||
@@ -36,13 +36,6 @@
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
#define BIGSIZE MIDSIZE
|
||||
#define BAR_HEIGHT (BOX_WIDTH-9)
|
||||
#define LBOX_CENTERX (BOX_WIDTH/2 + 17)
|
||||
#define RBOX_CENTERX (LCD_W-LBOX_CENTERX)
|
||||
#define BITMAP_X ((LCD_W-64)/2)
|
||||
#define BITMAP_Y (LCD_H/2)
|
||||
|
||||
#define TRIM_LH_X 90
|
||||
#define TRIM_LV_X 24
|
||||
#define TRIM_RV_X (LCD_W-35)
|
||||
@@ -51,32 +44,6 @@
|
||||
#define TRIM_H_Y 235
|
||||
#define TRIM_LEN 80
|
||||
|
||||
void drawPotsBars()
|
||||
{
|
||||
// Optimization by Mike Blandford
|
||||
uint8_t x, i, len ; // declare temporary variables
|
||||
for (x=LCD_W/2-9, i=NUM_STICKS; i<NUM_STICKS+NUM_POTS; x+=9, i++) {
|
||||
if (IS_POT_AVAILABLE(i)) {
|
||||
len = ((calibratedStick[i]+RESX)*BAR_HEIGHT/(RESX*2))+1l; // calculate once per loop
|
||||
// TODO 220 constant
|
||||
lcdDrawSolidFilledRect(x, 220-FH-len, 5, len, TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void doMainScreenGraphics()
|
||||
{
|
||||
int16_t calibStickVert = calibratedStick[CONVERT_MODE(1)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(1) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(LBOX_CENTERX, calibratedStick[CONVERT_MODE(0)], calibStickVert);
|
||||
|
||||
calibStickVert = calibratedStick[CONVERT_MODE(2)];
|
||||
if (g_model.throttleReversed && CONVERT_MODE(2) == THR_STICK)
|
||||
calibStickVert = -calibStickVert;
|
||||
drawStick(RBOX_CENTERX, calibratedStick[CONVERT_MODE(3)], calibStickVert);
|
||||
}
|
||||
|
||||
void drawTrimSquare(coord_t x, coord_t y)
|
||||
{
|
||||
lcdDrawSolidFilledRect(x-2, y, 15, 15, TITLE_BGCOLOR);
|
||||
@@ -141,7 +108,7 @@ void drawSticks()
|
||||
drawHorizontalStick(TRIM_RH_X-TRIM_LEN+1, calibratedStick[3]);
|
||||
}
|
||||
|
||||
void displayTrims(uint8_t flightMode)
|
||||
void drawTrims(uint8_t flightMode)
|
||||
{
|
||||
g_model.displayTrims = DISPLAY_TRIMS_ALWAYS;
|
||||
|
||||
@@ -191,33 +158,22 @@ void displayTrims(uint8_t flightMode)
|
||||
}
|
||||
}
|
||||
|
||||
void displayTimers()
|
||||
void drawTimer(coord_t x, coord_t y, int index)
|
||||
{
|
||||
// const int TIMERS_W = 56;
|
||||
const int TIMERS_H = 30;
|
||||
const int TIMERS_MARGIN = 16;
|
||||
const int TIMERS_PADDING = 4;
|
||||
|
||||
for (int i=0; i<TIMERS; i++) {
|
||||
if (g_model.timers[i].mode) {
|
||||
TimerState & timerState = timersStates[i];
|
||||
TimerData & timerData = g_model.timers[i];
|
||||
int y = TIMERS_MARGIN + i*(TIMERS_H+TIMERS_MARGIN);
|
||||
unsigned int len = zlen(timerData.name, LEN_TIMER_NAME);
|
||||
LcdFlags color=TEXT_COLOR, bgColor=TEXT_BGCOLOR;
|
||||
if (timerState.val < 0) {
|
||||
color = ALARM_COLOR;
|
||||
}
|
||||
// TODO lcdDrawSolidFilledRect(TIMERS_MARGIN, y, TIMERS_W, TIMERS_H, SOLID, bgColor);
|
||||
putsTimer(TIMERS_MARGIN+TIMERS_PADDING, y+12, abs(timerState.val), color|DBLSIZE|LEFT);
|
||||
if (len > 0)
|
||||
lcd_putsnAtt(TIMERS_MARGIN+TIMERS_PADDING, y+2, timerData.name, LEN_TIMER_NAME, color|ZCHAR);
|
||||
else
|
||||
putsTimerMode(TIMERS_MARGIN+TIMERS_PADDING, y+2, timerData.mode, color);
|
||||
}
|
||||
TimerData & timerData = g_model.timers[index];
|
||||
TimerState & timerState = timersStates[index];
|
||||
lcdDrawBitmapPattern(x, y, LBM_TIMER_BACKGROUND, TEXT_BGCOLOR);
|
||||
if (timerData.start) {
|
||||
lcdDrawBitmapPatternPie(x+2, y+3, LBM_RSCALE, TITLE_BGCOLOR, 0, timerState.val <= 0 ? 360 : 360*(timerData.start-timerState.val)/timerData.start);
|
||||
}
|
||||
putsTimer(x+74, y+31, abs(timerState.val), TEXT_COLOR|DBLSIZE|LEFT);
|
||||
if (ZLEN(timerData.name) > 0) {
|
||||
lcd_putsnAtt(x+74, y+20, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE|TEXT_COLOR);
|
||||
}
|
||||
putsStrIdx(x+137, y+17, "TMR", 1, SMLSIZE|TEXT_COLOR);
|
||||
}
|
||||
|
||||
|
||||
void displayMainTelemetryFields()
|
||||
{
|
||||
const int ALTITUDE_Y = 16;
|
||||
@@ -329,12 +285,6 @@ void onMainViewMenu(const char *result)
|
||||
#endif
|
||||
}
|
||||
|
||||
void displayTelemetryScreen(int index, unsigned int evt);
|
||||
|
||||
const uint16_t LBM_MAINVIEW_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/background.lbm"
|
||||
};
|
||||
|
||||
const uint16_t LBM_MAINVIEW_FLAT[] = {
|
||||
#include "../../bitmaps/Horus/mainview_flat.lbm"
|
||||
};
|
||||
@@ -343,13 +293,6 @@ const uint16_t LBM_CORSAIR[] = {
|
||||
#include "../../bitmaps/Horus/corsair.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_TIMER_BACKGROUND[] = {
|
||||
#include "../../bitmaps/Horus/mask_timer_bg.lbm"
|
||||
};
|
||||
|
||||
const uint8_t LBM_RSCALE[] = {
|
||||
#include "../../bitmaps/Horus/mask_rscale.lbm"
|
||||
};
|
||||
|
||||
void menuMainView(evt_t event)
|
||||
{
|
||||
@@ -412,6 +355,16 @@ void menuMainView(evt_t event)
|
||||
lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR);
|
||||
lcdDrawBitmapPattern(4, 10, LBM_TOPMENU_OPENTX, MENU_TITLE_COLOR);
|
||||
lcdDrawTopmenuDatetime();
|
||||
if (1 || usbPlugged()) {
|
||||
lcdDrawBitmapPattern(378, 8, LBM_TOPMENU_USB, MENU_TITLE_COLOR);
|
||||
}
|
||||
const uint8_t rssiBarsValue[] = { 30, 40, 50, 60, 80 };
|
||||
const uint8_t rssiBarsHeight[] = { 5, 10, 15, 21, 31 };
|
||||
for (unsigned int i=0; i<DIM(rssiBarsHeight); i++) {
|
||||
uint8_t height = rssiBarsHeight[i];
|
||||
lcdDrawSolidFilledRect(390+i*6, 38-height, 4, height, TELEMETRY_RSSI() >= rssiBarsValue[i] ? MENU_TITLE_COLOR : MENU_TITLE_DISABLE_COLOR);
|
||||
}
|
||||
|
||||
|
||||
// Flight Mode Name
|
||||
int mode = mixerCurrentFlightMode;
|
||||
@@ -426,38 +379,20 @@ void menuMainView(evt_t event)
|
||||
drawSticks();
|
||||
|
||||
// Trims
|
||||
displayTrims(mode);
|
||||
drawTrims(mode);
|
||||
|
||||
// Model panel
|
||||
lcdDrawFilledRect(248, 58, 188, 158, SOLID, TEXT_BGCOLOR | OPACITY(5));
|
||||
lcdDrawBitmapPattern(256, 62, LBM_MODEL_ICON, TITLE_BGCOLOR);
|
||||
lcd_putsnAtt(293, 68, g_model.header.name, ZCHAR|SMLSIZE, LEN_MODEL_NAME);
|
||||
lcd_putsnAtt(293, 68, g_model.header.name, LEN_MODEL_NAME, ZCHAR|SMLSIZE);
|
||||
lcdDrawSolidHorizontalLine(287, 85, 140, TITLE_BGCOLOR);
|
||||
lcdDrawBitmap(256, 104, LBM_CORSAIR);
|
||||
|
||||
// Timer 1
|
||||
if (g_model.timers[0].start) {
|
||||
TimerState & timerState = timersStates[0];
|
||||
lcdDrawBitmapPattern(58, 61, LBM_TIMER_BACKGROUND, TEXT_BGCOLOR);
|
||||
lcdDrawBitmapPatternPie(60, 64, LBM_RSCALE, TITLE_BGCOLOR, 0, 360*timerState.val/g_model.timers[0].start);
|
||||
putsTimer(125, 94, abs(timerState.val), TEXT_COLOR|DBLSIZE|LEFT);
|
||||
if (g_model.timers[0].mode) {
|
||||
drawTimer(50, 61, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
displayMainViewIndex();
|
||||
|
||||
if (g_eeGeneral.view == VIEW_TIMERS_ALTITUDE) {
|
||||
displayTimers();
|
||||
displayMainTelemetryFields();
|
||||
}
|
||||
else if (g_eeGeneral.view == VIEW_CHANNELS) {
|
||||
menuChannelsView(event);
|
||||
}
|
||||
else {
|
||||
displayTelemetryScreen(g_eeGeneral.view - VIEW_TELEM1, event);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (s_gvar_timer > 0) {
|
||||
s_gvar_timer--;
|
||||
|
||||
Reference in New Issue
Block a user