![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
First version
Dependencies: mbed EthernetInterface mbed-rto
Diff: LEDDriver.cpp
- Revision:
- 47:8fe84f455571
- Parent:
- 45:2d877f01ca7b
- Child:
- 48:c5cd73d93045
--- a/LEDDriver.cpp Wed May 09 07:45:44 2018 +0000 +++ b/LEDDriver.cpp Wed May 09 09:06:38 2018 +0000 @@ -5,14 +5,19 @@ //this->messageList=messageList; //this->leds=leds; this->queue=queue;// prep for multithreaded + printf("Queue created\r\n"); initArrays(); + printf("Arrays initialised.\r\n"); currentLocation=0; } void LEDDriver::drive(int numberOfLeds) { - poll(numberOfLeds,1); - poll(numberOfLeds,2); + if(currentLocation==0){ + poll(numberOfLeds,1); + poll(numberOfLeds,2); + } + setLEDS(currentLocation); currentLocation++; if(currentLocation>=20){ @@ -34,10 +39,12 @@ void LEDDriver::run(Ticker* ticker) { + printf("ticker attached.\r\n"); ticker->attach(this,&LEDDriver::drive8leds,1);//TODO faster } void LEDDriver::drive8leds(){ + printf("tick\r\n");//TODO drive(8); } @@ -91,17 +98,22 @@ // 1 1 1 1 1 1 0 0 0 1 int tempCodedMessage3[20]={1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,1,0}; int tempCodedMessage4[20]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};//default message for multithreading - int tempMessageList[8]={4,4,4,4,4,4,4,4}; + int tempMessageList[8]={0,0,0,0,0,0,0,0};//TODO DigitalOut tempLeds[]={DigitalOut(p23),DigitalOut(p11),DigitalOut(p12),DigitalOut(p13),DigitalOut(p14),DigitalOut(p15),DigitalOut(p16),DigitalOut(p17)}; + printf("Arrays created.\r\n"); 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)); + printf("First 5 arrays copied.\r\n"); - memcpy(tempMessageList,messageList,sizeof(messageList)); + memcpy(messageList,tempMessageList,sizeof(messageList)); + printf("messageList array copied.\r\n"); + memcpy(leds,tempLeds,sizeof(leds)); + printf("LEDS array copied.\r\n"); } void LEDDriver::setLEDS(int j){ @@ -127,7 +139,7 @@ leds[led].write(codedMessage3[j]); //ownWait(25); } - else if(messageList[led]==4) + else if(messageList[led]==4||messageList[led]==-1) { leds[led].write(codedMessage4[j]); //ownWait(25);