Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef C__USERS_BIPPI_ONEDRIVE_DOCUMENTS_ARDUINO_STEPMOTORV3_4_STEPMOTORV3_4_INO_STEPMOTORV3_4_TASKMANAGER_H_
- #define C__USERS_BIPPI_ONEDRIVE_DOCUMENTS_ARDUINO_STEPMOTORV3_4_STEPMOTORV3_4_INO_STEPMOTORV3_4_TASKMANAGER_H_
- // Copyright [2024] <Bipping>
- #include <avr/sleep.h>
- #include <avr/power.h>
- #include <avr/interrupt.h>
- #define MAX_TASKS 10
- const uint32_t DEFAULT_MARGIN = 288;
- uint8_t taskCount;
- volatile uint8_t isrCounter;
- volatile uint8_t remainingMicros;
- uint32_t margin;
- typedef void (*TaskFunction)(void);
- struct Task {
- TaskFunction callback;
- uint32_t interval;
- uint32_t lastRun;
- };
- // Enum for sleep modes
- enum SleepMode {
- IDLE_MODE,
- POWER_SAVE_MODE,
- EXTENDED_STANDBY_MODE
- };
- Task tasks[MAX_TASKS];
- void addTask(TaskFunction callback, uint32_t interval);
- void removeTask(TaskFunction callback);
- void changeTaskInterval(TaskFunction callback, uint32_t newInterval);
- void setSleepMode(SleepMode mode);
- void updateTasks();
- #endif // C__USERS_BIPPI_ONEDRIVE_DOCUMENTS_ARDUINO_STEPMOTORV3_4_STEPMOTORV3_4_INO_STEPMOTORV3_4_TASKMANAGER_H_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement