14#include "sylib/env.hpp"
18typedef pros::Mutex PlatformMutex;
19typedef pros::Task PlatformTask;
20#elif defined(SYLIB_ENV_VEXCODE)
21#define V5_MAX_DEVICE_PORTS 32
22typedef vex::mutex PlatformMutex;
23typedef vex::task PlatformTask;
47void delay_until(std::uint32_t*
const prev_time,
const std::uint32_t delta);
85class Mutex :
public PlatformMutex {
88 bool try_lock_until();
108class Task :
public PlatformTask {
111 Task(F&& func) : PlatformTask(func) {}
133 std::unique_ptr<sylib::Task> managerTask =
nullptr;
134 static int subTasksCreated;
135 static std::vector<sylib::Device*>& getLivingSubtasks();
136 static int frameCount;
240 bool subTaskPaused =
false;
266 Device(
int interval = 2,
int offset = 0);
Device Parent Class.
Definition: system.hpp:238
int getSubTaskID()
Gets the subtask ID of the device's update function.
int getUpdateFrequency()
Gets the number of frames delayed between updates.
void setUpdateFrequency(int interval)
Sets the number of frames to wait between updates.
void setUpdateOffset(int offset)
Sets the number of frames to shift the excecution of the update function.
sylib::Mutex mutex
Mutex to prevent multiple threads from performing operations on important system things at once.
Definition: system.hpp:252
bool getSubTaskPaused()
Gets whether or not the device update function is paused.
bool isSubTaskRunning()
Gets whether or not the device update function is running.
void resumeSubTask()
Resumes the device update function.
Device(int interval=2, int offset=0)
Creates a Device object.
void pauseSubTask()
Pauses the device update function.
virtual void update()=0
Default device update function. This is overridden by classes that inherit from Device for their own ...
void killSubTask()
Permanently ends the device update function.
int getUpdateOffset()
Gets the number of frames the update function is offset by.
Mutex.
Definition: system.hpp:85
bool give()
Unlocks the mutex.
bool take()
Locks the mutex.
Sylib System Daemon.
Definition: system.hpp:127
static sylib::Mutex mutex
Mutex to prevent multiple threads from performing operations on important system things at once.
Definition: system.hpp:143
static int managerTaskFunction()
The sole function that runs inside a task made specifically for the Sylib daemon. Contains an infinit...
static int createSubTask(sylib::Device *objectPointerToSchedule)
Adds a Device object or one of its child classes to the daemon's list of objects which need periodic ...
static SylibDaemon & getInstanceUnsafe()
Gets the single existing SylibDaemon object, or creates it if it doesn't exist yet.
void startSylibDaemon()
Starts the Sylib daemon. This should be called in initialize() or pre_auton()
static int createSubTaskUnsafe(sylib::Device *objectPointerToSchedule)
Adds a Device object or one of its child classes to the daemon's list of objects which need periodic ...
static SylibDaemon & getInstance()
Gets the single existing SylibDaemon object, or creates it if it doesn't exist yet.
static void removeSubTask(sylib::Device *objectPointerToSchedule)
Removes a Device object or one of its child classes from the daemon's list of objects which need peri...
static uint64_t getFrameCount()
Gets the number of ticks of the Sylib daemon update loop.
static void removeSubTaskByID(int idToKill)
Removes a subtask from the daemon's list of objects which need periodic updating.
Task.
Definition: system.hpp:108
Task(F &&func)
Definition: system.hpp:111
Definition: addrled.hpp:20
uint32_t millis()
The current system time.
uint64_t micros()
The current system time in microseconds.
void delay(std::uint32_t delay)
Delays the current task for a set number of milliseconds.
const std::lock_guard< sylib::Mutex > mutex_lock
Definition: system.hpp:116
Mutex sylib_controller_mutexes[2]
void initialize()
Starts Sylib background processes. Called by the user in initialize()
void delay_until(std::uint32_t *const prev_time, const std::uint32_t delta)
Delays the current task until a set time.
Mutex sylib_port_mutexes[V5_MAX_DEVICE_PORTS]