PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
Task Manager

Modules

 Task Manager Internals
 

Macros

#define TASK_LIST
 XMACRO(name,fn,docstring) for defining tasks. More...
 
#define XTASK(task, fn, doc)   TASK_ ## task /*!< doc See @ref fn. */,
 

Typedefs

typedef void(* task_fn_t) (void)
 

Enumerations

enum  task_t {
  TASK_REBOOT , TASK_FRAME_TX , TASK_FRAME_RENDER , TASK_TERMINAL_CONNECTED ,
  TASK_CMD_RX , TASK_CMD_HANDLER , TASK_CMD_PROMPT , TASK_COUNT ,
  TASK_UNDEFINED = -1
}
 Available tasks. More...
 
enum  task_status_t { TASK_STATUS_IDLE , TASK_STATUS_QUEUED , TASK_STATUS_PENDING , TASK_STATUS_RUNNING }
 Task status. More...
 

Functions

void tasks_run (task_fn_t idle_task)
 Main task runner loop. More...
 
void tasks_queue (task_t task)
 Queue a task for execution. More...
 
task_status_t tasks_status_get (task_t task)
 Gets the status of a given task. More...
 

Detailed Description

Macro Definition Documentation

◆ TASK_LIST

#define TASK_LIST
Value:
XTASK(REBOOT, pixelkey_reboot, Triggers a software reset.) \
XTASK(FRAME_TX, npdata_frame_send, Transmits the last rendered frame.) \
XTASK(FRAME_RENDER, pixelkey_task_do_frame, Calculates the next frame.) \
XTASK(TERMINAL_CONNECTED, pixelkey_task_terminal_connected, Sends strings for newly connected terminals.) \
XTASK(CMD_RX, pixelkey_task_command_rx, Command string reception and parsing.) \
XTASK(CMD_HANDLER, pixelkey_commandproc_task, Command handling.) \
XTASK(CMD_PROMPT, pixelkey_task_command_prompt, Sends the command prompt string once command handling completes.) \
void npdata_frame_send(void)
Kicks off a frame transmission to the attached NeoPixels.
Definition: hal_npdata_transfer.c:179
void pixelkey_commandproc_task(void)
Executes queued commands.
Definition: command_processor.c:131
void pixelkey_task_command_prompt(void)
Sends the command prompt.
Definition: tasks.c:98
void pixelkey_task_command_rx(void)
Processes data from the USB input buffer and parses into a command.
Definition: tasks.c:106
void pixelkey_task_terminal_connected(void)
Sends initial strings for a connected terminal.
Definition: tasks.c:90
void pixelkey_task_do_frame(void)
Renders and queues a frame to be transferred at the next frame interval.
Definition: tasks.c:63

XMACRO(name,fn,docstring) for defining tasks.

Note
Tasks should be defined in order of priority (highest first).

Enumeration Type Documentation

◆ task_status_t

Task status.

Enumerator
TASK_STATUS_IDLE 

The task is idle and not queued to run.

TASK_STATUS_QUEUED 

The task has been queued to run.

TASK_STATUS_PENDING 

The task is pending execution and is awaiting higher priority tasks.

TASK_STATUS_RUNNING 

The task is currently executing.

◆ task_t

enum task_t

Available tasks.

Enumerator
TASK_REBOOT 

Triggers a software reset. See pixelkey_reboot .

TASK_FRAME_TX 

Transmits the last rendered frame. See npdata_frame_send .

TASK_FRAME_RENDER 

Calculates the next frame. See pixelkey_task_do_frame .

TASK_TERMINAL_CONNECTED 

Sends strings for newly connected terminals. See pixelkey_task_terminal_connected .

TASK_CMD_RX 

Command string reception and parsing. See pixelkey_task_command_rx .

TASK_CMD_HANDLER 

Command handling. See pixelkey_commandproc_task .

TASK_CMD_PROMPT 

Sends the command prompt string once command handling completes. See pixelkey_task_command_prompt .

TASK_COUNT 

Number of available tasks.

TASK_UNDEFINED 

Task is undefined.

Function Documentation

◆ tasks_queue()

void tasks_queue ( task_t  task)

Queue a task for execution.

Parameters
taskThe task to queue.

◆ tasks_run()

void tasks_run ( task_fn_t  idle_task)

Main task runner loop.

Priority, round-robin task manager. Never exits.

Parameters
[in]idle_taskIdle function executed when no tasks are queued, specify NULL to ignore.

◆ tasks_status_get()

task_status_t tasks_status_get ( task_t  task)

Gets the status of a given task.

Parameters
taskThe task to check.
Returns
The task status.