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
Interpreter.cpp
00001 #include "Interpreter.h" 00002 00003 00004 00005 Interpreter::Interpreter (Queue<int,8>* queue){ 00006 Interpreter::queue=queue; 00007 } 00008 00009 void Interpreter::executeCommand(char* command){ 00010 for(int i=0;i<8;i++){ 00011 LED[i]=4; 00012 } //Set all default on 4 00013 00014 char *ID=strtok(command,"-"); 00015 char *direction=strtok(NULL," "); 00016 while((ID!=NULL)&&(direction!=NULL)){ 00017 int IDNumber=atoi(ID); 00018 int directionNumber=directionToNumber(direction); 00019 if((IDNumber>=0)&&(IDNumber<=11)&&(directionNumber>=0)&&(directionNumber<=4)){ 00020 LED[IDNumber]=directionNumber; 00021 } 00022 ID=strtok(NULL,"-"); 00023 direction=strtok(NULL," "); 00024 } 00025 00026 for(int i=0;i<8;i++){ 00027 queue->put(&LED[i]); 00028 } 00029 00030 for(int i=0;i<8;i++){ 00031 printf("LED %i, richting: %i\r\n",i,LED[i]); 00032 } 00033 } 00034 00035 int Interpreter::directionToNumber(char* direction){ 00036 if(strcmp(direction,"left")==0) 00037 return 0; 00038 else if(strcmp(direction,"right")==0) 00039 return 1; 00040 else if(strcmp(direction,"up")==0) 00041 return 2; 00042 else if(strcmp(direction,"down")==0) 00043 return 3; 00044 else 00045 return 4; 00046 }
Generated on Wed Jul 13 2022 07:48:05 by
1.7.2
