WrathPak
·
2025-04-24
polybuzzer.h
1#pragma once
2
3#include <Arduino.h>
4#define POLYBUZZER_MAX_TONES 2
5
6// PolyBuzzer provides a proritized monophonic buzzer.
7//
8// A given tone will only be played when all higher priority tones have stopped.
9class PolyBuzzer {
10public:
11 unsigned int tones[POLYBUZZER_MAX_TONES];
12 unsigned int playing;
13 uint8_t pin;
14
15 PolyBuzzer(uint8_t pin);
16 void update();
17 void Tone(int slot, unsigned int frequency);
18 void Note(int slot, uint8_t note);
19 void NoTone(int slot);
20
21 // Debug helper - print current state
22 void printDebugInfo() {
23 Serial.print("PolyBuzzer - Current tones: [");
24 for (int i = 0; i < POLYBUZZER_MAX_TONES; i++) {
25 Serial.print(tones[i]);
26 if (i < POLYBUZZER_MAX_TONES - 1) Serial.print(", ");
27 }
28 Serial.print("], Playing: ");
29 Serial.println(playing);
30 }
31};