Library thread Blink Led or other processes use RTOS
Fork of BlinkLed by
Example
https://developer.mbed.org/users/AVELARDEV/code/LedsThreading/
BlinkLed.h@0:a55a3351317d, 2012-09-01 (annotated)
- Committer:
- togayan
- Date:
- Sat Sep 01 04:02:02 2012 +0000
- Revision:
- 0:a55a3351317d
- Child:
- 2:1d0c09c1a8b4
1st revision of BlinkLed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
togayan | 0:a55a3351317d | 1 | /* BlinkLed.h */ |
togayan | 0:a55a3351317d | 2 | #ifndef BLINKLED_H_ |
togayan | 0:a55a3351317d | 3 | #define BLINKLED_H_ |
togayan | 0:a55a3351317d | 4 | |
togayan | 0:a55a3351317d | 5 | #include "mbed.h" |
togayan | 0:a55a3351317d | 6 | #include "rtos.h" |
togayan | 0:a55a3351317d | 7 | |
togayan | 0:a55a3351317d | 8 | /** LED which blinks automatically with RTOS |
togayan | 0:a55a3351317d | 9 | */ |
togayan | 0:a55a3351317d | 10 | class BlinkLed |
togayan | 0:a55a3351317d | 11 | { |
togayan | 0:a55a3351317d | 12 | public: |
togayan | 0:a55a3351317d | 13 | /** Constructor |
togayan | 0:a55a3351317d | 14 | */ |
togayan | 0:a55a3351317d | 15 | BlinkLed(PinName pin, float dutyChangeStep); |
togayan | 0:a55a3351317d | 16 | |
togayan | 0:a55a3351317d | 17 | /** Destructor |
togayan | 0:a55a3351317d | 18 | */ |
togayan | 0:a55a3351317d | 19 | ~BlinkLed(); |
togayan | 0:a55a3351317d | 20 | |
togayan | 0:a55a3351317d | 21 | /** Start biinking |
togayan | 0:a55a3351317d | 22 | */ |
togayan | 0:a55a3351317d | 23 | void startBlink(); |
togayan | 0:a55a3351317d | 24 | |
togayan | 0:a55a3351317d | 25 | /** Finish biinking |
togayan | 0:a55a3351317d | 26 | */ |
togayan | 0:a55a3351317d | 27 | void finishBlink(); |
togayan | 0:a55a3351317d | 28 | |
togayan | 0:a55a3351317d | 29 | private: |
togayan | 0:a55a3351317d | 30 | /** Copy constructor |
togayan | 0:a55a3351317d | 31 | * Disable because it is only declaration |
togayan | 0:a55a3351317d | 32 | */ |
togayan | 0:a55a3351317d | 33 | BlinkLed(const BlinkLed&); |
togayan | 0:a55a3351317d | 34 | |
togayan | 0:a55a3351317d | 35 | /** Copy assignment operators |
togayan | 0:a55a3351317d | 36 | * Disable because it is only declaration |
togayan | 0:a55a3351317d | 37 | */ |
togayan | 0:a55a3351317d | 38 | BlinkLed& operator=(const BlinkLed&); |
togayan | 0:a55a3351317d | 39 | |
togayan | 0:a55a3351317d | 40 | /** Function for blinking |
togayan | 0:a55a3351317d | 41 | * This function will be bind to new thread |
togayan | 0:a55a3351317d | 42 | */ |
togayan | 0:a55a3351317d | 43 | static void blink(void const *argument); |
togayan | 0:a55a3351317d | 44 | |
togayan | 0:a55a3351317d | 45 | /** Target Led |
togayan | 0:a55a3351317d | 46 | */ |
togayan | 0:a55a3351317d | 47 | PwmOut led; |
togayan | 0:a55a3351317d | 48 | |
togayan | 0:a55a3351317d | 49 | /** Duty ratio step of changing every 20ms |
togayan | 0:a55a3351317d | 50 | */ |
togayan | 0:a55a3351317d | 51 | float dutyChangeStep; |
togayan | 0:a55a3351317d | 52 | |
togayan | 0:a55a3351317d | 53 | /** Flag of pause |
togayan | 0:a55a3351317d | 54 | */ |
togayan | 0:a55a3351317d | 55 | bool pause; |
togayan | 0:a55a3351317d | 56 | |
togayan | 0:a55a3351317d | 57 | /** Pointer to thread for blinking |
togayan | 0:a55a3351317d | 58 | */ |
togayan | 0:a55a3351317d | 59 | Thread* thread; |
togayan | 0:a55a3351317d | 60 | }; |
togayan | 0:a55a3351317d | 61 | |
togayan | 0:a55a3351317d | 62 | #endif /* BLINKLED_H_ */ |