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

Handle update and tracking of user use statistics. More...

Classes

struct  Statistics_t
 Store the statistics of the system. More...
 

Functions

uint32_t get_alert_storage_key (uint8_t alertIndex)
 compute a key for each alert
 
uint32_t get_system_on_time ()
 system on time is easy: system always starts with time zero
 
void load_from_memory ()
 Load the statistics from the slash memeory.
 
void write_to_memory ()
 Write statistics to the system flash memory.
 
void signal_button_press ()
 Signal that a button press was detected.
 
uint32_t get_output_on_time ()
 Return the sum of the output on time. Depend on outputOn_time_s correct initialization.
 
void signal_output_on ()
 Signal that the output just turned on.
 
void signal_output_off ()
 Signal that the output just turned off.
 
uint32_t get_battery_charging_time ()
 Get the total battery charge time. Uses internally the batteryCharge_time_s to track when the charge started.
 
void signal_battery_charging_on ()
 Signal that the battery is charging.
 
void signal_battery_charging_off ()
 Signal that the battery is not charging.
 
void signal_alert_raised (uint32_t alertMask)
 Signal that an alert of any type was raised.
 
void show (const bool shouldShowAlerts=true)
 Debug the statistics to serial output.
 

Variables

static constexpr uint8_t alertArraySize = 32
 Size of the alert array. It should be egal to the maximum alert count.
 
Statistics_t statistics
 Statistics holder.
 
static constexpr uint32_t bootCountKey = utils::hash("bootCnt")
 hash key of the bootCount statistic
 
static constexpr uint32_t buttonPressCountKey = utils::hash("buttonP")
 hash key of the button press count
 
static constexpr uint32_t systemOnTimeSKey = utils::hash("sysOn")
 hash key of the system on time
 
static constexpr uint32_t outputOnTimeSKey = utils::hash("outOn")
 hash key of the output on time
 
static constexpr uint32_t chargeOnTimeSKey = utils::hash("chrgOn")
 hash key of the charging time
 
static uint32_t outputOn_time_s = UINT32_MAX
 Keep track of the output on start time.
 
static uint32_t batteryCharge_time_s = UINT32_MAX
 store the battery charge time sum
 

Detailed Description

Handle update and tracking of user use statistics.

Function Documentation

◆ show()

void lampda::logic::statistics::show ( const bool  shouldShowAlerts = true)

Debug the statistics to serial output.

Parameters
[in]shouldShowAlertsIf true, the alerts statistics will be displayed.

◆ signal_alert_raised()

void lampda::logic::statistics::signal_alert_raised ( uint32_t  alertMask)

Signal that an alert of any type was raised.

Parameters
[in]alertMaskbitwise mask of raised alerts