feat: direct tactile touch volume selection (0-5) and remove test button

This commit is contained in:
Sebastián Nieto 2026-09-09 23:23:57 -03:00
parent 5f8b3a04d8
commit 06a07091e3

View file

@ -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() {
clickSound();
@ -204,62 +204,92 @@ void volumeMenu() {
tft.drawCentreString("[--- Volumen de Bip ---]", 159, 0, 4);
auto drawVolUI = []() {
tft.fillRect(0, 34, 320, 96, TFT_BLACK);
tft.fillRect(0, 28, 320, 122, TFT_BLACK);
// Level number and title
tft.setTextColor(TFT_WHITE, TFT_BLACK);
String lvlStr = "Nivel " + String(buzzerVolumeLevel) + " / 5";
tft.drawCentreString(lvlStr.c_str(), 160, 38, 4);
String lvlStr = "Nivel " + String(buzzerVolumeLevel) + " de 5";
tft.drawCentreString(lvlStr.c_str(), 160, 32, 4);
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)
for (uint8_t b = 1; b <= 5; b++) {
uint16_t bCol = (b <= buzzerVolumeLevel) ? (b >= 4 ? TFT_ORANGE : TFT_GREEN) : METER_INACTIVE_COLOR;
tft.fillRect(36 + (b - 1) * 50, 102, 44, 20, bCol);
// 6 Direct Touch Tiles (0 to 5)
for (uint8_t i = 0; i <= 5; i++) {
int16_t bx = 7 + i * 52;
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();
// Draw interactive buttons
// [ - BAJAR ]
tft.fillRoundRect(20, 136, 85, 42, 6, TFT_NAVY);
// Bottom action buttons (large touch targets)
auto drawStepButtons = []() {
tft.fillRoundRect(15, 152, 138, 38, 5, TFT_NAVY);
tft.setTextColor(TFT_WHITE);
tft.drawCentreString("- BAJAR", 62, 148, 2);
tft.drawCentreString("- BAJAR", 84, 161, 4);
// [ PROBAR ]
tft.fillRoundRect(115, 136, 90, 42, 6, 0x03E0); // Dark Green
tft.fillRoundRect(167, 152, 138, 38, 5, TFT_NAVY);
tft.setTextColor(TFT_WHITE);
tft.drawCentreString("PROBAR", 160, 148, 2);
tft.drawCentreString("+ SUBIR", 236, 161, 4);
// [ + SUBIR ]
tft.fillRoundRect(215, 136, 85, 42, 6, TFT_NAVY);
// [ GUARDAR Y SALIR ]
tft.fillRoundRect(25, 198, 270, 36, 5, 0x02EC); // Rich Ocean Blue
tft.setTextColor(TFT_WHITE);
tft.drawCentreString("+ SUBIR", 257, 148, 2);
// [ GUARDAR Y VOLVER ]
tft.fillRoundRect(40, 192, 240, 38, 6, TFT_BLUE);
tft.setTextColor(TFT_WHITE);
tft.drawCentreString("GUARDAR Y VOLVER", 160, 202, 2);
tft.drawCentreString("GUARDAR Y SALIR", 160, 206, 4);
};
drawStepButtons();
delay(200);
while (true) {
autoDim();
uint16_t tx = 0, ty = 0;
if (getTouch(&tx, &ty)) {
if (ty >= 136 && ty < 178) {
if (tx >= 20 && tx < 105) { // BAJAR
// 1. Direct Touch on the 6 volume tiles (y: 82 to 146)
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) {
buzzerVolumeLevel--;
drawVolUI();
casioBeep(2048, 20);
}
} else if (tx >= 115 && tx < 205) { // PROBAR
casioBeep(2048, 20);
} else if (tx >= 215 && tx < 300) { // SUBIR
} else if (tx >= 160 && tx <= 310) { // SUBIR
if (buzzerVolumeLevel < 5) {
buzzerVolumeLevel++;
drawVolUI();
@ -267,8 +297,10 @@ void volumeMenu() {
}
}
while (isScreenPressed()) { delay(10); yield(); }
delay(60);
} else if ((ty >= 190 && ty <= 236 && tx >= 30 && tx <= 290) || ty < 30) { // GUARDAR Y VOLVER
delay(50);
}
// 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);
pref.begin("setting", false);
pref.putUChar("b_vol", buzzerVolumeLevel);