TactilityKernel improvements (#464)

* **New Features**
  * Thread API with lifecycle, priority, affinity and state monitoring
  * Timer subsystem: one-shot/periodic timers, reset, pending callbacks, expiry queries
  * Expanded I²C: register-level ops, bulk writes, presence checks, ESP32 integration and new config properties
  * GPIO controller: pin level and options APIs
  * Error utilities: new error code, error-to-string, timeout helper and common macros
  * Device construction helpers (construct+start)

* **Tests**
  * New unit tests for thread and timer behavior

* **Documentation**
  * Expanded coding style guide (files/folders, C conventions)
This commit is contained in:
Ken Van Hoeylandt
2026-01-28 23:58:11 +01:00
committed by GitHub
parent f6ddb14ec1
commit 71f8369377
36 changed files with 1771 additions and 339 deletions
+22 -9
View File
@@ -19,18 +19,31 @@ std::string getAddressText(uint8_t address) {
std::string getPortNamesForDropdown() {
std::vector<std::string> config_names;
size_t port_index = 0;
for (const auto& i2c_config: tt::getConfiguration()->hardware->i2c) {
if (!i2c_config.name.empty()) {
config_names.push_back(i2c_config.name);
} else {
std::stringstream stream;
stream << "Port " << std::to_string(port_index);
config_names.push_back(stream.str());
for (int port = 0; port < I2C_NUM_MAX; ++port) {
auto native_port = static_cast<i2c_port_t>(port);
if (hal::i2c::isStarted(native_port)) {
auto* name = hal::i2c::getName(native_port);
if (name != nullptr) {
config_names.push_back(name);
}
}
port_index++;
}
return string::join(config_names, "\n");
}
bool getActivePortAtIndex(int32_t index, int32_t& out) {
int current_index = -1;
for (int port = 0; port < I2C_NUM_MAX; ++port) {
auto native_port = static_cast<i2c_port_t>(port);
if (hal::i2c::isStarted(native_port)) {
current_index++;
if (current_index == index) {
out = port;
return true;
}
}
}
return false;
}
}
@@ -141,11 +141,10 @@ void I2cScannerApp::onShow(AppContext& app, lv_obj_t* parent) {
lv_obj_add_flag(scan_list, LV_OBJ_FLAG_HIDDEN);
scanListWidget = scan_list;
auto i2c_devices = getConfiguration()->hardware->i2c;
if (!i2c_devices.empty()) {
assert(selected_bus < i2c_devices.size());
port = i2c_devices[selected_bus].port;
selectBus(selected_bus);
int32_t first_port;
if (getActivePortAtIndex(0, first_port)) {
lv_dropdown_set_selected(port_dropdown, 0);
selectBus(0);
}
}
@@ -307,12 +306,14 @@ void I2cScannerApp::onSelectBus(lv_event_t* event) {
}
void I2cScannerApp::selectBus(int32_t selected) {
auto i2c_devices = getConfiguration()->hardware->i2c;
assert(selected < i2c_devices.size());
int32_t found_port;
if (!getActivePortAtIndex(selected, found_port)) {
return;
}
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
scannedAddresses.clear();
port = i2c_devices[selected].port;
port = static_cast<i2c_port_t>(found_port);
scanState = ScanStateInitial;
mutex.unlock();
}