bla blal

Dependencies:   FastPWM NeoStrip mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "NeoStrip.h"
00003 
00004 int N=2268; //number of leds
00005 
00006 Serial pc(USBTX, USBRX);
00007 NeoStrip strip(p22, N);
00008 extern "C" void mbed_reset();
00009 
00010 float bright = 1.0;
00011 
00012 /*bool equal(float a, float b) {
00013     if (abs(a - b) < 0.00001)
00014         return true;
00015     else
00016         return false;
00017 }*/
00018 
00019 void SetAll()
00020 {
00021     for (int i=0; i<N; i++) {
00022         strip.setPixel(i,255,255,255);
00023     }
00024     strip.write();
00025 }
00026 
00027 int main(int argc, char** argv) {
00028     pc.baud(115200);
00029     
00030     SetAll(1.0f);
00031     
00032     printf("Welcome!\n");
00033     
00034     while(1) {
00035         wait(0.5);
00036         
00037         //SetAll(1.0f);
00038         
00039         if (pc.readable()) {
00040             switch(pc.getc()) {
00041                 case 'r':
00042                     printf("Resetting");
00043                     mbed_reset();
00044                     break;
00045                 case 'b': {
00046                     bright += 0.1;
00047                     if (bright>1.01) bright=0;   // set default brightness
00048                     strip.setBrightness(bright);
00049                     SetAll(1.0f);
00050                     printf("brightness: %.2f\r\n",bright);  
00051                 }
00052                 break;
00053             }    
00054         }
00055     }
00056 }