From 25d27c1e1be2b0cb6914583a1a657925f10bf402 Mon Sep 17 00:00:00 2001 From: "Sebastian H. Gabrielli" Date: Tue, 30 Apr 2024 16:43:07 +0200 Subject: [PATCH] Add alarm code --- prosjekt.X/main.c | 6 ++++++ prosjekt.X/thermistor-temp.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/prosjekt.X/main.c b/prosjekt.X/main.c index b0612b7..5690960 100644 --- a/prosjekt.X/main.c +++ b/prosjekt.X/main.c @@ -74,4 +74,10 @@ int main() { 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); } diff --git a/prosjekt.X/thermistor-temp.c b/prosjekt.X/thermistor-temp.c index dccc95f..b5754a5 100644 --- a/prosjekt.X/thermistor-temp.c +++ b/prosjekt.X/thermistor-temp.c @@ -41,7 +41,7 @@ bool voltage_threshold_bool(float thermistor_temp, uint8_t max_temp){ //print if the maximum threshold is exceeded. void alert_voltage_threshold_exceeded(bool voltage_threshold_bool){ if (voltage_threshold_bool){ - printf("Error: maximum temperature exceeded"); + //printf("Error: maximum temperature exceeded"); PORTB.OUTSET = ALERT_PIN; } else{ PORTB.OUTCLR = ALERT_PIN;