From 1367d59affef74293249601ec5341dac2175738b Mon Sep 17 00:00:00 2001 From: Sebastian Nieto Date: Wed, 9 Sep 2026 23:29:17 -0300 Subject: [PATCH] feat: direct touch volume tiles (0-5 in font 6), remove subir/bajar buttons, add ultra-low volume level --- sketch/obd2_gauge/config.h | 69 ++++++++------------------------ sketch/obd2_gauge/obd2_gauge.ino | 8 ++-- 2 files changed, 21 insertions(+), 56 deletions(-) diff --git a/sketch/obd2_gauge/config.h b/sketch/obd2_gauge/config.h index a9058ef..2d1ece0 100644 --- a/sketch/obd2_gauge/config.h +++ b/sketch/obd2_gauge/config.h @@ -203,22 +203,22 @@ void volumeMenu() { tft.drawCentreString("[--- Volumen de Bip ---]", 159, 0, 4); auto drawVolUI = []() { - tft.fillRect(0, 28, 320, 122, TFT_BLACK); + tft.fillRect(0, 28, 320, 150, TFT_BLACK); // Level number and title tft.setTextColor(TFT_WHITE, TFT_BLACK); String lvlStr = "Nivel " + String(buzzerVolumeLevel) + " de 5"; - tft.drawCentreString(lvlStr.c_str(), 160, 32, 4); + tft.drawCentreString(lvlStr.c_str(), 160, 34, 4); tft.setTextColor(buzzerVolumeLevel == 0 ? TFT_RED : TFT_CYAN, TFT_BLACK); - tft.drawCentreString(VOL_NAME_TABLE[buzzerVolumeLevel], 160, 56, 4); + tft.drawCentreString(VOL_NAME_TABLE[buzzerVolumeLevel], 160, 60, 4); // 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 by = 94; int16_t bw = 46; - int16_t bh = 54; + int16_t bh = 68; bool isSel = (i == buzzerVolumeLevel); uint16_t bgCol; @@ -228,49 +228,32 @@ void volumeMenu() { bgCol = 0x18E3; // Dark charcoal slate } - tft.fillRoundRect(bx, by, bw, bh, 5, bgCol); + tft.fillRoundRect(bx, by, bw, bh, 6, 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.drawRoundRect(bx, by, bw, bh, 6, TFT_WHITE); + tft.drawRoundRect(bx + 1, by + 1, bw - 2, bh - 2, 5, 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); - } + tft.drawCentreString(String(i).c_str(), bx + bw / 2, by + 14, 6); } }; drawVolUI(); - // Bottom action buttons (large touch targets) - auto drawStepButtons = []() { - tft.fillRoundRect(15, 152, 138, 38, 5, TFT_NAVY); - tft.setTextColor(TFT_WHITE); - tft.drawCentreString("- BAJAR", 84, 161, 4); + // [ GUARDAR Y SALIR ] + tft.fillRoundRect(25, 186, 270, 42, 6, 0x02EC); // Rich Ocean Blue + tft.setTextColor(TFT_WHITE); + tft.drawCentreString("GUARDAR Y SALIR", 160, 196, 4); - tft.fillRoundRect(167, 152, 138, 38, 5, TFT_NAVY); - tft.setTextColor(TFT_WHITE); - tft.drawCentreString("+ SUBIR", 236, 161, 4); - - // [ GUARDAR Y SALIR ] - tft.fillRoundRect(25, 198, 270, 36, 5, 0x02EC); // Rich Ocean Blue - tft.setTextColor(TFT_WHITE); - tft.drawCentreString("GUARDAR Y SALIR", 160, 206, 4); - }; - - drawStepButtons(); delay(200); while (true) { autoDim(); uint16_t tx = 0, ty = 0; if (getTouch(&tx, &ty)) { - // 1. Direct Touch on the 6 volume tiles (y: 82 to 146) - if (ty >= 82 && ty <= 146) { + // 1. Direct Touch on the 6 volume tiles (y: 85 to 175) + if (ty >= 85 && ty <= 175) { int8_t touchedLvl = (tx - 7) / 52; if (touchedLvl >= 0 && touchedLvl <= 5) { buzzerVolumeLevel = touchedLvl; @@ -280,26 +263,8 @@ void volumeMenu() { 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 >= 160 && tx <= 310) { // SUBIR - if (buzzerVolumeLevel < 5) { - buzzerVolumeLevel++; - drawVolUI(); - casioBeep(2048, 20); - } - } - while (isScreenPressed()) { delay(10); yield(); } - 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) { + // 2. GUARDAR Y SALIR (y: 180 to 238) or top bar + else if ((ty >= 180 && ty <= 238 && tx >= 20 && tx <= 300) || ty < 30) { casioBeep(4096, 25); pref.begin("setting", false); pref.putUChar("b_vol", buzzerVolumeLevel); diff --git a/sketch/obd2_gauge/obd2_gauge.ino b/sketch/obd2_gauge/obd2_gauge.ino index 703b8e5..4b613f8 100644 --- a/sketch/obd2_gauge/obd2_gauge.ino +++ b/sketch/obd2_gauge/obd2_gauge.ino @@ -93,10 +93,10 @@ const String pidConfig[4][9] = { String warningValue[4] = { "106", "5000", "15.0", "130" }; bool alarmEnabled[4] = { true, true, true, true }; -// Buzzer volume control table (0: Silencio, 1: Muy Bajo, 2: Bajo/Casio, 3: Medio, 4: Alto, 5: Max) -const uint16_t VOL_DUTY_TABLE[6] = { 0, 20, 50, 120, 250, 512 }; -const char* const VOL_NAME_TABLE[6] = { "SILENCIO (MUTE)", "MUY BAJO", "BAJO (CASIO)", "MEDIO", "ALTO", "MAXIMO" }; -uint8_t buzzerVolumeLevel = 2; // Default 2: Bajo (Casio suave) +// Buzzer volume control table (0: Silencio, 1: Ultra Bajo, 2: Muy Bajo, 3: Bajo/Casio, 4: Medio, 5: Alto) +const uint16_t VOL_DUTY_TABLE[6] = { 0, 5, 18, 50, 140, 380 }; +const char* const VOL_NAME_TABLE[6] = { "SILENCIO", "ULTRA BAJO", "MUY BAJO", "BAJO (CASIO)", "MEDIO", "ALTO" }; +uint8_t buzzerVolumeLevel = 3; // Default 3: Bajo (Casio suave) /* 0 - Refrigerante