## New
- Read property files with `PropertiesFile`
- Support `boot.properties` so the user can specify the launcher app and an optional app to start after the launcher finishes. (see `BootProperties.cpp`)
- Create registry for CPU affinity and update code to make use of it
- `AppRegistration` and `ServiceRegistration` now also ensure that the `/data` directories always exist for all apps
- `Notes` is now the default app for opening text files. `TextViewer` is removed entirely. Created `tt::app:🎶:start(path)` function.
- WiFi settings moved from NVS to properties file.
- Specify `*.ap.properties` file on the SD card for automatic WiFi settings import on start-up.
- Added `file::getLock(path)` and `file::withLock(path, function)` to do safe file operations on SD cards
## Improvements
- Update TinyUSB to `1.7.6~1`
- Improved `Boot.cpp` code. General code quality fixes and some restructuring to improve readability.
- `tt::string` functionality improvements
- Rename `AppRegistry` to `AppRegistration`
- Rename `ServiceRegistry` to `ServiceRegistration`
- Cleanup in `Notes.cpp`
- `FileTest.cpp` fix for PC
- Created `TestFile` helper class for tests, which automatically deletes files after the test.
- Renamed `Partitions.h` to `MountPoints.h`
- Created `std::string getMountPoints()` function for easy re-use
- Other code quality improvements
- `SdCardDevice`'s `getState()` and `isMounted()` now have a timeout argument
## Fixes
- ELF loading now has a lock so to avoid a bug when 2 ELF apps are loaded in parallel
99 lines
2.7 KiB
C++
99 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include "RtosCompatTimers.h"
|
|
#include "Thread.h"
|
|
|
|
#include <memory>
|
|
#include <functional>
|
|
|
|
namespace tt {
|
|
|
|
class Timer {
|
|
|
|
public:
|
|
|
|
typedef std::function<void()> Callback;
|
|
typedef void (*PendingCallback)(void* context, uint32_t arg);
|
|
|
|
private:
|
|
|
|
struct TimerHandleDeleter {
|
|
void operator()(TimerHandle_t handleToDelete) const {
|
|
xTimerDelete(handleToDelete, portMAX_DELAY);
|
|
}
|
|
};
|
|
|
|
Callback callback;
|
|
std::unique_ptr<std::remove_pointer_t<TimerHandle_t>, TimerHandleDeleter> handle;
|
|
|
|
static void onCallback(TimerHandle_t hTimer);
|
|
|
|
public:
|
|
|
|
enum class Type {
|
|
Once = 0, ///< One-shot timer.
|
|
Periodic = 1 ///< Repeating timer.
|
|
};
|
|
|
|
enum class Priority{
|
|
Normal, /**< Lower then other threads */
|
|
Elevated, /**< Same as other threads */
|
|
};
|
|
|
|
/**
|
|
* @param[in] type The timer type
|
|
* @param[in] callback The callback function
|
|
*/
|
|
Timer(Type type, Callback callback);
|
|
|
|
~Timer();
|
|
|
|
/** Start timer
|
|
* @warning This is asynchronous call, real operation will happen as soon as timer service process this request.
|
|
* @param[in] interval The interval in ticks
|
|
* @return success result
|
|
*/
|
|
bool start(TickType_t interval);
|
|
|
|
/** Restart timer with previous timeout value
|
|
* @warning This is asynchronous call, real operation will happen as soon as timer service process this request.
|
|
* @param[in] interval The interval in ticks
|
|
* @return success result
|
|
*/
|
|
bool restart(TickType_t interval);
|
|
|
|
/** Stop timer
|
|
* @warning This is asynchronous call, real operation will happen as soon as timer service process this request.
|
|
* @return success result
|
|
*/
|
|
bool stop();
|
|
|
|
/** Is timer running
|
|
* @warning This cal may and will return obsolete timer state if timer commands are still in the queue. Please read FreeRTOS timer documentation first.
|
|
* @return true when running
|
|
*/
|
|
bool isRunning();
|
|
|
|
/** Get timer expire time
|
|
* @return expire tick
|
|
*/
|
|
TickType_t getExpireTime();
|
|
|
|
/**
|
|
* Calls xTimerPendFunctionCall internally.
|
|
* @param[in] callback the function to call
|
|
* @param[in] callbackContext the first function argument
|
|
* @param[in] callbackArg the second function argument
|
|
* @param[in] timeout the function timeout (must set to 0 in ISR mode)
|
|
* @return true on success
|
|
*/
|
|
bool setPendingCallback(PendingCallback callback, void* callbackContext, uint32_t callbackArg, TickType_t timeout);
|
|
|
|
/** Set Timer thread priority
|
|
* @param[in] priority The priority
|
|
*/
|
|
void setThreadPriority(Thread::Priority priority);
|
|
};
|
|
|
|
} // namespace
|