* SdCard HAL refactored (#135) - Refactor SdCard HAL - introduce Lockable * Screenshot and FatFS improvements (#136) - Fix screenshots on ESP32 - Improve Screenshot service - Convert Screenshot app to class-based instead of structs - Screenshot app now automatically updates when task is finished - Enable FatFS long filename support * Re-use common log messages (#138) For consistency and binary size reduction * Toolbar spinner should get margin to the right * More TactilityC features (#139) * Rewrote Loader - Simplified Loader by removing custom threa - Created DispatcherThread - Move auto-starting apps to Boot app - Fixed Dispatcher bug where it could get stuck not processing new messages * Hide AP settings if the AP is not saved * Missing from previous commit * Replace LV_EVENT_CLICKED with LV_EVENT_SHORT_CLICKED * Refactored files app and created InputDialog (#140) - Changed Files app so that it has a View and State - Files app now allows for long-pressing on files to perform actions - Files app now has rename and delete actions - Created InputDialog app - Improved AlertDialog app layout
99 lines
2.4 KiB
C++
99 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "CoreTypes.h"
|
|
|
|
#include "RtosCompatTimers.h"
|
|
#include <memory>
|
|
|
|
namespace tt {
|
|
|
|
class Timer {
|
|
private:
|
|
TimerHandle_t timerHandle;
|
|
public:
|
|
|
|
typedef void (*Callback)(std::shared_ptr<void> context);
|
|
typedef void (*PendingCallback)(void* context, uint32_t arg);
|
|
|
|
Callback callback;
|
|
std::shared_ptr<void> callbackContext;
|
|
|
|
typedef enum {
|
|
TypeOnce = 0, ///< One-shot timer.
|
|
TypePeriodic = 1 ///< Repeating timer.
|
|
} Type;
|
|
|
|
/**
|
|
* @param[in] type The timer type
|
|
* @param[in] callback The callback function
|
|
* @param callbackContext The callback context
|
|
*/
|
|
Timer(Type type, Callback callback, std::shared_ptr<void> callbackContext);
|
|
|
|
~Timer();
|
|
|
|
/** Start timer
|
|
*
|
|
* @warning This is asynchronous call, real operation will happen as soon as
|
|
* timer service process this request.
|
|
*
|
|
* @param[in] ticks The interval in ticks
|
|
* @return success result
|
|
*/
|
|
bool start(uint32_t intervalTicks);
|
|
|
|
/** 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] ticks The interval in ticks
|
|
*
|
|
* @return success result
|
|
*/
|
|
bool restart(uint32_t intervalTicks);
|
|
|
|
|
|
/** 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
|
|
*
|
|
* @param instance The Timer instance
|
|
*
|
|
* @return expire tick
|
|
*/
|
|
uint32_t getExpireTime();
|
|
|
|
bool setPendingCallback(PendingCallback callback, void* callbackContext, uint32_t arg);
|
|
|
|
typedef enum {
|
|
TimerThreadPriorityNormal, /**< Lower then other threads */
|
|
TimerThreadPriorityElevated, /**< Same as other threads */
|
|
} ThreadPriority;
|
|
|
|
/** Set Timer thread priority
|
|
*
|
|
* @param[in] priority The priority
|
|
*/
|
|
void setThreadPriority(ThreadPriority priority);
|
|
};
|
|
|
|
} // namespace
|