chipKIT® Development Platform

Inspired by Arduino™

Last edit: 2021-03-21 22:34 by Majenko

SetTaskState

  1. Synopsis

  2. Parameter

  3. Description

  4. Return Value

  5. Conforming To

  6. Example

  7. See Also

Synopsis

 void setTaskState(int id, unsigned short state)  

Parameter

id : Task identifier of task to modify
state : Task enable state to set

Description

This function will modify the enable state of the specified task. The enable states are the same as in createTask(). This can have the following values:

TASK_ENABLE The task is enabled and will be run at the specified intervals.
TASK_DISABLE The task is disabled and will not be run.
TASK_RUN_ONCE The task is enabled to run once and then will become disabled after running.
Number ‘n’ The task is enabled to run and will run ‘n’ times. After the ‘n’th execution, the task becomes disabled.

Return Value

None.

Conforming To

The Task Management Functions are specific to ChipKit and exceed the Arduino 1.6.x specification.

Example

 int blink_id;
 int test_id;
 unsigned long blink_var;
 void blink_task(int id, void * tptr) {
   digitalWrite(led, !digitalRead(led); // Toggle pin state
 }
 void setup() {
   pinMode(led, OUTPUT);
   blink_id = createTask(blink_task, 200, TASK_ENABLE, &blink_var);
   setTaskState( blink_id, TASK_RUN_ONCE);
 }

See Also

createTask(), destroyTask(), getTaskId(), getTaskNextExec(), getTaskPeriod(), getTaskState(), getTaskVar(), setTaskPeriod(), setTaskState(), setTaskVar(), startTaskAt(),