Main Program
Dependencies: mbed AQM1602 HMC6352 PID
Diff: main_processing/setup_command_active/active.cpp
- Revision:
- 19:342da3a5a474
- Child:
- 22:a95f7c63af3c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main_processing/setup_command_active/active.cpp Thu Jan 21 07:11:08 2016 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" +#include "extern.h" + +void ActiveLoop(void){ + uint8_t i; + void (*DutyFunction[DUTY_NUM])(void) = { + Active2Command + }; + void (*StrategyFunction[STRATEGY_NUM])(void) = { + modeAttack0 + }; + for(i=0; i<DUTY_NUM; i++){ + Duty[DUTY_SW].attach(DutyFunction[i], dutycycle[i]); + } + data.stopflag=0; + //スタート直前の処理 + SetUp2(); + while(1){ + //pc.printf("data.stopflag=%d\r\n", data.stopflag); + if(data.stopflag==1){ + //システム上の停止処理 + button.detach(); + last_statesum = statesum = 0; + state[0] = state[1] = state[2] = state[3] = 0; + + for(i=0; i<DUTY_NUM; i++){ + Duty[DUTY_SW].detach(); + } + data.stopflag=0; + //その他停止処理 + StopProcess(); + break; + } + StrategyFunction[data.strategy](); + } + return; +} +//for transition +void ResetState(void){ + last_statesum = statesum = 0; + state[0] = state[1] = state[2] = state[3] = 0; +} +void Active2Command(void){ + uint8_t i; + for(i=0; i<4; i++){ + if(CountSw(i)==1) state[i]=1; + } + last_statesum = statesum; + statesum = state[0]+state[1]+state[2]+state[3]; + if((statesum>=1)&&(!(statesum==last_statesum))){ + button.attach(&ResetState, 2.0); + } + if((statesum>=2)&&(1)){ + data.stopflag=1; + } +} \ No newline at end of file