|
Open Model Railroad Network (OpenMRN)
|
Operates an LED to visually display some activity. More...
#include <ActivityLed.hxx>
Public Member Functions | |
| ActivityLed (Service *service, const Gpio *pin, long long period=MSEC_TO_NSEC(33)) | |
| Constructor. | |
| void | activity () |
| Call this function when activity happens. | |
Private Member Functions | |
| long long | timeout () override |
| Clients of timer should override this function. | |
Private Member Functions inherited from Timer | |
| Timer (ActiveTimers *timers) | |
| Constructor. | |
| ~Timer () | |
| Destructor. | |
| void | run () override |
| Callback from the executor when this timer is scheduled. | |
| long long | schedule_time () |
| void | start (long long period=-1) |
| Starts a timer. | |
| void | start_absolute (long long expiry_time_nsec) |
| Starts the timer with an absolute deadline. | |
| void | restart () |
| Restart a timer with the existing period but from the current time. | |
| void | trigger () |
| This will wakeup the timer prematurely, immediately. | |
| void | ensure_triggered () |
| Triggers the timer if it is not expired yet. | |
| void | cancel () |
| Dangerous, do not call. | |
| bool | is_triggered () |
| void | set_triggered () |
| Sets the timer as if it was woken up by a trigger(), even if it was never started. | |
| void | update_period (long long period) |
| Updates the period, to be used after the next expiration of the timer in order to restart it. | |
Private Member Functions inherited from Executable | |
| void | test_deletion () |
| void | notify () override |
| Crashes the program – everyone who is expecting notify calls must override this function. | |
| virtual void | alloc_result (QMember *item) |
| Return the result of an alloc_async() from a memory Pool. | |
Private Member Functions inherited from QMember | |
| void | init () |
| Initiailize a QMember, in place of a public placement construction. | |
| QMember () | |
| Constructor. | |
| ~QMember () | |
| Destructor. | |
Private Attributes | |
| const Gpio * | gpio_ |
| Output pin to blink for activity. | |
| unsigned | triggerCount_ {0} |
| How many triggers happened since the last run of the timer. | |
Private Attributes inherited from QMember | |
| QMember * | next |
| pointer to the next member in the queue | |
Additional Inherited Members | |
Private Types inherited from Timer | |
| enum | { NONE = 0 , RESTART = 1 , DELETE = -1 } |
| Special return values from the timeout function. More... | |
Operates an LED to visually display some activity.
When the activity() function is called at least once within a period, we turn the LED on for the next period, if no call was made, the LED turns off for the next period.
Definition at line 45 of file ActivityLed.hxx.
|
inline |
Constructor.
| service | defines which executor this timer should be running on. |
| pin | the LED of the output. Will be high for activity, low for inactivity. Use InvertedGPIO if needed. |
| period | defines in nanosecond the time to spend between updates. |
Definition at line 53 of file ActivityLed.hxx.
|
inline |
Call this function when activity happens.
Definition at line 62 of file ActivityLed.hxx.
|
inlineoverrideprivatevirtual |
Clients of timer should override this function.
It will be called on the executor of the timer.
Implements Timer.
Definition at line 68 of file ActivityLed.hxx.
|
private |
Output pin to blink for activity.
Definition at line 83 of file ActivityLed.hxx.
|
private |
How many triggers happened since the last run of the timer.
Definition at line 85 of file ActivityLed.hxx.