Ken Van Hoeylandt 50007ea9ed
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)
2025-08-30 21:54:55 +02:00

68 lines
1.7 KiB
C++

#pragma once
#include <array>
#include <Tactility/hal/i2c/I2cDevice.h>
#define TCA8418_ADDRESS 0x34U
#define KEY_EVENT_LIST_SIZE 10
class Tca8418 final : public tt::hal::i2c::I2cDevice {
uint8_t tca8418_address;
uint32_t last_update_micros;
uint32_t this_update_micros;
uint8_t new_pressed_keys_count;
void clear_released_list();
void clear_pressed_list();
void add_pressed_key(uint8_t row, uint8_t col);
void add_released_key(uint8_t row, uint8_t col);
void remove_pressed_key(uint8_t row, uint8_t col);
void write(uint8_t register_address, uint8_t data);
bool read(uint8_t register_address, uint8_t* data);
public:
struct PressedKey {
uint8_t row;
uint8_t col;
uint32_t hold_time;
};
struct ReleasedKey {
uint8_t row;
uint8_t col;
};
std::string getName() const final { return "TCA8418"; }
std::string getDescription() const final { return "I2C-controlled keyboard scan IC"; }
explicit Tca8418(i2c_port_t port) : I2cDevice(port, TCA8418_ADDRESS) {
delta_micros = 0;
last_update_micros = 0;
this_update_micros = 0;
}
~Tca8418() {}
uint8_t num_rows;
uint8_t num_cols;
uint32_t delta_micros;
std::array<PressedKey, KEY_EVENT_LIST_SIZE> pressed_list;
std::array<ReleasedKey, KEY_EVENT_LIST_SIZE> released_list;
uint8_t pressed_key_count;
uint8_t released_key_count;
void init(uint8_t numrows, uint8_t numcols);
bool update();
uint8_t get_key_event();
bool button_pressed(uint8_t row, uint8_t button_bit_position);
bool button_released(uint8_t row, uint8_t button_bit_position);
bool button_held(uint8_t row, uint8_t button_bit_position);
};