svoe
Dependencies: mbed mbed-STM32F103C8T6 MPU6050_1
wifi.h@22:14e85f2068c7, 2019-07-23 (annotated)
- Committer:
- dima285
- Date:
- Tue Jul 23 12:55:23 2019 +0000
- Branch:
- svoe
- Revision:
- 22:14e85f2068c7
- Parent:
- 15:960b922433d1
23.07.2019
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Stas285 | 3:8e8458f45d19 | 1 | unsigned char volatile external_command = 0; |
Stas285 | 3:8e8458f45d19 | 2 | |
Stas285 | 3:8e8458f45d19 | 3 | void command_receive(){ |
Stas285 | 3:8e8458f45d19 | 4 | external_command = wifi.getc(); |
Stas285 | 3:8e8458f45d19 | 5 | //myled = !myled; |
Stas285 | 3:8e8458f45d19 | 6 | } |
Stas285 | 3:8e8458f45d19 | 7 | |
Stas285 | 3:8e8458f45d19 | 8 | void command_process(){ // Interrupt !!! - transfer to main |
Stas285 | 15:960b922433d1 | 9 | int command = int(external_command/64); |
Stas285 | 15:960b922433d1 | 10 | int value = external_command & 0x3f; |
dima285 | 12:721a9ea55e91 | 11 | switch (command){ |
dima285 | 22:14e85f2068c7 | 12 | case 0: x_prop = value * 10; break; //target.x = (float) value/100; break; |
dima285 | 22:14e85f2068c7 | 13 | case 1: x_diff = value * 10; break; //target.y = (float) value/100; break; |
dima285 | 22:14e85f2068c7 | 14 | case 2: balance_prop = value / 10; break; |
dima285 | 13:789b451cc27d | 15 | case 3: balance_diff = value; break; |
dima285 | 12:721a9ea55e91 | 16 | } |
dima285 | 12:721a9ea55e91 | 17 | |
dima285 | 12:721a9ea55e91 | 18 | /*if(external_command > 0xf0){ //16 commands w/o parameters |
Stas285 | 3:8e8458f45d19 | 19 | switch (external_command){ |
Stas285 | 3:8e8458f45d19 | 20 | case 0xff: {stop(); break;} //Command Stop |
Stas285 | 3:8e8458f45d19 | 21 | case 0xfe: {dance(10,2); break;} //Command Dance |
Stas285 | 3:8e8458f45d19 | 22 | } |
Stas285 | 3:8e8458f45d19 | 23 | } |
Stas285 | 1:e2a6e523bf1f | 24 | else{ |
dima285 | 9:8f98b1c277a4 | 25 | if (external_command < 128) k_1 = 0.05*(external_command - 10); //{speed = 2*(external_command - 20);} //Command Speed |
dima285 | 9:8f98b1c277a4 | 26 | else k_2 = 0.05*(external_command - 128 - 10); // {if ((external_command - 128 - 20) == 0)radius = 1e5; else radius = 100/(external_command - 128 - 20);} //Command Turn |
Stas285 | 3:8e8458f45d19 | 27 | stop_flag = 0; infinite_flag = 1; motor_enable = 1; motor_busy = 1; |
dima285 | 12:721a9ea55e91 | 28 | }*/ |
Stas285 | 3:8e8458f45d19 | 29 | external_command = 0; |
Stas285 | 1:e2a6e523bf1f | 30 | } |
Stas285 | 1:e2a6e523bf1f | 31 | |
Stas285 | 0:e9488589a8ee | 32 | void wifi_init(){ |
Stas285 | 3:8e8458f45d19 | 33 | wifi.attach(&command_receive); |
Stas285 | 1:e2a6e523bf1f | 34 | } |