Could be working version
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user