Add kernel drivers for SPI and UART and make locking APIs more consistent (#489)
- Add kernel support for SPI driver - Add kernel support for UART driver - Implemented ESP32 UART kernel driver - Update existing UART-related code in Tactility to use new kernel driver - Remove UART from tt::hal::Configuration - Remove tt_hal_uart functionality but keep functions for now - Update devicetrees for UART changes - Kernel mutex and recursive mutex: improved locking API design - Other kernel improvements - Added device_exists_of_type() and device_find_by_name()
This commit is contained in:
committed by
GitHub
parent
7e24105d0c
commit
74127a5f6c
@@ -3,11 +3,11 @@
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/hal/gps/GpsDevice.h>
|
||||
#include <Tactility/hal/uart/Uart.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/service/gps/GpsService.h>
|
||||
|
||||
#include "tactility/drivers/uart_controller.h"
|
||||
#include <cstring>
|
||||
#include <lvgl.h>
|
||||
|
||||
@@ -21,6 +21,8 @@ class AddGpsApp final : public App {
|
||||
lv_obj_t* modelDropdown = nullptr;
|
||||
lv_obj_t* baudDropdown = nullptr;
|
||||
|
||||
std::vector<::Device*> devices;
|
||||
|
||||
// Store as string instead of int, so app startup doesn't require parsing all entries.
|
||||
// We only need to parse back to int when adding the new GPS entry
|
||||
std::array<uint32_t, 6> baudRates = { 9600, 19200, 28800, 38400, 57600, 115200 };
|
||||
@@ -69,6 +71,24 @@ class AddGpsApp final : public App {
|
||||
}
|
||||
}
|
||||
|
||||
void updateUartDevices() {
|
||||
devices.clear();
|
||||
device_for_each_of_type(&UART_CONTROLLER_TYPE, &devices, [](auto* device, auto* context){
|
||||
auto* vector_ptr = static_cast<std::vector<::Device*>*>(context);
|
||||
vector_ptr->push_back(device);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
std::string getUartDropdownNames() {
|
||||
std::vector<std::string> names;
|
||||
names.push_back("");
|
||||
for (auto* device: devices) {
|
||||
names.push_back(device->name);
|
||||
}
|
||||
return string::join(names, "\n");
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent) final {
|
||||
@@ -95,9 +115,9 @@ public:
|
||||
|
||||
uartDropdown = lv_dropdown_create(uart_wrapper);
|
||||
|
||||
auto uart_names = hal::uart::getNames();
|
||||
uart_names.insert(uart_names.begin(), "");
|
||||
auto uart_options = string::join(uart_names, "\n");
|
||||
updateUartDevices();
|
||||
|
||||
auto uart_options = getUartDropdownNames();
|
||||
lv_dropdown_set_options(uartDropdown, uart_options.c_str());
|
||||
lv_obj_align(uartDropdown, LV_ALIGN_TOP_RIGHT, 0, 0);
|
||||
lv_obj_set_width(uartDropdown, LV_PCT(50));
|
||||
|
||||
@@ -292,14 +292,18 @@ class GpsSettingsApp final : public App {
|
||||
lv_obj_add_flag(statusLabelWidget, LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
lv_obj_clean(gpsConfigWrapper);
|
||||
std::vector<tt::hal::gps::GpsConfiguration> configurations;
|
||||
auto gps_service = tt::service::gps::findGpsService();
|
||||
if (gps_service && gps_service->getGpsConfigurations(configurations)) {
|
||||
int index = 0;
|
||||
for (auto& configuration : configurations) {
|
||||
createGpsView(configuration, index++);
|
||||
if (!lv_obj_has_flag(gpsConfigWrapper, LV_OBJ_FLAG_HIDDEN)) {
|
||||
lv_obj_clean(gpsConfigWrapper);
|
||||
std::vector<tt::hal::gps::GpsConfiguration> configurations;
|
||||
auto gps_service = tt::service::gps::findGpsService();
|
||||
if (gps_service && gps_service->getGpsConfigurations(configurations)) {
|
||||
int index = 0;
|
||||
for (auto& configuration : configurations) {
|
||||
createGpsView(configuration, index++);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lv_obj_clean(gpsConfigWrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Tactility/app/i2cscanner/I2cHelpers.h"
|
||||
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <Tactility/hal/i2c/I2c.h>
|
||||
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
|
||||
Reference in New Issue
Block a user