GPIO22 digital on/off toggle (default off) and flashable firmware/cyd package. Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
451 B
C++
26 lines
451 B
C++
#include "buzzer.h"
|
|
#include "pins.h"
|
|
|
|
#include <Arduino.h>
|
|
|
|
static bool g_on = false;
|
|
|
|
static void apply() {
|
|
digitalWrite(BUZZER_PIN, g_on ? HIGH : LOW);
|
|
}
|
|
|
|
void buzzer_init() {
|
|
pinMode(BUZZER_PIN, OUTPUT);
|
|
g_on = false;
|
|
apply();
|
|
Serial.printf("Buzzer GPIO%d OFF (default)\n", BUZZER_PIN);
|
|
}
|
|
|
|
void buzzer_set_on(bool on) {
|
|
g_on = on;
|
|
apply();
|
|
Serial.printf("Buzzer %s\n", g_on ? "ON" : "OFF");
|
|
}
|
|
|
|
bool buzzer_is_on() { return g_on; }
|