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: mbed AQM1602 HMC6352 PID
main_processing/setup_command_active/active.cpp@5:5ff3a7d5d8c2, 2016-03-04 (annotated)
- Committer:
- lilac0112_1
- Date:
- Fri Mar 04 09:01:20 2016 +0000
- Revision:
- 5:5ff3a7d5d8c2
- Parent:
- 0:ea35c18c85fc
- Child:
- 8:25c8c75d182a
somehow and new ir_pow_format
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| lilac0112_1 | 0:ea35c18c85fc | 1 | #include "mbed.h" |
| lilac0112_1 | 0:ea35c18c85fc | 2 | #include "extern.h" |
| lilac0112_1 | 0:ea35c18c85fc | 3 | |
| lilac0112_1 | 5:5ff3a7d5d8c2 | 4 | void Active(void){ |
| lilac0112_1 | 0:ea35c18c85fc | 5 | uint8_t i; |
| lilac0112_1 | 0:ea35c18c85fc | 6 | void (*DutyFunction[DUTY_NUM])(void) = { |
| lilac0112_1 | 0:ea35c18c85fc | 7 | Active2Command |
| lilac0112_1 | 0:ea35c18c85fc | 8 | }; |
| lilac0112_1 | 0:ea35c18c85fc | 9 | void (*StrategyFunction[STRATEGY_NUM])(void) = { |
| lilac0112_1 | 5:5ff3a7d5d8c2 | 10 | //modeAttack5, |
| lilac0112_1 | 0:ea35c18c85fc | 11 | modeAttack2, |
| lilac0112_1 | 0:ea35c18c85fc | 12 | //modeAttack4, |
| lilac0112_1 | 0:ea35c18c85fc | 13 | modeAttack1, |
| lilac0112_1 | 0:ea35c18c85fc | 14 | modeAttack2, |
| lilac0112_1 | 0:ea35c18c85fc | 15 | modeAttack3, |
| lilac0112_1 | 0:ea35c18c85fc | 16 | modeAttack4, |
| lilac0112_1 | 0:ea35c18c85fc | 17 | modeAttack5, |
| lilac0112_1 | 0:ea35c18c85fc | 18 | |
| lilac0112_1 | 0:ea35c18c85fc | 19 | modeDebug0, |
| lilac0112_1 | 0:ea35c18c85fc | 20 | modeDebug1, |
| lilac0112_1 | 0:ea35c18c85fc | 21 | modeDebug2, |
| lilac0112_1 | 0:ea35c18c85fc | 22 | modeDebug3, |
| lilac0112_1 | 0:ea35c18c85fc | 23 | modeDebug4, |
| lilac0112_1 | 0:ea35c18c85fc | 24 | modeDebug5, |
| lilac0112_1 | 0:ea35c18c85fc | 25 | }; |
| lilac0112_1 | 0:ea35c18c85fc | 26 | for(i=0; i<DUTY_NUM; i++){ |
| lilac0112_1 | 0:ea35c18c85fc | 27 | Duty[i].attach(DutyFunction[i], dutycycle[i]); |
| lilac0112_1 | 0:ea35c18c85fc | 28 | } |
| lilac0112_1 | 0:ea35c18c85fc | 29 | sys.stopflag=0; |
| lilac0112_1 | 0:ea35c18c85fc | 30 | //スタート直前の処理 |
| lilac0112_1 | 0:ea35c18c85fc | 31 | SetUp2(); |
| lilac0112_1 | 0:ea35c18c85fc | 32 | while(1){ |
| lilac0112_1 | 0:ea35c18c85fc | 33 | //pc.printf("sys.stopflag=%d\r\n", sys.stopflag); |
| lilac0112_1 | 0:ea35c18c85fc | 34 | StrategyFunction[sys.strategy](); |
| lilac0112_1 | 0:ea35c18c85fc | 35 | if(sys.stopflag==1){ |
| lilac0112_1 | 0:ea35c18c85fc | 36 | //システム上の停止処理 |
| lilac0112_1 | 0:ea35c18c85fc | 37 | button.detach(); |
| lilac0112_1 | 0:ea35c18c85fc | 38 | last_statesum = statesum = 0; |
| lilac0112_1 | 0:ea35c18c85fc | 39 | state[0] = state[1] = state[2] = state[3] = 0; |
| lilac0112_1 | 0:ea35c18c85fc | 40 | |
| lilac0112_1 | 0:ea35c18c85fc | 41 | for(i=0; i<DUTY_NUM; i++){ |
| lilac0112_1 | 0:ea35c18c85fc | 42 | Duty[DUTY_SW].detach(); |
| lilac0112_1 | 0:ea35c18c85fc | 43 | } |
| lilac0112_1 | 0:ea35c18c85fc | 44 | sys.stopflag=0; |
| lilac0112_1 | 0:ea35c18c85fc | 45 | //その他停止処理 |
| lilac0112_1 | 0:ea35c18c85fc | 46 | StopProcess(); |
| lilac0112_1 | 0:ea35c18c85fc | 47 | break; |
| lilac0112_1 | 0:ea35c18c85fc | 48 | } |
| lilac0112_1 | 0:ea35c18c85fc | 49 | } |
| lilac0112_1 | 0:ea35c18c85fc | 50 | return; |
| lilac0112_1 | 0:ea35c18c85fc | 51 | } |
| lilac0112_1 | 0:ea35c18c85fc | 52 | //for transition |
| lilac0112_1 | 0:ea35c18c85fc | 53 | void ResetState(void){ |
| lilac0112_1 | 0:ea35c18c85fc | 54 | last_statesum = statesum = 0; |
| lilac0112_1 | 0:ea35c18c85fc | 55 | state[0] = state[1] = state[2] = state[3] = 0; |
| lilac0112_1 | 0:ea35c18c85fc | 56 | } |
| lilac0112_1 | 0:ea35c18c85fc | 57 | void Active2Command(void){ |
| lilac0112_1 | 0:ea35c18c85fc | 58 | uint8_t i; |
| lilac0112_1 | 0:ea35c18c85fc | 59 | for(i=0; i<4; i++){ |
| lilac0112_1 | 0:ea35c18c85fc | 60 | if(CountSw(i)==1) state[i]=1; |
| lilac0112_1 | 0:ea35c18c85fc | 61 | } |
| lilac0112_1 | 0:ea35c18c85fc | 62 | last_statesum = statesum; |
| lilac0112_1 | 0:ea35c18c85fc | 63 | statesum = state[0]+state[1]+state[2]+state[3]; |
| lilac0112_1 | 0:ea35c18c85fc | 64 | if((statesum>=1)&&(!(statesum==last_statesum))){ |
| lilac0112_1 | 0:ea35c18c85fc | 65 | button.attach(&ResetState, 2.0); |
| lilac0112_1 | 0:ea35c18c85fc | 66 | } |
| lilac0112_1 | 0:ea35c18c85fc | 67 | if((statesum>=2)&&(1)){ |
| lilac0112_1 | 0:ea35c18c85fc | 68 | sys.stopflag=1; |
| lilac0112_1 | 0:ea35c18c85fc | 69 | } |
| lilac0112_1 | 0:ea35c18c85fc | 70 | } |