[Horus] Refactoring continued

This commit is contained in:
Bertrand Songis
2015-10-24 11:27:34 +02:00
parent fb371cf5b7
commit ab0272c16c
116 changed files with 1042 additions and 1269 deletions
+24 -12
View File
@@ -79,7 +79,7 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t a
uint8_t editDelay(const coord_t x, const coord_t y, const evt_t event, const uint8_t attr, const pm_char *str, uint8_t delay)
{
lcd_putsAtt(x+MENUS_MARGIN_LEFT, y, str, TEXT_COLOR);
lcdDrawText(x+MENUS_MARGIN_LEFT, y, str, TEXT_COLOR);
lcd_outdezAtt(x+MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX);
return delay;
@@ -118,18 +118,19 @@ static uint8_t editNameCursorPos = 0;
void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint8_t active)
{
uint8_t mode = 0;
uint8_t flags = 0;
if (active && s_editMode <= 0) {
mode = INVERS;
flags = INVERS;
}
if (!active || s_editMode <= 0) {
if (zlen(name, size) == 0) {
uint8_t len = zlen(name, size);
if (len == 0) {
char tmp[] = "---";
lcd_putsnAtt(x, y, tmp, size, mode);
lcdDrawTextWithLen(x, y, tmp, size, flags);
}
else {
lcd_putsnAtt(x, y, name, size, ZCHAR | mode);
lcdDrawTextWithLen(x, y, name, len, ZCHAR | flags);
}
}
@@ -139,13 +140,20 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint
int8_t c = name[cur];
int8_t v = c;
if (IS_ROTARY_RIGHT(event) || IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_FIRST(KEY_UP)
|| event==EVT_KEY_REPT(KEY_DOWN) || event==EVT_KEY_REPT(KEY_UP)) {
v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0);
if (c <= 0) v = -v;
if (event==EVT_ROTARY_RIGHT || event==EVT_ROTARY_LEFT) {
v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0);
if (c <= 0) v = -v;
}
switch (event) {
case EVT_KEY_BREAK(KEY_LEFT):
if (cur>0) cur--;
break;
case EVT_KEY_BREAK(KEY_RIGHT):
if (cur<size-1) cur++;
break;
case EVT_ROTARY_BREAK:
if (s_editMode == EDIT_MODIFY_FIELD) {
s_editMode = EDIT_MODIFY_STRING;
@@ -163,6 +171,10 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint
killEvents(event);
break;
}
// no break
case EVT_KEY_LONG(KEY_LEFT):
case EVT_KEY_LONG(KEY_RIGHT):
if (v>=-26 && v<=26) {
v = -v; // toggle case
if (event==EVT_KEY_LONG(KEY_LEFT))
@@ -176,11 +188,11 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint
storageDirty(g_menuPos[0] == 0 ? EE_MODEL : EE_GENERAL);
}
lcd_putsnAtt(x, y, name, size, ZCHAR | mode);
lcdDrawTextWithLen(x, y, name, size, ZCHAR | flags);
coord_t w = (editNameCursorPos == 0 ? 0 : getTextWidth(name, editNameCursorPos, ZCHAR));
char s[] = { idx2char(v), '\0' };
lcdDrawSolidFilledRect(x+w-1, y-INVERT_VERT_MARGIN, getTextWidth(s, 1)+1, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR);
lcd_putsAtt(x+w, y, s, TEXT_INVERTED_COLOR);
lcdDrawText(x+w, y, s, TEXT_INVERTED_COLOR);
}
else {
cur = 0;