Add cursor to custom curves - Closes #6399 (#7707)

Add cursor to custom curves
Refactor functions declaration
Cosmetics
This commit is contained in:
DanielGeA
2020-09-22 17:49:15 +02:00
committed by GitHub
parent b4d8504577
commit 869f8127ec
20 changed files with 137 additions and 981 deletions
+2 -3
View File
@@ -247,6 +247,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 uint8_t s_maxLines;
extern uint8_t s_copySrcIdx;
extern uint8_t s_copySrcCh;
@@ -284,9 +286,6 @@ void menuChannelsView(event_t event);
#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, uint8_t offset=0);
void onSourceLongEnterPress(const char *result);
uint8_t switchToMix(uint8_t source);
+2
View File
@@ -68,3 +68,5 @@ void editSingleName(coord_t x, coord_t y, const char * label, char *name, uint8_
uint8_t s_currIdx;
uint8_t s_currIdxSubMenu;
uint16_t s_currSrcRaw;
uint16_t s_currScale;
@@ -180,6 +180,8 @@ void menuModelCurveOne(event_t event)
}
drawCurve(FW);
if (s_currSrcRaw != MIXSRC_NONE)
drawCursor(applyCurrentCurve, FW);
uint8_t posY = FH+1;
attr = (s_editMode > 0 ? INVERS|BLINK : INVERS);
+4 -41
View File
@@ -30,28 +30,6 @@ int expoFn(int x)
return anas[ed->chn];
}
void drawFunction(FnFuncP fn, uint8_t offset)
{
lcdDrawVerticalLine(CURVE_CENTER_X-offset, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, 0xee);
lcdDrawHorizontalLine(CURVE_CENTER_X-CURVE_SIDE_WIDTH-offset, CURVE_CENTER_Y, CURVE_SIDE_WIDTH*2, 0xee);
coord_t prev_yv = (coord_t)-1;
for (int xv=-CURVE_SIDE_WIDTH; xv<=CURVE_SIDE_WIDTH; xv++) {
coord_t yv = (LCD_H-1) - (((uint16_t)RESX + fn(xv * (RESX/CURVE_SIDE_WIDTH))) / 2 * (LCD_H-1) / RESX);
if (prev_yv != (coord_t)-1) {
if (abs((int8_t)yv-prev_yv) <= 1) {
lcdDrawPoint(CURVE_CENTER_X+xv-offset-1, prev_yv, FORCE);
}
else {
uint8_t tmp = (prev_yv < yv ? 0 : 1);
lcdDrawSolidVerticalLine(CURVE_CENTER_X+xv-offset-1, yv+tmp, prev_yv-yv);
}
}
prev_yv = yv;
}
}
enum ExposFields {
EXPO_FIELD_INPUT_NAME,
EXPO_FIELD_LINE_NAME,
@@ -168,23 +146,8 @@ void menuModelExpoOne(event_t event)
}
drawFunction(expoFn);
int x512 = getValue(ed->srcRaw);
if (ed->srcRaw >= MIXSRC_FIRST_TELEM) {
drawSensorCustomValue(LCD_W-8, 6*FH, (ed->srcRaw - MIXSRC_FIRST_TELEM) / 3, x512, 0);
if (ed->scale > 0) x512 = (x512 * 1024) / convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale);
}
else {
lcdDrawNumber(LCD_W-8, 6*FH, calcRESXto1000(x512), RIGHT | PREC1);
}
x512 = limit(-1024, x512, 1024);
int y512 = expoFn(x512);
y512 = limit(-1024, y512, 1024);
lcdDrawNumber(LCD_W-8-6*FW, 1*FH, calcRESXto1000(y512), RIGHT | PREC1);
x512 = CURVE_CENTER_X+x512/(RESX/CURVE_SIDE_WIDTH);
y512 = (LCD_H-1) - ((y512+RESX)/2) * (LCD_H-1) / RESX;
lcdDrawSolidVerticalLine(x512, y512-3, 3*2+1);
lcdDrawSolidHorizontalLine(x512-3, y512, 3*2+1);
// 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);
}
+2
View File
@@ -140,6 +140,8 @@ void menuModelMixOne(event_t event)
case MIX_FIELD_CURVE:
lcdDrawTextAlignedLeft(y, STR_CURVE);
s_currSrcRaw = md2->srcRaw;
s_currScale = 0;
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr);
break;