Beep only on screen touch, eliminate alarm beeps, and soften buzzer volume
This commit is contained in:
parent
c3b15d6c34
commit
8c666d3024
4 changed files with 20 additions and 20 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue