[Horus] UI continued
This commit is contained in:
@@ -20,46 +20,45 @@
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
coord_t getCurveYCoord(FnFuncP fn, coord_t x)
|
||||
coord_t getCurveYCoord(FnFuncP fn, int x, int width)
|
||||
{
|
||||
return limit(CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_CENTER_Y - divRoundClosest(fn(divRoundClosest(x * RESX, CURVE_SIDE_WIDTH)) * CURVE_SIDE_WIDTH, RESX), CURVE_CENTER_Y+CURVE_SIDE_WIDTH);
|
||||
return limit(-width, -divRoundClosest(fn(divRoundClosest(x * RESX, width)) * width, RESX), +width);
|
||||
}
|
||||
|
||||
void drawFunction(FnFuncP fn, int offset)
|
||||
void drawFunction(FnFuncP fn, int x, int y, int width)
|
||||
{
|
||||
int left = CURVE_CENTER_X-offset-CURVE_SIDE_WIDTH;
|
||||
int right = CURVE_CENTER_X-offset+CURVE_SIDE_WIDTH;
|
||||
int center = CURVE_CENTER_X-offset;
|
||||
int left = x - width;
|
||||
int right = x + width;
|
||||
|
||||
// Axis
|
||||
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y, CURVE_SIDE_WIDTH*2+1, CURVE_AXIS_COLOR);
|
||||
lcdDrawSolidVerticalLine(center, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, CURVE_AXIS_COLOR);
|
||||
lcdDrawSolidHorizontalLine(left, y, width*2+1, CURVE_AXIS_COLOR);
|
||||
lcdDrawSolidVerticalLine(x, y-width, width*2, CURVE_AXIS_COLOR);
|
||||
|
||||
// Extra lines
|
||||
lcdDrawVerticalLine(left+CURVE_SIDE_WIDTH/2, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, STASHED, CURVE_AXIS_COLOR);
|
||||
lcdDrawVerticalLine(right-CURVE_SIDE_WIDTH/2, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, STASHED, CURVE_AXIS_COLOR);
|
||||
lcdDrawHorizontalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH/2, CURVE_SIDE_WIDTH*2+1, STASHED, CURVE_AXIS_COLOR);
|
||||
lcdDrawHorizontalLine(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH/2, CURVE_SIDE_WIDTH*2+1, STASHED, CURVE_AXIS_COLOR);
|
||||
lcdDrawVerticalLine(left+width/2, y-width, width*2, STASHED, CURVE_AXIS_COLOR);
|
||||
lcdDrawVerticalLine(right-width/2, y-width, width*2, STASHED, CURVE_AXIS_COLOR);
|
||||
lcdDrawHorizontalLine(left, y-width/2, width*2+1, STASHED, CURVE_AXIS_COLOR);
|
||||
lcdDrawHorizontalLine(left, y+width/2, width*2+1, STASHED, CURVE_AXIS_COLOR);
|
||||
|
||||
// Outside border
|
||||
lcdDrawSolidVerticalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, TEXT_COLOR);
|
||||
lcdDrawSolidVerticalLine(right, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, TEXT_COLOR);
|
||||
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2+1, TEXT_COLOR);
|
||||
lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2+1, TEXT_COLOR);
|
||||
lcdDrawSolidVerticalLine(left, y-width, width*2, TEXT_COLOR);
|
||||
lcdDrawSolidVerticalLine(right, y-width, width*2, TEXT_COLOR);
|
||||
lcdDrawSolidHorizontalLine(left, y-width, width*2+1, TEXT_COLOR);
|
||||
lcdDrawSolidHorizontalLine(left, y+width, width*2+1, TEXT_COLOR);
|
||||
|
||||
coord_t prev_yv = (coord_t)-1;
|
||||
|
||||
for (int xv=-CURVE_SIDE_WIDTH; xv<=CURVE_SIDE_WIDTH; xv+=1) {
|
||||
coord_t yv = getCurveYCoord(fn, xv);
|
||||
for (int xv=-width; xv<=width; xv+=1) {
|
||||
coord_t yv = y + getCurveYCoord(fn, xv, width);
|
||||
if (prev_yv != (coord_t)-1) {
|
||||
if (prev_yv < yv) {
|
||||
for (int y=prev_yv; y<=yv; y+=1) {
|
||||
lcdDrawBitmapPattern(CURVE_CENTER_X+xv-offset-2, y-2, LBM_POINT, TEXT_COLOR);
|
||||
lcdDrawBitmapPattern(x+xv-2, y-2, LBM_POINT, TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int y=yv; y<=prev_yv; y+=1) {
|
||||
lcdDrawBitmapPattern(CURVE_CENTER_X+xv-offset-2, y-2, LBM_POINT, TEXT_COLOR);
|
||||
lcdDrawBitmapPattern(x+xv-2, y-2, LBM_POINT, TEXT_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void drawStick(coord_t centrex, int16_t xval, int16_t yval);
|
||||
void drawSticks();
|
||||
|
||||
// Curve functions
|
||||
coord_t getCurveYCoord(FnFuncP fn, coord_t x);
|
||||
coord_t getCurveYCoord(FnFuncP fn, int x, int width);
|
||||
void drawFunction(FnFuncP fn, int offset);
|
||||
void drawCurveVerticalScale(int x);
|
||||
void drawCurveHorizontalScale();
|
||||
|
||||
@@ -49,9 +49,9 @@ point_t getPoint(uint8_t i)
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawCurve(int offset=0)
|
||||
void drawCurve(int x, int y, int width)
|
||||
{
|
||||
drawFunction(curveFn, offset);
|
||||
drawFunction(curveFn, x, y, width);
|
||||
|
||||
/*int i = 0;
|
||||
do {
|
||||
@@ -209,7 +209,7 @@ bool menuModelCurveOne(evt_t event)
|
||||
killEvents(event);
|
||||
}
|
||||
|
||||
DrawCurve();
|
||||
drawCurve(CURVE_CENTER_X, CURVE_CENTER_Y, CURVE_SIDE_WIDTH);
|
||||
drawCurveHorizontalScale();
|
||||
if (menuVerticalPosition < ITEM_CURVE_COORDS1) drawCurveVerticalScale(CURVE_CENTER_X-CURVE_SIDE_WIDTH-15);
|
||||
|
||||
@@ -351,13 +351,13 @@ bool menuModelCurvesAll(evt_t event)
|
||||
putsStrIdx(MENUS_MARGIN_LEFT, y, STR_CV, k+1, attr);
|
||||
editName(50, y, g_model.curveNames[k], sizeof(g_model.curveNames[k]), 0, 0);
|
||||
CurveInfo & crv = g_model.curves[k];
|
||||
lcdDrawNumber(100, y, 5+crv.points, LEFT, 0, NULL, STR_PTS);
|
||||
lcdDrawNumber(120, y, 5+crv.points, LEFT, 0, NULL, STR_PTS);
|
||||
}
|
||||
}
|
||||
|
||||
if (sub >= 0) {
|
||||
s_curveChan = sub;
|
||||
DrawCurve(23);
|
||||
drawCurve(CURVE_CENTER_X, CURVE_CENTER_Y+10, 80);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -296,8 +296,7 @@ bool menuModelExpoOne(evt_t event)
|
||||
|
||||
coord_t y = MENU_CONTENT_TOP;
|
||||
|
||||
drawFunction(expoFn);
|
||||
|
||||
drawFunction(expoFn, CURVE_CENTER_X, CURVE_CENTER_Y, CURVE_SIDE_WIDTH);
|
||||
drawCurveHorizontalScale();
|
||||
drawCurveVerticalScale(CURVE_CENTER_X-CURVE_SIDE_WIDTH-15);
|
||||
|
||||
@@ -319,7 +318,7 @@ bool menuModelExpoOne(evt_t event)
|
||||
sprintf(texty, "%d", calcRESXto100(y));
|
||||
|
||||
x = divRoundClosest(x*CURVE_SIDE_WIDTH, RESX);
|
||||
y = getCurveYCoord(expoFn, x);
|
||||
y = CURVE_CENTER_Y + getCurveYCoord(expoFn, x, CURVE_SIDE_WIDTH);
|
||||
|
||||
lcdDrawSolidFilledRect(CURVE_CENTER_X+x, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, 2, 2*CURVE_SIDE_WIDTH+2, CURVE_CURSOR_COLOR);
|
||||
lcdDrawSolidFilledRect(CURVE_CENTER_X-CURVE_SIDE_WIDTH-2, y-1, 2*CURVE_SIDE_WIDTH+2, 2, CURVE_CURSOR_COLOR);
|
||||
|
||||
@@ -49,7 +49,6 @@ enum LimitsItems {
|
||||
ITEM_LIMITS_MAXROW = ITEM_LIMITS_COUNT-1
|
||||
};
|
||||
|
||||
#if defined(PPM_CENTER_ADJUSTABLE)
|
||||
#define LIMITS_NAME_POS 52
|
||||
#define LIMITS_OFFSET_POS 160
|
||||
#define LIMITS_MIN_POS 220
|
||||
@@ -59,16 +58,6 @@ enum LimitsItems {
|
||||
#define LIMITS_CURVE_POS 350
|
||||
#define LIMITS_PPM_CENTER_POS 440
|
||||
#define LIMITS_SYMETRICAL_POS 450
|
||||
#else
|
||||
#define LIMITS_NAME_POS 44
|
||||
#define LIMITS_OFFSET_POS 136
|
||||
#define LIMITS_MIN_POS 178
|
||||
#define LIMITS_DIRECTION_POS 181
|
||||
#define LIMITS_MAX_POS 218
|
||||
#define LIMITS_REVERT_POS 228
|
||||
#define LIMITS_CURVE_POS 258
|
||||
#define LIMITS_SYMETRICAL_POS 294
|
||||
#endif
|
||||
|
||||
#define LIMITS_MIN_MAX_OFFSET 1000
|
||||
#define CONVERT_US_MIN_MAX(x) (((x)*1280)/250)
|
||||
@@ -222,11 +211,7 @@ bool menuModelLimits(evt_t event)
|
||||
case ITEM_LIMITS_DIRECTION:
|
||||
{
|
||||
uint8_t revert = ld->revert;
|
||||
#if defined(PPM_CENTER_ADJUSTABLE)
|
||||
lcdDrawText(LIMITS_REVERT_POS, y, revert ? "\177" : "\176", attr);
|
||||
#else
|
||||
lcdDrawTextAtIndex(LIMITS_REVERT_POS, y, STR_MMMINV, revert, attr);
|
||||
#endif
|
||||
if (active) {
|
||||
uint8_t revert_new = checkIncDecModel(event, revert, 0, 1);
|
||||
if (checkIncDec_Ret && isThrottleOutput(k)) {
|
||||
|
||||
@@ -400,7 +400,7 @@ void pushModelNotes();
|
||||
#define EDIT_MODE_INIT 0 // TODO enum
|
||||
|
||||
typedef int (*FnFuncP) (int x);
|
||||
void drawFunction(FnFuncP fn, int offset=0);
|
||||
void drawFunction(FnFuncP fn, int x, int y, int width);
|
||||
|
||||
uint8_t switchToMix(uint8_t source);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user