feat: direct touch volume tiles (0-5 in font 6), remove subir/bajar buttons, add ultra-low volume level
This commit is contained in:
parent
6697eb2ec4
commit
1367d59aff
2 changed files with 21 additions and 56 deletions
|
|
@ -203,22 +203,22 @@ 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, 28, 320, 122, TFT_BLACK);
|
tft.fillRect(0, 28, 320, 150, 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) + " de 5";
|
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.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)
|
// 6 Direct Touch Tiles (0 to 5)
|
||||||
for (uint8_t i = 0; i <= 5; i++) {
|
for (uint8_t i = 0; i <= 5; i++) {
|
||||||
int16_t bx = 7 + i * 52;
|
int16_t bx = 7 + i * 52;
|
||||||
int16_t by = 88;
|
int16_t by = 94;
|
||||||
int16_t bw = 46;
|
int16_t bw = 46;
|
||||||
int16_t bh = 54;
|
int16_t bh = 68;
|
||||||
bool isSel = (i == buzzerVolumeLevel);
|
bool isSel = (i == buzzerVolumeLevel);
|
||||||
|
|
||||||
uint16_t bgCol;
|
uint16_t bgCol;
|
||||||
|
|
@ -228,49 +228,32 @@ void volumeMenu() {
|
||||||
bgCol = 0x18E3; // Dark charcoal slate
|
bgCol = 0x18E3; // Dark charcoal slate
|
||||||
}
|
}
|
||||||
|
|
||||||
tft.fillRoundRect(bx, by, bw, bh, 5, bgCol);
|
tft.fillRoundRect(bx, by, bw, bh, 6, bgCol);
|
||||||
if (isSel) {
|
if (isSel) {
|
||||||
tft.drawRoundRect(bx, by, bw, bh, 5, TFT_WHITE);
|
tft.drawRoundRect(bx, by, bw, bh, 6, TFT_WHITE);
|
||||||
tft.drawRoundRect(bx + 1, by + 1, bw - 2, bh - 2, 4, TFT_WHITE);
|
tft.drawRoundRect(bx + 1, by + 1, bw - 2, bh - 2, 5, TFT_WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
tft.setTextColor(isSel ? TFT_WHITE : 0xAD55, bgCol);
|
tft.setTextColor(isSel ? TFT_WHITE : 0xAD55, bgCol);
|
||||||
if (i == 0) {
|
tft.drawCentreString(String(i).c_str(), bx + bw / 2, by + 14, 6);
|
||||||
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();
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
tft.fillRoundRect(167, 152, 138, 38, 5, TFT_NAVY);
|
|
||||||
tft.setTextColor(TFT_WHITE);
|
|
||||||
tft.drawCentreString("+ SUBIR", 236, 161, 4);
|
|
||||||
|
|
||||||
// [ GUARDAR Y SALIR ]
|
// [ GUARDAR Y SALIR ]
|
||||||
tft.fillRoundRect(25, 198, 270, 36, 5, 0x02EC); // Rich Ocean Blue
|
tft.fillRoundRect(25, 186, 270, 42, 6, 0x02EC); // Rich Ocean Blue
|
||||||
tft.setTextColor(TFT_WHITE);
|
tft.setTextColor(TFT_WHITE);
|
||||||
tft.drawCentreString("GUARDAR Y SALIR", 160, 206, 4);
|
tft.drawCentreString("GUARDAR Y SALIR", 160, 196, 4);
|
||||||
};
|
|
||||||
|
|
||||||
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)) {
|
||||||
// 1. Direct Touch on the 6 volume tiles (y: 82 to 146)
|
// 1. Direct Touch on the 6 volume tiles (y: 85 to 175)
|
||||||
if (ty >= 82 && ty <= 146) {
|
if (ty >= 85 && ty <= 175) {
|
||||||
int8_t touchedLvl = (tx - 7) / 52;
|
int8_t touchedLvl = (tx - 7) / 52;
|
||||||
if (touchedLvl >= 0 && touchedLvl <= 5) {
|
if (touchedLvl >= 0 && touchedLvl <= 5) {
|
||||||
buzzerVolumeLevel = touchedLvl;
|
buzzerVolumeLevel = touchedLvl;
|
||||||
|
|
@ -280,26 +263,8 @@ void volumeMenu() {
|
||||||
while (isScreenPressed()) { delay(10); yield(); }
|
while (isScreenPressed()) { delay(10); yield(); }
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
// 2. Step buttons (- BAJAR / + SUBIR) (y: 148 to 192)
|
// 2. GUARDAR Y SALIR (y: 180 to 238) or top bar
|
||||||
else if (ty >= 148 && ty <= 192) {
|
else if ((ty >= 180 && ty <= 238 && tx >= 20 && tx <= 300) || ty < 30) {
|
||||||
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) {
|
|
||||||
casioBeep(4096, 25);
|
casioBeep(4096, 25);
|
||||||
pref.begin("setting", false);
|
pref.begin("setting", false);
|
||||||
pref.putUChar("b_vol", buzzerVolumeLevel);
|
pref.putUChar("b_vol", buzzerVolumeLevel);
|
||||||
|
|
|
||||||
|
|
@ -93,10 +93,10 @@ const String pidConfig[4][9] = {
|
||||||
String warningValue[4] = { "106", "5000", "15.0", "130" };
|
String warningValue[4] = { "106", "5000", "15.0", "130" };
|
||||||
bool alarmEnabled[4] = { true, true, true, true };
|
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)
|
// 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, 20, 50, 120, 250, 512 };
|
const uint16_t VOL_DUTY_TABLE[6] = { 0, 5, 18, 50, 140, 380 };
|
||||||
const char* const VOL_NAME_TABLE[6] = { "SILENCIO (MUTE)", "MUY BAJO", "BAJO (CASIO)", "MEDIO", "ALTO", "MAXIMO" };
|
const char* const VOL_NAME_TABLE[6] = { "SILENCIO", "ULTRA BAJO", "MUY BAJO", "BAJO (CASIO)", "MEDIO", "ALTO" };
|
||||||
uint8_t buzzerVolumeLevel = 2; // Default 2: Bajo (Casio suave)
|
uint8_t buzzerVolumeLevel = 3; // Default 3: Bajo (Casio suave)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
0 - Refrigerante
|
0 - Refrigerante
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue