mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
* **New Features** * Time and delay utilities added (ticks, ms, µs); SD card now uses an expansion-header CS pin; HTTP downloads warn when run on the GUI task and yield to avoid blocking. * **Bug Fixes / Reliability** * Many hard-crash paths converted to guarded checks to reduce abrupt termination and improve stability. * **Tests** * Unit tests added to validate time and delay accuracy. * **Chores** * License header and build/macro updates.
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
#include "tt_hal_device.h"
|
|
|
|
#include "Tactility/Check.h"
|
|
|
|
#include <Tactility/hal/Device.h>
|
|
|
|
static tt::hal::Device::Type toTactilityDeviceType(DeviceType type) {
|
|
switch (type) {
|
|
case DEVICE_TYPE_I2C:
|
|
return tt::hal::Device::Type::I2c;
|
|
case DEVICE_TYPE_DISPLAY:
|
|
return tt::hal::Device::Type::Display;
|
|
case DEVICE_TYPE_TOUCH:
|
|
return tt::hal::Device::Type::Touch;
|
|
case DEVICE_TYPE_SDCARD:
|
|
return tt::hal::Device::Type::SdCard;
|
|
case DEVICE_TYPE_KEYBOARD:
|
|
return tt::hal::Device::Type::Keyboard;
|
|
case DEVICE_TYPE_POWER:
|
|
return tt::hal::Device::Type::Power;
|
|
case DEVICE_TYPE_GPS:
|
|
return tt::hal::Device::Type::Gps;
|
|
default:
|
|
check(false, "Device::Type not supported");
|
|
}
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
bool tt_hal_device_find(DeviceType type, DeviceId* deviceIds, uint16_t* count, uint16_t maxCount) {
|
|
assert(maxCount > 0);
|
|
|
|
int16_t currentIndex = -1;
|
|
uint16_t maxIndex = maxCount - 1;
|
|
|
|
findDevices<tt::hal::Device>(toTactilityDeviceType(type), [&](const auto& device) {
|
|
currentIndex++;
|
|
deviceIds[currentIndex] = device->getId();
|
|
// Continue if there is storage capacity left
|
|
return currentIndex < maxIndex;
|
|
});
|
|
|
|
*count = currentIndex + 1;
|
|
|
|
return currentIndex >= 0;
|
|
}
|
|
|
|
}
|