Hintergrundbeleuchtung geht nach 3 Minuten aus und mit dem ersten Tastendruck wieder an
This commit is contained in:
parent
8b070887e9
commit
30531b4c0b
@ -27,18 +27,23 @@ namespace ElektronischeLast
|
||||
this->debounceTimer = systick;
|
||||
}
|
||||
|
||||
void Button::cyclic(void)
|
||||
bool Button::cyclic(void)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
if((systick - this->debounceTimer) > this->debounce)
|
||||
{
|
||||
bool state = LL_GPIO_IsInputPinSet(this->port, this->pin);
|
||||
this->stateLast = this->state;
|
||||
if(state != this->state)
|
||||
{
|
||||
changed = true;
|
||||
this->debounceTimer = systick;
|
||||
this->state = state;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
bool Button::isPressed(void)
|
||||
|
@ -23,7 +23,7 @@ namespace ElektronischeLast
|
||||
uint32_t debounceTimer;
|
||||
public:
|
||||
void init(GPIO_TypeDef* port, uint16_t pin);
|
||||
void cyclic(void);
|
||||
bool cyclic(void);
|
||||
bool isPressed(void);
|
||||
bool isReleased(void);
|
||||
};
|
||||
|
@ -17,7 +17,8 @@
|
||||
|
||||
namespace ElektronischeLast
|
||||
{
|
||||
static Timer timer = Timer();
|
||||
static Timer timer_MainScreen = Timer();
|
||||
static Timer timer_Backlight = Timer();
|
||||
static Button ok = Button();
|
||||
static Button up = Button();
|
||||
static Button down = Button();
|
||||
@ -28,7 +29,8 @@ namespace ElektronischeLast
|
||||
|
||||
void Menu::init()
|
||||
{
|
||||
timer.start(500U);
|
||||
timer_MainScreen.start(500U);
|
||||
timer_Backlight.start(3UL * 60UL * 1000UL);
|
||||
ok.init(GPIOA, LL_GPIO_PIN_7);
|
||||
up.init(GPIOA, LL_GPIO_PIN_9);
|
||||
down.init(GPIOA, LL_GPIO_PIN_8);
|
||||
@ -76,9 +78,27 @@ namespace ElektronischeLast
|
||||
|
||||
void Menu::run()
|
||||
{
|
||||
ok.cyclic();
|
||||
up.cyclic();
|
||||
down.cyclic();
|
||||
if(ok.cyclic())
|
||||
{
|
||||
timer_Backlight.restart();
|
||||
lcd.set_backlight(true);
|
||||
}
|
||||
if(up.cyclic())
|
||||
{
|
||||
timer_Backlight.restart();
|
||||
lcd.set_backlight(true);
|
||||
}
|
||||
if(down.cyclic())
|
||||
{
|
||||
timer_Backlight.restart();
|
||||
lcd.set_backlight(true);
|
||||
}
|
||||
|
||||
if(timer_Backlight.elapsed())
|
||||
{
|
||||
lcd.set_backlight(false);
|
||||
this->menu_locked = true;
|
||||
}
|
||||
|
||||
switch(menu_level)
|
||||
{
|
||||
@ -110,11 +130,11 @@ namespace ElektronischeLast
|
||||
|
||||
void Menu::menu_main(void)
|
||||
{
|
||||
if(timer.elapsed())
|
||||
if(timer_MainScreen.elapsed())
|
||||
{
|
||||
if(lcd.ready_for_data())
|
||||
{
|
||||
timer.start(500U);
|
||||
timer_MainScreen.start(500U);
|
||||
|
||||
char data[17U];
|
||||
|
||||
@ -143,10 +163,17 @@ namespace ElektronischeLast
|
||||
|
||||
if(ok.isReleased())
|
||||
{
|
||||
if(this->menu_locked)
|
||||
{
|
||||
this->menu_locked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->menu_level = MenuLevel_ISoll;
|
||||
this->configurations = 0UL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::menu_call(void)
|
||||
{
|
||||
|
@ -38,6 +38,8 @@ namespace ElektronischeLast
|
||||
|
||||
uint8_t configurations = 0U;
|
||||
|
||||
bool menu_locked = false;
|
||||
|
||||
void menu_main(void);
|
||||
void menu_call(void);
|
||||
void menu_icall_init(void);
|
||||
|
@ -22,6 +22,12 @@ namespace ElektronischeLast
|
||||
this->isRunning = true;
|
||||
}
|
||||
|
||||
void Timer::restart(void)
|
||||
{
|
||||
this->timer_start = systick;
|
||||
this->isRunning = true;
|
||||
}
|
||||
|
||||
void Timer::stop(void)
|
||||
{
|
||||
this->isRunning = false;
|
||||
|
@ -21,6 +21,7 @@ namespace ElektronischeLast
|
||||
public:
|
||||
Timer();
|
||||
void start(uint32_t durationMs);
|
||||
void restart(void);
|
||||
void stop(void);
|
||||
bool elapsed(void);
|
||||
void tick(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user