15 #include "../includes/alarm_controller.h"
16 #include "../includes/buzzer.h"
17 #include "../includes/cycle.h"
18 #include "../includes/screen.h"
19 #include "../includes/telemetry.h"
181 m_snoozedAlarms[
i] =
false;
184 m_triggeredAlarms[
i] = 0u;
208 uint32_t p_cycleNumber,
210 uint32_t p_measured) {
230 current->
getPriority(),
true, p_expected, p_measured,
239 bool compare(uint8_t a, uint8_t b) {
return a > b; }
245 if (current->
getCode() == p_alarmCode) {
271 uint8_t numberOfTriggeredAlarms = 0;
272 bool justUnsnoozed =
false;
278 if (numberOfTriggeredAlarms == 0u) {
282 triggeredAlarmCodes[numberOfTriggeredAlarms] = current->
getCode();
283 numberOfTriggeredAlarms++;
287 justUnsnoozed =
true;
310 if ((p_tick % 100u) == 50u) {
312 }
else if ((p_tick % 100u) == 0u) {
324 if ((p_tick % 100u) == 50u) {
326 }
else if ((p_tick % 100u) == 0u) {
364 uint32_t p_cycle_number) {
384 if (enabledAlarms.
alarms[
i] != 0u) {
AlarmPriority
Priority levels of an alarm.
AlarmController alarmController
Instance of the alarm controller.
bool compare(uint8_t a, uint8_t b)
void Buzzer_High_Prio_Start(void)
Activate the buzzer pattern for high priority alarms.
void Buzzer_Low_Prio_Start(void)
Activate the buzzer pattern for low priority alarms.
void Buzzer_Mute()
Mute the buzzer for 120s.
void Buzzer_Stop(void)
Stop Buzzer.
void Buzzer_Medium_Prio_Start(void)
Activate the buzzer pattern for medium priority alarms.
bool m_snoozedAlarms[ALARMS_SIZE]
Collections of snoozed alarms.
void updateCoreData(uint32_t p_tick, uint16_t p_pressure, CyclePhases p_phase, uint32_t p_cycle_number)
Update internal state of alarm controller with data from pressure controller.
AlarmController()
Default constructor.
uint32_t m_cycle_number
Current cycle number.
void detectedAlarm(uint8_t p_alarmCode, uint32_t p_cycleNumber, uint32_t p_expected, uint32_t p_measured)
Mark a specific alarm as detected.
uint32_t m_snoozeTime
Time when snoozed was triggered.
bool m_unsnooze
Is unsnoozed right now.
uint16_t m_tick
Current pressure.
void snooze()
Snooze alarm for 2 minutes.
Alarm m_alarms[ALARMS_SIZE]
Collections of available alarms.
CyclePhases m_phase
Current phase.
void updateEnabledAlarms(Alarms enabledAlarms)
Update the list of enabled alarms (alarms not provided here will have no effects)
void unsnooze()
Unsnooze alarms.
uint8_t m_triggeredAlarms[ALARMS_SIZE]
Alarms currently triggered.
void runAlarmEffects(uint32_t p_tick)
Run effects (buzzer, LCD message, LED) according to the currently triggered alarms.
AlarmPriority m_highestPriority
Highest priority of the currently triggered alarms.
void notDetectedAlarm(uint8_t p_alarmCode)
Reset detection of a specific alarm.
uint16_t m_pressure
Current pressure.
Describe an alarm and handle its dynamic state.
bool isTriggered() const
True if the number of detections is equal or above the detection threshold, false otherwise.
void disable()
Disable this alarm.
void detected(uint32_t p_cycleNumber)
If the alarm is detected, it increments the number of detection until the detection threshold.
void notDetected()
Reset to zero the number of detection.
AlarmPriority getPriority() const
Get the alarm priority.
void enable()
Enable this alarm.
uint8_t getCode() const
Get the alarm code.
uint32_t getCyclesSinceTrigger() const
Get the number of cycles since the alarm was triggered.
bool isEnabled()
True if this alarm is enabled.
CyclePhases
Defines the 2 main phases of the respiratory cycle.
@ INHALATION
Inspiration and inspiration holding.
#define LCD_UPDATE_PERIOD_US
Period between screen updates in microsecond.
#define MAIN_CONTROLLER_COMPUTE_PERIOD_MICROSECONDS
#define LED_YELLOW_INACTIVE
#define LED_GREEN_INACTIVE
#define LED_YELLOW_ACTIVE
void displayAlarmInformation(uint8_t p_alarmCodes[], uint8_t p_nbTriggeredAlarms)
Display triggered alarm codes.
List of alarms (named by their code)
uint8_t alarms[ALARMS_SIZE]
void sendControlAck(uint8_t setting, uint16_t valueValue)
Send a "control ack" message.
void sendAlarmTrap(uint16_t centileValue, int16_t pressureValue, CyclePhases phase, uint32_t cycleValue, uint8_t alarmCode, AlarmPriority alarmPriority, bool triggered, uint32_t expectedValue, uint32_t measuredValue, uint32_t cyclesSinceTriggerValue)
Send a "alarm trap" message.