|
Debinix Team Library LedTask
The Arduino library shows the power of non-preemptive multitasking
|
Class that maintain and change state of LED's. More...
#include <LedTask.h>
Public Member Functions | |
| LedTask (uint16_t pin) | |
| Set which pin the user LED is attached to. More... | |
| ~LedTask (void) | |
| Deallocate LedTask object, set data pin back to INPUT. | |
| void | begin (uint32_t ms_on_tm, uint32_t ms_off_tm) |
| Sets the LED on time, and off time respectively. More... | |
| void | begin (float hz_pwm_frequency=1000) |
| Sets the frequency (in Hz) for pwm operation. More... | |
| void | updateBlinkLed (void) |
| If defined time has elapsed, changes the state of the LED. This method is called in the loop() section in Arduino's sketch. More... | |
| void | updatePwmTask (float percentage_high) |
| Updates the PWM signal output. More... | |
| void | pulseLedBlk (uint8_t pulse_cnt, uint32_t ms_on_tm, uint32_t ms_off_tm) |
| Pulses a LED a number of time with set duration. Note: This method uses delay() calls. More... | |
Static Public Member Functions | |
| static uint16_t | getInstanceCount (void) |
| Get number of instances created. More... | |
Static Public Attributes | |
| static uint16_t | instance_count |
| counter to keep track of instances More... | |
Private Attributes | |
| uint16_t | led_pin |
| LED pin. | |
| uint32_t | on_time |
| milliseconds of on-time | |
| uint32_t | off_time |
| milliseconds of off-time | |
| int | led_state |
| led_state (ON/OFF) for LED | |
| unsigned long | previous_millis |
| stores last time LED was updated | |
| float | pwm_frequency |
| repetition frequency for pwm output | |
Class that maintain and change state of LED's.
|
explicit |
Set which pin the user LED is attached to.
| pin | LED pin to toggle ON/OFF. |
| void LedTask::begin | ( | uint32_t | ms_on_tm, |
| uint32_t | ms_off_tm | ||
| ) |
Sets the LED on time, and off time respectively.
| ms_on_tm | Sets the time, in milliseconds for LED light should stay on. |
| ms_off_tm | Sets the time, in milliseconds for LED light should stay off. |
| void LedTask::begin | ( | float | hz_pwm_frequency = 1000 | ) |
Sets the frequency (in Hz) for pwm operation.
| hz_pwm_frequency |
| void LedTask::updateBlinkLed | ( | void | ) |
If defined time has elapsed, changes the state of the LED. This method is called in the loop() section in Arduino's sketch.
Each instance of a LedTask requires just three lines of code. Avoid any delay() calls for non-preemptive multitasking.
Run four LED tasks like this.
| void LedTask::updatePwmTask | ( | float | percentage_high | ) |
Updates the PWM signal output.
| percentage_high | Adjusts the PWM ratio for the high- and the low level output. |
| void LedTask::pulseLedBlk | ( | uint8_t | pulse_cnt, |
| uint32_t | ms_on_tm, | ||
| uint32_t | ms_off_tm | ||
| ) |
Pulses a LED a number of time with set duration. Note: This method uses delay() calls.
| pulse_cnt | The number of pulses (blinks). |
| ms_on_tm | Sets the time, in milliseconds for LED light should stay on. |
| ms_off_tm | Sets the time, in milliseconds for LED light should stay off. |
|
static |
Get number of instances created.
|
inlinestatic |
counter to keep track of instances