Files
activeBuzzerTest/src/buzzer.cpp
DESKTOP-PUHFO60\dsx2016 d71ee19edd Add active buzzer test with SoftSPI touch and LVGL.
GPIO22 digital on/off toggle (default off) and flashable firmware/cyd package.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-23 13:25:19 +08:00

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; }