Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
power_handler.h
Go to the documentation of this file.
1
5#ifndef POWER_POWER_HANDLER_H
6#define POWER_POWER_HANDLER_H
7
8#include <cstdint>
9#include <string>
10
11namespace lampda {
12namespace logic {
15namespace power {
16
21void init();
26bool is_setup();
27
29bool is_started();
35
50bool go_to_otg_mode();
55bool go_to_idle();
60bool go_to_shutdown();
65bool go_to_error();
66
73void set_output_voltage_mv(const uint16_t outputVoltage_mV);
80void set_output_max_current_mA(const uint16_t outputCurrent_mA);
81
91void set_temporary_output(const uint16_t outputVoltage_mV, const uint16_t outputCurrent_mA, const uint16_t timeout_ms);
92
98bool enable_charge(const bool);
99
103std::string get_state();
108std::string get_error_string();
109
115
119bool is_in_output_mode();
123bool is_in_otg_mode();
124
127
128} // namespace power
129} // namespace logic
130} // namespace lampda
131
132#endif
bool was_started_in_battery_recovery()
Indicates if the charger tried the battery recovery system.
Definition: power_handler.cpp:784
bool go_to_error()
Set the power handler to ERROR mode (locked safety state)
Definition: power_handler.cpp:722
bool enable_charge(const bool enable)
Block or allow the charging of the battery. Note that the system can still be in CHARGING_MODE mode i...
Definition: power_handler.cpp:771
bool is_started()
Return true when power machine finally exits the STARTUP.
Definition: power_handler.cpp:790
bool go_to_output_mode()
Set the power handler to main OUTPUT_VOLTAGE_MODE.
Definition: power_handler.cpp:652
bool is_output_mode_ready()
Return true when the current state is OUTPUT_VOLTAGE_MODE, and the desired voltage are set and gates ...
Definition: power_handler.cpp:139
bool go_to_charger_mode()
Set the power handler to battery CHARGING_MODE.
Definition: power_handler.cpp:670
std::string get_error_string()
Return the error string if set, or "x".
Definition: power_handler.cpp:80
bool is_setup()
Return true if the power handler system is effectivly started.
Definition: power_handler.cpp:788
bool go_to_idle()
Set the power handler to IDLE mode (no power output/input)
Definition: power_handler.cpp:701
bool is_in_error_state()
Return true if the power handling is locked in an ERROR state. No power actions can be made.
Definition: power_handler.cpp:649
void set_temporary_output(const uint16_t outputVoltage_mV, const uint16_t outputCurrent_mA, const uint16_t timeout)
Set a new output with a time limit, after wich the output will go back to the original values....
Definition: power_handler.cpp:753
bool is_in_output_mode()
Return true if the current state is OUTPUT_VOLTAGE_MODE.
Definition: power_handler.cpp:782
std::string get_state()
Return the current state, as a string.
Definition: power_handler.cpp:777
void set_output_voltage_mv(const uint16_t outputVoltage_mV)
Set the desired output voltage of the charger.
Definition: power_handler.cpp:731
void init()
Call once at system startup. This can fail, and it would set the state to ERROR.
Definition: power_handler.cpp:792
bool go_to_shutdown()
Set the power handler to SHUTDOWN mode (last mode before shuting system down)
Definition: power_handler.cpp:712
bool is_in_otg_mode()
Return true if the current state is OTG_MODE.
Definition: power_handler.cpp:783
bool go_to_otg_mode()
Set the power handler to OTG_MODE (eg: external battery mode)
Definition: power_handler.cpp:683
void set_output_max_current_mA(const uint16_t outputCurrent_mA)
Set the desired maximum output current of the charger. This is just an information,...
Definition: power_handler.cpp:747
Program scope.
Definition: control_fixed_modes.hpp:12