diff --git a/sketch/obd2_gauge/config.h b/sketch/obd2_gauge/config.h index 7f8b1fc..e48ae60 100644 --- a/sketch/obd2_gauge/config.h +++ b/sketch/obd2_gauge/config.h @@ -9,25 +9,29 @@ Configuration menu for OBD2 Gauge #define FORMAT_SPIFFS_IF_FAILED true /*------------ 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) -inline void casioBeep(uint16_t freq = 2048, uint8_t duration_ms = 24) { - ledcWriteTone(buzzerChannel, freq); +inline void casioBeep(uint16_t freq = 2048, uint8_t duration_ms = 20, uint16_t duty = CASIO_BEEP_DUTY) { + ledcSetup(buzzerChannel, freq, 10); + ledcWrite(buzzerChannel, duty); delay(duration_ms); - ledcWriteTone(buzzerChannel, 0); + ledcWrite(buzzerChannel, 0); } void beepbeep() { - casioBeep(2048, 35); - delay(35); - casioBeep(2048, 35); + casioBeep(2048, 30); + delay(30); + casioBeep(2048, 30); } void beep() { - casioBeep(2048, 200); + casioBeep(2048, 150); } void clickSound() { - casioBeep(2048, 24); + casioBeep(2048, 20); } // Configuration menu list diff --git a/sketch/obd2_gauge/meter.h b/sketch/obd2_gauge/meter.h index 4730c30..0ee3a6e 100644 --- a/sketch/obd2_gauge/meter.h +++ b/sketch/obd2_gauge/meter.h @@ -1270,13 +1270,6 @@ void updateMeter(uint8_t pidNo, String response) { // update parameter on screen 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 (pidNo == fullScreenCell) { plotFullScreen(fullScreenCell, data, warn, min, max, digit, unit); diff --git a/sketch/obd2_gauge/obd2_gauge.ino b/sketch/obd2_gauge/obd2_gauge.ino index 39a7aa9..395445e 100644 --- a/sketch/obd2_gauge/obd2_gauge.ino +++ b/sketch/obd2_gauge/obd2_gauge.ino @@ -361,19 +361,19 @@ void loop() { static int8_t clickQuadrant = -1; static bool longPressHandled = false; - if (isTouched || btnPressed) { + if (isTouched) { if (!isTouching) { isTouching = true; touchStartTime = millis(); lastTouchX = touchX; lastTouchY = touchY; 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)) { - // Long press (> 1s) or button hold: Open Config Menu! + // Long press (> 1s): Open Config Menu! longPressHandled = true; clickCount = 0; - casioBeep(4096, 35); // High confirmation beep + casioBeep(4096, 30); // High confirmation chirp configMenu(); if (foundOBD2) initScreen(); isTouching = false; diff --git a/sketch/obd2_gauge/touchscreen.h b/sketch/obd2_gauge/touchscreen.h index 8034015..9695b6d 100644 --- a/sketch/obd2_gauge/touchscreen.h +++ b/sketch/obd2_gauge/touchscreen.h @@ -29,12 +29,15 @@ bool getTouch(uint16_t *x, uint16_t *y) { if (ts.touched(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 ty = map(p.y, 240, 3800, 0, 240); *x = constrain(tx, 0, 319); *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 false;