projectwerk

Dependencies:   NeoPixelString SimplyLog

Fork of NeoPixelI2cSlave by Nico De Witte

Committer:
BramHeldenbergh
Date:
Sat Jan 09 13:10:19 2016 +0000
Revision:
3:02931c2b1e82
programma projectwerk

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BramHeldenbergh 3:02931c2b1e82 1 #include "neopixel_i2c_daemon.h"
BramHeldenbergh 3:02931c2b1e82 2 #include "strobe.h"
BramHeldenbergh 3:02931c2b1e82 3 #define DEBUG_MODE 1
BramHeldenbergh 3:02931c2b1e82 4 #include "log.h"
BramHeldenbergh 3:02931c2b1e82 5 #include "neopixel.h"
BramHeldenbergh 3:02931c2b1e82 6
BramHeldenbergh 3:02931c2b1e82 7 DigitalOut myled(LED2);
BramHeldenbergh 3:02931c2b1e82 8
BramHeldenbergh 3:02931c2b1e82 9 Strobe::Strobe(NeoPixelI2cDaemon * deamon){
BramHeldenbergh 3:02931c2b1e82 10 freddy=deamon;
BramHeldenbergh 3:02931c2b1e82 11 SimplyLog::Log::i("6\r\n");
BramHeldenbergh 3:02931c2b1e82 12 state = SOFF;
BramHeldenbergh 3:02931c2b1e82 13 doExecute = false;
BramHeldenbergh 3:02931c2b1e82 14 }
BramHeldenbergh 3:02931c2b1e82 15 void Strobe::execute(){
BramHeldenbergh 3:02931c2b1e82 16
BramHeldenbergh 3:02931c2b1e82 17 if(doExecute){
BramHeldenbergh 3:02931c2b1e82 18 if(state==SON){
BramHeldenbergh 3:02931c2b1e82 19 SimplyLog::Log::i("4\r\n");
BramHeldenbergh 3:02931c2b1e82 20 neopixel::Pixel test;
BramHeldenbergh 3:02931c2b1e82 21 test.red = 255;
BramHeldenbergh 3:02931c2b1e82 22 test.green = 255;
BramHeldenbergh 3:02931c2b1e82 23 test.blue = 255;
BramHeldenbergh 3:02931c2b1e82 24 myled = !myled;
BramHeldenbergh 3:02931c2b1e82 25 freddy->allSingleColor(test);
BramHeldenbergh 3:02931c2b1e82 26 state=SOFF;
BramHeldenbergh 3:02931c2b1e82 27 }
BramHeldenbergh 3:02931c2b1e82 28 else if(state==SOFF){
BramHeldenbergh 3:02931c2b1e82 29 SimplyLog::Log::i("9\r\n");
BramHeldenbergh 3:02931c2b1e82 30 freddy->allOff();
BramHeldenbergh 3:02931c2b1e82 31 SimplyLog::Log::i("10\r\n");
BramHeldenbergh 3:02931c2b1e82 32 state=SON;
BramHeldenbergh 3:02931c2b1e82 33 SimplyLog::Log::i("7\r\n");
BramHeldenbergh 3:02931c2b1e82 34 }
BramHeldenbergh 3:02931c2b1e82 35 doExecute=false;
BramHeldenbergh 3:02931c2b1e82 36 }
BramHeldenbergh 3:02931c2b1e82 37 }
BramHeldenbergh 3:02931c2b1e82 38 void Strobe::isrTicker(){
BramHeldenbergh 3:02931c2b1e82 39 SimplyLog::Log::i("3\r\n");
BramHeldenbergh 3:02931c2b1e82 40 doExecute=true;
BramHeldenbergh 3:02931c2b1e82 41 }
BramHeldenbergh 3:02931c2b1e82 42 void Strobe::strstart(){
BramHeldenbergh 3:02931c2b1e82 43 SimplyLog::Log::i("1\r\n");
BramHeldenbergh 3:02931c2b1e82 44 ticker.attach(this, &Strobe::isrTicker, 0.1);
BramHeldenbergh 3:02931c2b1e82 45 doExecute=false;
BramHeldenbergh 3:02931c2b1e82 46 state = SOFF;
BramHeldenbergh 3:02931c2b1e82 47 }
BramHeldenbergh 3:02931c2b1e82 48 void Strobe::strstop(){
BramHeldenbergh 3:02931c2b1e82 49 SimplyLog::Log::i("2\r\n");
BramHeldenbergh 3:02931c2b1e82 50 ticker.detach();
BramHeldenbergh 3:02931c2b1e82 51 doExecute=false;
BramHeldenbergh 3:02931c2b1e82 52 state = SOFF;
BramHeldenbergh 3:02931c2b1e82 53 }