![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Main Program
Dependencies: mbed AQM1602 HMC6352 PID
main_processing/setup_command_active/command.cpp
- Committer:
- lilac0112_1
- Date:
- 2016-01-30
- Revision:
- 21:d69a8f3c76e1
- Parent:
- 19:342da3a5a474
- Child:
- 22:a95f7c63af3c
File content as of revision 21:d69a8f3c76e1:
#include "mbed.h" #include "extern.h" void CommandLoop(void){ uint8_t SwState,x=0,y=0, z; uint8_t (*Function[STATE_NUM_Y])(uint8_t x) = { LoopFunction0, LoopFunction1, LoopFunction2, LoopFunction3, LoopFunction4, LoopFunction5, LoopFunction6, LoopFunction7, LoopFunction8, LoopFunction9, LoopFunctionA, LoopFunctionB, LoopFunctionC, LoopFunctionD, LoopFunctionE, LoopFunctionF }; data.init_point_flag=0; while(1){ SwState = ReadSw(); if(SwState == NONE){ if(x!=0){ z = (*Function[y])(x); if(z==1){ x=0; Lcd.cls(); Lcd.locate(0, 0); Lcd.print(lcdstr[y][0]); Lcd.locate(7, 0); Lcd.print(">"); Lcd.locate(9, 0); if(x!=0) Lcd.print(lcdstr[y][x]); } //Z==1...Once //Z==0...Endless } continue; } if(SwState == UP){ y += -1 + STATE_NUM_Y; y %= STATE_NUM_Y; x=0; } if(SwState == DOWN){ y++; y %= STATE_NUM_Y; x=0; } if(SwState == RIGHT){ if(lcdstr[y][1][0]==0) x=0; else x++; if(x==STATE_NUM_X) x=0; if(lcdstr[y][x][0]==0) x=0; else x %= STATE_NUM_X; } if(SwState == LEFT){ if((x!=0)&&(data.init_point_flag==1)){ data.init_point_flag=0; y = 1; } x=0; } Lcd.cls(); Lcd.locate(0, 0); Lcd.print(lcdstr[y][0]); Lcd.locate(7, 0); Lcd.print(">"); Lcd.locate(9, 0); if(x!=0) Lcd.print(lcdstr[y][x]); } } uint8_t LoopFunction0(uint8_t x){ char buf[0x10]; sprintf(buf, "CAR%d", x); Lcd.locate(0, 1);Lcd.print(buf);return 0; } uint8_t LoopFunction1(uint8_t x){ char buf[0x10]; sprintf(buf, "CatPot"); Lcd.locate(0, 1);Lcd.print(buf); ActiveLoop(); return 1; } uint8_t LoopFunction2(uint8_t x){ char buf[0x10]; sprintf(buf, "RR%d", x); Lcd.locate(0, 1);Lcd.print(buf);return 0; } uint8_t LoopFunction3(uint8_t x){ return 0; } uint8_t LoopFunction4(uint8_t x){ char buf[0x10]; uint8_t linedata=0, line[3]; if(x==1){ linedata = RawLineSignal; } line[2] = (0x4 & linedata)>>2; line[1] = (0x2 & linedata)>>1; line[0] = (0x1 & linedata)>>0; sprintf(buf, "A:%1d B:%1d C:%1d ", line[2], line[1], line[0]); Lcd.locate(0, 1);Lcd.print(buf);return 0; } uint8_t LoopFunction5(uint8_t x){ return 0; } uint8_t LoopFunction6(uint8_t x){ return 0; } uint8_t LoopFunction7(uint8_t x){ return 0; } uint8_t LoopFunction8(uint8_t x){ return 0; } uint8_t LoopFunction9(uint8_t x){ return 0; } uint8_t LoopFunctionA(uint8_t x){ return 0; } uint8_t LoopFunctionB(uint8_t x){ return 0; } uint8_t LoopFunctionC(uint8_t x){ return 0; } uint8_t LoopFunctionD(uint8_t x){ char buf[0x10]; if(x==1) data.strategy = 0; if(x==2) data.strategy = 1; if(x==3) data.strategy = 2; data.init_point_flag=1; sprintf(buf, "Make a strategy"); Lcd.locate(0, 1);Lcd.print(buf);return 0; } uint8_t LoopFunctionE(uint8_t x){ char buf[0x10]; if(x==1) data.strategy = 3; if(x==2) data.strategy = 4; if(x==3) data.strategy = 5; data.init_point_flag=1; sprintf(buf, "Make a strategy"); Lcd.locate(0, 1);Lcd.print(buf);return 0; } uint8_t LoopFunctionF(uint8_t x){ return 0; }