Skip to content

Commit ca0e59f

Browse files
committed
Implement beep-at-set-temperature function
1 parent c2e808c commit ca0e59f

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

AxxSolder_firmware/Core/Inc/buzzer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
/* Function prototypes -------------------------------------------------------*/
1313
void beep(float buzzer_enabled);
14-
void beep_startup(float buzzer_enabled);
14+
void beep_double(float buzzer_enabled);
1515

1616
#endif /* INC_BUZZER_H_ */

AxxSolder_firmware/Core/Inc/main.h

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ typedef struct{
5757
float displayed_temp_filter;
5858
float startup_temp_is_previous_temp;
5959
float three_button_mode;
60+
float beep_at_set_temp;
6061
}Flash_values;
6162

6263
/* USER CODE END Includes */

AxxSolder_firmware/Core/Src/buzzer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void beep(float buzzer_enabled){
1212
}
1313

1414
/* Beep the beeper twice*/
15-
void beep_startup(float buzzer_enabled){
15+
void beep_double(float buzzer_enabled){
1616
beep(buzzer_enabled);
1717
HAL_Delay(100);
1818
beep(buzzer_enabled);

AxxSolder_firmware/Core/Src/main.c

+26-4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ uint8_t startup_done = 0;
160160
/* Flag to indicate that settings menu is active */
161161
uint8_t settings_menu_active = 0;
162162

163+
/* Flag to indicate if beep has been done at set temperature */
164+
uint8_t beeped_at_set_temp = 0;
165+
163166
/* Variables for thermocouple outlier detection */
164167
float TC_temp_from_ADC = 0;
165168
float TC_temp_from_ADC_previous = 0;
@@ -296,10 +299,11 @@ Flash_values default_flash_values = {.startup_temperature = 330,
296299
.serial_debug_print = 0,
297300
.displayed_temp_filter = 5,
298301
.startup_temp_is_previous_temp = 0,
299-
.three_button_mode = 0};
302+
.three_button_mode = 0,
303+
.beep_at_set_temp = 0};
300304

301305
/* List of names for settings menu */
302-
#define menu_length 27
306+
#define menu_length 28
303307
char menu_names[menu_length][30] = { "Startup Temp °C ",
304308
"Temp Offset °C ",
305309
"Standby Temp °C ",
@@ -324,6 +328,7 @@ char menu_names[menu_length][30] = { "Startup Temp °C ",
324328
"Disp Temp. filter ",
325329
"Start at prev. temp ",
326330
"3-button mode ",
331+
"Beep at set temp ",
327332
"-Load Default- ",
328333
"-Save and Reboot- ",
329334
"-Exit no Save- "};
@@ -461,6 +466,10 @@ void change_state(mainstates new_state){
461466
else{
462467
HAL_GPIO_WritePin(GPIOB, USR_4_Pin, GPIO_PIN_RESET);
463468
}
469+
if((sensor_values.previous_state != RUN) && (sensor_values.current_state == RUN)){
470+
beeped_at_set_temp = 0;
471+
}
472+
464473
}
465474

466475
/* Function to get the filtered MCU temperature */
@@ -647,7 +656,7 @@ void settings_menu(){
647656
((float*)&flash_values)[menu_cursor_position] = (float)old_value + (float)(TIM2->CNT - 1000.0) / 2.0 - (float)menu_cursor_position;
648657
}
649658

650-
if ((menu_cursor_position == 5) || (menu_cursor_position == 8) || (menu_cursor_position == 11) || (menu_cursor_position == 12) || (menu_cursor_position == 13) || (menu_cursor_position == 20) || (menu_cursor_position == 22) || (menu_cursor_position == 23)){
659+
if ((menu_cursor_position == 5) || (menu_cursor_position == 8) || (menu_cursor_position == 11) || (menu_cursor_position == 12) || (menu_cursor_position == 13) || (menu_cursor_position == 20) || (menu_cursor_position == 22) || (menu_cursor_position == 23) || (menu_cursor_position == 24)){
651660
((float*)&flash_values)[menu_cursor_position] = fmod(round(fmod(fabs(((float*)&flash_values)[menu_cursor_position]), 2)), 2);
652661
}
653662
else if (menu_cursor_position == 9){
@@ -1301,6 +1310,18 @@ void set_handle_values(){
13011310
}
13021311
}
13031312

1313+
void beep_at_set_temp(){
1314+
if(flash_values.beep_at_set_temp == 1){
1315+
if(beeped_at_set_temp == 0){
1316+
if((sensor_values.thermocouple_temperature_filtered > (sensor_values.set_temperature - 5)) && (sensor_values.thermocouple_temperature_filtered < (sensor_values.set_temperature + 5))){
1317+
beeped_at_set_temp = 1;
1318+
//beep(flash_values.buzzer_enabled);
1319+
beep_double(flash_values.buzzer_enabled);
1320+
}
1321+
}
1322+
}
1323+
}
1324+
13041325
/* Interrupts at button press */
13051326
volatile static uint16_t btnPressed = 0;
13061327
volatile static uint16_t debounceDone = 0;
@@ -1616,7 +1637,7 @@ int main(void)
16161637
LCD_draw_main_screen();
16171638

16181639
/* Start-up beep */
1619-
beep_startup(flash_values.startup_beep);
1640+
beep_double(flash_values.startup_beep);
16201641

16211642
//Flag to indicate that the startup sequence is done
16221643
startup_done = 1;
@@ -1639,6 +1660,7 @@ int main(void)
16391660
get_bus_voltage();
16401661
get_heater_current();
16411662
get_mcu_temp();
1663+
beep_at_set_temp();
16421664
previous_sensor_update_low_update = HAL_GetTick();
16431665
}
16441666

0 commit comments

Comments
 (0)