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