Could be working version

This commit is contained in:
2024-04-12 15:18:31 +03:00
parent 5bb3ebe1bf
commit f8b62d4b00
19 changed files with 632 additions and 53 deletions

View File

@@ -25,6 +25,8 @@ hw::Button::Button(bsp::DigitalIn* din_ch, uint8_t act_lvl, uint8_t dbnc_lim, ui
this->time = 0;
this->is_new = 0;
this->hold_time = 0;
}
hw::Button::~Button(void)
@@ -40,6 +42,13 @@ uint8_t hw::Button::update(void)
// Increase state counter
this->time = util::sat_add(this->time, 1);
// Repeat new flag after hold time
if((this->state == BUTTON_ON)&&(this->time > this->hold_time)&&(this->hold_time > 0))
{
this->time = 0;
this->is_new = 1;
};
// Determine next state
uint8_t next_state = BUTTON_OFF;
if(lvl==this->act_lvl) next_state = BUTTON_ON;