Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables
lampda::logic::alerts Namespace Reference

Handle the system alerts, that are displayed on the RGB indicator. More...

Classes

struct  Alert_BatteryCritical
 This alert is raised when the battery level falls below a critical threshold. Falling further will dammage the battery. More...
 
struct  Alert_BatteryLow
 This alert is raised when the battery level gets low. More...
 
struct  Alert_BatteryMissing
 This alert is raised when no connected battery is detected. More...
 
struct  Alert_BatteryReadingIncoherent
 This alert is raised when the battery readings do not fit the battery physical model. More...
 
struct  Alert_BluetoothAdvertisement
 This alert is raised when the Bluetooth advertising is turned on. It is just an informative alert. More...
 
struct  Alert_ChargerError
 This alert is raised when the battery charger signals an error. It is not well handled at the moment, so it does not block anything. More...
 
struct  Alert_FavoriteSet
 This alert is raised when new favorite mode is added. More...
 
struct  Alert_HardwareAlert
 This alert is raised when a problem is detected in the hardware. Usually, it means that an electrical component may have become unresponsive. More...
 
struct  Alert_LongLoopUpdate
 This alert is raised when the main loop becomes slower than the defined behavior. This is not a critical alert, but it sually indicates that the user mode in use is too slow. More...
 
struct  Alert_MainLoopFreeze
 This alert is raised when the main loop becomes unresponsive. More...
 
struct  Alert_OtgFailed
 This alert is raised when the output power fails to start. It can happen with logic bugs, or if the output rail is shorted. More...
 
struct  Alert_SkippedCleanSleep
 This alert is raised when the system starts without sleeping cleanly first. It appears after updates, crashes, power failures, ... More...
 
struct  Alert_SunsetTimerSet
 This alert is raised when the sunset timer is active. It means that the system will turn off on it's own after a delay. More...
 
struct  Alert_SystemInErrorState
 This alert is raised when the system falls into an unrecoverable state. It can be raised by logic error, or detected bugs at program start. More...
 
struct  Alert_SystemInLockout
 This alert is raised when the user tries to power the system as it is in lockout mode. More...
 
struct  Alert_SystemShutdownFailed
 This alert is raised when the system fails to go to sleep. There is no way to recover from this, as we depend on the low level handlers for this functionality. More...
 
struct  Alert_TempCritical
 This alert is raised when the temperature gets too high. If it keeps climbing, the components will get dammaged. More...
 
struct  Alert_TempTooHigh
 This alert is raised when the internal temperature gets high. If it keeps rising, the battery may get dammaged. More...
 
struct  Alert_UsbPortShort
 This alert is raised when a short circuit is detected in the USB lines. The port should be cleaned before using it again. More...
 
struct  AlertBase
 Base class for all alerts. Must be overloaded to define an alert. More...
 
class  AlertManager_t
 Handle the whole alerts logic. Use this to raise and clear alerts, and make decisions based on those alerts. Alerts can be raised and cleared on their own. More...
 

Enumerations

enum class  Type : uint32_t {
  MAIN_LOOP_FREEZE = 1 << 0 , BATTERY_READINGS_INCOHERENT = 1 << 1 , BATTERY_CRITICAL = 1 << 2 , BATTERY_LOW = 1 << 3 ,
  LONG_LOOP_UPDATE = 1 << 4 , TEMP_TOO_HIGH = 1 << 5 , TEMP_CRITICAL = 1 << 6 , BLUETOOTH_ADVERT = 1 << 7 ,
  HARDWARE_ALERT = 1 << 8 , FAVORITE_SET = 1 << 9 , OTG_FAILED = 1 << 10 , SYSTEM_OFF_FAILED = 1 << 11 ,
  SYSTEM_IN_ERROR_STATE = 1 << 12 , SYSTEM_IN_LOCKOUT = 1 << 13 , SUNSET_TIMER_ENABLED = 1 << 14 , SYSTEM_SLEEP_SKIPPED = 1 << 15 ,
  USB_PORT_SHORT = 1 << 16 , BATTERY_MISSING = 1 << 17 , CHARGER_ERROR = 1 << 18
}
 Alert types : 31 errors max.
 

Functions

bool is_battery_alert_ready ()
 Return true if we are ready to display battery alerts.
 
const char * AlertsToText (const Type type)
 Convert alerts enums to text.
 
void update_alerts ()
 
void signal_wake_up_from_charger ()
 Signal slot that the system just powered up from charger.
 
void handle_all (const bool shouldIgnoreAlerts)
 handle the behavior for all alerts. Must be called often
 
void show_all ()
 show all the raised alerts in Serial debug
 
bool is_request_shutdown ()
 Return true if an alert requested an immediate shutdown. Handling this is urgent or dammages can happen.
 

Variables

AlertManager_t manager
 Instanciation of the AlertManager.
 
bool _request_shutdown = false
 Set to true if an alert requested an emmergency shutdown.
 
uint32_t _startupChargerTime = 0
 Stay at zero in normal operation. Set to the real startup time to ignore the battery alerts while the system starts.
 
AlertBaseallAlerts []
 Alerts must be sorted by importance, only the first activated one will be shown.
 

Detailed Description

Handle the system alerts, that are displayed on the RGB indicator.

Variable Documentation

◆ allAlerts

AlertBase* lampda::logic::alerts::allAlerts[]
Initial value:
= {
new Alert_SystemShutdownFailed,
new Alert_BatteryMissing,
new Alert_HardwareAlert,
new Alert_TempCritical,
new Alert_UsbPortShort,
new Alert_SkippedCleanSleep,
new Alert_BatteryCritical,
new Alert_TempTooHigh,
new Alert_BatteryReadingIncoherent,
new Alert_BatteryLow,
new Alert_OtgFailed,
new Alert_SystemInErrorState,
new Alert_SystemInLockout,
new Alert_LongLoopUpdate,
new Alert_BluetoothAdvertisement,
new Alert_FavoriteSet,
new Alert_SunsetTimerSet,
new Alert_ChargerError}

Alerts must be sorted by importance, only the first activated one will be shown.

◆ manager

AlertManager_t lampda::logic::alerts::manager

Instanciation of the AlertManager.

external global reference to the AlertManager