Update stable version 24/05/2025 #2

Merged
rafa merged 29 commits from dev into main 2025-05-24 20:00:44 +02:00
Showing only changes of commit 6b4835d1da - Show all commits

40
code/ButtonController.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <Arduino.h>
class ButtonController {
private:
int pin;
int new_value;
int old_value = HIGH;
public:
ButtonController(int pin){
this->set_pin(pin);
};
void configure_pins(){
pinMode(this->pin, INPUT_PULLUP);
}
void set_pin(int pin){
this->pin = pin;
}
void read(){
this->new_value = digitalRead(this->pin);
}
bool value_changed(){
return (this->new_value != this->old_value);
}
bool is_pressed(){
if(this->value_changed()){
bool is_pressed = (this->new_value == LOW);
this->old_value = this->new_value;
return is_pressed;
}
return this->new_value == LOW;
}
};