## 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)
80 lines
2.0 KiB
C++
80 lines
2.0 KiB
C++
#include "TpagerPower.h"
|
|
|
|
#include <Bq25896.h>
|
|
#include <Tactility/Log.h>
|
|
|
|
constexpr auto* TAG = "TpagerPower";
|
|
|
|
constexpr auto TPAGER_GAUGE_I2C_BUS_HANDLE = I2C_NUM_0;
|
|
|
|
TpagerPower::~TpagerPower() {}
|
|
|
|
bool TpagerPower::supportsMetric(MetricType type) const {
|
|
switch (type) {
|
|
using enum MetricType;
|
|
case IsCharging:
|
|
case Current:
|
|
case BatteryVoltage:
|
|
case ChargeLevel:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
|
|
return false; // Safety guard for when new enum values are introduced
|
|
}
|
|
|
|
bool TpagerPower::getMetric(MetricType type, MetricData& data) {
|
|
uint16_t u16 = 0;
|
|
int16_t s16 = 0;
|
|
switch (type) {
|
|
using enum MetricType;
|
|
case IsCharging:
|
|
Bq27220::BatteryStatus status;
|
|
if (gauge->getBatteryStatus(status)) {
|
|
data.valueAsBool = !status.reg.DSG;
|
|
return true;
|
|
}
|
|
return false;
|
|
case Current:
|
|
if (gauge->getCurrent(s16)) {
|
|
data.valueAsInt32 = s16;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
case BatteryVoltage:
|
|
if (gauge->getVoltage(u16)) {
|
|
data.valueAsUint32 = u16;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
case ChargeLevel:
|
|
if (gauge->getStateOfCharge(u16)) {
|
|
data.valueAsUint8 = u16;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
void TpagerPower::powerOff() {
|
|
auto device = tt::hal::findDevice([](auto device) {
|
|
return device->getName() == "BQ25896";
|
|
});
|
|
|
|
if (device == nullptr) {
|
|
TT_LOG_E(TAG, "BQ25896 not found");
|
|
return;
|
|
}
|
|
|
|
auto bq25896 = std::reinterpret_pointer_cast<Bq25896>(device);
|
|
if (bq25896 != nullptr) {
|
|
bq25896->powerOff();
|
|
}
|
|
}
|