FEATURE: automatic backlight control

This commit is contained in:
Robin Dietzel 2023-01-13 13:50:40 +01:00
parent 503675d46b
commit 97d690fac1
2 changed files with 24 additions and 6 deletions

View File

@ -7,6 +7,6 @@
// Auto generated header file containing the last git revision
#define GIT_HASH "79077af"
#define GIT_HASH "cf1254c"
#endif //FLOATPUMP_GIT_REVISION_TEMPLATE_H

View File

@ -70,7 +70,7 @@ void CheckTankConditions(Config_Store &cfg, io::PressureChannel &tankLevel, io::
void CheckRefillConditions(Config_Store &cfg, io::PressureChannel &tankLevel, io::GPIChannel &refillBlock,
io::RelayChannel &refillPump) {
bool rblock = (cfg.RefillBlockInvert.getValue())? !refillBlock.getStateBool() : refillBlock.getStateBool();
bool rblock = (cfg.RefillBlockInvert.getValue()) ? !refillBlock.getStateBool() : refillBlock.getStateBool();
if (cfg.RefillEnable.getValue()) {
//Check whether refilling is necessary
if (tankLevel.getPercent() < cfg.RefillBelow.getValue()) {
@ -256,8 +256,7 @@ int main(void) {
if (S_refilling) {
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung laeuft ").c_str()));
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_RESET);
}
else {
} else {
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung inaktiv").c_str()));
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_SET);
@ -267,13 +266,29 @@ int main(void) {
if (S_refillempty) {
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung mangel ").c_str()));
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET);
}
else {
} else {
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung ok ").c_str()));
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET);
}
//Check for rotation to enable display backlight
if (old_pos < rot_counter) {
controller.pushEvent(menu::Menu_Controller::Event::Increase);
old_pos = rot_counter;
last_backlight_retrigger = HAL_GetTick();
} else if (old_pos > rot_counter) {
controller.pushEvent(menu::Menu_Controller::Event::Decrease);
old_pos = rot_counter;
last_backlight_retrigger = HAL_GetTick();
}
//Check and toggle backlight state
if(HAL_GetTick() > last_backlight_retrigger + 60000) {
S_backlight = false;
} else {
S_backlight = true;
}
if (rot_button) {
display.LCDSetBacklight(true);
@ -328,6 +343,7 @@ int main(void) {
}
}
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);
//Poll Sensors
tankLevel0.poll();
@ -336,6 +352,8 @@ int main(void) {
//Check conditions
CheckTankConditions(globalConfig, tankLevel0, tankPump);
CheckRefillConditions(globalConfig, tankLevel0, refillBlocker0, refillPump);
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
HAL_Delay(1000);
}