24 MAIN_LOOP_FREEZE = 1 << 0,
25 BATTERY_READINGS_INCOHERENT = 1 << 1,
27 BATTERY_CRITICAL = 1 << 2,
29 LONG_LOOP_UPDATE = 1 << 4,
31 TEMP_TOO_HIGH = 1 << 5,
32 TEMP_CRITICAL = 1 << 6,
34 BLUETOOTH_ADVERT = 1 << 7,
36 HARDWARE_ALERT = 1 << 8,
38 FAVORITE_SET = 1 << 9,
42 SYSTEM_OFF_FAILED = 1 << 11,
43 SYSTEM_IN_ERROR_STATE = 1 << 12,
45 SYSTEM_IN_LOCKOUT = 1 << 13,
47 SUNSET_TIMER_ENABLED = 1 << 14,
49 SYSTEM_SLEEP_SKIPPED = 1 << 15,
51 USB_PORT_SHORT = 1 << 16,
53 BATTERY_MISSING = 1 << 17,
55 CHARGER_ERROR = 1 << 18,
81 const std::atomic<uint32_t>& refreshCount,
82 const uint32_t refreshCountAtDecision);
85 bool is_raised(
const Type type)
const {
return (_current.load() &
static_cast<uint32_t
>(type)) != 0x00; }
88 bool is_clear()
const {
return _current.load() == 0x00; }
110 std::atomic<uint32_t> _current {0};
129void handle_all(
const bool shouldIgnoreAlerts);
Handle the whole alerts logic. Use this to raise and clear alerts, and make decisions based on those ...
Definition: alerts.h:65
uint32_t get_time_since_raised(const Type type) const
the time in milliseconds since this alert was raised, or zero if it's not. This raise time is updated...
Definition: alerts.cpp:1101
bool is_clear() const
Return true if no alerts are raised.
Definition: alerts.h:88
bool can_charge_battery() const
Return true if a raised alert prevents battery charging.
Definition: alerts.cpp:1132
bool can_use_usb_port() const
Return true if no raised alerts block the use of power through USB port.
Definition: alerts.cpp:1147
bool can_use_output_power() const
Return true if a raised alert prevents power set to output.
Definition: alerts.cpp:1117
void clear(const Type type)
Clear an alert.
Definition: alerts.cpp:1063
void raise(const Type type)
Raise an alert.
Definition: alerts.cpp:1031
bool clear_unless_refreshed(const Type type, const std::atomic< uint32_t > &refreshCount, const uint32_t refreshCountAtDecision)
Clear an alert, unless it was refreshed by a raise() since the clear decision was taken.
Definition: alerts.cpp:1072
bool is_raised(const Type type) const
Return true if the target alert is raised.
Definition: alerts.h:85
Type
Alert types : 31 errors max.
Definition: alerts.h:20
@ OTG_OVER_LIMITS
OTG has gone over the limits (current or voltage)
brightness_t get_alerts_max_brightness()
Return the max output brightness allowed by the raised alerts (the lowest of their limits)
Definition: alerts.cpp:902
void signal_wake_up_from_charger()
Signal slot that the system just powered up from charger.
Definition: alerts.cpp:900
AlertManager_t manager
Instanciation of the AlertManager.
Definition: alerts.cpp:30
bool is_request_shutdown()
Return true if an alert requested an immediate shutdown. Handling this is urgent or dammages can happ...
Definition: alerts.cpp:1029
void process_interrupt_signals()
Raise the alerts signaled from interrupts since the last call. Called by the alerts loop and the powe...
Definition: alerts.cpp:839
void handle_all(const bool shouldIgnoreAlerts)
handle the behavior for all alerts. Must be called often
Definition: alerts.cpp:913
void signal_usb_port_fault()
Signal a fault of the USB port protection. Safe to call from an interrupt: it only sets a flag....
Definition: alerts.cpp:833
void show_all()
show all the raised alerts in Serial debug
Definition: alerts.cpp:1010
Program scope.
Definition: control_fixed_modes.hpp:14
uint16_t brightness_t
Define the type of the brightness parameters.
Definition: constants.h:151
Define the system hardware constants.