summaryrefslogtreecommitdiff
path: root/src/drivers/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-07-24 15:29:45 +1000
committerjacqueline <me@jacqueline.id.au>2024-07-24 15:29:45 +1000
commit0cc75366848e9205ac88884afcc128925024ccec (patch)
tree82fcd90d7f427c5f40112b8d8aa6293535372702 /src/drivers/include
parenteb5d0d50cd5a8d807897c08438e932083e5197c2 (diff)
downloadtangara-fw-0cc75366848e9205ac88884afcc128925024ccec.tar.gz
Add a settings screen with power+battery info
Mostly for debugging, but also u can toggle fast charging off and on now
Diffstat (limited to 'src/drivers/include')
-rw-r--r--src/drivers/include/drivers/nvs.hpp4
-rw-r--r--src/drivers/include/drivers/samd.hpp13
2 files changed, 14 insertions, 3 deletions
diff --git a/src/drivers/include/drivers/nvs.hpp b/src/drivers/include/drivers/nvs.hpp
index 8eb28cc9..e298ffc3 100644
--- a/src/drivers/include/drivers/nvs.hpp
+++ b/src/drivers/include/drivers/nvs.hpp
@@ -90,6 +90,9 @@ class NvsStorage {
auto LraCalibration() -> std::optional<LraData>;
auto LraCalibration(const LraData&) -> void;
+ auto FastCharge() -> bool;
+ auto FastCharge(bool) -> void;
+
auto PreferredBluetoothDevice() -> std::optional<bluetooth::MacAndName>;
auto PreferredBluetoothDevice(std::optional<bluetooth::MacAndName>) -> void;
@@ -150,6 +153,7 @@ class NvsStorage {
Setting<uint16_t> display_rows_;
Setting<uint8_t> haptic_motor_type_;
Setting<LraData> lra_calibration_;
+ Setting<uint8_t> fast_charge_;
Setting<uint8_t> brightness_;
Setting<uint8_t> sensitivity_;
diff --git a/src/drivers/include/drivers/samd.hpp b/src/drivers/include/drivers/samd.hpp
index 897e78d6..ff479225 100644
--- a/src/drivers/include/drivers/samd.hpp
+++ b/src/drivers/include/drivers/samd.hpp
@@ -10,6 +10,7 @@
#include <optional>
#include <string>
+#include "drivers/nvs.hpp"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
@@ -17,9 +18,7 @@ namespace drivers {
class Samd {
public:
- static auto Create() -> Samd* { return new Samd(); }
-
- Samd();
+ Samd(NvsStorage& nvs);
~Samd();
auto Version() -> std::string;
@@ -37,8 +36,14 @@ class Samd {
kChargingFast,
// The battery is full charged, and we are still plugged in.
kFullCharge,
+ // Charging failed.
+ kFault,
+ // The battery status returned isn't a known enum value.
+ kUnknown,
};
+ static auto chargeStatusToString(ChargeStatus) -> std::string;
+
auto GetChargeStatus() -> std::optional<ChargeStatus>;
auto UpdateChargeStatus() -> void;
@@ -68,6 +73,8 @@ class Samd {
Samd& operator=(const Samd&) = delete;
private:
+ NvsStorage& nvs_;
+
uint8_t version_;
std::optional<ChargeStatus> charge_status_;
UsbStatus usb_status_;