Skip to content

Commit 70b0b6d

Browse files
committed
remove HAL_delay(2000) from show_popup and make the show-time based on a HAL_GetTick() counter
1 parent c22832a commit 70b0b6d

File tree

1 file changed

+30
-18
lines changed
  • AxxSolder_firmware/Core/Src

1 file changed

+30
-18
lines changed

AxxSolder_firmware/Core/Src/main.c

+30-18
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ uint32_t interval_sensor_update_high_update = 10;
9393
uint32_t previous_sensor_update_low_update = 0;
9494
uint32_t interval_sensor_update_low_update = 100;
9595

96+
uint32_t previous_millis_popup = 0;
97+
uint32_t interval_popup = 2000;
98+
9699
/* Handles */
97100
enum handles {
98101
NT115,
@@ -163,6 +166,9 @@ uint8_t settings_menu_active = 0;
163166
/* Flag to indicate if beep has been done at set temperature */
164167
uint8_t beeped_at_set_temp = 0;
165168

169+
/* Flag to indicate if a popup is shown */
170+
uint8_t popup_shown = 0;
171+
166172
/* Variables for thermocouple outlier detection */
167173
float TC_temp_from_ADC = 0;
168174
float TC_temp_from_ADC_previous = 0;
@@ -466,10 +472,9 @@ void change_state(mainstates new_state){
466472
else{
467473
HAL_GPIO_WritePin(GPIOB, USR_4_Pin, GPIO_PIN_RESET);
468474
}
469-
if((sensor_values.previous_state != RUN) && (sensor_values.current_state == RUN)){
470-
beeped_at_set_temp = 0;
471-
}
472-
475+
if((sensor_values.previous_state != RUN) && (sensor_values.current_state == RUN)){
476+
beeped_at_set_temp = 0;
477+
}
473478
}
474479

475480
/* Function to get the filtered MCU temperature */
@@ -615,7 +620,7 @@ void settings_menu(){
615620
if (HAL_GPIO_ReadPin (GPIOB, SW_1_Pin) == 1){
616621
settings_menu_active = 1;
617622

618-
UG_FillScreen(RGB_to_BRG(C_BLACK));
623+
UG_FillScreen(RGB_to_BRG(C_BLACK));
619624
char str[32];
620625
memset(&str, '\0', strlen(str));
621626
if((flash_values.screen_rotation == 0) || (flash_values.screen_rotation == 2)){
@@ -1080,8 +1085,8 @@ void show_popup(char *text){
10801085
UG_FillFrame(10, 50, 235, 105, RGB_to_BRG(C_ORANGE));
10811086
UG_FillFrame(15, 55, 230, 100, RGB_to_BRG(C_WHITE));
10821087
LCD_PutStr(20, 70, text, FONT_arial_20X23, RGB_to_BRG(C_ORANGE), RGB_to_BRG(C_WHITE));
1083-
HAL_Delay(2000);
1084-
LCD_draw_main_screen();
1088+
popup_shown = 1;
1089+
previous_millis_popup = HAL_GetTick();
10851090
standby_state_written_to_LCD = 0;
10861091
sleep_state_written_to_LCD = 0;
10871092
}
@@ -1119,7 +1124,6 @@ void handle_delta_temperature(){
11191124
if((startup_done == 1) && ((sensor_values.thermocouple_temperature - sensor_values.thermocouple_temperature_previous) > MAX_TC_DELTA_FAULTDETECTION)){
11201125
heater_off();
11211126
sensor_values.heater_current = 0;
1122-
update_display();
11231127
show_popup("No or Faulty tip!");
11241128
change_state(EMERGENCY_SLEEP);
11251129
}
@@ -1195,7 +1199,7 @@ void handle_button_status(){
11951199
/* start settings menu */
11961200
settings_menu();
11971201
}
1198-
1202+
11991203
/* Set "set temp" to preset temp 1 */
12001204
if(SW_2_pressed == 1){
12011205
SW_2_pressed = 0;
@@ -1218,7 +1222,7 @@ void handle_button_status(){
12181222
sleep_state_written_to_LCD = 0;
12191223
}
12201224
}
1221-
1225+
12221226
/* Set "set temp" to preset temp 2 */
12231227
if(SW_3_pressed == 1){
12241228
SW_3_pressed = 0;
@@ -1240,6 +1244,7 @@ void handle_button_status(){
12401244
LCD_draw_main_screen();
12411245
sleep_state_written_to_LCD = 0;
12421246
}
1247+
}
12431248
}
12441249

12451250
/* Get the status of handle in/on stand to trigger SLEEP */
@@ -1341,7 +1346,6 @@ void beep_at_set_temp(){
13411346
if(beeped_at_set_temp == 0){
13421347
if((sensor_values.thermocouple_temperature_filtered > (sensor_values.set_temperature - 5)) && (sensor_values.thermocouple_temperature_filtered < (sensor_values.set_temperature + 5))){
13431348
beeped_at_set_temp = 1;
1344-
//beep(flash_values.buzzer_enabled);
13451349
beep_double(flash_values.buzzer_enabled);
13461350
}
13471351
}
@@ -1663,7 +1667,7 @@ int main(void)
16631667
LCD_draw_main_screen();
16641668

16651669
/* Start-up beep */
1666-
beep_double(flash_values.startup_beep);
1670+
beep_double(flash_values.startup_beep);
16671671

16681672
//Flag to indicate that the startup sequence is done
16691673
startup_done = 1;
@@ -1759,12 +1763,20 @@ int main(void)
17591763
sensor_values.heater_current = 1; // If the current is not measured, apply a dummy value to heater_current
17601764
}
17611765

1762-
/* Update display */
1763-
if(HAL_GetTick() - previous_millis_display >= interval_display){
1764-
sensor_values.requested_power_filtered = clamp(Moving_Average_Compute(sensor_values.requested_power, &requested_power_filtered_filter_struct), 0, PID_MAX_OUTPUT);
1765-
update_display();
1766-
previous_millis_display = HAL_GetTick();
1767-
}
1766+
if(popup_shown == 1){
1767+
if(HAL_GetTick() - previous_millis_popup >= interval_popup){
1768+
popup_shown = 0;
1769+
LCD_draw_main_screen();
1770+
}
1771+
}
1772+
else{
1773+
/* Update display */
1774+
if(HAL_GetTick() - previous_millis_display >= interval_display){
1775+
sensor_values.requested_power_filtered = clamp(Moving_Average_Compute(sensor_values.requested_power, &requested_power_filtered_filter_struct), 0, PID_MAX_OUTPUT);
1776+
update_display();
1777+
previous_millis_display = HAL_GetTick();
1778+
}
1779+
}
17681780
/* USER CODE END WHILE */
17691781

17701782
/* USER CODE BEGIN 3 */

0 commit comments

Comments
 (0)