feat: direct tactile touch volume selection (0-5) and remove test button
This commit is contained in:
parent
5f8b3a04d8
commit
06a07091e3
1 changed files with 66 additions and 34 deletions
|
|
@ -194,7 +194,7 @@ void warningMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
// Sub-screen 1: Volumen de Bip (Ajuste Tactil con Prueba en Vivo)
|
// Sub-screen 1: Volumen de Bip (Ajuste Tactil Directo)
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
void volumeMenu() {
|
void volumeMenu() {
|
||||||
clickSound();
|
clickSound();
|
||||||
|
|
@ -204,62 +204,92 @@ void volumeMenu() {
|
||||||
tft.drawCentreString("[--- Volumen de Bip ---]", 159, 0, 4);
|
tft.drawCentreString("[--- Volumen de Bip ---]", 159, 0, 4);
|
||||||
|
|
||||||
auto drawVolUI = []() {
|
auto drawVolUI = []() {
|
||||||
tft.fillRect(0, 34, 320, 96, TFT_BLACK);
|
tft.fillRect(0, 28, 320, 122, TFT_BLACK);
|
||||||
|
|
||||||
// Level number and title
|
// Level number and title
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
String lvlStr = "Nivel " + String(buzzerVolumeLevel) + " / 5";
|
String lvlStr = "Nivel " + String(buzzerVolumeLevel) + " de 5";
|
||||||
tft.drawCentreString(lvlStr.c_str(), 160, 38, 4);
|
tft.drawCentreString(lvlStr.c_str(), 160, 32, 4);
|
||||||
|
|
||||||
tft.setTextColor(buzzerVolumeLevel == 0 ? TFT_RED : TFT_CYAN, TFT_BLACK);
|
tft.setTextColor(buzzerVolumeLevel == 0 ? TFT_RED : TFT_CYAN, TFT_BLACK);
|
||||||
tft.drawCentreString(VOL_NAME_TABLE[buzzerVolumeLevel], 160, 66, 4);
|
tft.drawCentreString(VOL_NAME_TABLE[buzzerVolumeLevel], 160, 56, 4);
|
||||||
|
|
||||||
// Visual volume meter bar (5 discrete blocks)
|
// 6 Direct Touch Tiles (0 to 5)
|
||||||
for (uint8_t b = 1; b <= 5; b++) {
|
for (uint8_t i = 0; i <= 5; i++) {
|
||||||
uint16_t bCol = (b <= buzzerVolumeLevel) ? (b >= 4 ? TFT_ORANGE : TFT_GREEN) : METER_INACTIVE_COLOR;
|
int16_t bx = 7 + i * 52;
|
||||||
tft.fillRect(36 + (b - 1) * 50, 102, 44, 20, bCol);
|
int16_t by = 88;
|
||||||
|
int16_t bw = 46;
|
||||||
|
int16_t bh = 54;
|
||||||
|
bool isSel = (i == buzzerVolumeLevel);
|
||||||
|
|
||||||
|
uint16_t bgCol;
|
||||||
|
if (isSel) {
|
||||||
|
bgCol = (i == 0) ? 0x8000 : (i >= 4 ? TFT_ORANGE : (i >= 2 ? TFT_GREEN : 0x03E0));
|
||||||
|
} else {
|
||||||
|
bgCol = 0x18E3; // Dark charcoal slate
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.fillRoundRect(bx, by, bw, bh, 5, bgCol);
|
||||||
|
if (isSel) {
|
||||||
|
tft.drawRoundRect(bx, by, bw, bh, 5, TFT_WHITE);
|
||||||
|
tft.drawRoundRect(bx + 1, by + 1, bw - 2, bh - 2, 4, TFT_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
tft.setTextColor(isSel ? TFT_WHITE : 0xAD55, bgCol);
|
||||||
|
if (i == 0) {
|
||||||
|
tft.drawCentreString("MUTE", bx + bw / 2, by + 8, 2);
|
||||||
|
tft.drawCentreString("0", bx + bw / 2, by + 26, 4);
|
||||||
|
} else {
|
||||||
|
tft.drawCentreString(String(i).c_str(), bx + bw / 2, by + 12, 6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
drawVolUI();
|
drawVolUI();
|
||||||
|
|
||||||
// Draw interactive buttons
|
// Bottom action buttons (large touch targets)
|
||||||
// [ - BAJAR ]
|
auto drawStepButtons = []() {
|
||||||
tft.fillRoundRect(20, 136, 85, 42, 6, TFT_NAVY);
|
tft.fillRoundRect(15, 152, 138, 38, 5, TFT_NAVY);
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawCentreString("- BAJAR", 62, 148, 2);
|
tft.drawCentreString("- BAJAR", 84, 161, 4);
|
||||||
|
|
||||||
// [ PROBAR ]
|
tft.fillRoundRect(167, 152, 138, 38, 5, TFT_NAVY);
|
||||||
tft.fillRoundRect(115, 136, 90, 42, 6, 0x03E0); // Dark Green
|
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawCentreString("PROBAR", 160, 148, 2);
|
tft.drawCentreString("+ SUBIR", 236, 161, 4);
|
||||||
|
|
||||||
// [ + SUBIR ]
|
// [ GUARDAR Y SALIR ]
|
||||||
tft.fillRoundRect(215, 136, 85, 42, 6, TFT_NAVY);
|
tft.fillRoundRect(25, 198, 270, 36, 5, 0x02EC); // Rich Ocean Blue
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawCentreString("+ SUBIR", 257, 148, 2);
|
tft.drawCentreString("GUARDAR Y SALIR", 160, 206, 4);
|
||||||
|
};
|
||||||
// [ GUARDAR Y VOLVER ]
|
|
||||||
tft.fillRoundRect(40, 192, 240, 38, 6, TFT_BLUE);
|
|
||||||
tft.setTextColor(TFT_WHITE);
|
|
||||||
tft.drawCentreString("GUARDAR Y VOLVER", 160, 202, 2);
|
|
||||||
|
|
||||||
|
drawStepButtons();
|
||||||
delay(200);
|
delay(200);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
autoDim();
|
autoDim();
|
||||||
uint16_t tx = 0, ty = 0;
|
uint16_t tx = 0, ty = 0;
|
||||||
if (getTouch(&tx, &ty)) {
|
if (getTouch(&tx, &ty)) {
|
||||||
if (ty >= 136 && ty < 178) {
|
// 1. Direct Touch on the 6 volume tiles (y: 82 to 146)
|
||||||
if (tx >= 20 && tx < 105) { // BAJAR
|
if (ty >= 82 && ty <= 146) {
|
||||||
|
int8_t touchedLvl = (tx - 7) / 52;
|
||||||
|
if (touchedLvl >= 0 && touchedLvl <= 5) {
|
||||||
|
buzzerVolumeLevel = touchedLvl;
|
||||||
|
drawVolUI();
|
||||||
|
casioBeep(2048, 20); // Immediate acoustic feedback at selected volume
|
||||||
|
}
|
||||||
|
while (isScreenPressed()) { delay(10); yield(); }
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
|
// 2. Step buttons (- BAJAR / + SUBIR) (y: 148 to 192)
|
||||||
|
else if (ty >= 148 && ty <= 192) {
|
||||||
|
if (tx >= 10 && tx < 155) { // BAJAR
|
||||||
if (buzzerVolumeLevel > 0) {
|
if (buzzerVolumeLevel > 0) {
|
||||||
buzzerVolumeLevel--;
|
buzzerVolumeLevel--;
|
||||||
drawVolUI();
|
drawVolUI();
|
||||||
casioBeep(2048, 20);
|
casioBeep(2048, 20);
|
||||||
}
|
}
|
||||||
} else if (tx >= 115 && tx < 205) { // PROBAR
|
} else if (tx >= 160 && tx <= 310) { // SUBIR
|
||||||
casioBeep(2048, 20);
|
|
||||||
} else if (tx >= 215 && tx < 300) { // SUBIR
|
|
||||||
if (buzzerVolumeLevel < 5) {
|
if (buzzerVolumeLevel < 5) {
|
||||||
buzzerVolumeLevel++;
|
buzzerVolumeLevel++;
|
||||||
drawVolUI();
|
drawVolUI();
|
||||||
|
|
@ -267,8 +297,10 @@ void volumeMenu() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (isScreenPressed()) { delay(10); yield(); }
|
while (isScreenPressed()) { delay(10); yield(); }
|
||||||
delay(60);
|
delay(50);
|
||||||
} else if ((ty >= 190 && ty <= 236 && tx >= 30 && tx <= 290) || ty < 30) { // GUARDAR Y VOLVER
|
}
|
||||||
|
// 3. GUARDAR Y SALIR (y: 196 to 238) or top bar
|
||||||
|
else if ((ty >= 196 && ty <= 238 && tx >= 20 && tx <= 300) || ty < 30) {
|
||||||
casioBeep(4096, 25);
|
casioBeep(4096, 25);
|
||||||
pref.begin("setting", false);
|
pref.begin("setting", false);
|
||||||
pref.putUChar("b_vol", buzzerVolumeLevel);
|
pref.putUChar("b_vol", buzzerVolumeLevel);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue