diff --git a/src/menu_model.cpp b/src/menu_model.cpp index 85899d346..4a0c9e226 100644 --- a/src/menu_model.cpp +++ b/src/menu_model.cpp @@ -724,20 +724,23 @@ void menuModelFailsafe(uint8_t event) } #endif +#if defined(CPUM64) + #define editNameCursorPos m_posHorz +#else + static uint8_t editNameCursorPos = 0; +#endif + void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, uint8_t active) { #if defined(CPUM64) // in order to save flash lcd_putsLeft(y, STR_NAME); -#define cursorPos m_posHorz -#else - static uint8_t cursorPos = 0; #endif lcd_putsnAtt(x, y, name, size, ZCHAR | ((active && s_editMode <= 0) ? INVERS : 0)); if (active) { - uint8_t cur = cursorPos; + uint8_t cur = editNameCursorPos; if (s_editMode > 0) { int8_t c = name[cur]; int8_t v = c; @@ -798,12 +801,12 @@ void editName(uint8_t x, uint8_t y, char *name, uint8_t size, uint8_t event, uin name[cur] = v; STORE_MODELVARS; } - lcd_putcAtt(x+cursorPos*FW, y, idx2char(v), INVERS); + lcd_putcAtt(x+editNameCursorPos*FW, y, idx2char(v), INVERS); } else { cur = 0; } - cursorPos = cur; + editNameCursorPos = cur; } } @@ -2068,30 +2071,52 @@ bool moveCurve(uint8_t index, int8_t shift, int8_t custom=0) } #if defined(PCBTARANIS) -void menuModelCurveOne(uint8_t event) +const pm_char STR_NEXT_PRESET[] PROGMEM = "Next Preset"; +const pm_char STR_CURVE_NAME[] PROGMEM = "Curve Name..."; +const pm_char STR_CURVE_TYPE[] PROGMEM = "Curve Type..."; +int8_t presetIdx = 0; +uint8_t paramsEditMode = 0; +void onCurveOneMenu(const char *result) { - static uint8_t coordsOfs = 0; - - TITLE(STR_MENUCURVE); - lcd_outdezAtt(PSIZE(TR_MENUCURVE)*FW+1, 0, s_curveChan+1, INVERS|LEFT); - DISPLAY_PROGRESS_BAR(20*FW+1); - CurveInfo crv = curveinfo(s_curveChan); - const uint8_t mstate_tab[] = { 0, 0, uint8_t(NAVIGATION_LINE_BY_LINE|(crv.points-1)), 0 }; - if (!check(event, 0, 0, 0, mstate_tab, 3, 3)) - return; + if (result == STR_NEXT_PRESET) { + if (++presetIdx > 4) + presetIdx = -4; + for (uint8_t i=0; i 0) { - coordsOfs = 0; + lcd_puts(9*FW, 0, "pt\003X\006Y"); + lcd_filled_rect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT); + + SIMPLE_SUBMENU(STR_MENUCURVE, crv.points); + lcd_outdezAtt(PSIZE(TR_MENUCURVE)*FW+1, 0, s_curveChan+1, INVERS|LEFT); + + lcd_putsLeft(FH+1, STR_NAME); + editName(INDENT_WIDTH, 2*FH+1, g_model.curveNames[s_curveChan], sizeof(g_model.curveNames[s_curveChan]), event, paramsEditMode==1); + lcd_putsLeft(3*FH+3, STR_TYPE); + lcd_outdezAtt(INDENT_WIDTH, 4*FH+3, crv.points, LEFT|(paramsEditMode==2 ? INVERS|BLINK : 0)); + lcd_putsAtt(lcdLastPos, 4*FH+3, crv.custom ? PSTR("pt'") : PSTR("pt"), (paramsEditMode==2 ? INVERS|BLINK : 0)); + if (paramsEditMode==2) { + switch(event) { + case EVT_KEY_REPT(KEY_LEFT): + case EVT_KEY_FIRST(KEY_LEFT): if (crv.custom) { moveCurve(s_curveChan, -crv.points+2); } @@ -2101,14 +2126,10 @@ void menuModelCurveOne(uint8_t event) else { AUDIO_WARNING2(); } - return; - } - break; + break; - case EVT_KEY_REPT(KEY_RIGHT): - case EVT_KEY_FIRST(KEY_RIGHT): - if (m_posVert == 0 && s_editMode > 0) { - coordsOfs = 0; + case EVT_KEY_REPT(KEY_RIGHT): + case EVT_KEY_FIRST(KEY_RIGHT): if (!crv.custom) { moveCurve(s_curveChan, crv.points-2, crv.points); } @@ -2125,60 +2146,62 @@ void menuModelCurveOne(uint8_t event) else { AUDIO_WARNING2(); } - } - break; + break; + } + crv = curveinfo(s_curveChan); + m_posVert = 0; } - lcd_putsLeft(FH+1, STR_CURVE_TYPE); - uint8_t attr = (m_posVert==0 ? (s_editMode <= 0 ? INVERS : INVERS|BLINK) : 0); - lcd_outdezAtt(5*FW, FH+1, crv.points, LEFT|attr); - lcd_putsAtt(lcdLastPos, FH+1, crv.custom ? PSTR("pt'") : PSTR("pt"), attr); - - lcd_putsLeft(2*FH+1, STR_NAME); - editName(5*FW, 2*FH+1, g_model.curveNames[s_curveChan], sizeof(g_model.curveNames[s_curveChan]), event, m_posVert==1 ? INVERS : 0); - - lcd_putsAtt(0*FW, 3*FH+3, PSTR("[Edit]"), m_posVert==2 ? INVERS : 0); - lcd_putsAtt(0*FW, 4*FH+3, PSTR("[Preset]"), m_posVert==3 ? INVERS : 0); - if (m_posVert==3 && event==EVT_KEY_BREAK(KEY_ENTER)) { - static int8_t presetIdx = 0; - if (++presetIdx > 4) - presetIdx = -4; - for (uint8_t i=0; i0 && i=coordsOfs && i<=coordsOfs+5) { + if (i>=s_pgOfs && i0 && i 0) { if (event==EVT_KEY_BREAK(KEY_ENTER)) { if (s_editMode == EDIT_MODIFY_FIELD) - s_editMode = (crv.custom && m_posHorz>0 && m_posHorz= coordsOfs+6) - coordsOfs = m_posHorz-5; + if (m_posVert < s_pgOfs) + s_pgOfs = m_posVert; + else if (m_posVert >= s_pgOfs+5) + s_pgOfs = m_posVert-4; } } } @@ -2283,7 +2306,7 @@ void menuModelCurveOne(uint8_t event) break; } - lcd_putsLeft(7*FH, STR_CURVE_TYPE); + lcd_putsLeft(7*FH, STR_TYPE); uint8_t attr = (s_editMode <= 0 ? INVERS : 0); lcd_outdezAtt(5*FW-2, 7*FH, crv.points, LEFT|attr); lcd_putsAtt(lcdLastPos, 7*FH, crv.custom ? PSTR("pt'") : PSTR("pt"), attr); @@ -3414,10 +3437,12 @@ void menuModelCurvesAll(uint8_t event) #if defined(ROTARY_ENCODER_NAVIGATION) case EVT_ROTARY_BREAK: #endif -#if !defined(PCBTARANIS) +#if defined(PCBTARANIS) + case EVT_KEY_BREAK(KEY_ENTER): +#else case EVT_KEY_FIRST(KEY_RIGHT): -#endif case EVT_KEY_FIRST(KEY_ENTER): +#endif if (CURVE_SELECTED()) { s_curveChan = sub; pushMenu(menuModelCurveOne); @@ -3430,13 +3455,7 @@ void menuModelCurvesAll(uint8_t event) uint8_t k = i + s_pgOfs; uint8_t attr = (sub == k ? INVERS : 0); #if defined(GVARS) && defined(PCBSTD) - if (k < MAX_CURVES) { - putsStrIdx(0, y, STR_CV, k+1, attr); -#if defined(PCBTARANIS) - lcd_putsnAtt(5*FW, y, g_model.curveNames[k], sizeof(g_model.curveNames[k]), ZCHAR); -#endif - } - else { + if (k >= MAX_CURVES) { putsStrIdx(0, y, STR_GV, k-MAX_CURVES+1); if (GVAR_SELECTED()) { if (attr && s_editMode>0) attr |= BLINK; @@ -3444,12 +3463,17 @@ void menuModelCurvesAll(uint8_t event) if (attr) g_model.gvars[k-MAX_CURVES] = checkIncDec(event, g_model.gvars[k-MAX_CURVES], -1000, 1000, EE_MODEL); } } -#else - putsStrIdx(0, y, STR_CV, k+1, attr); + else +#endif + { + putsStrIdx(0, y, STR_CV, k+1, attr); #if defined(PCBTARANIS) - lcd_putsnAtt(5*FW, y, g_model.curveNames[k], sizeof(g_model.curveNames[k]), ZCHAR); -#endif + editName(4*FW, y, g_model.curveNames[k], sizeof(g_model.curveNames[k]), 0, 0); + CurveInfo crv = curveinfo(k); + lcd_outdezAtt(11*FW, y, crv.points, LEFT); + lcd_putsAtt(lcdLastPos, y, crv.custom ? PSTR("pt'") : PSTR("pt"), 0); #endif + } } if (CURVE_SELECTED()) { diff --git a/src/translations.cpp b/src/translations.cpp index d40be447c..ad2a35012 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -417,7 +417,7 @@ const pm_char STR_SD_TYPE[] PROGMEM = TR_SD_TYPE; const pm_char STR_SD_SPEED[] PROGMEM = TR_SD_SPEED; const pm_char STR_SD_SECTORS[] PROGMEM = TR_SD_SECTORS; const pm_char STR_SD_SIZE[] PROGMEM = TR_SD_SIZE; -const pm_char STR_CURVE_TYPE[] PROGMEM = TR_CURVE_TYPE; +const pm_char STR_TYPE[] PROGMEM = TR_TYPE; const pm_char STR_GLOBAL_VARS[] PROGMEM = TR_GLOBAL_VARS; const pm_char STR_OWN[] PROGMEM = TR_OWN; const pm_char STR_ROTARY_ENCODER[] PROGMEM = TR_ROTARY_ENCODER; diff --git a/src/translations.h b/src/translations.h index 0bad92ad6..58f02e93f 100644 --- a/src/translations.h +++ b/src/translations.h @@ -545,7 +545,7 @@ extern const pm_char STR_SD_TYPE[]; extern const pm_char STR_SD_SPEED[]; extern const pm_char STR_SD_SECTORS[]; extern const pm_char STR_SD_SIZE[]; -extern const pm_char STR_CURVE_TYPE[]; +extern const pm_char STR_TYPE[]; extern const pm_char STR_GLOBAL_VARS[]; extern const pm_char STR_OWN[]; extern const pm_char STR_ROTARY_ENCODER[]; diff --git a/src/translations/cz.h b/src/translations/cz.h index c8bf2e76d..21a1f5669 100644 --- a/src/translations/cz.h +++ b/src/translations/cz.h @@ -569,7 +569,7 @@ #define TR_SD_SPEED "Rychlost:" #define TR_SD_SECTORS "Sektor\211 :" #define TR_SD_SIZE "Velikost:" -#define TR_CURVE_TYPE TR_SD_TYPE +#define TR_TYPE TR_SD_TYPE #define TR_GLOBAL_VARS "Glob\200ln\204 prom\203nn\202" #define TR_OWN " \043 " #define TR_DATE "Date" diff --git a/src/translations/de.h b/src/translations/de.h index cf9c146da..1916f5dfb 100644 --- a/src/translations/de.h +++ b/src/translations/de.h @@ -570,7 +570,7 @@ #define TR_SD_SPEED "Geschw:" #define TR_SD_SECTORS "Sektoren:" #define TR_SD_SIZE "Gr\203\206e:" -#define TR_CURVE_TYPE "Typ" +#define TR_TYPE "Typ" #define TR_GLOBAL_VARS "Globale Variablen" #define TR_OWN "Eigen" #define TR_DATE "Datum:" diff --git a/src/translations/en.h b/src/translations/en.h index 16497bb80..8a53c1032 100644 --- a/src/translations/en.h +++ b/src/translations/en.h @@ -582,7 +582,7 @@ #define TR_SD_SPEED "Speed:" #define TR_SD_SECTORS "Sectors:" #define TR_SD_SIZE "Size:" -#define TR_CURVE_TYPE "Type" +#define TR_TYPE "Type" #define TR_GLOBAL_VARS "Global Variables" #define TR_OWN "Own" #define TR_DATE "Date" diff --git a/src/translations/es.h b/src/translations/es.h index b0a9f5b7f..74d50a6cd 100644 --- a/src/translations/es.h +++ b/src/translations/es.h @@ -582,7 +582,7 @@ #define TR_SD_SPEED "Velocidad:" #define TR_SD_SECTORS "Sectores:" #define TR_SD_SIZE "Talla:" -#define TR_CURVE_TYPE "Tipo" +#define TR_TYPE "Tipo" #define TR_GLOBAL_VARS "Global Variables" #define TR_OWN "Propio" #define TR_DATE "Fecha" diff --git a/src/translations/fr.h b/src/translations/fr.h index dfe0ae519..865747a88 100644 --- a/src/translations/fr.h +++ b/src/translations/fr.h @@ -588,7 +588,7 @@ #define TR_SD_SPEED "Vitesse:" #define TR_SD_SECTORS "Secteurs:" #define TR_SD_SIZE "Taille:" -#define TR_CURVE_TYPE "Type" +#define TR_TYPE "Type" #define TR_GLOBAL_VARS "Variables Globales" #define TR_OWN "Pers" #define TR_DATE "Date" diff --git a/src/translations/it.h b/src/translations/it.h index 382a24c65..147f68c5b 100644 --- a/src/translations/it.h +++ b/src/translations/it.h @@ -573,7 +573,7 @@ #define TR_SD_SPEED "Veloc.:" #define TR_SD_SECTORS "Settori:" #define TR_SD_SIZE "Dimens:" -#define TR_CURVE_TYPE "Tipo" +#define TR_TYPE "Tipo" #define TR_GLOBAL_VARS "Variabili Globali" #define TR_OWN "Own" #define TR_DATE "Date" diff --git a/src/translations/pt.h b/src/translations/pt.h index c5128cbcc..64c9ee4a5 100644 --- a/src/translations/pt.h +++ b/src/translations/pt.h @@ -552,7 +552,7 @@ #define TR_SD_SPEED "Velocidade" #define TR_SD_SECTORS "Sectores" #define TR_SD_SIZE "Tamanho" -#define TR_CURVE_TYPE "Type" +#define TR_TYPE "Type" #define TR_GLOBAL_VARS "Variaveis" #define TR_OWN "Propr." #define TR_DATE "Data" diff --git a/src/translations/se.h b/src/translations/se.h index 1471bf3f1..e47cd43d0 100644 --- a/src/translations/se.h +++ b/src/translations/se.h @@ -582,7 +582,7 @@ #define TR_SD_SPEED "Hastighet:" #define TR_SD_SECTORS "Sektorer:" #define TR_SD_SIZE "Strl:" -#define TR_CURVE_TYPE "Typ " +#define TR_TYPE "Typ " #define TR_GLOBAL_VARS "Globala Variabler" #define TR_OWN "Egen" #define TR_DATE "Datum"