Add cursor to custom curves Refactor functions declaration Cosmetics
This commit is contained in:
@@ -94,3 +94,36 @@ void drawCurvePoint(int x, int y, LcdFlags color)
|
||||
lcdDrawBitmapPattern(x, y, LBM_CURVE_POINT, color);
|
||||
lcdDrawBitmapPattern(x, y, LBM_CURVE_POINT_CENTER, TEXT_BGCOLOR);
|
||||
}
|
||||
|
||||
void drawCursor(FnFuncP fn)
|
||||
{
|
||||
char textx[5];
|
||||
char texty[5];
|
||||
int x = getValue(s_currSrcRaw);
|
||||
if (s_currSrcRaw >= MIXSRC_FIRST_TELEM) {
|
||||
strAppendUnsigned(textx, calcRESXto100(x));
|
||||
// TODO drawSensorCustomValue(LCD_W-8, 6*FH, ed->srcRaw - MIXSRC_FIRST_TELEM, x);
|
||||
if (s_currScale > 0)
|
||||
x = (x * 1024) / convertTelemValue(s_currSrcRaw - MIXSRC_FIRST_TELEM + 1, s_currScale);
|
||||
}
|
||||
else {
|
||||
strAppendSigned(textx, calcRESXto100(x));
|
||||
}
|
||||
|
||||
x = limit(-1024, x, 1024);
|
||||
int y = limit<int>(-1024, applyCurrentCurve(x), 1024);
|
||||
strAppendSigned(texty, calcRESXto100(y));
|
||||
|
||||
x = divRoundClosest(x * CURVE_SIDE_WIDTH, RESX);
|
||||
y = CURVE_CENTER_Y + getCurveYCoord(applyCurrentCurve, 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);
|
||||
lcdDrawBitmapPattern(CURVE_CENTER_X + x - 4, y - 4, LBM_CURVE_POINT, CURVE_CURSOR_COLOR);
|
||||
lcdDrawBitmapPattern(CURVE_CENTER_X + x - 4, y - 4, LBM_CURVE_POINT_CENTER, TEXT_BGCOLOR);
|
||||
|
||||
int left = limit(CURVE_CENTER_X - CURVE_SIDE_WIDTH, CURVE_CENTER_X - CURVE_COORD_WIDTH / 2 + x, CURVE_CENTER_X + CURVE_SIDE_WIDTH - CURVE_COORD_WIDTH + 2);
|
||||
drawCurveCoord(left, CURVE_CENTER_Y + CURVE_SIDE_WIDTH + 2, textx);
|
||||
int top = limit(CURVE_CENTER_Y - CURVE_SIDE_WIDTH - 1, -CURVE_COORD_HEIGHT / 2 + y, CURVE_CENTER_Y + CURVE_SIDE_WIDTH - CURVE_COORD_HEIGHT + 1);
|
||||
drawCurveCoord(CURVE_CENTER_X-CURVE_SIDE_WIDTH - 37, top, texty);
|
||||
}
|
||||
|
||||
@@ -152,6 +152,8 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, ui
|
||||
|
||||
uint8_t s_currIdx;
|
||||
uint8_t s_currIdxSubMenu;
|
||||
uint16_t s_currSrcRaw;
|
||||
uint16_t s_currScale;
|
||||
|
||||
void copySelection(char * dst, const char * src, uint8_t size)
|
||||
{
|
||||
|
||||
@@ -460,6 +460,8 @@ extern int8_t s_copySrcRow;
|
||||
extern int8_t s_copyTgtOfs;
|
||||
extern uint8_t s_currIdx;
|
||||
extern uint8_t s_currIdxSubMenu;
|
||||
extern uint16_t s_currSrcRaw;
|
||||
extern uint16_t s_currScale;
|
||||
extern int8_t s_currCh;
|
||||
extern uint8_t s_copySrcIdx;
|
||||
extern uint8_t s_copySrcCh;
|
||||
@@ -626,6 +628,7 @@ void readModelNotes();
|
||||
|
||||
typedef int (*FnFuncP) (int x);
|
||||
void drawFunction(FnFuncP fn, int x, int y, int width);
|
||||
void drawCursor(FnFuncP fn);
|
||||
|
||||
void onSourceLongEnterPress(const char *result);
|
||||
|
||||
|
||||
@@ -203,6 +203,8 @@ bool menuModelCurveOne(event_t event)
|
||||
drawCurve(CURVE_CENTER_X, CURVE_CENTER_Y, CURVE_SIDE_WIDTH);
|
||||
drawCurveHorizontalScale();
|
||||
if (menuVerticalPosition < ITEM_CURVE_COORDS1) drawCurveVerticalScale(CURVE_CENTER_X-CURVE_SIDE_WIDTH-15);
|
||||
if (s_currSrcRaw != MIXSRC_NONE)
|
||||
drawCursor(applyCurrentCurve);
|
||||
|
||||
coord_t posX = 47;
|
||||
attr = (s_editMode > 0 ? INVERS|BLINK : INVERS);
|
||||
@@ -324,6 +326,7 @@ bool menuModelCurvesAll(event_t event)
|
||||
switch (event) {
|
||||
case EVT_KEY_BREAK(KEY_ENTER):
|
||||
if (!READ_ONLY()) {
|
||||
s_currSrcRaw = MIXSRC_NONE;
|
||||
pushMenu(menuModelCurveOne);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -185,38 +185,11 @@ bool menuModelExpoOne(event_t event)
|
||||
|
||||
drawFunction(expoFn, CURVE_CENTER_X, CURVE_CENTER_Y, CURVE_SIDE_WIDTH);
|
||||
drawCurveHorizontalScale();
|
||||
drawCurveVerticalScale(CURVE_CENTER_X-CURVE_SIDE_WIDTH-15);
|
||||
|
||||
{
|
||||
char textx[5];
|
||||
char texty[5];
|
||||
int x = getValue(ed->srcRaw);
|
||||
if (ed->srcRaw >= MIXSRC_FIRST_TELEM) {
|
||||
strAppendUnsigned(textx, calcRESXto100(x));
|
||||
// TODO drawSensorCustomValue(LCD_W-8, 6*FH, ed->srcRaw - MIXSRC_FIRST_TELEM, x);
|
||||
if (ed->scale > 0) x = (x * 1024) / convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale);
|
||||
}
|
||||
else {
|
||||
strAppendSigned(textx, calcRESXto100(x));
|
||||
}
|
||||
|
||||
x = limit(-1024, x, 1024);
|
||||
int y = limit<int>(-1024, expoFn(x), 1024);
|
||||
strAppendSigned(texty, calcRESXto100(y));
|
||||
|
||||
x = divRoundClosest(x*CURVE_SIDE_WIDTH, RESX);
|
||||
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);
|
||||
lcdDrawBitmapPattern(CURVE_CENTER_X+x-4, y-4, LBM_CURVE_POINT, CURVE_CURSOR_COLOR);
|
||||
lcdDrawBitmapPattern(CURVE_CENTER_X+x-4, y-4, LBM_CURVE_POINT_CENTER, TEXT_BGCOLOR);
|
||||
|
||||
int left = limit(CURVE_CENTER_X-CURVE_SIDE_WIDTH, CURVE_CENTER_X-CURVE_COORD_WIDTH/2+x, CURVE_CENTER_X+CURVE_SIDE_WIDTH-CURVE_COORD_WIDTH+2);
|
||||
drawCurveCoord(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+2, textx);
|
||||
int top = limit(CURVE_CENTER_Y-CURVE_SIDE_WIDTH-1, -CURVE_COORD_HEIGHT/2+y, CURVE_CENTER_Y+CURVE_SIDE_WIDTH-CURVE_COORD_HEIGHT+1);
|
||||
drawCurveCoord(CURVE_CENTER_X-CURVE_SIDE_WIDTH-37, top, texty);
|
||||
}
|
||||
drawCurveVerticalScale(CURVE_CENTER_X-CURVE_SIDE_WIDTH - 15);
|
||||
// those parameters are global so that they can be reused in the curve edit screen
|
||||
s_currSrcRaw = ed->srcRaw;
|
||||
s_currScale = ed->scale;
|
||||
drawCursor(expoFn);
|
||||
|
||||
for (uint8_t k=0; k<NUM_BODY_LINES+1; k++) {
|
||||
int i = k + menuVerticalOffset;
|
||||
|
||||
@@ -207,10 +207,12 @@ bool menuModelMixOne(event_t event)
|
||||
drawSource(MIXES_2ND_COLUMN, y, md2->srcRaw, attr);
|
||||
if (attr) CHECK_INCDEC_MODELSOURCE(event, md2->srcRaw, 1, MIXSRC_LAST);
|
||||
break;
|
||||
|
||||
case MIX_FIELD_WEIGHT:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_WEIGHT);
|
||||
gvarWeightItem(MIXES_2ND_COLUMN, y, md2, attr|LEFT, event);
|
||||
break;
|
||||
|
||||
case MIX_FIELD_OFFSET:
|
||||
{
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_OFFSET);
|
||||
@@ -230,6 +232,8 @@ bool menuModelMixOne(event_t event)
|
||||
break;
|
||||
case MIX_FIELD_CURVE:
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CURVE);
|
||||
s_currSrcRaw = md2->srcRaw;
|
||||
s_currScale = 0;
|
||||
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr);
|
||||
break;
|
||||
#if defined(FLIGHT_MODES)
|
||||
|
||||
Reference in New Issue
Block a user