![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo versie 16/05
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
Diff: LEDDriver.cpp
- Revision:
- 78:8efde3e9e3fb
- Parent:
- 69:8b42082accc2
- Child:
- 79:ebff08a66ff3
--- a/LEDDriver.cpp Tue May 15 22:31:05 2018 +0000 +++ b/LEDDriver.cpp Wed May 16 09:44:54 2018 +0000 @@ -1,22 +1,31 @@ #include "LEDDriver.h" +Serial pc(USBTX,USBRX); LEDDriver::LEDDriver( Queue<int,8>* queue) { this->queue=queue; initArrays(); currentLocation=0; + mask=16777216; + codedMessage0=32852653;// 2796202 commented message is frequency measure message(standard square wave) 4:('1')+2 ticker 0.002f. (250Hz, 10ms down) + codedMessage1=32853165; + codedMessage2=32854701; + codedMessage3=32855213; + codedMessage4=0; } void LEDDriver::drive(int numberOfLeds) { + if(currentLocation>=25){ + currentLocation=0; + mask = 16777216; + } if(currentLocation==0){ poll(numberOfLeds); } - - setLEDS(currentLocation); + setLEDS(mask); + mask=mask>>1; currentLocation++; - if(currentLocation>=25){ - currentLocation=0; - } + } void LEDDriver::drive8leds(){ @@ -25,7 +34,7 @@ void LEDDriver::poll(int numberOfLeds) { - for(int i =0;i<(numberOfLeds);i++) + for(int i =7;i<(numberOfLeds);i++) { osEvent event = queue->get(); int temp = *((int*)event.value.p); @@ -38,47 +47,35 @@ void LEDDriver::initArrays() { - int tempCodedMessage0[25]=/*{1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1};*/{1,1,1,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,1,0,1};// commented message is frequency measure message(standard square wave) 4:('1')+2 ticker 0.002f. (250Hz, 10ms down) - int tempCodedMessage1[25]={1,1,1,1,1,0,1,0,1,0,1,0,0,1,1,0,0,1,0,1,0,1,1,0,1}; - int tempCodedMessage2[25]={1,1,1,1,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1}; - int tempCodedMessage3[25]={1,1,1,1,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,1,0,1}; - int tempCodedMessage4[25]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int tempMessageList[8]={4,4,4,4,4,4,4,4}; DigitalOut *tempLeds[]={new DigitalOut(p11),new DigitalOut(p10),new DigitalOut(p12),new DigitalOut(p13),new DigitalOut(p14),new DigitalOut(p15),new DigitalOut(p16),new DigitalOut(p17)}; - memcpy(codedMessage0,tempCodedMessage0,sizeof(codedMessage0)); - memcpy(codedMessage1,tempCodedMessage1,sizeof(codedMessage1)); - memcpy(codedMessage2,tempCodedMessage2,sizeof(codedMessage2)); - memcpy(codedMessage3,tempCodedMessage3,sizeof(codedMessage3)); - memcpy(codedMessage4,tempCodedMessage4,sizeof(codedMessage4)); - memcpy(messageList,tempMessageList,sizeof(messageList)); - memcpy(leds,tempLeds,sizeof(leds)); } -void LEDDriver::setLEDS(int j){ +void LEDDriver::setLEDS(int mask){ for(int led =0 ; led<8;led++) { if(messageList[led]==0) { - leds[led]->write(codedMessage0[j]); + leds[led]->write(codedMessage0&mask); } else if(messageList[led]==1) { - leds[led]->write(codedMessage1[j]); + leds[led]->write(codedMessage1&mask); } else if(messageList[led]==2) { - leds[led]->write(codedMessage2[j]); + leds[led]->write((codedMessage2)&mask); } else if(messageList[led]==3) { - leds[led]->write(codedMessage3[j]); + leds[led]->write((codedMessage3)&mask); } else if(messageList[led]==4||messageList[led]==-1) { - leds[led]->write(codedMessage4[j]); + leds[led]->write((codedMessage4)&mask); } } }