Fixes and new apps (#30)

- M5 Unit Modules library + M5 Unit Test app
- Minor fixes for TodoList, TwoEleven, Snake, Brainfuck and Breakout
- Fixed SerialConsole to use the uart controller as it was broken in one of the many updates
- Fixed keyboard input in TwoEleven, Breakout, Magic8Ball and Snake
- Bluetooth Media Keys app, supports pressing physical keys to trigger the corresponding buttonmatrix button
- Epub Reader app
This commit is contained in:
Shadowtrance
2026-06-07 23:56:32 +10:00
committed by GitHub
parent 1f959c8bbf
commit dbf850c434
127 changed files with 11156 additions and 174 deletions
@@ -0,0 +1,42 @@
#include <UnitPaHub.h>
#include <esp_log.h>
static constexpr auto* TAG = "UnitPaHub";
bool UnitPaHub::begin(Device* dev, uint8_t addr) {
if (!dev || !device_is_ready(dev)) return false;
if (!unitProbe(dev, addr)) {
ESP_LOGW(TAG, "PaHub not found at 0x%02X", addr);
return false;
}
dev_ = dev;
addr_ = addr;
// Disable all channels on init
if (!deselect()) {
ESP_LOGE(TAG, "PaHub deselect failed at 0x%02X", addr_);
dev_ = nullptr;
addr_ = 0;
return false;
}
ESP_LOGI(TAG, "PaHub ready at 0x%02X", addr_);
return true;
}
bool UnitPaHub::select(uint8_t channel) {
if (!dev_ || channel >= NUM_CHANNELS) return false;
// TCA9548A: write one byte - bit i set = channel i enabled
uint8_t mask = (uint8_t)(1u << channel);
bool ok = i2c_controller_write(dev_, addr_, &mask, 1,
pdMS_TO_TICKS(UNIT_I2C_TIMEOUT_MS)) == ERROR_NONE;
if (ok) channel_ = channel;
return ok;
}
bool UnitPaHub::deselect() {
if (!dev_) return false;
uint8_t mask = 0x00;
bool ok = i2c_controller_write(dev_, addr_, &mask, 1,
pdMS_TO_TICKS(UNIT_I2C_TIMEOUT_MS)) == ERROR_NONE;
if (ok) channel_ = NO_CHANNEL;
return ok;
}