Mercurial > hg > beaglert
annotate projects/d-box/StatusLED.h @ 24:ad5cd8dd99b3 bbb_network
UDP communication in place, pre-alpha
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 08 May 2015 11:12:13 +0100 |
parents | 8a575ba3ab52 |
children |
rev | line source |
---|---|
andrewm@0 | 1 /* |
andrewm@0 | 2 * StatusLED.h |
andrewm@0 | 3 * |
andrewm@0 | 4 * |
andrewm@0 | 5 */ |
andrewm@0 | 6 |
andrewm@0 | 7 #ifndef STATUSLED_H_ |
andrewm@0 | 8 #define STATUSLED_H_ |
andrewm@0 | 9 |
andrewm@0 | 10 #include <pthread.h> |
andrewm@0 | 11 |
andrewm@0 | 12 class StatusLED |
andrewm@0 | 13 { |
andrewm@0 | 14 public: |
andrewm@0 | 15 StatusLED(); |
andrewm@0 | 16 ~StatusLED(); |
andrewm@0 | 17 |
andrewm@0 | 18 bool init(int gpio_pin); |
andrewm@0 | 19 |
andrewm@0 | 20 void on(); |
andrewm@0 | 21 void off(); |
andrewm@0 | 22 void blink(int ms_on, int ms_off); |
andrewm@0 | 23 |
andrewm@0 | 24 static void *static_blink_loop(void *data) { |
andrewm@0 | 25 ((StatusLED*)data)->blink_loop(NULL); |
andrewm@0 | 26 return 0; |
andrewm@0 | 27 } |
andrewm@0 | 28 |
andrewm@0 | 29 void* blink_loop(void *); |
andrewm@0 | 30 |
andrewm@0 | 31 private: |
andrewm@0 | 32 int gpio_number; |
andrewm@0 | 33 int milliseconds_on, milliseconds_off; |
andrewm@0 | 34 bool this_should_stop; |
andrewm@0 | 35 pthread_t blink_thread; |
andrewm@0 | 36 }; |
andrewm@0 | 37 |
andrewm@0 | 38 #endif // STATUSLED_H_ |