GPS refactored (#262)

- Refactored GPS service and HAL: GPS is no longer part of the HAL configuration. You can now add configure new GPS devices from the GPS settings app.
- T-Deck adds a boot hook to check if a GPS configuration exists and adds it when the config is empty.
- Implemented the concept of ObjectFile to read/write arrays of a raw data type (e.g. struct) to disk.
- Implemented more file utils (e.g. to create all directories of a path)
This commit is contained in:
Ken Van Hoeylandt
2025-03-30 01:14:22 +01:00
committed by GitHub
parent 81ece6f2e7
commit d0ca3b16f8
47 changed files with 1266 additions and 277 deletions
@@ -138,6 +138,5 @@ extern const Configuration crowpanel_advance_28 = {
}
}
}
},
.gps = {}
}
};
@@ -138,6 +138,5 @@ extern const Configuration crowpanel_advance_35 = {
}
}
}
},
.gps = {}
}
};
@@ -121,6 +121,5 @@ extern const Configuration crowpanel_advance_50 = {
}
}
}
},
.gps = {}
}
};
@@ -116,6 +116,5 @@ extern const Configuration crowpanel_basic_28 = {
}
}
}
},
.gps = {}
}
};
@@ -116,6 +116,5 @@ extern const Configuration crowpanel_basic_35 = {
}
}
}
},
.gps = {}
}
};
@@ -86,6 +86,5 @@ extern const Configuration crowpanel_basic_50 = {
}
}
}
},
.gps = {}
}
};
+21
View File
@@ -1,6 +1,9 @@
#include "PwmBacklight.h"
#include "Tactility/kernel/SystemEvents.h"
#include "Tactility/service/gps/GpsService.h"
#include <Tactility/TactilityCore.h>
#include <Tactility/hal/gps/GpsConfiguration.h>
#define TAG "tdeck"
@@ -42,5 +45,23 @@ bool tdeckInit() {
return false;
}
tt::kernel::systemEventAddListener(tt::kernel::SystemEvent::BootSplash, [](tt::kernel::SystemEvent event){
auto gps_service = tt::service::gps::findGpsService();
if (gps_service != nullptr) {
std::vector<tt::hal::gps::GpsConfiguration> gps_configurations;
gps_service->getGpsConfigurations(gps_configurations);
if (gps_configurations.empty()) {
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {
.uartName = "Grove",
.baudRate = 38400,
.model = tt::hal::gps::GpsModel::UBLOX10
})) {
TT_LOG_I(TAG, "Configured internal GPS");
} else {
TT_LOG_E(TAG, "Failed to configure internal GPS");
}
}
}
});
return true;
}
@@ -104,13 +104,5 @@ extern const Configuration lilygo_tdeck = {
}
}
}
},
.gps = {
gps::GpsDevice::Configuration {
.name = "Internal",
.uartName = "Grove",
.baudRate = 38400,
.model = gps::GpsModel::UBLOX10
}
}
};
+118 -9
View File
@@ -1,23 +1,27 @@
#include "M5stackCoreS3.h"
#include "InitBoot.h"
#include "Tactility/lvgl/LvglSync.h"
#include "hal/CoreS3Display.h"
#include "hal/CoreS3DisplayConstants.h"
#include "hal/CoreS3Power.h"
#include "hal/CoreS3SdCard.h"
#include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/uart/Uart.h>
#define CORES3_TRANSACTION_SIZE (CORES3_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
const tt::hal::Configuration m5stack_cores3 = {
using namespace tt::hal;
const Configuration m5stack_cores3 = {
.initBoot = initBoot,
.createDisplay = createDisplay,
.sdcard = createSdCard(),
.power = createPower,
.i2c = {
tt::hal::i2c::Configuration {
i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.initMode = i2c::InitMode::ByTactility,
.isMutable = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
@@ -31,10 +35,10 @@ const tt::hal::Configuration m5stack_cores3 = {
.clk_flags = 0
}
},
tt::hal::i2c::Configuration {
.name = "External", // Grove
i2c::Configuration {
.name = "Port A", // Grove
.port = I2C_NUM_1,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.initMode = i2c::InitMode::Disabled,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
@@ -47,10 +51,44 @@ const tt::hal::Configuration m5stack_cores3 = {
},
.clk_flags = 0
}
},
i2c::Configuration {
.name = "Port B", // Grove
.port = I2C_NUM_1,
.initMode = i2c::InitMode::Disabled,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_9,
.scl_io_num = GPIO_NUM_8,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
i2c::Configuration {
.name = "Port C", // Grove
.port = I2C_NUM_1,
.initMode = i2c::InitMode::Disabled,
.isMutable = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_18,
.scl_io_num = GPIO_NUM_17,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
},
.spi {
tt::hal::spi::Configuration {
spi::Configuration {
.device = SPI3_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
@@ -69,9 +107,80 @@ const tt::hal::Configuration m5stack_cores3 = {
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
}
},
.uart {
uart::Configuration {
.name = "Port A",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_2,
.txPin = GPIO_NUM_1,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
},
uart::Configuration {
.name = "Port B",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_9,
.txPin = GPIO_NUM_8,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
},
uart::Configuration {
.name = "Port C",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_18,
.txPin = GPIO_NUM_17,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
}
}
};
-8
View File
@@ -79,13 +79,5 @@ extern const Configuration hardware = {
.name = "/dev/ttyACM0",
.baudRate = 115200
}
},
.gps = {
gps::GpsDevice::Configuration {
.name = "Internal",
.uartName = "/dev/ttyACM0",
.baudRate = 115200,
.model = gps::GpsModel::UBLOX10
}
}
};
@@ -80,6 +80,5 @@ extern const Configuration waveshare_s3_touch_43 = {
}
}
}
},
.gps = {}
}
};