BreathLed demo

Dependencies:   BreathLed mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "BreathLed.h"
00003 
00004 using namespace steeven;
00005 
00006 BreathLed leds[] = { BreathLed(LED1), BreathLed(LED2), BreathLed(LED3),
00007         BreathLed(LED4) };
00008 const int n = sizeof(leds) / sizeof(leds[0]);
00009 Serial pc(USBTX, USBRX);
00010 
00011 /*
00012  * Demo the BreahLed usage
00013  * Press 0/1/2 on console to loop/on/off the leds
00014  */
00015 int main() {
00016     int i;
00017     for (i = 0; i < n; ++i) {
00018         leds[i].loop((i + 0.5) / 2, 0.3);
00019     }
00020     pc.printf("Press 0/1/2 to loop/on/off the leds\n");
00021     while (1) {
00022         switch (pc.getc()) {
00023         case '0':
00024             for (i = 0; i < n; ++i) {
00025                 leds[i].loop(i + 0.5, 0.5);
00026             }
00027             pc.printf("loop...");
00028             break;
00029         case '1':
00030             for (i = 0; i < n; ++i) {
00031                 leds[i].on();
00032             }
00033             pc.printf("on...");
00034             break;
00035         case '2':
00036             for (i = 0; i < n; ++i) {
00037                 leds[i].off();
00038             }
00039             pc.printf("off...");
00040             break;
00041         default:
00042             break;
00043         }
00044     }
00045 }
00046 //  Auto Added by "SMeshLink SMeshStudio"
00047