Skip to content

Commit 227cb53

Browse files
author
dingo35
committed
esp32.cpp: activate buzzer on v3.1 hardware
1 parent f3e0d5c commit 227cb53

File tree

4 files changed

+39
-4
lines changed

4 files changed

+39
-4
lines changed

SmartEVSE-3/src/OneWire.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ void CheckRFID(void) {
337337
break;
338338
}
339339
}
340+
if (RFIDstatus <= 3)
341+
BuzzConfirmation();
342+
else
343+
BuzzError();
340344
}
341345
#else //CH32
342346

SmartEVSE-3/src/esp32.cpp

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ const char StrStateNameWeb[15][17] = {"Ready to Charge", "Connected to EV", "Cha
139139
const char StrErrorNameWeb[9][20] = {"None", "No Power Available", "Communication Error", "Temperature High", "EV Meter Comm Error", "RCM Tripped", "Waiting for Solar", "Test IO", "Flash Error"};
140140
const char StrMode[3][8] = {"Normal", "Smart", "Solar"};
141141
const char StrRFIDStatusWeb[8][20] = {"Ready to read card","Present", "Card Stored", "Card Deleted", "Card already stored", "Card not in storage", "Card Storage full", "Invalid" };
142-
143-
// Global data
144-
142+
bool BuzzerPresent = false;
145143

146144
// The following data will be updated by eeprom/storage data at powerup:
147145
extern uint16_t MaxMains;
@@ -2552,6 +2550,33 @@ void WCHUPDATE(unsigned long RunningVersion) {
25522550
}
25532551
#endif
25542552

2553+
2554+
void BuzzConfirmation (void) {
2555+
if (!BuzzerPresent) return;
2556+
ledcWriteTone(6, 2637); // E7
2557+
ledcWrite(6, 128); // Buzzer: 50% duty cycle
2558+
delay(100);
2559+
ledcWriteTone(6, 2794); // F7
2560+
delay(100);
2561+
ledcWriteTone(6, 3136); // G7
2562+
delay(100);
2563+
ledcWrite(6, 0); // Buzzer off
2564+
}
2565+
2566+
2567+
void BuzzError (void) {
2568+
if (!BuzzerPresent) return;
2569+
ledcWriteTone(6, 3136); // G7
2570+
ledcWrite(6, 128); // Buzzer: 50% duty cycle
2571+
delay(100);
2572+
ledcWriteTone(6, 2794); // F7
2573+
delay(100);
2574+
ledcWriteTone(6, 2637); // E7
2575+
delay(100);
2576+
ledcWrite(6, 0); // Buzzer off
2577+
}
2578+
2579+
25552580
void setup() {
25562581
//detect if we are on 3.1 hardware version:
25572582
uint8_t chip_ver = (( *(volatile uint32_t *) 0x3ff5A00c) >> 9 ) & 7 ; // Read chip version directly from Efuses. 0=ESP32D0WDQ6 4=ESP32U4WDH
@@ -2565,6 +2590,10 @@ void setup() {
25652590
pinMode(PIN_EXT_V31, INPUT);
25662591
pinMode(PIN_BUZZER_V31, OUTPUT);
25672592
digitalWrite(PIN_BUZZER_V31, LOW);
2593+
ledcSetup(6, 4186, 8); // channel 6, 4kHz, 8bit
2594+
ledcAttachPin(PIN_BUZZER_V31, 6);
2595+
BuzzerPresent = true;
2596+
BuzzConfirmation();
25682597
} else { //SmartEVSE hw version 3.0 or 4.0
25692598
PIN_SW_IN = PIN_SW_IN_V30;
25702599
PIN_ACTA = PIN_ACTA_V30;

SmartEVSE-3/src/esp32.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,9 @@ void SetCPDuty(uint32_t DutyCycle);
218218
uint8_t setItemValue(uint8_t nav, uint16_t val);
219219
uint16_t getItemValue(uint8_t nav);
220220
void ConfigureModbusMode(uint8_t newmode);
221-
222221
void setMode(uint8_t NewMode) ;
222+
void BuzzConfirmation(void);
223+
void BuzzError(void);
223224

224225
#if ENABLE_OCPP && defined(SMARTEVSE_VERSION) //run OCPP only on ESP32
225226
void ocppUpdateRfidReading(const unsigned char *uuid, size_t uuidLen);

SmartEVSE-3/src/main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,5 @@ struct Node_t {
345345
uint8_t Mode;
346346
};
347347

348+
extern bool BuzzerPresent;
348349
#endif

0 commit comments

Comments
 (0)