![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo versie 16/05
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
LEDDriver.cpp
- Committer:
- albireo987
- Date:
- 2018-04-15
- Revision:
- 2:36158325f7b0
- Child:
- 8:a987e04734dd
File content as of revision 2:36158325f7b0:
#include "LEDDriver.h" LEDDriver::LEDDriver(/*Mutex* lock,*/ int sharedDirections[], int sizeOfSharedDirections) { static int start[]={1,0,1,0,1,0,1,0}; static int stop[]={0,1,0,1,0,1,0,1}; static int message1[20]={0}; static int message2[20]={0}; static int message3[20]={0}; static int message4[20]={0}; static int message5[20]={0}; static int message6[20]={0}; static int message7[20]={0}; static int message8[20]={0}; static int* messageList[8]={0}; messageList[0]=message1; messageList[1]=message2; messageList[2]=message3; messageList[3]=message4; messageList[4]=message5; messageList[5]=message6; messageList[6]=message7; messageList[7]=message8; static DigitalOut leds[]={DigitalOut(p10),DigitalOut(p11),DigitalOut(p12),DigitalOut(p13),DigitalOut(p14),DigitalOut(p15),DigitalOut(p16),DigitalOut(p17),DigitalOut(p18),DigitalOut(p19),DigitalOut(p20)}; this->start=start; this->stop=stop; //this->lock=lock; this->copy=Copy(); this->messageList=messageList; this->leds=leds; copy.copyInt(this->directions,sharedDirections,sizeOfSharedDirections); } void LEDDriver::encode(int directionValue,int led) { switch(directionValue) { case 0: copy.copyInt(messageList[led],start,8); int code0[]={0,0}; copy.copyInt(messageList[led],code0,2,8); copy.copyInt(messageList[led],stop,8,16); break; case 1: copy.copyInt(messageList[led],start,8); int code1[]={0,1}; copy.copyInt(messageList[led],code1,2,8); copy.copyInt(messageList[led],stop,8,16); break; case 2: copy.copyInt(messageList[led],start,8); int code2[]={1,0}; copy.copyInt(messageList[led],code2,2,8); copy.copyInt(messageList[led],stop,8,16); break; case 3: copy.copyInt(messageList[led],start,8); static int code3[]={1,1}; copy.copyInt(messageList[led],code3,2,8); copy.copyInt(messageList[led],stop,8,16); break; default: return; } this->messageList[led]=messageList[led]; } int LEDDriver::getDirection(int id) { int direction= directions[id]; return direction; } void LEDDriver::drive(int numberOfLeds) { for(int j=0;j<20;j++) { encodeAll(numberOfLeds); for(int i =0;i<numberOfLeds;i++) { int* message={messageList[j]}; leds[i].write(message[j]); wait_ms(0.25);//500Hz 1/500 gewenste periode 8/90MHz(#leds/fclock) basis periode dus verhouding van de perioden / Clock is uiteindelijke frequentie (grof) moet manueel // gefinetuned worden. } } } void LEDDriver::run(int numberOfLeds) { drive(numberOfLeds); } void LEDDriver::encodeAll(int numberOfLeds) { for(int i = 0;i<numberOfLeds;i++) { encode(getDirection(i),i); } }