![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
今までのジョイスティックの入力を段階分けしていた方式から、アナログ値をできる限りそのまま使用する方式に変更しました。
Fork of ControlMain2017 by
main.cpp@25:12408563540d, 2017-03-20 (annotated)
- Committer:
- YusukeWakuta
- Date:
- Mon Mar 20 23:33:54 2017 +0000
- Revision:
- 25:12408563540d
- Parent:
- 24:72f9cb6e9440
- Child:
- 26:745735b0479d
??????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
YusukeWakuta | 13:79eb74eb86c4 | 1 | //中央 |
YusukeWakuta | 0:b1290ca6c4a2 | 2 | |
YusukeWakuta | 0:b1290ca6c4a2 | 3 | #include "mbed.h" |
tsumagari | 10:b7159feb11fd | 4 | #define WAIT_LOOP_TIME 0.001 |
tsumagari | 9:c32999b4d2f9 | 5 | #define YOKUTAN_DATAS_NUM 7 |
tsumagari | 10:b7159feb11fd | 6 | #define INPUT_DATAS_NUM 5 |
YusukeWakuta | 0:b1290ca6c4a2 | 7 | #define SEND_DATAS_CAN_ID 100 |
tsumagari | 8:dbc8c87dac78 | 8 | #define SEND_DATAS_TIME 0.5 |
tsumagari | 8:dbc8c87dac78 | 9 | #define THRESHOLD_OH_VALUE 0.14 |
YusukeWakuta | 16:336e8b102555 | 10 | #define SUM_UP_NUM 20 |
YusukeWakuta | 15:c5ade23e5de4 | 11 | #define SAMPLE_INTERVAL 0.05 |
YusukeWakuta | 0:b1290ca6c4a2 | 12 | |
YusukeWakuta | 20:d4951f491642 | 13 | #define PHASE_NUM 6 //偶数にしてください |
YusukeWakuta | 24:72f9cb6e9440 | 14 | #define SUM_UP_NUM 10.0 |
YusukeWakuta | 19:6387e3f02b37 | 15 | /* |
YusukeWakuta | 19:6387e3f02b37 | 16 | roll入力とピッチ入力だとピッチの方が1.5倍効くように |
YusukeWakuta | 19:6387e3f02b37 | 17 | */ |
YusukeWakuta | 18:31722545ecf1 | 18 | |
tsumagari | 9:c32999b4d2f9 | 19 | //-----------------------------------(resetInterrupt def) |
tsumagari | 9:c32999b4d2f9 | 20 | extern "C" void mbed_reset(); |
YusukeWakuta | 13:79eb74eb86c4 | 21 | InterruptIn resetPin(p22); |
tsumagari | 9:c32999b4d2f9 | 22 | Timer resetTimeCount; |
YusukeWakuta | 15:c5ade23e5de4 | 23 | void resetInterrupt() |
YusukeWakuta | 15:c5ade23e5de4 | 24 | { |
YusukeWakuta | 15:c5ade23e5de4 | 25 | while(resetPin) { |
tsumagari | 9:c32999b4d2f9 | 26 | resetTimeCount.start(); |
tsumagari | 9:c32999b4d2f9 | 27 | if(resetTimeCount.read()>3) mbed_reset(); |
tsumagari | 9:c32999b4d2f9 | 28 | } |
tsumagari | 9:c32999b4d2f9 | 29 | resetTimeCount.reset(); |
tsumagari | 9:c32999b4d2f9 | 30 | } |
tsumagari | 9:c32999b4d2f9 | 31 | //------------------------------------------------------- |
tsumagari | 9:c32999b4d2f9 | 32 | |
taurin | 6:7484315ba88a | 33 | CAN can_R(p30,p29); |
taurin | 6:7484315ba88a | 34 | CAN can_L(p9,p10); |
YusukeWakuta | 14:ffe9460922cb | 35 | Serial toKeikiSerial(p28,p27); |
tsumagari | 7:59ddbe239835 | 36 | Serial pc(USBTX,USBRX); |
tsumagari | 10:b7159feb11fd | 37 | AnalogIn rollPin(p15); |
YusukeWakuta | 18:31722545ecf1 | 38 | AnalogIn pitchPin(p20); |
YusukeWakuta | 13:79eb74eb86c4 | 39 | DigitalIn drug_R(p14); |
taurin | 6:7484315ba88a | 40 | DigitalIn drug_L(p19); |
YusukeWakuta | 25:12408563540d | 41 | DigitalOut led1(LED1); |
YusukeWakuta | 25:12408563540d | 42 | DigitalOut led2(LED2); |
YusukeWakuta | 15:c5ade23e5de4 | 43 | DigitalOut led4(LED4); |
YusukeWakuta | 15:c5ade23e5de4 | 44 | DigitalOut led3(LED3); |
tsumagari | 9:c32999b4d2f9 | 45 | //Ticker sendDatasTicker; |
YusukeWakuta | 0:b1290ca6c4a2 | 46 | |
taurin | 4:4a13dd263a7b | 47 | char yokutanDatas_R[YOKUTAN_DATAS_NUM]; |
taurin | 4:4a13dd263a7b | 48 | char yokutanDatas_L[YOKUTAN_DATAS_NUM]; |
tsumagari | 10:b7159feb11fd | 49 | char inputDatas_R[INPUT_DATAS_NUM]; |
tsumagari | 10:b7159feb11fd | 50 | char inputDatas_L[INPUT_DATAS_NUM]; |
YusukeWakuta | 24:72f9cb6e9440 | 51 | |
YusukeWakuta | 25:12408563540d | 52 | float rollNeutral = 0.739; |
YusukeWakuta | 25:12408563540d | 53 | float rollUpperDiff = 0; |
YusukeWakuta | 25:12408563540d | 54 | float rollLowerDiff = 0; |
YusukeWakuta | 24:72f9cb6e9440 | 55 | |
YusukeWakuta | 25:12408563540d | 56 | float pitchNeutral = 0.468 ;//1って書いた方 |
YusukeWakuta | 25:12408563540d | 57 | float pitchUpperDiff = 0; |
YusukeWakuta | 25:12408563540d | 58 | float pitchLowerDiff = 0; |
YusukeWakuta | 24:72f9cb6e9440 | 59 | float neutralDiff; |
YusukeWakuta | 0:b1290ca6c4a2 | 60 | |
YusukeWakuta | 3:0e66ce2ab2fb | 61 | CANMessage recmsg_R; |
YusukeWakuta | 3:0e66ce2ab2fb | 62 | CANMessage recmsg_L; |
YusukeWakuta | 0:b1290ca6c4a2 | 63 | |
YusukeWakuta | 25:12408563540d | 64 | enum InputType { |
YusukeWakuta | 25:12408563540d | 65 | roll, |
YusukeWakuta | 25:12408563540d | 66 | pitch |
YusukeWakuta | 25:12408563540d | 67 | }; |
YusukeWakuta | 25:12408563540d | 68 | |
YusukeWakuta | 24:72f9cb6e9440 | 69 | void setNeutral() |
YusukeWakuta | 24:72f9cb6e9440 | 70 | { |
YusukeWakuta | 24:72f9cb6e9440 | 71 | float rollSum; |
YusukeWakuta | 24:72f9cb6e9440 | 72 | float pitchSum; |
YusukeWakuta | 25:12408563540d | 73 | |
YusukeWakuta | 24:72f9cb6e9440 | 74 | for(int i = 0; i < SUM_UP_NUM; i++) { |
YusukeWakuta | 24:72f9cb6e9440 | 75 | rollSum += rollPin.read(); |
YusukeWakuta | 24:72f9cb6e9440 | 76 | pitchSum += pitchPin.read(); |
YusukeWakuta | 24:72f9cb6e9440 | 77 | } |
YusukeWakuta | 25:12408563540d | 78 | rollNeutral = rollSum / SUM_UP_NUM; |
YusukeWakuta | 25:12408563540d | 79 | pitchNeutral = pitchSum / SUM_UP_NUM; |
YusukeWakuta | 25:12408563540d | 80 | } |
YusukeWakuta | 25:12408563540d | 81 | |
YusukeWakuta | 25:12408563540d | 82 | void setMaxAndMin(InputType it,float value) |
YusukeWakuta | 25:12408563540d | 83 | { |
YusukeWakuta | 25:12408563540d | 84 | if(it = InputType.pitch) { |
YusukeWakuta | 25:12408563540d | 85 | if(value >pitchNeutral + pitchUpperDiff) |
YusukeWakuta | 25:12408563540d | 86 | pitchUpperDiff = value - pitchNeutral; |
YusukeWakuta | 25:12408563540d | 87 | else if(value < rollNeutral - pitchLowerDiff) |
YusukeWakuta | 25:12408563540d | 88 | pitchLowerDiff = pitchNeutral - value; |
YusukeWakuta | 25:12408563540d | 89 | } else if(it = InputType.roll) { |
YusukeWakuta | 25:12408563540d | 90 | if(value >rollNeutral + rollUpperDiff) |
YusukeWakuta | 25:12408563540d | 91 | rollUpperDiff = value - rollNeutral; |
YusukeWakuta | 25:12408563540d | 92 | else if(value < rollNeutral - rollLowerDiff) |
YusukeWakuta | 25:12408563540d | 93 | rollLowerDiff = rollNeutral - value; |
YusukeWakuta | 25:12408563540d | 94 | } |
YusukeWakuta | 24:72f9cb6e9440 | 95 | } |
YusukeWakuta | 24:72f9cb6e9440 | 96 | |
YusukeWakuta | 24:72f9cb6e9440 | 97 | |
YusukeWakuta | 25:12408563540d | 98 | void calibrateRoll2Pitch() |
YusukeWakuta | 24:72f9cb6e9440 | 99 | { |
YusukeWakuta | 25:12408563540d | 100 | neutralDiff = pitchNeutral - rollNeutral; //ピッチの初期値の方がい小さいと仮定 |
YusukeWakuta | 25:12408563540d | 101 | rollNeutral += neutralDiff; |
YusukeWakuta | 25:12408563540d | 102 | rollUpperDiff += neutralDiff; |
YusukeWakuta | 25:12408563540d | 103 | rollLowerDiff += neutralDiff; |
YusukeWakuta | 24:72f9cb6e9440 | 104 | } |
YusukeWakuta | 24:72f9cb6e9440 | 105 | |
YusukeWakuta | 20:d4951f491642 | 106 | //ジョイスティックの中間値から上と下の幅を合わせます。値を取得するたびに呼び出してください。範囲は広い方に合わせる物とします |
YusukeWakuta | 25:12408563540d | 107 | float MatchRollUpperAndLower(InputType it, float max,float min,float neutral,float value) |
YusukeWakuta | 18:31722545ecf1 | 108 | { |
YusukeWakuta | 20:d4951f491642 | 109 | float Upper = max- neutral; |
YusukeWakuta | 20:d4951f491642 | 110 | float Lower = neutral - min; |
YusukeWakuta | 25:12408563540d | 111 | |
YusukeWakuta | 25:12408563540d | 112 | if(it = InputType.roll) { |
YusukeWakuta | 25:12408563540d | 113 | if(Upper > Lower) { |
YusukeWakuta | 25:12408563540d | 114 | if(value < neutral) { |
YusukeWakuta | 25:12408563540d | 115 | value = neutral - ((neutral - value) * (Upper / Lower)); |
YusukeWakuta | 25:12408563540d | 116 | rollLowerDiff = (rollLowerDiff)* (Upper / Lower); |
YusukeWakuta | 25:12408563540d | 117 | } |
YusukeWakuta | 25:12408563540d | 118 | } else { |
YusukeWakuta | 25:12408563540d | 119 | if(value > neutral) { |
YusukeWakuta | 25:12408563540d | 120 | value = neutral + ((value - neutral) * (Lower / Upper)); |
YusukeWakuta | 25:12408563540d | 121 | rollUpperDiff = rollUpperDiff* (Upper / Lower); |
YusukeWakuta | 25:12408563540d | 122 | } |
YusukeWakuta | 20:d4951f491642 | 123 | } |
YusukeWakuta | 25:12408563540d | 124 | return value; |
YusukeWakuta | 25:12408563540d | 125 | } else if(it = InputType.pitch) { |
YusukeWakuta | 25:12408563540d | 126 | if(Upper > Lower) { |
YusukeWakuta | 25:12408563540d | 127 | if(value < neutral) { |
YusukeWakuta | 25:12408563540d | 128 | value = neutral - ((neutral - value) * (Upper / Lower)); |
YusukeWakuta | 25:12408563540d | 129 | pitchLowerDiff = (pitchLowerDiff)* (Upper / Lower); |
YusukeWakuta | 25:12408563540d | 130 | } |
YusukeWakuta | 25:12408563540d | 131 | } else { |
YusukeWakuta | 25:12408563540d | 132 | if(value > neutral) { |
YusukeWakuta | 25:12408563540d | 133 | value = neutral + ((value - neutral) * (Lower / Upper)); |
YusukeWakuta | 25:12408563540d | 134 | pitchUpperDiff= (pitchUpperDiff)* (Upper / Lower); |
YusukeWakuta | 25:12408563540d | 135 | } |
YusukeWakuta | 20:d4951f491642 | 136 | } |
YusukeWakuta | 25:12408563540d | 137 | return value; |
YusukeWakuta | 20:d4951f491642 | 138 | } |
YusukeWakuta | 18:31722545ecf1 | 139 | } |
YusukeWakuta | 18:31722545ecf1 | 140 | |
YusukeWakuta | 21:9b1f5123f4a8 | 141 | //範囲外に値がない場合にエラーが発生するので範囲内に収める |
YusukeWakuta | 21:9b1f5123f4a8 | 142 | float Format2Range(float value,float max,float min) |
YusukeWakuta | 18:31722545ecf1 | 143 | { |
YusukeWakuta | 18:31722545ecf1 | 144 | float result; |
YusukeWakuta | 21:9b1f5123f4a8 | 145 | |
YusukeWakuta | 18:31722545ecf1 | 146 | if(value > max) |
YusukeWakuta | 18:31722545ecf1 | 147 | result= max; |
YusukeWakuta | 18:31722545ecf1 | 148 | else if(value < min) |
YusukeWakuta | 18:31722545ecf1 | 149 | result = min; |
YusukeWakuta | 21:9b1f5123f4a8 | 150 | else if(value > 1) |
YusukeWakuta | 21:9b1f5123f4a8 | 151 | result = 1; |
YusukeWakuta | 21:9b1f5123f4a8 | 152 | else if(value < 0) |
YusukeWakuta | 21:9b1f5123f4a8 | 153 | result = 0; |
YusukeWakuta | 18:31722545ecf1 | 154 | else |
YusukeWakuta | 18:31722545ecf1 | 155 | result = value; |
YusukeWakuta | 18:31722545ecf1 | 156 | return result; |
YusukeWakuta | 18:31722545ecf1 | 157 | } |
YusukeWakuta | 18:31722545ecf1 | 158 | |
YusukeWakuta | 21:9b1f5123f4a8 | 159 | //値をint型の段階に分ける |
YusukeWakuta | 18:31722545ecf1 | 160 | int PhaseFloat(float value,float max,float min) |
YusukeWakuta | 18:31722545ecf1 | 161 | { |
YusukeWakuta | 18:31722545ecf1 | 162 | float PhaseWidth = (max - min) / PHASE_NUM; |
YusukeWakuta | 18:31722545ecf1 | 163 | if(value< max&& value > min) { |
YusukeWakuta | 18:31722545ecf1 | 164 | for(int i = 1; i <= PHASE_NUM; i++) { |
YusukeWakuta | 18:31722545ecf1 | 165 | if(value < min + PhaseWidth * i&& value > min + PhaseWidth * (i - 1) ) |
YusukeWakuta | 18:31722545ecf1 | 166 | return i; |
YusukeWakuta | 18:31722545ecf1 | 167 | } |
YusukeWakuta | 18:31722545ecf1 | 168 | } else if(value <= min) |
YusukeWakuta | 18:31722545ecf1 | 169 | return 0; |
YusukeWakuta | 18:31722545ecf1 | 170 | else if(value>=max) |
YusukeWakuta | 18:31722545ecf1 | 171 | return PHASE_NUM; |
YusukeWakuta | 18:31722545ecf1 | 172 | } |
YusukeWakuta | 18:31722545ecf1 | 173 | |
YusukeWakuta | 15:c5ade23e5de4 | 174 | void InputControlValues() |
YusukeWakuta | 15:c5ade23e5de4 | 175 | { |
YusukeWakuta | 25:12408563540d | 176 | setRollMaxAndMin(InputType.roll, rollPin.read()); |
YusukeWakuta | 25:12408563540d | 177 | setPitchMaxAndMin(InputType.pitch, pitchPin.read()); |
YusukeWakuta | 25:12408563540d | 178 | calibrateRoll2Pitch(); |
YusukeWakuta | 25:12408563540d | 179 | float MatchedRoll = MatchUpperAndLower(InputType.roll, rollNeutral + rollUpperDiff,rollLowerDiff + rollLowerDiff,rollNeutral,rollPin.read() - neutralDiff); |
YusukeWakuta | 25:12408563540d | 180 | float MatchedPitch = MatchUpperAndLower(InputType.pitch, pitchNeutral + pitchUpperDiff,pitchNeutral + pitchLowerDiff,pitchNeutral,pitchPin.read()); |
YusukeWakuta | 24:72f9cb6e9440 | 181 | |
YusukeWakuta | 25:12408563540d | 182 | float FormatedRoll_R = Format2Range((MatchedPitch +MatchedRoll ) / 2.0,(rollNeutral + rollUpperDiff+ pitchNeutral + pitchUpperDiff) / 2.0,(rollNeutral + rollLowerDiff+ pitchNeutral + pitchLowerDiff) / 2.0); |
YusukeWakuta | 25:12408563540d | 183 | *(int *)inputDatas_R =PhaseFloat(FormatedRoll_R,(rollNeutral + rollUpperDiff+ pitchNeutral + pitchUpperDiff) / 2.0,(rollNeutral + rollLowerDiff+ pitchNeutral + pitchLowerDiff) / 2.0); |
YusukeWakuta | 24:72f9cb6e9440 | 184 | |
YusukeWakuta | 25:12408563540d | 185 | float FormatedRoll_L = Format2Range((MatchedPitch - MatchedRoll) / 2.0,(rollNeutral + rollUpperDiff- pitchNeutral -pitchLowerDiff) / 2.0,(rollNeutral + rollLowerDiff- pitchNeutral - pitchUpperDiff) / 2.0); |
YusukeWakuta | 25:12408563540d | 186 | *(int *)inputDatas_L = PhaseFloat(FormatedRoll_R,(rollNeutral + rollUpperDiff- pitchNeutral - pitchLowerDiff) / 2.0,(rollNeutral + rollLowerDiff- pitchNeutral + pitchUpperDiff) / 2.0); |
YusukeWakuta | 16:336e8b102555 | 187 | |
YusukeWakuta | 25:12408563540d | 188 | |
YusukeWakuta | 25:12408563540d | 189 | if(*(int *)inputDatas_R < 0) |
YusukeWakuta | 25:12408563540d | 190 | *(int *)inputDatas_R = 0; |
YusukeWakuta | 25:12408563540d | 191 | else if(*(int *)inputDatas_R > PHASE_NUM) |
YusukeWakuta | 25:12408563540d | 192 | *(int *)inputDatas_R = PHASE_NUM; |
YusukeWakuta | 25:12408563540d | 193 | if(*(int *)inputDatas_L < 0) |
YusukeWakuta | 25:12408563540d | 194 | *(int *)inputDatas_L = 0 ; |
YusukeWakuta | 25:12408563540d | 195 | else if(*(int *)inputDatas_L > PHASE_NUM) |
YusukeWakuta | 25:12408563540d | 196 | *(int *)inputDatas_L =PHASE_NUM; |
YusukeWakuta | 16:336e8b102555 | 197 | |
YusukeWakuta | 19:6387e3f02b37 | 198 | pc.printf("input_R:%d input_L:%d\n\r",*(int *)inputDatas_R,*(int *)inputDatas_L); |
tsumagari | 10:b7159feb11fd | 199 | inputDatas_R[4] = (char)drug_R; |
YusukeWakuta | 15:c5ade23e5de4 | 200 | led4 =! led4; |
YusukeWakuta | 15:c5ade23e5de4 | 201 | pc.printf("%c",*(char *)inputDatas_R[4]); |
YusukeWakuta | 15:c5ade23e5de4 | 202 | //pc.printf("%c",(char)drug_R); |
tsumagari | 10:b7159feb11fd | 203 | inputDatas_L[4] = (char)drug_L; |
YusukeWakuta | 15:c5ade23e5de4 | 204 | // pc.printf(""); |
YusukeWakuta | 0:b1290ca6c4a2 | 205 | } |
YusukeWakuta | 0:b1290ca6c4a2 | 206 | |
YusukeWakuta | 15:c5ade23e5de4 | 207 | void SendDatas() |
YusukeWakuta | 15:c5ade23e5de4 | 208 | { |
tsumagari | 10:b7159feb11fd | 209 | can_R.write(CANMessage(SEND_DATAS_CAN_ID, inputDatas_R, INPUT_DATAS_NUM)); |
tsumagari | 10:b7159feb11fd | 210 | can_L.write(CANMessage(SEND_DATAS_CAN_ID, inputDatas_L, INPUT_DATAS_NUM)); |
tsumagari | 8:dbc8c87dac78 | 211 | toKeikiSerial.putc(';'); |
YusukeWakuta | 15:c5ade23e5de4 | 212 | for(int i = 0; i < YOKUTAN_DATAS_NUM; i++) { |
YusukeWakuta | 0:b1290ca6c4a2 | 213 | toKeikiSerial.putc(yokutanDatas_R[i]); |
YusukeWakuta | 0:b1290ca6c4a2 | 214 | toKeikiSerial.putc(yokutanDatas_L[i]); |
YusukeWakuta | 0:b1290ca6c4a2 | 215 | } |
YusukeWakuta | 15:c5ade23e5de4 | 216 | for(int i = 0; i < INPUT_DATAS_NUM; i++) { |
taurin | 4:4a13dd263a7b | 217 | toKeikiSerial.putc(inputDatas_R[i]); |
taurin | 4:4a13dd263a7b | 218 | toKeikiSerial.putc(inputDatas_L[i]); |
taurin | 4:4a13dd263a7b | 219 | } |
YusukeWakuta | 0:b1290ca6c4a2 | 220 | } |
tsumagari | 8:dbc8c87dac78 | 221 | |
YusukeWakuta | 15:c5ade23e5de4 | 222 | void init() |
YusukeWakuta | 15:c5ade23e5de4 | 223 | { |
tsumagari | 9:c32999b4d2f9 | 224 | //--------------------------------------(resetInterrupt init) |
tsumagari | 9:c32999b4d2f9 | 225 | resetPin.rise(resetInterrupt); |
tsumagari | 9:c32999b4d2f9 | 226 | resetPin.mode(PullDown); |
tsumagari | 9:c32999b4d2f9 | 227 | //----------------------------------------------------------- |
tsumagari | 9:c32999b4d2f9 | 228 | // sendDatasTicker.attach(SendDatas,SEND_DATAS_TIME); |
YusukeWakuta | 15:c5ade23e5de4 | 229 | for(int i = 0; i < INPUT_DATAS_NUM; i++) { |
taurin | 2:9dc7d5f1e910 | 230 | inputDatas_R[i] = 0; |
taurin | 2:9dc7d5f1e910 | 231 | inputDatas_L[i] = 0; |
taurin | 2:9dc7d5f1e910 | 232 | } |
YusukeWakuta | 0:b1290ca6c4a2 | 233 | } |
YusukeWakuta | 0:b1290ca6c4a2 | 234 | |
YusukeWakuta | 15:c5ade23e5de4 | 235 | void receiveDatas() |
YusukeWakuta | 15:c5ade23e5de4 | 236 | { |
YusukeWakuta | 15:c5ade23e5de4 | 237 | if(can_R.read(recmsg_R)) { |
YusukeWakuta | 15:c5ade23e5de4 | 238 | for(int i = 0; i < recmsg_R.len; i++) { |
YusukeWakuta | 0:b1290ca6c4a2 | 239 | yokutanDatas_R[i] = recmsg_R.data[i]; |
YusukeWakuta | 15:c5ade23e5de4 | 240 | // pc.printf("%c",yokutanDatas_R[i]); |
YusukeWakuta | 0:b1290ca6c4a2 | 241 | } |
YusukeWakuta | 25:12408563540d | 242 | led1 = !led1; |
YusukeWakuta | 0:b1290ca6c4a2 | 243 | } |
YusukeWakuta | 15:c5ade23e5de4 | 244 | if(can_L.read(recmsg_L)) { |
YusukeWakuta | 15:c5ade23e5de4 | 245 | for(int i = 0; i < recmsg_L.len; i++) { |
YusukeWakuta | 0:b1290ca6c4a2 | 246 | yokutanDatas_L[i] = recmsg_L.data[i]; |
YusukeWakuta | 15:c5ade23e5de4 | 247 | led3 = !led3; |
YusukeWakuta | 15:c5ade23e5de4 | 248 | // pc.printf("%c",yokutanDatas_L[i]); |
YusukeWakuta | 0:b1290ca6c4a2 | 249 | } |
YusukeWakuta | 25:12408563540d | 250 | led2 = !led2; |
YusukeWakuta | 0:b1290ca6c4a2 | 251 | } |
YusukeWakuta | 0:b1290ca6c4a2 | 252 | } |
YusukeWakuta | 0:b1290ca6c4a2 | 253 | |
YusukeWakuta | 15:c5ade23e5de4 | 254 | int main() |
YusukeWakuta | 15:c5ade23e5de4 | 255 | { |
YusukeWakuta | 0:b1290ca6c4a2 | 256 | init(); |
YusukeWakuta | 24:72f9cb6e9440 | 257 | setNeutral(); |
YusukeWakuta | 15:c5ade23e5de4 | 258 | while(1) { |
tsumagari | 8:dbc8c87dac78 | 259 | InputControlValues(); |
tsumagari | 10:b7159feb11fd | 260 | wait_us(5); |
YusukeWakuta | 0:b1290ca6c4a2 | 261 | receiveDatas(); |
tsumagari | 9:c32999b4d2f9 | 262 | SendDatas(); |
YusukeWakuta | 0:b1290ca6c4a2 | 263 | wait(WAIT_LOOP_TIME); |
YusukeWakuta | 0:b1290ca6c4a2 | 264 | } |
YusukeWakuta | 0:b1290ca6c4a2 | 265 | } |