![](/media/cache/profiles/IMG_0710-2.jpg.50x50_q85.jpg)
Light Show library for organic, calm, light display.
Dependencies: BLE_API mbed nRF51822
Fork of mbed_blinky by
main.cpp@8:5ed23e276c8a, 2015-10-10 (annotated)
- Committer:
- nargetdev
- Date:
- Sat Oct 10 07:22:30 2015 +0000
- Revision:
- 8:5ed23e276c8a
- Parent:
- 4:81cea7a352b0
- Child:
- 9:1bd0f7a2ee71
stupid homebrew
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan | 0:7dec7e9ac085 | 1 | #include "mbed.h" |
nargetdev | 8:5ed23e276c8a | 2 | |
nargetdev | 8:5ed23e276c8a | 3 | typedef unsigned char byte; |
nargetdev | 8:5ed23e276c8a | 4 | |
nargetdev | 8:5ed23e276c8a | 5 | //PwmOut blue(p18); |
nargetdev | 8:5ed23e276c8a | 6 | //PwmOut green(p19); |
nargetdev | 8:5ed23e276c8a | 7 | DigitalOut red(p18); |
nargetdev | 8:5ed23e276c8a | 8 | DigitalOut green(p19); |
nargetdev | 8:5ed23e276c8a | 9 | DigitalOut blue(p20); |
dan | 0:7dec7e9ac085 | 10 | |
nargetdev | 8:5ed23e276c8a | 11 | void error_code(){ |
nargetdev | 8:5ed23e276c8a | 12 | for(;;){ |
nargetdev | 8:5ed23e276c8a | 13 | green = !green; |
nargetdev | 8:5ed23e276c8a | 14 | blue = !blue; |
nargetdev | 8:5ed23e276c8a | 15 | red = !red; |
nargetdev | 8:5ed23e276c8a | 16 | wait(.5); |
stevep | 4:81cea7a352b0 | 17 | } |
dan | 0:7dec7e9ac085 | 18 | } |
nargetdev | 8:5ed23e276c8a | 19 | |
nargetdev | 8:5ed23e276c8a | 20 | void primative_channel(int rgb, byte duty){ |
nargetdev | 8:5ed23e276c8a | 21 | for (byte i = 0; i < 255; i++){ |
nargetdev | 8:5ed23e276c8a | 22 | switch (rgb){ |
nargetdev | 8:5ed23e276c8a | 23 | case 'r': |
nargetdev | 8:5ed23e276c8a | 24 | red = ( i < duty ); |
nargetdev | 8:5ed23e276c8a | 25 | break; |
nargetdev | 8:5ed23e276c8a | 26 | case 'g': |
nargetdev | 8:5ed23e276c8a | 27 | green = (i < duty); |
nargetdev | 8:5ed23e276c8a | 28 | break; |
nargetdev | 8:5ed23e276c8a | 29 | case 'b': |
nargetdev | 8:5ed23e276c8a | 30 | blue = (i < duty); |
nargetdev | 8:5ed23e276c8a | 31 | break; |
nargetdev | 8:5ed23e276c8a | 32 | default: |
nargetdev | 8:5ed23e276c8a | 33 | error_code(); |
nargetdev | 8:5ed23e276c8a | 34 | } |
nargetdev | 8:5ed23e276c8a | 35 | } |
nargetdev | 8:5ed23e276c8a | 36 | } |
nargetdev | 8:5ed23e276c8a | 37 | |
nargetdev | 8:5ed23e276c8a | 38 | int main() { |
nargetdev | 8:5ed23e276c8a | 39 | while(1){ |
nargetdev | 8:5ed23e276c8a | 40 | |
nargetdev | 8:5ed23e276c8a | 41 | primative_channel('g',20); |
nargetdev | 8:5ed23e276c8a | 42 | primative_channel('b',150); |
nargetdev | 8:5ed23e276c8a | 43 | for (int i = 0; i < 256; i++){ |
nargetdev | 8:5ed23e276c8a | 44 | primative_channel('b',i); |
nargetdev | 8:5ed23e276c8a | 45 | } |
nargetdev | 8:5ed23e276c8a | 46 | |
nargetdev | 8:5ed23e276c8a | 47 | } |
nargetdev | 8:5ed23e276c8a | 48 | } |