/*
* button_ISR_global.ino
* Digital - class developement and module test
* author: Rad!hu
* date: 2023/10/09
* update: 2024/11/13
*/
#include "digital.hpp"
#include "arduino_timer.h"
DigitalOut buzzer;
SR_FF button;
auto timer = timer_create_default();
bool timer_activated = false;
void toggle_buzzer();
void setup() {
Serial.begin(9600);
timer.every(125, toggle_buzzer); // makes the timer execute toggle_buzzer every 0.125 seconds
}
void loop() { // activates and deactivates the timer when the button is pushed
if(button.isPushed()) {
timer_activated = !timer_activated;
button.reset();
buzzer.switchOff();
}
if(timer_activated) { // the timer needs to be ticked to funktion.
timer.tick();
}
}
void toggle_buzzer() {
buzzer.toggle();
}