![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo versie 16/05
Dependencies: EthernetInterface mbed-rto mbed
Fork of ProjectVLC by
Interpreter.cpp
- Committer:
- KlaasGovaerts
- Date:
- 2018-05-09
- Revision:
- 50:c5cd73d93045
- Parent:
- 48:0ed7f44202c0
- Child:
- 54:45207965e160
File content as of revision 50:c5cd73d93045:
#include "Interpreter.h" Interpreter::Interpreter(Queue<int,8>* queue){ printf("Interpreter created.\r\n"); Interpreter::queue=queue; } void Interpreter::executeCommand(char* command){ for(int i=0;i<8;i++){ LED[i]=-1; } //Set all default on -1 char *ID=strtok(command,"-"); char *direction=strtok(NULL," "); while((ID!=NULL)&&(direction!=NULL)){ int IDNumber=atoi(ID); int directionNumber=directionToNumber(direction); if((IDNumber>=0)&&(IDNumber<=11)&&(directionNumber>=-1)&&(directionNumber<=3)){ LED[IDNumber]=directionNumber; } ID=strtok(NULL,"-"); direction=strtok(NULL," "); } for(int i=0;i<8;i++){ queue->put(&LED[i]); } for(int i=0;i<8;i++){ printf("LED %i, richting: %i\r\n",i,LED[i]); } } int Interpreter::directionToNumber(char* direction){ if(strcmp(direction,"left")==0) return 0; else if(strcmp(direction,"right")==0) return 1; else if(strcmp(direction,"up")==0) return 2; else if(strcmp(direction,"down")==0) return 3; else return -1; }