Beep only on screen touch, eliminate alarm beeps, and soften buzzer volume

This commit is contained in:
Sebastián Nieto 2026-09-09 23:09:53 -03:00
parent c3b15d6c34
commit 8c666d3024
4 changed files with 20 additions and 20 deletions

View file

@ -9,25 +9,29 @@ Configuration menu for OBD2 Gauge
#define FORMAT_SPIFFS_IF_FAILED true #define FORMAT_SPIFFS_IF_FAILED true
/*------------ SOUND EFFECTS ----------*/ /*------------ SOUND EFFECTS ----------*/
// Buzzer volume control: duty cycle out of 1023 (512 = 100% max loud, 40 = soft, gentle chirp)
const uint16_t CASIO_BEEP_DUTY = 40;
// Classic Casio Watch Beep (F-91W / G-Shock Module 593: 32768 / 16 = 2048 Hz, exact C7 note) // Classic Casio Watch Beep (F-91W / G-Shock Module 593: 32768 / 16 = 2048 Hz, exact C7 note)
inline void casioBeep(uint16_t freq = 2048, uint8_t duration_ms = 24) { inline void casioBeep(uint16_t freq = 2048, uint8_t duration_ms = 20, uint16_t duty = CASIO_BEEP_DUTY) {
ledcWriteTone(buzzerChannel, freq); ledcSetup(buzzerChannel, freq, 10);
ledcWrite(buzzerChannel, duty);
delay(duration_ms); delay(duration_ms);
ledcWriteTone(buzzerChannel, 0); ledcWrite(buzzerChannel, 0);
} }
void beepbeep() { void beepbeep() {
casioBeep(2048, 35); casioBeep(2048, 30);
delay(35); delay(30);
casioBeep(2048, 35); casioBeep(2048, 30);
} }
void beep() { void beep() {
casioBeep(2048, 200); casioBeep(2048, 150);
} }
void clickSound() { void clickSound() {
casioBeep(2048, 24); casioBeep(2048, 20);
} }
// Configuration menu list // Configuration menu list

View file

@ -1270,13 +1270,6 @@ void updateMeter(uint8_t pidNo, String response) { // update parameter on screen
last_valid_data[pidNo] = data; last_valid_data[pidNo] = data;
// Alarm warning audio alert
if (warn > 0 && data >= warn) {
ledcWriteTone(buzzerChannel, 2000);
delay(10);
ledcWriteTone(buzzerChannel, 0);
}
if (fullScreenCell >= 0 && fullScreenCell < 4) { if (fullScreenCell >= 0 && fullScreenCell < 4) {
if (pidNo == fullScreenCell) { if (pidNo == fullScreenCell) {
plotFullScreen(fullScreenCell, data, warn, min, max, digit, unit); plotFullScreen(fullScreenCell, data, warn, min, max, digit, unit);

View file

@ -361,19 +361,19 @@ void loop() {
static int8_t clickQuadrant = -1; static int8_t clickQuadrant = -1;
static bool longPressHandled = false; static bool longPressHandled = false;
if (isTouched || btnPressed) { if (isTouched) {
if (!isTouching) { if (!isTouching) {
isTouching = true; isTouching = true;
touchStartTime = millis(); touchStartTime = millis();
lastTouchX = touchX; lastTouchX = touchX;
lastTouchY = touchY; lastTouchY = touchY;
longPressHandled = false; longPressHandled = false;
casioBeep(2048, 24); // Instant Casio beep on every screen touch! casioBeep(2048, 20); // Soft, instant Casio beep ONLY on touch screen press!
} else if (!longPressHandled && (millis() - touchStartTime > 1000)) { } else if (!longPressHandled && (millis() - touchStartTime > 1000)) {
// Long press (> 1s) or button hold: Open Config Menu! // Long press (> 1s): Open Config Menu!
longPressHandled = true; longPressHandled = true;
clickCount = 0; clickCount = 0;
casioBeep(4096, 35); // High confirmation beep casioBeep(4096, 30); // High confirmation chirp
configMenu(); configMenu();
if (foundOBD2) initScreen(); if (foundOBD2) initScreen();
isTouching = false; isTouching = false;

View file

@ -29,12 +29,15 @@ bool getTouch(uint16_t *x, uint16_t *y) {
if (ts.touched(tsSoftSpi)) { if (ts.touched(tsSoftSpi)) {
TS_Point p = ts.getPoint(tsSoftSpi); TS_Point p = ts.getPoint(tsSoftSpi);
// Filter noise: require solid touch pressure and coordinates within active screen
if (p.z < 600) return false;
if (p.x < 150 || p.x > 3850 || p.y < 150 || p.y > 3850) return false;
int16_t tx = map(p.x, 200, 3700, 0, 320); int16_t tx = map(p.x, 200, 3700, 0, 320);
int16_t ty = map(p.y, 240, 3800, 0, 240); int16_t ty = map(p.y, 240, 3800, 0, 240);
*x = constrain(tx, 0, 319); *x = constrain(tx, 0, 319);
*y = constrain(ty, 0, 239); *y = constrain(ty, 0, 239);
Serial.printf("[TOUCH] raw:(%d,%d,z=%d) -> screen:(%d,%d)\n", p.x, p.y, p.z, *x, *y);
return true; return true;
} }
return false; return false;