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
main.cpp@8:a435e7aa7a02, 2019-03-29 (annotated)
- Committer:
- whutsup
- Date:
- Fri Mar 29 01:29:39 2019 +0000
- Revision:
- 8:a435e7aa7a02
- Parent:
- 7:8fb5513a2231
- Child:
- 9:7d6fa62f9022
anybaro_ver_7;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
whutsup | 0:cbbc3528eb59 | 1 | #include "mbed.h" |
whutsup | 4:bf4ad2079096 | 2 | #include "MotorControl.h" |
whutsup | 4:bf4ad2079096 | 3 | #include "ForceRead.h" |
whutsup | 0:cbbc3528eb59 | 4 | |
whutsup | 4:bf4ad2079096 | 5 | #define DEBUG |
whutsup | 0:cbbc3528eb59 | 6 | |
whutsup | 4:bf4ad2079096 | 7 | Serial bt(PA_9,PA_10); // USART1 Bluetooth (Tx, Rx) |
whutsup | 4:bf4ad2079096 | 8 | Serial pc(PA_2,PA_3); // USART2 pc (Tx, Rx) |
whutsup | 2:b7d4195e0fea | 9 | |
whutsup | 4:bf4ad2079096 | 10 | InterruptIn up(PC_8); // Button Interrupt Motor control |
whutsup | 4:bf4ad2079096 | 11 | InterruptIn down(PC_9); |
whutsup | 8:a435e7aa7a02 | 12 | InterruptIn bt_ml(PC_10); // Millking action button |
whutsup | 4:bf4ad2079096 | 13 | |
whutsup | 4:bf4ad2079096 | 14 | DigitalOut led(LED2); // Operating LED signal |
whutsup | 4:bf4ad2079096 | 15 | |
whutsup | 4:bf4ad2079096 | 16 | AnalogIn disSensor(PA_7); // Distance Sensor |
whutsup | 0:cbbc3528eb59 | 17 | |
whutsup | 4:bf4ad2079096 | 18 | Timeout ResetTimer; // Reset angle 0 position |
whutsup | 4:bf4ad2079096 | 19 | |
whutsup | 4:bf4ad2079096 | 20 | Ticker timer0; // Operating MCU LED on |
whutsup | 4:bf4ad2079096 | 21 | Ticker timer1; // Control Angle By Using Distance Sensor |
whutsup | 4:bf4ad2079096 | 22 | Ticker timer2; // Force Sensor |
whutsup | 4:bf4ad2079096 | 23 | Ticker timer3; // Millking Action Mode |
whutsup | 5:6bb52b2a79bf | 24 | Ticker timer4; |
whutsup | 0:cbbc3528eb59 | 25 | |
whutsup | 4:bf4ad2079096 | 26 | int targetDis; // Target Of Distance |
whutsup | 4:bf4ad2079096 | 27 | int milLoop; // Number of Millking Action |
whutsup | 8:a435e7aa7a02 | 28 | //float errorPrevious; |
whutsup | 8:a435e7aa7a02 | 29 | |
whutsup | 4:bf4ad2079096 | 30 | int onewayNum=0; // Counting Turning Point |
whutsup | 4:bf4ad2079096 | 31 | int sysStatus=0; |
whutsup | 4:bf4ad2079096 | 32 | bool mkOn = 0; |
whutsup | 2:b7d4195e0fea | 33 | |
whutsup | 4:bf4ad2079096 | 34 | /*----------------------- ReadData Variables ------------------------*/ |
whutsup | 0:cbbc3528eb59 | 35 | |
whutsup | 4:bf4ad2079096 | 36 | char rxData[7]; |
whutsup | 4:bf4ad2079096 | 37 | bool flagRx = 0; |
whutsup | 0:cbbc3528eb59 | 38 | |
whutsup | 5:6bb52b2a79bf | 39 | #define parA 343.75f // parmeter of equation (values of distance sensor) |
whutsup | 5:6bb52b2a79bf | 40 | #define parB -1*508.08f |
whutsup | 5:6bb52b2a79bf | 41 | #define parC 166.67f |
whutsup | 0:cbbc3528eb59 | 42 | |
whutsup | 4:bf4ad2079096 | 43 | /*----------------------- Callback Functions ------------------------*/ |
whutsup | 0:cbbc3528eb59 | 44 | |
whutsup | 5:6bb52b2a79bf | 45 | void Test() |
whutsup | 5:6bb52b2a79bf | 46 | { |
whutsup | 5:6bb52b2a79bf | 47 | float d1 = disSensor.read(); |
whutsup | 8:a435e7aa7a02 | 48 | float d2 = parA*d1*d1+parB*d1+parC; |
whutsup | 5:6bb52b2a79bf | 49 | |
whutsup | 8:a435e7aa7a02 | 50 | bt.printf("%1.3f\n",d2); |
whutsup | 5:6bb52b2a79bf | 51 | } |
whutsup | 5:6bb52b2a79bf | 52 | |
whutsup | 4:bf4ad2079096 | 53 | void ReadData() |
whutsup | 0:cbbc3528eb59 | 54 | { |
whutsup | 4:bf4ad2079096 | 55 | char inChar; |
whutsup | 8:a435e7aa7a02 | 56 | |
whutsup | 4:bf4ad2079096 | 57 | static char rxCount = 0; |
whutsup | 4:bf4ad2079096 | 58 | static char rxBuf[7]; |
whutsup | 0:cbbc3528eb59 | 59 | |
whutsup | 4:bf4ad2079096 | 60 | while(1 == bt.readable()) |
whutsup | 0:cbbc3528eb59 | 61 | { |
whutsup | 8:a435e7aa7a02 | 62 | |
whutsup | 4:bf4ad2079096 | 63 | inChar = bt.getc(); |
whutsup | 8:a435e7aa7a02 | 64 | |
whutsup | 8:a435e7aa7a02 | 65 | bt.putc(inChar); |
whutsup | 8:a435e7aa7a02 | 66 | |
whutsup | 4:bf4ad2079096 | 67 | if('<' == inChar) |
whutsup | 4:bf4ad2079096 | 68 | { |
whutsup | 4:bf4ad2079096 | 69 | rxCount = 1; |
whutsup | 4:bf4ad2079096 | 70 | } |
whutsup | 0:cbbc3528eb59 | 71 | |
whutsup | 4:bf4ad2079096 | 72 | else if (rxCount > 0 && rxCount <8) |
whutsup | 4:bf4ad2079096 | 73 | { |
whutsup | 4:bf4ad2079096 | 74 | rxBuf[rxCount-1] = inChar; |
whutsup | 4:bf4ad2079096 | 75 | rxCount++; |
whutsup | 4:bf4ad2079096 | 76 | } |
whutsup | 0:cbbc3528eb59 | 77 | |
whutsup | 4:bf4ad2079096 | 78 | else if ( 8 == rxCount && '>' == inChar) |
whutsup | 4:bf4ad2079096 | 79 | { |
whutsup | 4:bf4ad2079096 | 80 | rxCount = 0; |
whutsup | 4:bf4ad2079096 | 81 | flagRx = 1; |
whutsup | 4:bf4ad2079096 | 82 | memcpy(rxData, rxBuf, 7); |
whutsup | 4:bf4ad2079096 | 83 | } |
whutsup | 8:a435e7aa7a02 | 84 | else{ |
whutsup | 8:a435e7aa7a02 | 85 | rxCount = 0; |
whutsup | 8:a435e7aa7a02 | 86 | flagRx = 0; |
whutsup | 8:a435e7aa7a02 | 87 | } |
whutsup | 8:a435e7aa7a02 | 88 | |
whutsup | 4:bf4ad2079096 | 89 | } |
whutsup | 0:cbbc3528eb59 | 90 | } |
whutsup | 0:cbbc3528eb59 | 91 | |
whutsup | 4:bf4ad2079096 | 92 | |
whutsup | 0:cbbc3528eb59 | 93 | void ControlLED(int mode) |
whutsup | 0:cbbc3528eb59 | 94 | { |
whutsup | 4:bf4ad2079096 | 95 | |
whutsup | 0:cbbc3528eb59 | 96 | |
whutsup | 0:cbbc3528eb59 | 97 | switch (mode) |
whutsup | 0:cbbc3528eb59 | 98 | { |
whutsup | 0:cbbc3528eb59 | 99 | case 0 : |
whutsup | 4:bf4ad2079096 | 100 | timer0.detach(); |
whutsup | 0:cbbc3528eb59 | 101 | led = 0; |
whutsup | 0:cbbc3528eb59 | 102 | |
whutsup | 0:cbbc3528eb59 | 103 | break; |
whutsup | 0:cbbc3528eb59 | 104 | |
whutsup | 0:cbbc3528eb59 | 105 | case 1 : |
whutsup | 4:bf4ad2079096 | 106 | timer0.detach(); |
whutsup | 0:cbbc3528eb59 | 107 | led = 1; |
whutsup | 0:cbbc3528eb59 | 108 | |
whutsup | 0:cbbc3528eb59 | 109 | break; |
whutsup | 0:cbbc3528eb59 | 110 | |
whutsup | 0:cbbc3528eb59 | 111 | case 2 : |
whutsup | 4:bf4ad2079096 | 112 | bt.puts("ANYBARO"); |
whutsup | 0:cbbc3528eb59 | 113 | |
Bhoney | 6:549177f76f8e | 114 | break; |
Bhoney | 6:549177f76f8e | 115 | |
Bhoney | 6:549177f76f8e | 116 | default: |
Bhoney | 6:549177f76f8e | 117 | break; |
whutsup | 0:cbbc3528eb59 | 118 | } |
whutsup | 0:cbbc3528eb59 | 119 | |
whutsup | 0:cbbc3528eb59 | 120 | } |
whutsup | 0:cbbc3528eb59 | 121 | |
whutsup | 4:bf4ad2079096 | 122 | void stop() |
whutsup | 0:cbbc3528eb59 | 123 | { |
whutsup | 8:a435e7aa7a02 | 124 | MotorTest(0); |
whutsup | 4:bf4ad2079096 | 125 | } |
whutsup | 0:cbbc3528eb59 | 126 | |
whutsup | 4:bf4ad2079096 | 127 | void ReadAng() |
whutsup | 4:bf4ad2079096 | 128 | { |
whutsup | 4:bf4ad2079096 | 129 | float d1 = disSensor.read(); |
whutsup | 4:bf4ad2079096 | 130 | float d2 = parA*d1*d1+parB*d1+parC; |
Bhoney | 6:549177f76f8e | 131 | |
Bhoney | 6:549177f76f8e | 132 | // original |
Bhoney | 6:549177f76f8e | 133 | // bt.printf("%1.2f",d2); |
Bhoney | 6:549177f76f8e | 134 | |
Bhoney | 6:549177f76f8e | 135 | // fixed |
Bhoney | 6:549177f76f8e | 136 | bt.printf("<DIO%1.4f>",d2); |
Bhoney | 6:549177f76f8e | 137 | |
whutsup | 0:cbbc3528eb59 | 138 | } |
whutsup | 0:cbbc3528eb59 | 139 | |
whutsup | 8:a435e7aa7a02 | 140 | void ModeSelect(int mode) |
whutsup | 0:cbbc3528eb59 | 141 | { |
whutsup | 4:bf4ad2079096 | 142 | |
whutsup | 4:bf4ad2079096 | 143 | switch(mode) |
whutsup | 4:bf4ad2079096 | 144 | { |
whutsup | 1:a003b900b810 | 145 | |
whutsup | 4:bf4ad2079096 | 146 | case 0 : //Standard Mode |
whutsup | 4:bf4ad2079096 | 147 | |
whutsup | 4:bf4ad2079096 | 148 | timer1.detach(); |
whutsup | 4:bf4ad2079096 | 149 | timer2.detach(); |
whutsup | 4:bf4ad2079096 | 150 | timer3.detach(); |
whutsup | 4:bf4ad2079096 | 151 | |
whutsup | 4:bf4ad2079096 | 152 | break; |
whutsup | 4:bf4ad2079096 | 153 | |
whutsup | 4:bf4ad2079096 | 154 | case 1 : //Reset Mode |
whutsup | 8:a435e7aa7a02 | 155 | { |
whutsup | 8:a435e7aa7a02 | 156 | timer3.detach(); |
whutsup | 8:a435e7aa7a02 | 157 | timer2.detach(); |
whutsup | 8:a435e7aa7a02 | 158 | timer1.detach(); |
whutsup | 8:a435e7aa7a02 | 159 | onewayNum = 0; |
whutsup | 8:a435e7aa7a02 | 160 | milLoop = 0; |
whutsup | 8:a435e7aa7a02 | 161 | |
whutsup | 8:a435e7aa7a02 | 162 | float d1 = disSensor.read(); |
whutsup | 8:a435e7aa7a02 | 163 | float d2 = parA*d1*d1+parB*d1+parC; |
whutsup | 8:a435e7aa7a02 | 164 | |
whutsup | 8:a435e7aa7a02 | 165 | MotorTest(2); |
whutsup | 8:a435e7aa7a02 | 166 | ResetTimer.attach(&stop,0.5f+d2/3.0f); |
whutsup | 8:a435e7aa7a02 | 167 | |
whutsup | 8:a435e7aa7a02 | 168 | break; |
whutsup | 8:a435e7aa7a02 | 169 | } |
whutsup | 4:bf4ad2079096 | 170 | |
whutsup | 4:bf4ad2079096 | 171 | case 2 : //Read Force |
whutsup | 1:a003b900b810 | 172 | |
whutsup | 8:a435e7aa7a02 | 173 | timer2.attach(&ReadForce,0.05); |
whutsup | 4:bf4ad2079096 | 174 | |
whutsup | 4:bf4ad2079096 | 175 | break; |
whutsup | 4:bf4ad2079096 | 176 | |
whutsup | 4:bf4ad2079096 | 177 | case 3 : //Read Angle |
whutsup | 1:a003b900b810 | 178 | |
whutsup | 4:bf4ad2079096 | 179 | timer2.detach(); |
Bhoney | 6:549177f76f8e | 180 | ReadAng(); // return only one message |
whutsup | 4:bf4ad2079096 | 181 | |
whutsup | 4:bf4ad2079096 | 182 | break; |
whutsup | 4:bf4ad2079096 | 183 | |
whutsup | 4:bf4ad2079096 | 184 | case 4 : //Pause Temporarily |
whutsup | 4:bf4ad2079096 | 185 | |
whutsup | 4:bf4ad2079096 | 186 | MotorTest(0); |
whutsup | 4:bf4ad2079096 | 187 | |
whutsup | 4:bf4ad2079096 | 188 | break; |
whutsup | 4:bf4ad2079096 | 189 | |
whutsup | 4:bf4ad2079096 | 190 | |
whutsup | 4:bf4ad2079096 | 191 | } |
whutsup | 0:cbbc3528eb59 | 192 | } |
whutsup | 0:cbbc3528eb59 | 193 | |
whutsup | 2:b7d4195e0fea | 194 | |
whutsup | 3:b79aa7d836fb | 195 | void OperateLED() |
whutsup | 3:b79aa7d836fb | 196 | { |
whutsup | 3:b79aa7d836fb | 197 | led =!led; |
whutsup | 3:b79aa7d836fb | 198 | } |
whutsup | 0:cbbc3528eb59 | 199 | |
whutsup | 4:bf4ad2079096 | 200 | void ManualMk() |
whutsup | 4:bf4ad2079096 | 201 | { |
whutsup | 4:bf4ad2079096 | 202 | |
whutsup | 4:bf4ad2079096 | 203 | if( 1 == sysStatus | 2 == sysStatus) |
whutsup | 4:bf4ad2079096 | 204 | { |
Bhoney | 6:549177f76f8e | 205 | bt.puts("Please Wait Moving Anybaro"); //<STA> |
whutsup | 4:bf4ad2079096 | 206 | } |
whutsup | 4:bf4ad2079096 | 207 | else |
whutsup | 4:bf4ad2079096 | 208 | { |
whutsup | 4:bf4ad2079096 | 209 | sysStatus = 6; |
whutsup | 4:bf4ad2079096 | 210 | MkActionManual(); |
whutsup | 4:bf4ad2079096 | 211 | } |
whutsup | 4:bf4ad2079096 | 212 | |
whutsup | 4:bf4ad2079096 | 213 | |
whutsup | 4:bf4ad2079096 | 214 | } |
whutsup | 4:bf4ad2079096 | 215 | |
whutsup | 4:bf4ad2079096 | 216 | void ButtonSys() |
whutsup | 4:bf4ad2079096 | 217 | { |
whutsup | 4:bf4ad2079096 | 218 | if( 1 == sysStatus | 2 == sysStatus) |
whutsup | 4:bf4ad2079096 | 219 | { |
Bhoney | 6:549177f76f8e | 220 | bt.puts("Please Wait Moving Anybaro"); //<STA> 또는 ifdef debug 처리? |
Bhoney | 6:549177f76f8e | 221 | |
whutsup | 4:bf4ad2079096 | 222 | } |
whutsup | 4:bf4ad2079096 | 223 | else |
whutsup | 4:bf4ad2079096 | 224 | { |
whutsup | 4:bf4ad2079096 | 225 | MotorButton(); |
whutsup | 4:bf4ad2079096 | 226 | } |
whutsup | 4:bf4ad2079096 | 227 | } |
whutsup | 4:bf4ad2079096 | 228 | |
whutsup | 0:cbbc3528eb59 | 229 | int main() |
whutsup | 0:cbbc3528eb59 | 230 | { |
whutsup | 4:bf4ad2079096 | 231 | bt.baud(115200); |
whutsup | 8:a435e7aa7a02 | 232 | // pc.baud(115200); |
whutsup | 8:a435e7aa7a02 | 233 | bt.puts("START 181228 Ver.6 \n"); |
whutsup | 4:bf4ad2079096 | 234 | |
Bhoney | 6:549177f76f8e | 235 | int modeNum = 0; |
whutsup | 4:bf4ad2079096 | 236 | int modeLED = 0; |
Bhoney | 6:549177f76f8e | 237 | int modeMotor = 0; |
whutsup | 4:bf4ad2079096 | 238 | |
whutsup | 8:a435e7aa7a02 | 239 | char tmpCommand[4]={0,}; // [ADD] command |
whutsup | 4:bf4ad2079096 | 240 | int rxVal; |
whutsup | 0:cbbc3528eb59 | 241 | |
whutsup | 0:cbbc3528eb59 | 242 | up.mode(PullNone); |
whutsup | 0:cbbc3528eb59 | 243 | down.mode(PullNone); |
whutsup | 8:a435e7aa7a02 | 244 | bt_ml.mode(PullNone); // [ADD] Setup Millking Action Manual Button |
whutsup | 2:b7d4195e0fea | 245 | |
whutsup | 4:bf4ad2079096 | 246 | up.fall(&ButtonSys); |
whutsup | 4:bf4ad2079096 | 247 | up.rise(&ButtonSys); |
whutsup | 4:bf4ad2079096 | 248 | down.fall(&ButtonSys); |
whutsup | 4:bf4ad2079096 | 249 | down.rise(&ButtonSys); |
whutsup | 0:cbbc3528eb59 | 250 | |
whutsup | 8:a435e7aa7a02 | 251 | bt_ml.fall(&ManualMk); // [ADD] Interrupt Millking Action Manual Button |
whutsup | 3:b79aa7d836fb | 252 | |
whutsup | 8:a435e7aa7a02 | 253 | // timer0.attach(&OperateLED,0.2); |
whutsup | 5:6bb52b2a79bf | 254 | // timer4.attach(&Test,0.1); |
whutsup | 4:bf4ad2079096 | 255 | bt.attach(&ReadData, Serial::RxIrq); |
whutsup | 3:b79aa7d836fb | 256 | |
whutsup | 3:b79aa7d836fb | 257 | |
whutsup | 0:cbbc3528eb59 | 258 | while(1) |
whutsup | 0:cbbc3528eb59 | 259 | { |
whutsup | 4:bf4ad2079096 | 260 | |
whutsup | 4:bf4ad2079096 | 261 | if (1 == flagRx) |
whutsup | 4:bf4ad2079096 | 262 | { |
whutsup | 8:a435e7aa7a02 | 263 | |
whutsup | 4:bf4ad2079096 | 264 | flagRx = 0; |
whutsup | 4:bf4ad2079096 | 265 | tmpCommand[0] = rxData[0]; |
whutsup | 4:bf4ad2079096 | 266 | tmpCommand[1] = rxData[1]; |
whutsup | 4:bf4ad2079096 | 267 | tmpCommand[2] = rxData[2]; |
whutsup | 4:bf4ad2079096 | 268 | rxVal = atoi(rxData+3); |
whutsup | 0:cbbc3528eb59 | 269 | |
whutsup | 4:bf4ad2079096 | 270 | if (0 == strcmp(tmpCommand,"LED")) |
whutsup | 0:cbbc3528eb59 | 271 | { |
whutsup | 4:bf4ad2079096 | 272 | #ifdef DEBUG |
whutsup | 4:bf4ad2079096 | 273 | bt.puts("\nLED CONTROL MODE!!\n"); |
whutsup | 4:bf4ad2079096 | 274 | #endif |
Bhoney | 6:549177f76f8e | 275 | modeLED = rxVal; // if(modeLED != 0 || modeLED != 1 || modeLED != 2) |
whutsup | 0:cbbc3528eb59 | 276 | ControlLED(modeLED); |
whutsup | 0:cbbc3528eb59 | 277 | } |
whutsup | 4:bf4ad2079096 | 278 | |
whutsup | 4:bf4ad2079096 | 279 | else if (0 == strcmp(tmpCommand,"MOD")) |
whutsup | 4:bf4ad2079096 | 280 | { |
whutsup | 4:bf4ad2079096 | 281 | #ifdef DEBUG |
whutsup | 4:bf4ad2079096 | 282 | bt.puts("\nMODE SELECT!!\n"); |
whutsup | 4:bf4ad2079096 | 283 | #endif |
Bhoney | 6:549177f76f8e | 284 | modeNum = rxVal; // 1 ~ 6 |
Bhoney | 6:549177f76f8e | 285 | sysStatus = rxVal; // Why this value are assigned directly? |
Bhoney | 6:549177f76f8e | 286 | // assigning sys variable after checking condition is correct progress, i think. |
whutsup | 4:bf4ad2079096 | 287 | ModeSelect(modeNum); |
whutsup | 4:bf4ad2079096 | 288 | } |
whutsup | 0:cbbc3528eb59 | 289 | |
whutsup | 4:bf4ad2079096 | 290 | else if (0 == strcmp(tmpCommand,"MOT")) |
whutsup | 4:bf4ad2079096 | 291 | { |
whutsup | 4:bf4ad2079096 | 292 | #ifdef DEBUG |
whutsup | 4:bf4ad2079096 | 293 | bt.puts("\nMOTOR TEST CONTROL MODE!!\n"); |
whutsup | 4:bf4ad2079096 | 294 | #endif |
whutsup | 4:bf4ad2079096 | 295 | modeMotor = rxVal; |
Bhoney | 6:549177f76f8e | 296 | MotorTest(modeMotor); |
whutsup | 1:a003b900b810 | 297 | } |
whutsup | 1:a003b900b810 | 298 | |
whutsup | 4:bf4ad2079096 | 299 | else if (0 == strcmp(tmpCommand,"POS")) |
whutsup | 4:bf4ad2079096 | 300 | { |
whutsup | 8:a435e7aa7a02 | 301 | // errorPrevious = 0; |
whutsup | 4:bf4ad2079096 | 302 | #ifdef DEBUG |
whutsup | 4:bf4ad2079096 | 303 | bt.puts("\nMOTOR DISTANCE CONTROL MODE!!\n"); |
Bhoney | 6:549177f76f8e | 304 | #endif |
whutsup | 4:bf4ad2079096 | 305 | targetDis = rxVal; |
whutsup | 8:a435e7aa7a02 | 306 | // float d1 = disSensor.read(); |
whutsup | 8:a435e7aa7a02 | 307 | // float d2 = parA*d1*d1+parB*d1+parC; |
whutsup | 8:a435e7aa7a02 | 308 | // errorPrevious = targetDis - d2; |
whutsup | 8:a435e7aa7a02 | 309 | |
whutsup | 8:a435e7aa7a02 | 310 | timer1.attach(&ControlAng,0.01); |
whutsup | 4:bf4ad2079096 | 311 | } |
whutsup | 4:bf4ad2079096 | 312 | |
whutsup | 4:bf4ad2079096 | 313 | if (0 == strcmp(tmpCommand,"MIL")) |
whutsup | 1:a003b900b810 | 314 | { |
whutsup | 4:bf4ad2079096 | 315 | sysStatus = 5; |
whutsup | 4:bf4ad2079096 | 316 | #ifdef DEBUG |
whutsup | 4:bf4ad2079096 | 317 | bt.puts("\nMILLKING ACTION MODE!!\n"); |
whutsup | 4:bf4ad2079096 | 318 | #endif |
whutsup | 4:bf4ad2079096 | 319 | targetDis = atoi(rxData+5); // [ADD] return 2 characters in the back of 4 characters |
whutsup | 4:bf4ad2079096 | 320 | milLoop = 0.01*(atoi(rxData+3)-atoi(rxData+5)); // [ADD] return 2 cahracters in the front of 4 characters |
whutsup | 4:bf4ad2079096 | 321 | timer3.attach(&MkAction,0.1); |
whutsup | 4:bf4ad2079096 | 322 | |
whutsup | 4:bf4ad2079096 | 323 | if ( 0 == mkOn) mkOn = 1; |
whutsup | 4:bf4ad2079096 | 324 | |
whutsup | 1:a003b900b810 | 325 | } |
whutsup | 4:bf4ad2079096 | 326 | |
whutsup | 4:bf4ad2079096 | 327 | |
whutsup | 4:bf4ad2079096 | 328 | } |
whutsup | 2:b7d4195e0fea | 329 | |
whutsup | 0:cbbc3528eb59 | 330 | |
whutsup | 0:cbbc3528eb59 | 331 | } |
whutsup | 0:cbbc3528eb59 | 332 | |
whutsup | 0:cbbc3528eb59 | 333 | } |