Add alarm code

This commit is contained in:
Sebastian H. Gabrielli 2024-04-30 16:43:07 +02:00
parent cd65b8fd1f
commit 25d27c1e1b
2 changed files with 7 additions and 1 deletions

View File

@ -74,4 +74,10 @@ int main() {
store_config = false; store_config = false;
} }
} }
// Check the temperature, and start the alarm if required
uint16_t thermistor_voltage = thermistor_voltage_read();
float temperature = calculate_thermistor_temp(thermistor_voltage);
bool start_alarm = voltage_threshold_bool(temperature, 40);
alert_voltage_threshold_exceeded(start_alarm);
} }

View File

@ -41,7 +41,7 @@ bool voltage_threshold_bool(float thermistor_temp, uint8_t max_temp){
//print if the maximum threshold is exceeded. //print if the maximum threshold is exceeded.
void alert_voltage_threshold_exceeded(bool voltage_threshold_bool){ void alert_voltage_threshold_exceeded(bool voltage_threshold_bool){
if (voltage_threshold_bool){ if (voltage_threshold_bool){
printf("Error: maximum temperature exceeded"); //printf("Error: maximum temperature exceeded");
PORTB.OUTSET = ALERT_PIN; PORTB.OUTSET = ALERT_PIN;
} else{ } else{
PORTB.OUTCLR = ALERT_PIN; PORTB.OUTCLR = ALERT_PIN;