Remove buzzer state variable
This commit is contained in:
28
buzzer.ino
28
buzzer.ino
@@ -1,17 +1,13 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
SAMDTimer BuzzerTimer(TIMER_TC5);
|
SAMDTimer BuzzerTimer(TIMER_TC5);
|
||||||
|
|
||||||
bool attached = false;
|
bool attached = false;
|
||||||
|
|
||||||
void initBuzzer() {
|
void initBuzzer() {
|
||||||
pinMode(BUZZER_PIN, OUTPUT);
|
pinMode(BUZZER_PIN, OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile bool buzzing = false;
|
|
||||||
void buzzerISR() {
|
void buzzerISR() {
|
||||||
digitalWrite(BUZZER_PIN, buzzing ? LOW : HIGH);
|
digitalWrite(BUZZER_PIN, !digitalRead(BUZZER_PIN));
|
||||||
buzzing = !buzzing;
|
|
||||||
//digitalToggle(BUZZER_PIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void buzz() {
|
void buzz() {
|
||||||
@@ -24,23 +20,3 @@ void buzz() {
|
|||||||
void noBuzz() {
|
void noBuzz() {
|
||||||
BuzzerTimer.disableTimer();
|
BuzzerTimer.disableTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// https://forum.arduino.cc/t/adding-a-toggle-function-to-wiring-digital-c/975608
|
|
||||||
void digitalToggle(uint8_t pin) {
|
|
||||||
uint8_t timer = digitalPinToTimer(pin);
|
|
||||||
uint8_t bit = digitalPinToBitMask(pin);
|
|
||||||
uint8_t port = digitalPinToPort(pin);
|
|
||||||
volatile uint8_t *out;
|
|
||||||
|
|
||||||
if (port == NOT_A_PIN) return;
|
|
||||||
if (timer != NOT_ON_TIMER) turnOffPWM(timer);
|
|
||||||
|
|
||||||
out = portOutputRegister(port);
|
|
||||||
|
|
||||||
uint8_t oldSREG = SREG;
|
|
||||||
cli();
|
|
||||||
*out ^= bit;
|
|
||||||
SREG = oldSREG;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void setup() {
|
|||||||
TaskTimer.attachInterruptInterval_MS(20, TasksHandler);
|
TaskTimer.attachInterruptInterval_MS(20, TasksHandler);
|
||||||
TasksISRs.setInterval(PERIOD_MS, runMetronome);
|
TasksISRs.setInterval(PERIOD_MS, runMetronome);
|
||||||
TasksISRs.setInterval(PERIOD_MS, readTemperature);
|
TasksISRs.setInterval(PERIOD_MS, readTemperature);
|
||||||
TasksISRs.setInterval(PERIOD_MS, updateTube);
|
TasksISRs.setInterval(200, updateTube);
|
||||||
}
|
}
|
||||||
|
|
||||||
void runMetronome() {
|
void runMetronome() {
|
||||||
|
|||||||
Reference in New Issue
Block a user