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