PATCH: Responsitivity patch
This commit is contained in:
parent
2a9e8efb3d
commit
15352ddfcd
@ -218,57 +218,62 @@ int main(void) {
|
||||
|
||||
static uint16_t old_minute_counter = minute_counter;
|
||||
|
||||
static uint32_t dly_disp, dly_stats, dly_switch;
|
||||
|
||||
|
||||
SendUartString(&huart1, "Hello from FloatPUMP Controller");
|
||||
SendUartString(&huart1, {"Revision: " GIT_HASH});
|
||||
|
||||
while (1) {
|
||||
|
||||
display.LCDSetBacklight(S_backlight);
|
||||
//Execute this block each second only
|
||||
if(HAL_GetTick() > dly_disp + 1000)
|
||||
{
|
||||
dly_disp = HAL_GetTick();
|
||||
display.LCDSetBacklight(S_backlight);
|
||||
char buf[20];
|
||||
|
||||
char buf[20];
|
||||
display.LCDSetCursor(0, 0);
|
||||
sprintf(buf, "Fuellstand %3d %%", tankLevel0.getPercent());
|
||||
display.LCDSendCString(buf);
|
||||
display.LCDSetCursor(0, 1);
|
||||
if (S_tankempty) {
|
||||
display.LCDSendCString(const_cast<char *>(std::string("Tank Wassermangel ").c_str()));
|
||||
HAL_GPIO_WritePin(LED5_GPIO_Port, LED5_Pin, GPIO_PIN_SET);
|
||||
|
||||
display.LCDSetCursor(0, 0);
|
||||
sprintf(buf, "Fuellstand %3d %%", tankLevel0.getPercent());
|
||||
display.LCDSendCString(buf);
|
||||
display.LCDSetCursor(0, 1);
|
||||
if (S_tankempty) {
|
||||
display.LCDSendCString(const_cast<char *>(std::string("Tank Wassermangel ").c_str()));
|
||||
HAL_GPIO_WritePin(LED5_GPIO_Port, LED5_Pin, GPIO_PIN_SET);
|
||||
|
||||
} else {
|
||||
display.LCDSendCString(const_cast<char *>(std::string("Tank Normal ").c_str()));
|
||||
HAL_GPIO_WritePin(LED5_GPIO_Port, LED5_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
|
||||
display.LCDSetCursor(0, 2);
|
||||
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 {
|
||||
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung inaktiv").c_str()));
|
||||
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_SET);
|
||||
|
||||
}
|
||||
|
||||
display.LCDSetCursor(0, 3);
|
||||
if (S_refillcooldown > 0) {
|
||||
int remaining_mins = S_refillcooldown / 60;
|
||||
if (remaining_mins > 0) {
|
||||
sprintf(buf, "Nsp. wartet: %3d min", S_refillcooldown / 60);
|
||||
display.LCDSendCString(buf);
|
||||
} else {
|
||||
sprintf(buf, "Nsp. wartet: %3d sec", S_refillcooldown);
|
||||
display.LCDSendCString(buf);
|
||||
display.LCDSendCString(const_cast<char *>(std::string("Tank Normal ").c_str()));
|
||||
HAL_GPIO_WritePin(LED5_GPIO_Port, LED5_Pin, GPIO_PIN_RESET);
|
||||
}
|
||||
} else 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 {
|
||||
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung ok ").c_str()));
|
||||
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
display.LCDSetCursor(0, 2);
|
||||
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 {
|
||||
display.LCDSendCString(const_cast<char *>(std::string("Nachspeisung inaktiv").c_str()));
|
||||
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_SET);
|
||||
|
||||
}
|
||||
|
||||
display.LCDSetCursor(0, 3);
|
||||
if (S_refillcooldown > 0) {
|
||||
int remaining_mins = S_refillcooldown / 60;
|
||||
if (remaining_mins > 0) {
|
||||
sprintf(buf, "Nsp. wartet: %3d min", S_refillcooldown / 60);
|
||||
display.LCDSendCString(buf);
|
||||
} else {
|
||||
sprintf(buf, "Nsp. wartet: %3d sec", S_refillcooldown);
|
||||
display.LCDSendCString(buf);
|
||||
}
|
||||
} else 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 {
|
||||
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) {
|
||||
@ -316,7 +321,7 @@ int main(void) {
|
||||
old_pos = rot_counter;
|
||||
last_menu_retrigger = HAL_GetTick();
|
||||
}
|
||||
HAL_Delay(100);
|
||||
HAL_Delay(10);
|
||||
|
||||
//Execute Calibrations if necessary
|
||||
if (a_caliblow) {
|
||||
@ -350,53 +355,63 @@ int main(void) {
|
||||
}
|
||||
}
|
||||
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);
|
||||
//Execute this only each 5 seconds
|
||||
if(HAL_GetTick() > dly_switch + 5000)
|
||||
{
|
||||
dly_switch = HAL_GetTick();
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET);
|
||||
|
||||
//Poll Sensors
|
||||
tankLevel0.poll();
|
||||
refillBlocker0.poll();
|
||||
//Poll Sensors
|
||||
tankLevel0.poll();
|
||||
refillBlocker0.poll();
|
||||
|
||||
//Check conditions
|
||||
CheckTankConditions(Config_Store::getInstance(), tankLevel0, tankPump);
|
||||
CheckRefillConditions(Config_Store::getInstance(), tankLevel0, refillBlocker0, refillPump);
|
||||
//Check conditions
|
||||
CheckTankConditions(Config_Store::getInstance(), tankLevel0, tankPump);
|
||||
CheckRefillConditions(Config_Store::getInstance(), tankLevel0, refillBlocker0, refillPump);
|
||||
|
||||
//Create history
|
||||
if (old_minute_counter < minute_counter) {
|
||||
old_minute_counter = minute_counter;
|
||||
history_h[minute_counter % 60] = tankLevel0.getPercent();
|
||||
history_d[minute_counter / 60] = tankLevel0.getPercent();
|
||||
//Create history
|
||||
if (old_minute_counter < minute_counter) {
|
||||
old_minute_counter = minute_counter;
|
||||
history_h[minute_counter % 60] = tankLevel0.getPercent();
|
||||
history_d[minute_counter / 60] = tankLevel0.getPercent();
|
||||
|
||||
//Calculate diff to value 1h ago -> minute_counter+1's entry is always 60mins ago !
|
||||
diff_hist_hour = history_h[minute_counter % 60] - history_h[(minute_counter + 1) % 60];
|
||||
//Same here for daily history
|
||||
diff_hist_day = history_d[(minute_counter / 60) % 24] - history_d[((minute_counter + 60) / 60) % 24];
|
||||
//Calculate diff to value 1h ago -> minute_counter+1's entry is always 60mins ago !
|
||||
diff_hist_hour = history_h[minute_counter % 60] - history_h[(minute_counter + 1) % 60];
|
||||
//Same here for daily history
|
||||
diff_hist_day = history_d[(minute_counter / 60) % 24] - history_d[((minute_counter + 60) / 60) % 24];
|
||||
}
|
||||
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(1000);
|
||||
|
||||
//Periodically send stats via uart in json format:
|
||||
|
||||
char buffer[400];
|
||||
sprintf(buffer, "{"
|
||||
"\"Status\": true, "
|
||||
"\"TankLevel\": %hhd, "
|
||||
"\"TankPump\": %s, "
|
||||
"\"RefillPump\": %s, "
|
||||
"\"RefillEmpty\": %s, "
|
||||
"\"RefillCooldown\": %hhd, "
|
||||
"\"HourlyHist\": %hhd, "
|
||||
"\"DailyHist\": %hhd, "
|
||||
"}",
|
||||
tankLevel0.getPercent(),
|
||||
(S_tankempty) ? "false" : "true",
|
||||
(S_refilling) ? "true" : "false",
|
||||
(S_refillempty) ? "true" : "false",
|
||||
S_refillcooldown,
|
||||
diff_hist_hour,
|
||||
diff_hist_day);
|
||||
SendUartString(&huart1, buffer);
|
||||
//HAL_UART_Transmit(&huart1, (uint8_t*) buffer, sizeof(buffer), 100);
|
||||
//Periodically send stats via uart in json format each minute
|
||||
if(HAL_GetTick() > dly_stats + 60000)
|
||||
{
|
||||
dly_stats = HAL_GetTick();
|
||||
char buffer[400];
|
||||
sprintf(buffer, "{"
|
||||
"\"Status\": true, "
|
||||
"\"TankLevel\": %hhd, "
|
||||
"\"TankPump\": %s, "
|
||||
"\"RefillPump\": %s, "
|
||||
"\"RefillEmpty\": %s, "
|
||||
"\"RefillCooldown\": %hhd, "
|
||||
"\"HourlyHist\": %hhd, "
|
||||
"\"DailyHist\": %hhd, "
|
||||
"}",
|
||||
tankLevel0.getPercent(),
|
||||
(S_tankempty) ? "false" : "true",
|
||||
(S_refilling) ? "true" : "false",
|
||||
(S_refillempty) ? "true" : "false",
|
||||
S_refillcooldown,
|
||||
diff_hist_hour,
|
||||
diff_hist_day);
|
||||
SendUartString(&huart1, buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user