From e068d199bb5b0c345f217e0d8341cdd9b61346af Mon Sep 17 00:00:00 2001 From: Carsten Keller Date: Sun, 9 Jun 2024 17:58:27 +0200 Subject: [PATCH] =?UTF-8?q?Kalibrierung=20=C3=BCber=20Display=20hinzugef?= =?UTF-8?q?=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/ElektronischeLast.cpp | 22 ++++-- Source/ElektronischeLast.hpp | 4 +- Source/Menu.cpp | 138 +++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 7 deletions(-) diff --git a/Source/ElektronischeLast.cpp b/Source/ElektronischeLast.cpp index 18e1420..17842ce 100644 --- a/Source/ElektronischeLast.cpp +++ b/Source/ElektronischeLast.cpp @@ -166,6 +166,20 @@ void set_new_sollstrom(uint32_t soll) i_soll = soll; } +void start_icall(void) +{ + spannung = 0UL; + strom = 0UL; + modus = icall; +} + +void start_ucall(void) +{ + spannung = 0UL; + strom = 0UL; + modus = ucall; +} + /** * @brief Callback Function for Command Line * @param [in] pfvOutFunction Function to Print Data to Output @@ -249,17 +263,13 @@ uint16_t set_dutyCyle (CLI_OutFunction pfvOutFunction, char *acCommands[], uint1 } uint16_t set_ucall(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount) { - spannung = 0UL; - strom = 0UL; - modus = ucall; + start_ucall(); return 0U; } uint16_t set_icall(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount) { - spannung = 0UL; - strom = 0UL; - modus = icall; + start_icall(); return 0U; } diff --git a/Source/ElektronischeLast.hpp b/Source/ElektronischeLast.hpp index 89ffa14..ad25d01 100644 --- a/Source/ElektronischeLast.hpp +++ b/Source/ElektronischeLast.hpp @@ -13,5 +13,7 @@ void set_new_sollstrom(uint32_t soll); uint32_t get_current_sollstrom(void); +void start_icall(void); +void start_ucall(void); -#endif /* ELEKTRONISCHELAST_HPP_ */ +#endif diff --git a/Source/Menu.cpp b/Source/Menu.cpp index d7c26ef..38014c6 100644 --- a/Source/Menu.cpp +++ b/Source/Menu.cpp @@ -57,6 +57,13 @@ namespace ElektronischeLast } lcd.lcd_set_display(Display::eDispalyOn, Display::eCursorOff, Display::eCursorBlinkOff); lcd.print(Display::Line1, "Elektronische Last"); + + up.cyclic(); + down.cyclic(); + if(up.isPressed() && down.isPressed()) + { + menu_level = MenuLevel_Call; + } } void Menu::set_measurements(uint32_t spannung, uint32_t strom, uint32_t temperatur, uint32_t geschwindigkeit) @@ -143,22 +150,153 @@ namespace ElektronischeLast void Menu::menu_call(void) { + if(lcd.ready_for_data()) + { + switch(this->configurations) + { + case 0UL: + lcd.print(Display::Line1, "Kalibrierung: I"); + lcd.print(Display::Line2, "Kalibrierung: U"); + this->configurations++; + break; + case 1UL: + lcd.lcd_set_display(Display::eDispalyOn, Display::eCursorOn, Display::eCursorBlinkOn); + this->configurations++; + break; + case 2UL: + lcd.set_cursor(Display::Line1, 15U); + this->configurations++; + this->cursor = 1UL; + break; + default: + break; + } + } + + if(ok.isReleased()) + { + if(this->cursor == 1UL) + { + this->menu_level = MenuLevel_ICallInit; + } + else if(this->cursor == 2UL) + { + this->menu_level = MenuLevel_UCallInit; + } + this->configurations = 0UL; + } + else if(up.isReleased()) + { + if(this->cursor == 1UL) + { + this->cursor = 2UL; + lcd.set_cursor(Display::Line2, 15U); + } + else if(this->cursor == 2UL) + { + this->cursor = 1UL; + lcd.set_cursor(Display::Line1, 15U); + } + } + else if(down.isReleased()) + { + if(this->cursor == 1UL) + { + this->cursor = 2UL; + lcd.set_cursor(Display::Line2, 15U); + } + else if(this->cursor == 2UL) + { + this->cursor = 1UL; + lcd.set_cursor(Display::Line1, 15U); + } + } } void Menu::menu_icall_init(void) { + char data[17U]; + if(lcd.ready_for_data()) + { + switch(this->configurations) + { + case 0UL: + set_new_sollstrom(1000UL); + soll = get_current_sollstrom(); + snprintf(data, sizeof(data), "iSoll: %5" PRIu32 "mA", soll); + lcd.print(Display::Line1, "Stelle 1A ein "); + lcd.print(Display::Line2, data); + this->configurations++; + break; + case 1UL: + lcd.set_cursor(Display::Line2, 13UL); + this->configurations++; + break; + default: + break; + } + } + + if(ok.isReleased()) + { + this->menu_level = MenuLevel_ICall; + this->configurations = 0UL; + } + else if(down.isReleased()) + { + soll--; + set_new_sollstrom(soll); + snprintf(data, sizeof(data), "iSoll: %5" PRIu32 "mA", soll); + lcd.print(Display::Line2, data); + this->configurations = 1UL; + } + else if(up.isReleased()) + { + soll++; + set_new_sollstrom(soll); + snprintf(data, sizeof(data), "iSoll: %5" PRIu32 "mA", soll); + lcd.print(Display::Line2, data); + this->configurations = 1UL; + } } void Menu::menu_icall(void) { + if(this->configurations == 0UL) + { + start_icall(); + lcd.print(Display::Line1, "Kalibrierung... "); + lcd.print(Display::Line2, " "); + this->configurations++; + } } void Menu::menu_ucall_init(void) { + if(this->configurations == 0UL) + { + set_new_sollstrom(0UL); + lcd.print(Display::Line1, "Lege 15V an "); + lcd.print(Display::Line2, " "); + this->configurations++; + } + + if(ok.isReleased()) + { + this->menu_level = MenuLevel_UCall; + this->configurations = 0UL; + } } void Menu::menu_ucall(void) { + if(this->configurations == 0UL) + { + start_ucall(); + lcd.print(Display::Line1, "Kalibrierung... "); + lcd.print(Display::Line2, " "); + this->configurations++; + } } void Menu::menu_isoll(void)