diff --git a/Core/Src/main.cpp b/Core/Src/main.cpp index 93e21ce..679bc56 100644 --- a/Core/Src/main.cpp +++ b/Core/Src/main.cpp @@ -194,6 +194,8 @@ int main(void) { //Instantiate Input and Output modules io::PressureChannel tankLevel0(&hadc1, MPWR0_GPIO_Port, MPWR0_Pin, 50); + tankLevel0.LinkCalibConfig(globalConfig.TankCalibLow.getLink(), globalConfig.TankCalibHigh.getLink()); + io::GPIChannel refillBlocker0(GPI0_GPIO_Port, GPI0_Pin); io::RelayChannel tankPump(OCHAN0_GPIO_Port, OCHAN0_Pin, true, io::RelayChannel::state::OFF); io::RelayChannel refillPump(OCHAN1_GPIO_Port, OCHAN1_Pin, false, io::RelayChannel::state::OFF); @@ -214,19 +216,24 @@ int main(void) { while (1) { + display.LCDSetBacklight(false); display.LCDSetCursor(0,0); display.LCDSendCString(const_cast(std::string("Tank: " + std::to_string(tankLevel0.getPercent()) + " %").c_str())); display.LCDSetCursor(0, 1); if(tankLevel0.getPercent() < globalConfig.TankMinLevel.getValue()) { - display.LCDSendCString(const_cast(std::string("Tank Wassermangel").c_str())); + display.LCDSendCString(const_cast(std::string("Tank Wassermangel ").c_str())); } else { - display.LCDSendCString(const_cast(std::string("Tank Normal").c_str())); + display.LCDSendCString(const_cast(std::string("Tank Normal ").c_str())); } + display.LCDSetCursor(0,2); + + if(rot_button) { + display.LCDSetBacklight(true); rot_button = false; last_menu_retrigger = HAL_GetTick(); while(true) { diff --git a/Middlewares/floatpump/Inc/PressureChannel.h b/Middlewares/floatpump/Inc/PressureChannel.h index 0e2c58a..f30b711 100644 --- a/Middlewares/floatpump/Inc/PressureChannel.h +++ b/Middlewares/floatpump/Inc/PressureChannel.h @@ -30,13 +30,15 @@ namespace floatpump::io { void calibrateHigh(); + void LinkCalibConfig(uint16_t *low, uint16_t *high); + private: const uint16_t m_avg_size = 50; const uint16_t m_avg_delay = 10; const uint16_t m_cooldown = 500; - uint16_t m_lowcalib = 0; - uint16_t m_highcalib = 65535; + uint16_t *m_lowcalib = new uint16_t(0); + uint16_t *m_highcalib = new uint16_t(65535); uint16_t m_raw = 0; int8_t m_percent = 0; diff --git a/Middlewares/floatpump/Src/PressureChannel.cpp b/Middlewares/floatpump/Src/PressureChannel.cpp index 8b3ec7e..c4c9b0b 100644 --- a/Middlewares/floatpump/Src/PressureChannel.cpp +++ b/Middlewares/floatpump/Src/PressureChannel.cpp @@ -25,7 +25,7 @@ namespace floatpump::io { m_raw = average / m_avg_size; - m_percent = (int8_t) (((m_raw - m_lowcalib) * 100) / (m_highcalib - m_lowcalib)); + m_percent = (int8_t) (((m_raw - *m_lowcalib) * 100) / (*m_highcalib - *m_lowcalib)); } @@ -42,20 +42,25 @@ namespace floatpump::io { } void PressureChannel::calibrateManualLow(uint16_t low) { - m_lowcalib = low; + *m_lowcalib = low; } void PressureChannel::calibrateManualHigh(uint16_t high) { - m_highcalib = high; + *m_highcalib = high; } void PressureChannel::calibrateLow() { poll(); - m_lowcalib = m_raw; + *m_lowcalib = m_raw; } void PressureChannel::calibrateHigh() { poll(); - m_highcalib = m_raw; + *m_highcalib = m_raw; + } + + void PressureChannel::LinkCalibConfig(uint16_t *low, uint16_t *high) { + m_lowcalib = low; + m_highcalib = high; } } \ No newline at end of file