Moved some of the strings to PROGMEM. added "Done" message when the encoder is reversed

This commit is contained in:
Oleksiy
2024-07-31 16:44:04 +03:00
parent e14d627238
commit 8346c4d764
3 changed files with 39 additions and 37 deletions

View File

@ -6,7 +6,7 @@ void updateScreen() {
byte width;
//String textToShow;
String valueStr;
char valueChar[16];
//char valueChar[16];
u8g2.setDrawColor(1);
if (displayScreen == 0) {
@ -39,11 +39,11 @@ void updateScreen() {
} else if (i == 3 && masterClockMode == 0) {
valueStr = "RANGE:";
}
valueStr.toCharArray(valueChar, 16);
//valueStr.toCharArray(valueChar, 16);
if (menuItem == i && insideTab) {
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, width, 1, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, width, 1, 2, valueStr.c_str() );
} else {
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW0, width, 1, 2, valueChar);
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW0, width, 1, 2, valueStr.c_str());
}
}
if (masterClockMode != 0 && menuItem == 0) { //to make main param non selectable for external clock
@ -72,14 +72,14 @@ void updateScreen() {
valueStr = String(bpmModulationRange * 10);
}
valueStr.toCharArray(valueChar, 16);
//valueStr.toCharArray(valueChar, 16);
if (menuItem == i && insideTab && (menuItemSelected || shiftBtnPushed)) {
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1, 26, 2, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1, 26, 2, 2, valueStr.c_str() );
} else if (menuItem == i && insideTab && (!menuItemSelected || !shiftBtnPushed)) {
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, 26, 2, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, 26, 2, 2, valueStr.c_str() );
} else {
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW0, 26, 2, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW0, 26, 2, 2, valueStr.c_str() );
}
}
@ -141,11 +141,11 @@ void updateScreen() {
} else if (i == 3) {
valueStr = "MOD:";
}
valueStr.toCharArray(valueChar, 16);
//valueStr.toCharArray(valueChar, 16);
if (menuItem == i && insideTab) {
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, width, 1, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, width, 1, 2, valueStr.c_str() );
} else {
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW0, width, 1, 2, valueChar);
u8g2.drawButtonUTF8(leftOffset, 8 + (i-1) *11, U8G2_BTN_BW0, width, 1, 2, valueStr.c_str());
}
}
@ -178,18 +178,18 @@ void updateScreen() {
valueStr = "CV2";
}
valueStr.toCharArray(valueChar, 16);
//valueStr.toCharArray(valueChar, 16);
if (i == 2 && channels[displayTab - 1].mode == 2) { //EDIT PATTERN thing
if (menuItem == i && insideTab) {
u8g2.drawBox(leftOffset + 54, ((i-1) * 11), 11, 11);
}
} else {
if (menuItem == i && insideTab && (menuItemSelected || shiftBtnPushed)) {
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1, 26, 2, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1, 26, 2, 2, valueStr.c_str() );
} else if (menuItem == i && insideTab && (!menuItemSelected || !shiftBtnPushed)) {
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, 26, 2, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW1|U8G2_BTN_INV, 26, 2, 2, valueStr.c_str() );
} else {
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW0, 26, 2, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset + 37, 8 + (i-1) *11, U8G2_BTN_BW0, 26, 2, 2, valueStr.c_str() );
}
}
}
@ -198,17 +198,17 @@ void updateScreen() {
leftOffset = 29;
width = 55;
if (channels[displayTab - 1].mode == 0) {
valueStr = "SUBDIVISION";
valueStr = F("SUBDIVISION");
} else if (channels[displayTab - 1].mode == 1) {
valueStr = "SKIP CHANCE";
valueStr = F("SKIP CHANCE");
} else if (channels[displayTab - 1].mode == 2) {
valueStr = "PATTERN";
valueStr = F("PATTERN");
}
valueStr.toCharArray(valueChar, 16);
//valueStr.toCharArray(valueChar, 16);
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0)) {
u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueChar );
u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
} else {
u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 1, 2, valueChar );
u8g2.drawButtonUTF8(leftOffset, 41, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 1, 2, valueStr.c_str() );
}
if (channels[displayTab - 1].mode == 0) {
@ -226,14 +226,14 @@ void updateScreen() {
valueStr = "B" + String(channels[displayTab - 1].seqPattern - 7);
}
}
valueStr.toCharArray(valueChar, 16);
//valueStr.toCharArray(valueChar, 16);
u8g2.setFont(stkL);
if ((!insideTab && shiftBtnPushed) || (insideTab && menuItem == 0 && (menuItemSelected || shiftBtnPushed))) {
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, valueChar );
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW1|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
} else if (insideTab && menuItem == 0 && !menuItemSelected) {
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueChar );
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW1|U8G2_BTN_INV|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
} else {
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, valueChar );
u8g2.drawButtonUTF8(leftOffset, 28, U8G2_BTN_BW0|U8G2_BTN_HCENTER, width, 0, 3, valueStr.c_str() );
}
}
@ -317,7 +317,7 @@ void updateScreen() {
//Settings Screen
else if (displayScreen == 2) {
u8g2.drawStr(8, 5,"SETTINGS" );
u8g2.drawStr(8, 5, "SETTINGS");
u8g2.drawStr(102, 5, version );
u8g2.drawHLine(0, 8, 128);
lastMenuItem = 3;
@ -325,23 +325,23 @@ void updateScreen() {
for (byte i = 0; i <= lastMenuItem; i++) {
switch(i) {
case 0:
valueStr = "CALIBRATE CV";
valueStr = F("CALIBRATE CV");
break;
case 1:
valueStr = "ROTATE SCREEN";
valueStr = F("ROTATE SCREEN");
break;
case 2:
valueStr = "REVERSE ENC";
valueStr = F("REVERSE ENCODER");//"REVERSE ENC";
break;
case 3:
valueStr = "FULL RESET";
valueStr = F("FULL RESET");
break;
};
valueStr.toCharArray(valueChar, 16);
//valueStr.toCharArray(valueChar, 16);
if (menuItem == i) {
u8g2.drawButtonUTF8(8, 19 + (i*11), U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 3, valueChar );
u8g2.drawButtonUTF8(8, 19 + (i*11), U8G2_BTN_BW0|U8G2_BTN_INV, width, 2, 3, valueStr.c_str() );
} else {
u8g2.drawButtonUTF8(8, 19 + (i*11), U8G2_BTN_BW0, width, 2, 3, valueChar );
u8g2.drawButtonUTF8(8, 19 + (i*11), U8G2_BTN_BW0, width, 2, 3, valueStr.c_str() );
}
}
}