![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo versie 16/05
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
LEDDriver.cpp@74:8c0068ed7c1e, 2018-05-15 (annotated)
- Committer:
- KlaasGovaerts
- Date:
- Tue May 15 21:34:09 2018 +0000
- Revision:
- 74:8c0068ed7c1e
- Parent:
- 69:8b42082accc2
Probeersel (werkt niet).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
albireo987 | 38:47c075a354b5 | 1 | #include "LEDDriver.h" |
KlaasGovaerts | 74:8c0068ed7c1e | 2 | LEDDriver::LEDDriver( Queue<QueueMessage,1>* queue) |
albireo987 | 2:36158325f7b0 | 3 | { |
KlaasGovaerts | 58:4e06cfb6d010 | 4 | this->queue=queue; |
KlaasGovaerts | 47:2d877f01ca7b | 5 | initArrays(); |
KlaasGovaerts | 47:2d877f01ca7b | 6 | currentLocation=0; |
albireo987 | 2:36158325f7b0 | 7 | } |
albireo987 | 2:36158325f7b0 | 8 | |
albireo987 | 2:36158325f7b0 | 9 | void LEDDriver::drive(int numberOfLeds) |
albireo987 | 2:36158325f7b0 | 10 | { |
KlaasGovaerts | 49:8fe84f455571 | 11 | if(currentLocation==0){ |
KlaasGovaerts | 58:4e06cfb6d010 | 12 | poll(numberOfLeds); |
KlaasGovaerts | 49:8fe84f455571 | 13 | } |
KlaasGovaerts | 49:8fe84f455571 | 14 | |
KlaasGovaerts | 47:2d877f01ca7b | 15 | setLEDS(currentLocation); |
KlaasGovaerts | 47:2d877f01ca7b | 16 | currentLocation++; |
KlaasGovaerts | 56:4274186bf584 | 17 | if(currentLocation>=25){ |
KlaasGovaerts | 47:2d877f01ca7b | 18 | currentLocation=0; |
KlaasGovaerts | 47:2d877f01ca7b | 19 | } |
KlaasGovaerts | 46:ffac07bff0d8 | 20 | } |
KlaasGovaerts | 46:ffac07bff0d8 | 21 | |
KlaasGovaerts | 46:ffac07bff0d8 | 22 | void LEDDriver::drive8leds(){ |
KlaasGovaerts | 46:ffac07bff0d8 | 23 | drive(8); |
albireo987 | 2:36158325f7b0 | 24 | } |
albireo987 | 2:36158325f7b0 | 25 | |
KlaasGovaerts | 58:4e06cfb6d010 | 26 | void LEDDriver::poll(int numberOfLeds) |
albireo987 | 10:7871aeacea08 | 27 | { |
KlaasGovaerts | 74:8c0068ed7c1e | 28 | osEvent event = queue->get(); |
KlaasGovaerts | 74:8c0068ed7c1e | 29 | if (event.status == osEventMessage){ |
KlaasGovaerts | 74:8c0068ed7c1e | 30 | QueueMessage* receivedMessage=(QueueMessage*) event.value.p; |
KlaasGovaerts | 74:8c0068ed7c1e | 31 | int* array=receivedMessage->getArray(); |
KlaasGovaerts | 74:8c0068ed7c1e | 32 | memcpy(messageList,array,sizeof(messageList)); |
KlaasGovaerts | 74:8c0068ed7c1e | 33 | delete receivedMessage; |
KlaasGovaerts | 74:8c0068ed7c1e | 34 | } |
albireo987 | 38:47c075a354b5 | 35 | } |
albireo987 | 38:47c075a354b5 | 36 | |
KlaasGovaerts | 47:2d877f01ca7b | 37 | void LEDDriver::initArrays() |
albireo987 | 38:47c075a354b5 | 38 | { |
KlaasGovaerts | 58:4e06cfb6d010 | 39 | 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) |
KlaasGovaerts | 56:4274186bf584 | 40 | 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}; |
KlaasGovaerts | 56:4274186bf584 | 41 | 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}; |
KlaasGovaerts | 56:4274186bf584 | 42 | 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}; |
KlaasGovaerts | 58:4e06cfb6d010 | 43 | 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}; |
KlaasGovaerts | 58:4e06cfb6d010 | 44 | int tempMessageList[8]={4,4,4,4,4,4,4,4}; |
albireo987 | 65:7951d11432f8 | 45 | 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)}; |
KlaasGovaerts | 47:2d877f01ca7b | 46 | |
KlaasGovaerts | 47:2d877f01ca7b | 47 | memcpy(codedMessage0,tempCodedMessage0,sizeof(codedMessage0)); |
KlaasGovaerts | 47:2d877f01ca7b | 48 | memcpy(codedMessage1,tempCodedMessage1,sizeof(codedMessage1)); |
KlaasGovaerts | 47:2d877f01ca7b | 49 | memcpy(codedMessage2,tempCodedMessage2,sizeof(codedMessage2)); |
KlaasGovaerts | 47:2d877f01ca7b | 50 | memcpy(codedMessage3,tempCodedMessage3,sizeof(codedMessage3)); |
KlaasGovaerts | 47:2d877f01ca7b | 51 | memcpy(codedMessage4,tempCodedMessage4,sizeof(codedMessage4)); |
KlaasGovaerts | 47:2d877f01ca7b | 52 | |
KlaasGovaerts | 49:8fe84f455571 | 53 | memcpy(messageList,tempMessageList,sizeof(messageList)); |
KlaasGovaerts | 49:8fe84f455571 | 54 | |
KlaasGovaerts | 47:2d877f01ca7b | 55 | memcpy(leds,tempLeds,sizeof(leds)); |
KlaasGovaerts | 47:2d877f01ca7b | 56 | } |
KlaasGovaerts | 47:2d877f01ca7b | 57 | |
KlaasGovaerts | 47:2d877f01ca7b | 58 | void LEDDriver::setLEDS(int j){ |
albireo987 | 38:47c075a354b5 | 59 | for(int led =0 ; led<8;led++) |
albireo987 | 38:47c075a354b5 | 60 | { |
albireo987 | 38:47c075a354b5 | 61 | if(messageList[led]==0) |
albireo987 | 38:47c075a354b5 | 62 | { |
KlaasGovaerts | 50:c5cd73d93045 | 63 | leds[led]->write(codedMessage0[j]); |
albireo987 | 38:47c075a354b5 | 64 | } |
albireo987 | 38:47c075a354b5 | 65 | else if(messageList[led]==1) |
albireo987 | 38:47c075a354b5 | 66 | { |
KlaasGovaerts | 50:c5cd73d93045 | 67 | leds[led]->write(codedMessage1[j]); |
albireo987 | 38:47c075a354b5 | 68 | } |
albireo987 | 38:47c075a354b5 | 69 | else if(messageList[led]==2) |
albireo987 | 38:47c075a354b5 | 70 | { |
KlaasGovaerts | 50:c5cd73d93045 | 71 | leds[led]->write(codedMessage2[j]); |
albireo987 | 38:47c075a354b5 | 72 | } |
albireo987 | 38:47c075a354b5 | 73 | else if(messageList[led]==3) |
albireo987 | 38:47c075a354b5 | 74 | { |
KlaasGovaerts | 50:c5cd73d93045 | 75 | leds[led]->write(codedMessage3[j]); |
albireo987 | 38:47c075a354b5 | 76 | } |
KlaasGovaerts | 49:8fe84f455571 | 77 | else if(messageList[led]==4||messageList[led]==-1) |
albireo987 | 38:47c075a354b5 | 78 | { |
KlaasGovaerts | 50:c5cd73d93045 | 79 | leds[led]->write(codedMessage4[j]); |
albireo987 | 38:47c075a354b5 | 80 | } |
KlaasGovaerts | 56:4274186bf584 | 81 | } |
KlaasGovaerts | 50:c5cd73d93045 | 82 | } |
KlaasGovaerts | 50:c5cd73d93045 | 83 | |
KlaasGovaerts | 61:738f026cf667 | 84 | LEDDriver::~LEDDriver(){ |
KlaasGovaerts | 61:738f026cf667 | 85 | for(int i=0;i<8;i++){ |
KlaasGovaerts | 61:738f026cf667 | 86 | delete leds[i]; |
KlaasGovaerts | 61:738f026cf667 | 87 | } |
KlaasGovaerts | 61:738f026cf667 | 88 | } |