ジャパンオープン用のメインプログラム
Dependencies: mbed AQM1602 HMC6352 PID
Diff: main_processing/setup_command_active/command_functions.cpp
- Revision:
- 4:52da8da146d4
- Parent:
- 3:c49ea7ad8e91
- Child:
- 5:5ff3a7d5d8c2
--- a/main_processing/setup_command_active/command_functions.cpp Thu Mar 03 11:47:49 2016 +0000 +++ b/main_processing/setup_command_active/command_functions.cpp Fri Mar 04 03:39:29 2016 +0000 @@ -189,4 +189,195 @@ Lcd.locate(0, 1);Lcd.print(buf); ActiveLoop(); return 1; +} + + + +uint8_t ZeroFunction(uint8_t x){ + char buf[0x10]; + if(x==1){ + sprintf(buf, "Strategy:%2d", sys.strategy); + Lcd.locate(0, 1);Lcd.print(buf);wait_ms(50);return 0; + } + else{//x==2 + sprintf(buf, "SeeYouAgain!"); + Lcd.locate(0, 1);Lcd.print(buf);wait(0.5); + NVIC_SystemReset(); + return 1; + } +} +uint8_t Start(uint8_t x){ + char buf[0x10]; + sprintf(buf, "CatPot"); + Lcd.locate(0, 1);Lcd.print(buf); + sys.strategy=0; + ActiveLoop(); + return 1; +} +uint8_t GetIr(uint8_t x){ + char buf[0x10]; + ReadIr(); + + //if(x==1) sprintf(buf, "SHRT:%2d, LNG:%2d", data.irSpot[0], data.irSpot[1]); + //if(x==2) sprintf(buf, "NOTE:%2d", data.irNotice); + //if(x==3) sprintf(buf, "POSITION:%2d", data.irPosition); + if(x==1) sprintf(buf, "POSI:%2d NOTE:%1d", data.irPosition, data.irNotice); + if(x==2) sprintf(buf, "PH_L:%1d PH_S:%1d", data.irValPhase[IR_LONG], data.irValPhase[IR_SHORT]); + if(x==3) sprintf(buf, "DIF:%1d KEY:%2d", data.irDif[IR_LONG], data.irKey); + Lcd.locate(0, 1);Lcd.print(buf);wait_ms(50);return 0; +} +uint8_t GetLine(uint8_t x){ + char buf[0x10]; + uint8_t raw[3]; + uint8_t held[3]; + if(x==1){ + raw[2] = GetBit(LineRaw, 3); + raw[1] = GetBit(LineRaw, 2); + raw[0] = GetBit(LineRaw, 1); + + held[2] = GetBit(LineHold, 3); + held[1] = GetBit(LineHold, 2); + held[0] = GetBit(LineHold, 1); + //BusOut LineKeeper(lineInA, lineInB, lineInC); + //BusIn LineRaw(lineA2, lineB2, lineC2); + //BusIn LineHold(lineA1, lineB1, lineC1); + sprintf(buf, "A:%1d%1d B:%1d%1d C:%1d%1d ", raw[0],held[0],raw[1],held[1],raw[2],held[2]); + //sprintf(buf, "A:%1d B:%1d C:%1d ", Line[0].read(), Line[1].read(), Line[2].read()); + Lcd.locate(0, 1);Lcd.print(buf);wait_ms(50);return 0; + } + if(x==2){ + ReadPing(); + sprintf(buf, "L:%3d R:%3d", data.ping[L_PING], data.ping[R_PING]); + Lcd.locate(0, 1);Lcd.print(buf);wait_ms(50);return 0; + } + if(x==3){ + //ReadIr(); + //sprintf(buf, "IR_KEY:%2d", data.irKey); + //sprintf(buf, "BALL:%1d", BallChecker.read()); + sprintf(buf, "BALLA%6d", BallCheckerA.read_u16()); + Lcd.locate(0, 1);Lcd.print(buf);wait_ms(50);return 0; + } + return 0; +} +uint8_t GetPidValue(uint8_t x){ + char buf[0x10]; + PidUpdate(); + sprintf(buf, "In:%03.0f Out:%+02d", cmps_set.InputPID, cmps_set.OutputPID); + Lcd.locate(0, 1);Lcd.print(buf);wait_ms(50);return 0; +} +uint8_t CalibrationEnter(uint8_t x){ + char buf[0x10]; + sprintf(buf, "Enter"); + Lcd.locate(0, 1);Lcd.print(buf); + hmc.setCalibrationMode(HMC6352_EXIT_CALIB); + sys.jump_flag=CALIBRATION_EXIT; + return 1; +} +uint8_t CalibrationExit(uint8_t x){ + char buf[0x10]; + sprintf(buf, "Exit"); + Lcd.locate(0, 1);Lcd.print(buf); + hmc.setCalibrationMode(HMC6352_ENTER_CALIB); + sys.jump_flag=START; + return 1; +} +uint8_t FrontReset(uint8_t x){ + char buf[0x10]; + sys.jump_flag=START; + sprintf(buf, "FaceToFront!"); + Lcd.locate(0, 1);Lcd.print(buf); + for(int i=0; i<5; i++){ + ReadCmps(); + cmps_set.CmpsInitialValue = cmps_set.cmps; + wait_ms(100); + } + cmps_set.CmpsDiff = REFERENCE - cmps_set.cmps; + cmps_set.FrontDeg=0; + return 1; +} +uint8_t SetPower1(uint8_t x){ + char buf[0x10]; + if(x==1){ + sys.s_pow = 20; + sys.l_pow = 20; + } + if(x==2){ + sys.s_pow = 30; + sys.l_pow = 30; + } + if(x==3){ + sys.s_pow = 40; + sys.l_pow = 40; + } + sys.jump_flag=START; + sprintf(buf, "TuningS_power"); + Lcd.locate(0, 1);Lcd.print(buf);return 0; +} +uint8_t SetPower2(uint8_t x){ + char buf[0x10]; + if(x==1){ + sys.s_pow = 20; + sys.l_pow = 30; + } + if(x==2){ + sys.s_pow = 25; + sys.l_pow = 35; + } + if(x==3){ + sys.s_pow = 35; + sys.l_pow = 45; + } + sys.jump_flag=START; + sprintf(buf, "TuningL_power"); + Lcd.locate(0, 1);Lcd.print(buf);return 0; +} +uint8_t SoftReset(uint8_t x){ + char buf[0x10]; + sprintf(buf, "SeeYouAgain!"); + Lcd.locate(0, 1);Lcd.print(buf);wait(0.5); + NVIC_SystemReset(); + return 1; +} +uint8_t SetStrategy1(uint8_t x){ + char buf[0x10]; + if(x==1) sys.strategy = 6; + if(x==2) sys.strategy = 7; + if(x==3) sys.strategy = 8; + sys.jump_flag=START; + sprintf(buf, "Make a strategy"); + Lcd.locate(0, 1);Lcd.print(buf);return 0; +} +uint8_t SetStrategy2(uint8_t x){ + char buf[0x10]; + if(x==1) sys.strategy = 9; + if(x==2) sys.strategy = 10; + if(x==3) sys.strategy = 11; + sys.jump_flag=START; + sprintf(buf, "Make a strategy"); + Lcd.locate(0, 1);Lcd.print(buf);return 0; +} +uint8_t SetStrategy3(uint8_t x){ + char buf[0x10]; + if(x==1) sys.strategy = 0; + if(x==2) sys.strategy = 1; + if(x==3) sys.strategy = 2; + sys.jump_flag=START; + sprintf(buf, "Make a strategy"); + Lcd.locate(0, 1);Lcd.print(buf);return 0; +} +uint8_t SetStrategy4(uint8_t x){ + char buf[0x10]; + if(x==1) sys.strategy = 3; + if(x==2) sys.strategy = 4; + if(x==3) sys.strategy = 5; + sys.jump_flag=START; + sprintf(buf, "Make a strategy"); + Lcd.locate(0, 1);Lcd.print(buf);return 0; +} +uint8_t Start2(uint8_t x){ + char buf[0x10]; + sprintf(buf, "CatPotForDebug"); + Lcd.locate(0, 1);Lcd.print(buf); + ActiveLoop(); + return 1; } \ No newline at end of file