Merge develop into main (#307)
## Launcher - Launcher now has optional power button to show - Launcher layout improvements - Removed text from Launcher (translations with larger amounts of text did not fit small device formats) ## T-Lora Pager - Implement power off (created `BQ25896` driver) - Implemented haptics (created `DRV2605` driver project) and buzz on startup - Reversed scroll wheel - Created `TloraEncoder` device and relocated its logic from `TloraKeyboard` - Disabled SPIRAM test to save 0.5 seconds of boot time (current boot time is very slow) - Update `ST7796` esp_lcd driver to v1.3.4 - Fixed keyboard bug: delete queue in destructor - Fixed driver dependencies: Avoiding usage of global static shared_ptr. Properly constructor-inject everywhere, or use `tt::hal::findDevices()` - I2C configuration is now immutable (you cannot disable it anymore from the I2C Settings app, as it would break crucial drivers) - Renamed I2C and UART subsystems to "Internal" ## Drivers - On/off interface added to `PowerDevice` - Created `tt::hal::Configuration.createDevices`, which is intended to replace all custom create calls for display, keyboard, etc. - Created `EncoderDevice` as a `Device` subtype ## Other Improvements - Changed `findDevices(type, function)` into a templatized function. - Improved SD card mounting ## Fixes - Show Screenshot app again - Fixed Statusbar: some updates were allowed to time out and fail silently: When the Statusbar service would do a state update, the LVGL statusbar would never get updated due to this timeout. - Fixed memory leaks in all `createSdCard()` functions (in most board implementations)
This commit is contained in:
committed by
GitHub
parent
e9f72490fc
commit
50007ea9ed
@@ -1,15 +1,11 @@
|
||||
#include "TpagerPower.h"
|
||||
|
||||
#include <Bq25896.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#define TAG "power"
|
||||
constexpr auto* TAG = "TpagerPower";
|
||||
|
||||
#define TPAGER_GAUGE_I2C_BUS_HANDLE I2C_NUM_0
|
||||
|
||||
/*
|
||||
TpagerPower::TpagerPower() : gauge(TPAGER_GAUGE_I2C_BUS_HANDLE) {
|
||||
gauge->configureCapacity(1500, 1500);
|
||||
}*/
|
||||
constexpr auto TPAGER_GAUGE_I2C_BUS_HANDLE = I2C_NUM_0;
|
||||
|
||||
TpagerPower::~TpagerPower() {}
|
||||
|
||||
@@ -29,12 +25,6 @@ bool TpagerPower::supportsMetric(MetricType type) const {
|
||||
}
|
||||
|
||||
bool TpagerPower::getMetric(MetricType type, MetricData& data) {
|
||||
/* IsCharging, // bool
|
||||
Current, // int32_t, mAh - battery current: either during charging (positive value) or discharging (negative value)
|
||||
BatteryVoltage, // uint32_t, mV
|
||||
ChargeLevel, // uint8_t [0, 100]
|
||||
*/
|
||||
|
||||
uint16_t u16 = 0;
|
||||
int16_t s16 = 0;
|
||||
switch (type) {
|
||||
@@ -46,7 +36,6 @@ bool TpagerPower::getMetric(MetricType type, MetricData& data) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case Current:
|
||||
if (gauge->getCurrent(s16)) {
|
||||
data.valueAsInt32 = s16;
|
||||
@@ -54,7 +43,6 @@ bool TpagerPower::getMetric(MetricType type, MetricData& data) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case BatteryVoltage:
|
||||
if (gauge->getVoltage(u16)) {
|
||||
data.valueAsUint32 = u16;
|
||||
@@ -62,7 +50,6 @@ bool TpagerPower::getMetric(MetricType type, MetricData& data) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case ChargeLevel:
|
||||
if (gauge->getStateOfCharge(u16)) {
|
||||
data.valueAsUint8 = u16;
|
||||
@@ -70,21 +57,23 @@ bool TpagerPower::getMetric(MetricType type, MetricData& data) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
static std::shared_ptr<PowerDevice> power;
|
||||
extern std::shared_ptr<Bq27220> bq27220;
|
||||
void TpagerPower::powerOff() {
|
||||
auto device = tt::hal::findDevice([](auto device) {
|
||||
return device->getName() == "BQ25896";
|
||||
});
|
||||
|
||||
std::shared_ptr<PowerDevice> tpager_get_power() {
|
||||
if (power == nullptr) {
|
||||
power = std::make_shared<TpagerPower>(bq27220);
|
||||
if (device == nullptr) {
|
||||
TT_LOG_E(TAG, "BQ25896 not found");
|
||||
return;
|
||||
}
|
||||
|
||||
auto bq25896 = std::reinterpret_pointer_cast<Bq25896>(device);
|
||||
if (bq25896 != nullptr) {
|
||||
bq25896->powerOff();
|
||||
}
|
||||
return power;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user