WIP: keep local changes before merging remote

This commit is contained in:
Filipriec
2025-11-13 14:42:47 +01:00
parent 915c573b27
commit 3c11e1dff8
9 changed files with 320 additions and 47 deletions

46
cvicenie_5/Button.cpp Normal file
View File

@@ -0,0 +1,46 @@
#include "Button.h"
// Constructor
Button::Button(PinName pin)
: button(pin)
{
counter = 0;
pressed = false;
button.rise(callback(this, &Button::interrupt)); // attach increment function of this counter instance
// set pin mode : PullUp / PullDown / PullNone / OpenDrain
};
void Button::interrupt()
{
pressed = true;
counter++;
if(counter >= 8)
counter=0;
};
// Destructor
Button::~Button()
{
};
bool Button::read(void)
{
return button.read();
};
bool Button::wasPressed(void)
{
if(pressed)
{
pressed = false;
return true;
}
else
return false;
};
uint16_t Button::getCount(void)
{
return counter;
};