A gesture project based on X_NUCLRO_53L1A1
Dependencies: Test_SSD1306 mbed X_NUCLEO_53L1A1
main.cpp@0:5ea7efe9f6c9, 2022-09-02 (annotated)
- Committer:
- nanecho
- Date:
- Fri Sep 02 16:02:17 2022 +0000
- Revision:
- 0:5ea7efe9f6c9
A gesture recognition project based X_Nucleo_53L1A1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nanecho | 0:5ea7efe9f6c9 | 1 | #include <stdint.h> |
nanecho | 0:5ea7efe9f6c9 | 2 | #include <stdio.h> |
nanecho | 0:5ea7efe9f6c9 | 3 | #include "mbed.h" |
nanecho | 0:5ea7efe9f6c9 | 4 | #include "XNucleo53L1A1.h" |
nanecho | 0:5ea7efe9f6c9 | 5 | #include "VL53L1X_I2C.h" |
nanecho | 0:5ea7efe9f6c9 | 6 | |
nanecho | 0:5ea7efe9f6c9 | 7 | uint16_t distance_centre = 0; |
nanecho | 0:5ea7efe9f6c9 | 8 | uint16_t distance_left = 0; |
nanecho | 0:5ea7efe9f6c9 | 9 | int16_t distance_right = 0; |
nanecho | 0:5ea7efe9f6c9 | 10 | uint8_t state =0; |
nanecho | 0:5ea7efe9f6c9 | 11 | uint8_t command = 0; |
nanecho | 0:5ea7efe9f6c9 | 12 | int wait_fun(); |
nanecho | 0:5ea7efe9f6c9 | 13 | |
nanecho | 0:5ea7efe9f6c9 | 14 | void speed(void) |
nanecho | 0:5ea7efe9f6c9 | 15 | { |
nanecho | 0:5ea7efe9f6c9 | 16 | if (command == 1 ) { |
nanecho | 0:5ea7efe9f6c9 | 17 | printf("go forward, speed = %d\r\n",distance_centre - 80); |
nanecho | 0:5ea7efe9f6c9 | 18 | } else if (command == 2) { |
nanecho | 0:5ea7efe9f6c9 | 19 | printf("go back, speed = %d\r\n",50 - distance_centre); |
nanecho | 0:5ea7efe9f6c9 | 20 | } else if (command == 3) { |
nanecho | 0:5ea7efe9f6c9 | 21 | printf("Waiting, speed = 0\r\n"); |
nanecho | 0:5ea7efe9f6c9 | 22 | } else if (command == 7) { |
nanecho | 0:5ea7efe9f6c9 | 23 | printf("turn right\r\n"); |
nanecho | 0:5ea7efe9f6c9 | 24 | } else if (command == 8) { |
nanecho | 0:5ea7efe9f6c9 | 25 | printf("turn left\r\n"); |
nanecho | 0:5ea7efe9f6c9 | 26 | } else if (command ==5) { |
nanecho | 0:5ea7efe9f6c9 | 27 | printf("left forward, speed = %d\r\n",distance_centre - 80); |
nanecho | 0:5ea7efe9f6c9 | 28 | } else if (command ==55) { |
nanecho | 0:5ea7efe9f6c9 | 29 | printf("left backward, speed = %d\r\n",50 - distance_centre); |
nanecho | 0:5ea7efe9f6c9 | 30 | } else if (command == 6) { |
nanecho | 0:5ea7efe9f6c9 | 31 | printf ("right forward, speed = %d\r\n",distance_centre - 80); |
nanecho | 0:5ea7efe9f6c9 | 32 | } else if (command == 66) { |
nanecho | 0:5ea7efe9f6c9 | 33 | printf ("right backward, speed = %d\r\n",50 - distance_centre); |
nanecho | 0:5ea7efe9f6c9 | 34 | } else if (command == 4) { |
nanecho | 0:5ea7efe9f6c9 | 35 | printf("Stop\r\n"); |
nanecho | 0:5ea7efe9f6c9 | 36 | } |
nanecho | 0:5ea7efe9f6c9 | 37 | } |
nanecho | 0:5ea7efe9f6c9 | 38 | |
nanecho | 0:5ea7efe9f6c9 | 39 | void main() |
nanecho | 0:5ea7efe9f6c9 | 40 | { |
nanecho | 0:5ea7efe9f6c9 | 41 | speed(); |
nanecho | 0:5ea7efe9f6c9 | 42 | } |