You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gets the remaining time of the timer with the specified id.
193
214
215
+
## Best Practices / Tips
216
+
- Update configuration values and types in the `flexitimer.h` header to match specific needs. Adjust `FLEXITIMER_MAX_TIMERS` to support more timers along with the `timer_id_t` if required, and modify the type of `timer_time_t` for saving memory in environments with limited resources:
217
+
```c
218
+
/**
219
+
@brief Number of timers
220
+
*/
221
+
#define FLEXITIMER_MAX_TIMERS (20) // Example for increasing the number of timers
222
+
223
+
/**
224
+
@brief Id unit type
225
+
*/
226
+
typedef uint16_t timer_id_t; // Example for larger ID range
227
+
228
+
/**
229
+
@brief Time unit type
230
+
*/
231
+
typedef uint16_t timer_time_t; // Example for smaller time unit to save memory
232
+
```
233
+
- Ensure callback functions are non-blocking and consist of minimal, efficient code to prevent delays in the scheduler execution.
234
+
- Use an enum to list timer IDs in a single place for easier management and readability.
235
+
- Utilize getter functions to control the flow and monitor timer states effectively.
236
+
- Always check the return values of library functions to handle errors appropriately.
237
+
- Avoid using the same callback function for both periodic and single-shot timers to prevent unexpected behavior.
238
+
- Use mutexes or other synchronization mechanisms if timers interact with shared resources in a multi-threaded environment.
239
+
- Implement robust error handling and logging within callback functions to identify and troubleshoot issues quickly.
240
+
- Consider using the Proxy design pattern to test callbacks. By using a proxy, you can intercept calls to the real callback functions, allowing you to simulate different conditions, measure execution times, and verify that the scheduler behaves correctly without modifying the actual callback logic.
0 commit comments