HAL renaming & relocation (#215)

Implemented more consistent naming:
- Moved all HAL devices into their own namespace (and related folder)
- Post-fixed all HAL device names with "Device"
This commit is contained in:
Ken Van Hoeylandt
2025-02-09 16:48:23 +01:00
committed by GitHub
parent a7a3b17ff6
commit 2345ba6d13
62 changed files with 263 additions and 250 deletions
+2 -2
View File
@@ -4,9 +4,9 @@
#include "Tactility/file/File.h"
#include "Tactility/service/loader/Loader.h"
#include "Tactility/hal/sdcard/SdCardDevice.h"
#include <Tactility/Log.h>
#include <Tactility/StringUtils.h>
#include <Tactility/hal/SdCard.h>
#include "esp_elf.h"
@@ -50,7 +50,7 @@ private:
assert(elfFileData == nullptr);
size_t size = 0;
hal::withSdCardLock<void>(filePath, [this, &size](){
hal::sdcard::withSdCardLock<void>(filePath, [this, &size](){
elfFileData = file::readBinary(filePath, size);
});
+3 -4
View File
@@ -5,8 +5,8 @@
#include "Tactility/service/loader/Loader.h"
#include "Tactility/lvgl/Style.h"
#include "Tactility/hal/display/DisplayDevice.h"
#include <Tactility/TactilityPrivate.h>
#include <Tactility/hal/Display.h>
#include <Tactility/hal/usb/Usb.h>
#include <Tactility/kernel/SystemEvents.h>
@@ -24,8 +24,8 @@
namespace tt::app::boot {
static std::shared_ptr<tt::hal::Display> getHalDisplay() {
return hal::findFirstDevice<hal::Display>(hal::Device::Type::Display);
static std::shared_ptr<tt::hal::display::DisplayDevice> getHalDisplay() {
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
}
class BootApp : public App {
@@ -57,7 +57,6 @@ private:
TickType_t ticks_passed = end_time - start_time;
TickType_t minimum_ticks = (CONFIG_TT_SPLASH_DURATION / portTICK_PERIOD_MS);
if (minimum_ticks > ticks_passed) {
TT_LOG_I(TAG, "Remaining delay: %lu", minimum_ticks - ticks_passed);
kernel::delayTicks(minimum_ticks - ticks_passed);
}
+4 -4
View File
@@ -1,6 +1,6 @@
#include "Tactility/app/display/DisplaySettings.h"
#include "Tactility/hal/Display.h"
#include "Tactility/hal/display/DisplayDevice.h"
#include "Tactility/lvgl/Toolbar.h"
#include <Tactility/Assets.h>
@@ -22,8 +22,8 @@ static uint8_t gamma = 255;
#define ROTATION_270 2
#define ROTATION_90 3
static std::shared_ptr<tt::hal::Display> getHalDisplay() {
return hal::findFirstDevice<hal::Display>(hal::Device::Type::Display);
static std::shared_ptr<tt::hal::display::DisplayDevice> getHalDisplay() {
return hal::findFirstDevice<hal::display::DisplayDevice>(hal::Device::Type::Display);
}
static void onBacklightSliderEvent(lv_event_t* event) {
@@ -46,7 +46,7 @@ static void onGammaSliderEvent(lv_event_t* event) {
auto* slider = static_cast<lv_obj_t*>(lv_event_get_target(event));
auto* lvgl_display = lv_display_get_default();
assert(lvgl_display != nullptr);
auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display);
auto* hal_display = (tt::hal::display::DisplayDevice*)lv_display_get_user_data(lvgl_display);
assert(hal_display != nullptr);
if (hal_display->getGammaCurveCount() > 0) {
+3 -3
View File
@@ -1,9 +1,9 @@
#include "Tactility/app/files/State.h"
#include "Tactility/app/files/FileUtils.h"
#include "Tactility/hal/sdcard/SdCardDevice.h"
#include <Tactility/Log.h>
#include <Tactility/Partitions.h>
#include <Tactility/hal/SdCard.h>
#include <Tactility/kernel/Kernel.h>
#include <cstring>
@@ -59,10 +59,10 @@ bool State::setEntriesForPath(const std::string& path) {
.d_name = DATA_PARTITION_NAME
});
auto sdcards = tt::hal::findDevices<hal::SdCard>(hal::Device::Type::SdCard);
auto sdcards = tt::hal::findDevices<hal::sdcard::SdCardDevice>(hal::Device::Type::SdCard);
for (auto& sdcard : sdcards) {
auto state = sdcard->getState();
if (state == hal::SdCard::State::Mounted) {
if (state == hal::sdcard::SdCardDevice::State::Mounted) {
auto mount_name = sdcard->getMountPath().substr(1);
auto dir_entry = dirent {
.d_ino = 2,
+9 -9
View File
@@ -4,10 +4,10 @@
#include "Tactility/lvgl/Toolbar.h"
#include "Tactility/service/loader/Loader.h"
#include <Tactility/hal/Device.h>
#include <Tactility/hal/Power.h>
#include "Tactility/hal/power/PowerDevice.h"
#include <Tactility/Assets.h>
#include <Tactility/Timer.h>
#include <Tactility/hal/Device.h>
#include <lvgl.h>
@@ -35,7 +35,7 @@ private:
Timer update_timer = Timer(Timer::Type::Periodic, &onTimer, nullptr);
std::shared_ptr<hal::Power> power;
std::shared_ptr<hal::power::PowerDevice> power;
lv_obj_t* enableLabel = nullptr;
lv_obj_t* enableSwitch = nullptr;
@@ -71,8 +71,8 @@ private:
void updateUi() {
const char* charge_state;
hal::Power::MetricData metric_data;
if (power->getMetric(hal::Power::MetricType::IsCharging, metric_data)) {
hal::power::PowerDevice::MetricData metric_data;
if (power->getMetric(hal::power::PowerDevice::MetricType::IsCharging, metric_data)) {
charge_state = metric_data.valueAsBool ? "yes" : "no";
} else {
charge_state = "N/A";
@@ -80,7 +80,7 @@ private:
uint8_t charge_level;
bool charge_level_scaled_set = false;
if (power->getMetric(hal::Power::MetricType::ChargeLevel, metric_data)) {
if (power->getMetric(hal::power::PowerDevice::MetricType::ChargeLevel, metric_data)) {
charge_level = metric_data.valueAsUint8;
charge_level_scaled_set = true;
}
@@ -90,14 +90,14 @@ private:
int32_t current;
bool current_set = false;
if (power->getMetric(hal::Power::MetricType::Current, metric_data)) {
if (power->getMetric(hal::power::PowerDevice::MetricType::Current, metric_data)) {
current = metric_data.valueAsInt32;
current_set = true;
}
uint32_t battery_voltage;
bool battery_voltage_set = false;
if (power->getMetric(hal::Power::MetricType::BatteryVoltage, metric_data)) {
if (power->getMetric(hal::power::PowerDevice::MetricType::BatteryVoltage, metric_data)) {
battery_voltage = metric_data.valueAsUint32;
battery_voltage_set = true;
}
@@ -139,7 +139,7 @@ private:
public:
void onCreate(AppContext& app) override {
power = hal::findFirstDevice<hal::Power>(hal::Device::Type::Power);
power = hal::findFirstDevice<hal::power::PowerDevice>(hal::Device::Type::Power);
}
void onShow(AppContext& app, lv_obj_t* parent) override {
@@ -205,9 +205,13 @@ void ScreenshotApp::createFilePathWidgets(lv_obj_t* parent) {
lv_textarea_set_one_line(pathTextArea, true);
lv_obj_set_flex_grow(pathTextArea, 1);
if (kernel::getPlatform() == kernel::PlatformEsp) {
auto sdcard = tt::hal::getConfiguration()->sdcard;
if (sdcard != nullptr && sdcard->getState() == hal::SdCard::State::Mounted) {
lv_textarea_set_text(pathTextArea, "A:/sdcard");
auto sdcard_devices = tt::hal::findDevices<tt::hal::sdcard::SdCardDevice>(tt::hal::Device::Type::SdCard);
if (sdcard_devices.size() > 1) {
TT_LOG_W(TAG, "Found multiple SD card devices - picking first");
}
if (!sdcard_devices.empty() && sdcard_devices.front()->isMounted()) {
std::string lvgl_mount_path = "A:" + sdcard_devices.front()->getMountPath();
lv_textarea_set_text(pathTextArea, lvgl_mount_path.c_str());
} else {
lv_textarea_set_text(pathTextArea, "Error: no SD card");
}