Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
LEDDriver.cpp
00001 #include "LEDDriver.h" 00002 Serial pc(USBTX,USBRX); 00003 LEDDriver::LEDDriver( Queue<int,8>* queue) 00004 { 00005 this->queue=queue; 00006 initArrays(); 00007 currentLocation=0; 00008 mask=16777216; 00009 codedMessage0=0x1F54AAD;//32852653;// 2796202 commented message is frequency measure message(standard square wave) 4:('1')+2 ticker 0.002f. (250Hz, 10ms down) 00010 codedMessage1=0x1F54CAD;//32853165 00011 codedMessage2=0x1F552AD;//32854701; 00012 codedMessage3=0x1F554AD;//32855213; 00013 codedMessage4=0; 00014 } 00015 00016 void LEDDriver::drive(int numberOfLeds) 00017 { 00018 if(currentLocation>=25){ 00019 currentLocation=0; 00020 mask = 16777216; 00021 } 00022 if(currentLocation==0){ 00023 poll(numberOfLeds); 00024 } 00025 setLEDS(mask); 00026 mask=mask>>1; 00027 currentLocation++; 00028 00029 } 00030 00031 void LEDDriver::drive8leds(){ 00032 drive(8); 00033 } 00034 00035 void LEDDriver::poll(int numberOfLeds) 00036 { 00037 for(int i =0;i<(numberOfLeds);i++) 00038 { 00039 osEvent event = queue->get(); 00040 int temp = *((int*)event.value.p); 00041 if(temp==0||temp==1||temp==2||temp==3||temp==4) 00042 { 00043 messageList[i]=temp; 00044 } 00045 } 00046 } 00047 00048 void LEDDriver::initArrays() 00049 { 00050 int tempMessageList[8]={4,4,4,4,4,4,4,4}; 00051 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)}; 00052 00053 memcpy(messageList,tempMessageList,sizeof(messageList)); 00054 memcpy(leds,tempLeds,sizeof(leds)); 00055 } 00056 00057 void LEDDriver::setLEDS(int mask){ 00058 for(int led =0 ; led<8;led++) 00059 { 00060 if(messageList[led]==0) 00061 { 00062 leds[led]->write(codedMessage0&mask); 00063 } 00064 else if(messageList[led]==1) 00065 { 00066 leds[led]->write(codedMessage1&mask); 00067 } 00068 else if(messageList[led]==2) 00069 { 00070 leds[led]->write((codedMessage2)&mask); 00071 } 00072 else if(messageList[led]==3) 00073 { 00074 leds[led]->write((codedMessage3)&mask); 00075 } 00076 else if(messageList[led]==4||messageList[led]==-1) 00077 { 00078 leds[led]->write((codedMessage4)&mask); 00079 } 00080 } 00081 } 00082 00083 LEDDriver::~LEDDriver(){ 00084 for(int i=0;i<8;i++){ 00085 delete leds[i]; 00086 } 00087 }
Generated on Wed Jul 13 2022 07:48:05 by
1.7.2
