Compare commits

..

6 Commits

12 changed files with 56 additions and 44 deletions

View File

@ -18,33 +18,8 @@
std::shared_ptr<Bq27220> bq27220;
std::shared_ptr<Tca8418> tca8418;
static bool powerOn() {
/*
gpio_config_t device_power_signal_config = {
.pin_bit_mask = BIT64(TDECK_POWERON_GPIO),
.mode = GPIO_MODE_OUTPUT,
.pull_up_en = GPIO_PULLUP_DISABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE,
};
if (gpio_config(&device_power_signal_config) != ESP_OK) {
return false;
}
if (gpio_set_level(TDECK_POWERON_GPIO, 1) != ESP_OK) {
return false;
}
*/
return true;
}
bool tdeckInit() {
bool tpagerInit() {
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
if (!powerOn()) {
TT_LOG_E(TAG, LOG_MESSAGE_POWER_ON_FAILED);
return false;
}
/* 32 Khz and higher gives an issue where the screen starts dimming again above 80% brightness
* when moving the brightness slider rapidly from a lower setting to 100%.

View File

@ -9,12 +9,12 @@
#define TDECK_SPI_TRANSFER_SIZE_LIMIT (TDECK_LCD_HORIZONTAL_RESOLUTION * TDECK_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8))
bool tdeckInit();
bool tpagerInit();
using namespace tt::hal;
extern const Configuration lilygo_tlora_pager = {
.initBoot = tdeckInit,
.initBoot = tpagerInit,
.createDisplay = createDisplay,
.createKeyboard = createKeyboard,
.sdcard = createTpagerSdCard(),

View File

@ -19,7 +19,9 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
true, //swapXY
true, //mirrorX
true, //mirrorY
true //invertColor
true, //invertColor
0, //gapX
49 //gapY
);
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;

View File

@ -219,6 +219,10 @@ void TpagerKeyboard::initEncoder(void) {
const int low_limit = -127;
const int high_limit = 126;
// Original implementation based on
// https://github.com/UsefulElectronics/esp32s3-gc9a01-lvgl/blob/main/main/hardware/rotary_encoder.c
// Copyright (c) 2023 Ward Almasarani
// Accum. count makes it that over- and underflows are automatically compensated.
// Prerequisite: watchpoints at low and high limit
pcnt_unit_config_t unit_config = {

View File

@ -1,5 +1,6 @@
# BQ24295
# BQ27220
Power management: I2C-controlled 3A single cell USB charger with narrow VDC 4.5-5.5V adjustable voltage at 1.5A synchronous boost operation.
Power management: Single-Cell CEDV Fuel Gauge
[Datasheet](https://www.ti.com/lit/ds/symlink/bq24295.pdf)
[Datasheet](https://www.ti.com/lit/gpn/bq27220)
[User Guide](https://www.ti.com/lit/pdf/sluubd4)

View File

@ -7,9 +7,9 @@
#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a)))
uint8_t highByte(const uint16_t word) { return (word >> 8) & 0xFF; }
uint8_t lowByte(const uint16_t word) { return word & 0xFF; }
void swapEndianess(uint16_t &word) { word = (lowByte(word) << 8) | highByte(word); }
static uint8_t highByte(const uint16_t word) { return (word >> 8) & 0xFF; }
static uint8_t lowByte(const uint16_t word) { return word & 0xFF; }
static constexpr void swapEndianess(uint16_t &word) { word = (lowByte(word) << 8) | highByte(word); }
namespace registers {
static const uint16_t SUBCMD_CTRL_STATUS = 0x0000U;
@ -314,8 +314,6 @@ bool Bq27220::configPreamble(bool &isSealed) {
if (!unsealFullAccess()) {
TT_LOG_E(TAG, "Unsealing full access failure!");
return false;
} else {
TT_LOG_I(TAG, "Full access theoretically.");
}
}

View File

@ -20,6 +20,11 @@ private:
template<typename T>
bool performConfigUpdate(T configUpdateFunc)
{
// Configuration routine lifted from
// https://github.com/Xinyuan-LilyGO/T-Echo/blob/main/lib/SensorLib/src/GaugeBQ27220.hpp
// Copyright (c) 2025 lewis he
// SPDX-License-Identifier: MIT
bool isSealed = false;
if (!configPreamble(isSealed)) {
@ -32,6 +37,10 @@ private:
}
public:
// Register structures lifted from
// https://github.com/Xinyuan-LilyGO/T-Deck-Pro/blob/master/lib/BQ27220/bq27220.h
// Copyright (c) 2025 Liygo / Shenzhen Xinyuan Electronic Technology Co., Ltd
union BatteryStatus {
struct
{

View File

@ -1,3 +1,3 @@
# ST7789
# ST7796
A basic ESP32 LVGL driver for ST7789 displays.
A basic ESP32 LVGL driver for ST7796 displays.

View File

@ -123,7 +123,7 @@ bool St7796Display::start() {
return false;
}
if (esp_lcd_panel_set_gap(panelHandle, 0, 49) != ESP_OK) {
if (esp_lcd_panel_set_gap(panelHandle, configuration->gapX, configuration->gapY) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel gap");
return false;
}

View File

@ -28,6 +28,8 @@ public:
bool mirrorX = false,
bool mirrorY = false,
bool invertColor = false,
unsigned int gapX = 0,
unsigned int gapY = 0,
uint32_t bufferSize = 0 // Size in pixel count. 0 means default, which is 1/10 of the screen size
) : spiBusHandle(spi_bus_handle),
csPin(csPin),
@ -38,6 +40,8 @@ public:
mirrorX(mirrorX),
mirrorY(mirrorY),
invertColor(invertColor),
gapX(gapX),
gapY(gapY),
bufferSize(bufferSize),
touch(std::move(touch)) {}
@ -53,6 +57,8 @@ public:
bool mirrorX = false;
bool mirrorY = false;
bool invertColor = false;
unsigned int gapX = 0;
unsigned int gapY = 0;
uint32_t bufferSize = 0; // Size in pixel count. 0 means default, which is 1/10 of the screen size
std::shared_ptr<tt::hal::touch::TouchDevice> touch;
std::function<void(uint8_t)> _Nullable backlightDutyFunction = nullptr;

View File

@ -0,0 +1,18 @@
Copyright 2023 Anthony DiGirolamo
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,5 +1,4 @@
# BQ24295
# TCA8418 I2C Controlled Keypad Scan IC With Integrated ESD Protection
Power management: I2C-controlled 3A single cell USB charger with narrow VDC 4.5-5.5V adjustable voltage at 1.5A synchronous boost operation.
[Datasheet](https://www.ti.com/lit/ds/symlink/bq24295.pdf)
[Datasheet](https://www.ti.com/lit/ds/symlink/tca8418.pdf?ts=1751500237439)
[Original implementation](https://github.com/AnthonyDiGirolamo/i2c-thumb-keyboard/tree/master) by Anthony DiGirolamo