diff --git a/Core/Inc/git_rev.h b/Core/Inc/git_rev.h index ed74d6f..8dcdea0 100644 --- a/Core/Inc/git_rev.h +++ b/Core/Inc/git_rev.h @@ -7,6 +7,6 @@ // Auto generated header file containing the last git revision -#define GIT_HASH "a7d18ec" +#define GIT_HASH "59fdd3a" #endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H \ No newline at end of file diff --git a/Core/Src/main.cpp b/Core/Src/main.cpp index b043252..b0b6821 100644 --- a/Core/Src/main.cpp +++ b/Core/Src/main.cpp @@ -17,6 +17,7 @@ #include "PressureChannel.h" #include "RelayChannel.h" #include "GPIChannel.h" +#include "Menu_Entry_Type_Execute.h" #define SLAVE_ADDRESS_LCD 0x4e @@ -86,113 +87,163 @@ int main(void) { /// /// - using namespace floatpump::menu; - Menu mainmenu("Hauptmenu"); - Menu_Entry_Type_Checkable entry1bool(false), entry2bool(false); - - bool l_calib, h_calib = false; - uint8_t cur_perc = 0; - uint32_t current = 0; - uint16_t prescaler = 0; - uint32_t curCooldown = 0; - - entry1bool.linkConfig(&l_calib); - entry2bool.linkConfig(&h_calib); - - Menu_Entry entry(entry1bool, "Low Calib"); - Menu_Entry entry2(entry2bool, "High Calib"); - - Menu_Entry_Type_Percent entry1perc(15); - Menu_Entry entry3(entry1perc, "Pegel Schalten"); - - Menu_Entry_Type_ReadOnly entry1read(0); - entry1read.linkConfig(¤t); - Menu_Entry entry4(entry1read, "Pegel"); - - Menu_Entry_Type_ReadOnly entry2read(0); - entry2read.linkConfig(&cur_perc); - Menu_Entry entry5(entry2read, "Pegel Proz"); - - mainmenu.addEntry(entry); - mainmenu.addEntry(entry2); - mainmenu.addEntry(entry3); - mainmenu.addEntry(entry4); - mainmenu.addEntry(entry5); - - Menu_Entry_Type_ReadOnly cdd(0); - cdd.linkConfig(&curCooldown); - Menu_Entry entry6(cdd, "Cooldown"); - - Menu_Entry_Type_Checkable tr(false); - bool inputTest; - tr.linkConfig(&inputTest); - Menu_Entry entry7(tr, "Input"); - - mainmenu.addEntry(entry7); + using namespace floatpump; - Menu_Controller controller(&mainmenu, display); + menu::Menu tankmenu("Tank"); - floatpump::io::PressureChannel channel(&hadc1, MPWR0_GPIO_Port, MPWR0_Pin); - floatpump::io::RelayChannel relay(OCHAN0_GPIO_Port, OCHAN0_Pin, false); - floatpump::io::GPIChannel swimmer(GPI0_GPIO_Port, GPI0_Pin, false); + bool a_caliblow, a_calibhigh = false; + menu::Menu_Entry_Type_Execute t_exCalibLow; + menu::Menu_Entry_Type_Execute t_exCalibHigh; + t_exCalibLow.linkConfig(&a_caliblow); + t_exCalibHigh.linkConfig(&a_calibhigh); + menu::Menu_Entry exCalibLow(t_exCalibLow, "Kal. Unt. Punkt"); + menu::Menu_Entry exCalibHigh(t_exCalibHigh, "Kal. Unt. Punkt"); + + menu::Menu_Entry_Type_Numeric t_CalibLow(0); + menu::Menu_Entry_Type_Numeric t_CalibHigh(65535); + t_CalibLow.linkConfig(globalConfig.TankCalibLow.getLink()); + t_CalibHigh.linkConfig(globalConfig.TankCalibHigh.getLink()); + menu::Menu_Entry CalibLow(t_CalibLow, "K Unten"); + menu::Menu_Entry CalibHigh(t_CalibHigh, "K Oben"); + + menu::Menu_Entry_Type_Percent t_tankLevel(25); + t_tankLevel.linkConfig(globalConfig.TankMinLevel.getLink()); + menu::Menu_Entry TankLevel(t_tankLevel, "Min. Fuellst."); + + menu::Menu_Entry_Type_Percent t_tankHysteresis(5); + t_tankHysteresis.linkConfig(globalConfig.TankHysteresis.getLink()); + menu::Menu_Entry TankHysteresis(t_tankHysteresis, "Hysterese"); + + menu::Menu_Entry_Type_Checkable t_tankInvert(false); + t_tankInvert.linkConfig(globalConfig.TankPumpInvert.getLink()); + menu::Menu_Entry TankInvert(t_tankInvert, "Inv. Relais"); + + tankmenu.addEntry(exCalibLow); + tankmenu.addEntry(exCalibHigh); + tankmenu.addEntry(CalibLow); + tankmenu.addEntry(CalibHigh); + tankmenu.addEntry(TankLevel); + tankmenu.addEntry(TankHysteresis); + tankmenu.addEntry(TankInvert); + + + menu::Menu refillmenu("Nachspeisung"); + + menu::Menu_Entry_Type_Checkable t_refillEnable(false); + menu::Menu_Entry_Type_Checkable t_refillBlock(true); + menu::Menu_Entry_Type_Checkable t_refillBlockInvert(false); + t_refillEnable.linkConfig(globalConfig.RefillEnable.getLink()); + t_refillBlock.linkConfig(globalConfig.RefillBlockEnable.getLink()); + t_refillBlockInvert.linkConfig(globalConfig.RefillBlockInvert.getLink()); + menu::Menu_Entry refillEnable(t_refillEnable, "Nachsp. akt."); + menu::Menu_Entry refillBlock(t_refillBlock, "Notabschalt."); + menu::Menu_Entry refillBlockInvert(t_refillBlockInvert, "NotAbs. Inv."); + + menu::Menu_Entry_Type_Percent t_RefillBelow(20); + menu::Menu_Entry_Type_Percent t_RefillHysteresis(5); + t_RefillBelow.linkConfig(globalConfig.RefillBelow.getLink()); + t_RefillHysteresis.linkConfig(globalConfig.RefillHysteresis.getLink()); + menu::Menu_Entry refillBelow(t_RefillBelow, "Auff. bis"); + menu::Menu_Entry refillHysteresis(t_RefillHysteresis, "Hysterese"); + + refillmenu.addEntry(refillEnable); + refillmenu.addEntry(refillBlock); + refillmenu.addEntry(refillBlockInvert); + refillmenu.addEntry(refillBelow); + refillmenu.addEntry(refillHysteresis); - relay.setCooldown(10000); + menu::Menu mainmenu("Hauptmenu"); + mainmenu.addSubmenu(&tankmenu); + mainmenu.addSubmenu(&refillmenu); + menu::Menu_Controller controller(&mainmenu, display); static int old_pos = 0; + while (1) { //render menu controller.execute(); if (rot_button) { rot_button = false; - controller.pushEvent(Menu_Controller::Event::Push); + controller.pushEvent(menu::Menu_Controller::Event::Push); } if (old_pos < rot_counter) { - controller.pushEvent(Menu_Controller::Event::Increase); + controller.pushEvent(menu::Menu_Controller::Event::Increase); old_pos = rot_counter; } else if (old_pos > rot_counter) { - controller.pushEvent(Menu_Controller::Event::Decrease); + controller.pushEvent(menu::Menu_Controller::Event::Decrease); old_pos = rot_counter; } HAL_Delay(100); - - if(l_calib) { - relay.switchRelay(floatpump::io::RelayChannel::state::ON); - } - //channel.calibrateLow(); - - if(h_calib) { - relay.switchRelay(floatpump::io::RelayChannel::state::OFF); - } - //channel.calibrateHigh(); - - l_calib = false; - h_calib = false; - - curCooldown = relay.getRemainingCooldown(); - - prescaler++; - - - swimmer.poll(); - if(prescaler % 100 == 0) - channel.poll(); - - current = channel.getRaw(); - cur_perc = channel.getPercent(); - inputTest = swimmer.getStateBool(); - - /*if(cur_perc > 50) { - relay.switchRelay(floatpump::io::RelayChannel::state::ON); - } else if(cur_perc < 45) { - relay.switchRelay(floatpump::io::RelayChannel::state::OFF); - }*/ } + +// Menu_Controller controller(&mainmenu, display); +// +// floatpump::io::PressureChannel channel(&hadc1, MPWR0_GPIO_Port, MPWR0_Pin); +// floatpump::io::RelayChannel relay(OCHAN0_GPIO_Port, OCHAN0_Pin, false); +// floatpump::io::GPIChannel swimmer(GPI0_GPIO_Port, GPI0_Pin, false); +// +// +// +// relay.setCooldown(10000); +// +// static int old_pos = 0; +// while (1) { +// +// //render menu +// controller.execute(); +// if (rot_button) { +// rot_button = false; +// controller.pushEvent(Menu_Controller::Event::Push); +// } +// +// if (old_pos < rot_counter) { +// controller.pushEvent(Menu_Controller::Event::Increase); +// old_pos = rot_counter; +// } else if (old_pos > rot_counter) { +// controller.pushEvent(Menu_Controller::Event::Decrease); +// old_pos = rot_counter; +// } +// HAL_Delay(100); +// +// +// if(l_calib) { +// relay.switchRelay(floatpump::io::RelayChannel::state::ON); +// } +// //channel.calibrateLow(); +// +// if(h_calib) { +// relay.switchRelay(floatpump::io::RelayChannel::state::OFF); +// } +// //channel.calibrateHigh(); +// +// l_calib = false; +// h_calib = false; +// +// curCooldown = relay.getRemainingCooldown(); +// +// prescaler++; +// +// +// swimmer.poll(); +// if(prescaler % 100 == 0) +// channel.poll(); +// +// current = channel.getRaw(); +// cur_perc = channel.getPercent(); +// inputTest = swimmer.getStateBool(); +// +// /*if(cur_perc > 50) { +// relay.switchRelay(floatpump::io::RelayChannel::state::ON); +// } else if(cur_perc < 45) { +// relay.switchRelay(floatpump::io::RelayChannel::state::OFF); +// }*/ +// } } diff --git a/Middlewares/floatpump/Inc/Config_Store.h b/Middlewares/floatpump/Inc/Config_Store.h index a94d75b..a820974 100644 --- a/Middlewares/floatpump/Inc/Config_Store.h +++ b/Middlewares/floatpump/Inc/Config_Store.h @@ -40,8 +40,21 @@ namespace floatpump { T m_data; }; + Config_Object TankCalibLow = Config_Object(0); + Config_Object TankCalibHigh = Config_Object(65535); + Config_Object TankMinLevel = Config_Object(20); + Config_Object TankHysteresis = Config_Object(5); + Config_Object TankCooldown = Config_Object(5); + Config_Object TankZeroLevelCM = Config_Object(0); + Config_Object TankFullLevelCM = Config_Object(200); + Config_Object TankPumpInvert = Config_Object(false); - Config_Object testbool = Config_Object(false); + Config_Object RefillEnable = Config_Object(false); + Config_Object RefillBlockInvert = Config_Object(false); + Config_Object RefillBlockEnable = Config_Object(true); + Config_Object RefillBelow = Config_Object(false); + Config_Object RefillHysteresis = Config_Object(false); + Config_Object RefillCooldown = Config_Object(60); }; } // floatpump