From 814a99f7330408b48561d7691879c3974f571dfa Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sun, 9 Oct 2022 21:48:16 +0200 Subject: [PATCH] Remove buzzer state variable --- buzzer.ino | 28 ++-------------------------- metronom.ino | 2 +- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/buzzer.ino b/buzzer.ino index 7edbc85..39ff25c 100644 --- a/buzzer.ino +++ b/buzzer.ino @@ -1,17 +1,13 @@ -#include - SAMDTimer BuzzerTimer(TIMER_TC5); + bool attached = false; void initBuzzer() { pinMode(BUZZER_PIN, OUTPUT); } -volatile bool buzzing = false; void buzzerISR() { - digitalWrite(BUZZER_PIN, buzzing ? LOW : HIGH); - buzzing = !buzzing; - //digitalToggle(BUZZER_PIN); + digitalWrite(BUZZER_PIN, !digitalRead(BUZZER_PIN)); } void buzz() { @@ -24,23 +20,3 @@ void buzz() { void noBuzz() { 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; -} -*/ diff --git a/metronom.ino b/metronom.ino index e2dc9ac..501be2c 100644 --- a/metronom.ino +++ b/metronom.ino @@ -32,7 +32,7 @@ void setup() { TaskTimer.attachInterruptInterval_MS(20, TasksHandler); TasksISRs.setInterval(PERIOD_MS, runMetronome); TasksISRs.setInterval(PERIOD_MS, readTemperature); - TasksISRs.setInterval(PERIOD_MS, updateTube); + TasksISRs.setInterval(200, updateTube); } void runMetronome() {