From 8449ca098e4635b195edddab3b1713ca926a73ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andis=20Z=C4=ABle?= Date: Sat, 13 Apr 2024 12:27:58 +0300 Subject: [PATCH] Added lock --- firmware/src/hw/display_led.cpp | 15 +++++++++++++++ firmware/src/hw/display_led.h | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/firmware/src/hw/display_led.cpp b/firmware/src/hw/display_led.cpp index 801d0da..af9085b 100644 --- a/firmware/src/hw/display_led.cpp +++ b/firmware/src/hw/display_led.cpp @@ -30,6 +30,9 @@ hw::DisplayLed::DisplayLed(bsp::DigitalOut* led0, bsp::DigitalOut* led1, bsp::Di this->led4->write(0); this->led5->write(0); this->common->write(0); + + this->lock_counter = 0; + this->locked = 1; } hw::DisplayLed::~DisplayLed(void) @@ -91,6 +94,18 @@ void hw::DisplayLed::set_brigthness(uint8_t percent) this->common->write(percent); } +void hw::DisplayLed::set_lock(uint16_t timeout) +{ + this->lock_counter = timeout; + this->locked = 1; +} + +void hw::DisplayLed::process_timer(void) +{ + if(this->lock_counter) this->lock_counter--; + else this->locked = 0; +} + /**** Private function definitions ****/ static uint8_t img_gen_dot10(uint8_t percent) { diff --git a/firmware/src/hw/display_led.h b/firmware/src/hw/display_led.h index 455e5ad..6e73567 100644 --- a/firmware/src/hw/display_led.h +++ b/firmware/src/hw/display_led.h @@ -21,6 +21,8 @@ class DisplayLed bsp::DigitalOut* led5; bsp::PWMout* common; + uint16_t lock_counter; + public: typedef enum { LED_DSP_DOT20, @@ -35,6 +37,11 @@ class DisplayLed void write(uint8_t image); void set_brigthness(uint8_t percent); + + void set_lock(uint16_t timeout); + void process_timer(void); + + uint8_t locked; }; /**** Public function declarations ****/