|
1 | 1 | /********************************************** FLYING_CAR ******************************************/ |
2 | 2 | /* 3xMotionBlock, 3xCubeBlock, 1xMainBlock, 1xDetectBlock, 1xLightBlock, 1xBippBlock */ |
3 | 3 |
|
4 | | -#include "SmartBlockFunctions.h" |
| 4 | +#include "cezerioBlocks.h" |
5 | 5 | #include "DataTransferFunctions.h" |
6 | 6 |
|
7 | 7 | unsigned char timerFlag = 0; |
8 | 8 | extern unsigned char resolvePacketFlag; |
9 | 9 | extern capturedPacketType capturedPacket; |
10 | 10 |
|
11 | 11 | void setup() |
12 | | -{ |
13 | | - initSmartBlocks(); |
| 12 | +{ |
| 13 | + initcezerioBlocks(); |
14 | 14 | initSmartBlue(); |
15 | 15 | } |
16 | 16 |
|
17 | 17 | void loop() |
18 | 18 | { |
19 | | -#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) |
| 19 | +#if defined(CAN_RECEIVE_INTERRUPT_ENABLE) |
20 | 20 | if(!digitalRead(CAN_INT)) |
21 | 21 | { |
22 | | - |
| 22 | + |
23 | 23 | } |
24 | 24 | #endif |
25 | 25 |
|
26 | 26 | if(timerFlag) |
27 | 27 | { |
28 | | - |
| 28 | + |
29 | 29 | timerFlag = 0; |
30 | 30 | } |
31 | 31 |
|
32 | | - getSmartBlueData(); |
| 32 | + getSmartBlueData(); |
33 | 33 |
|
34 | 34 | if(resolvePacketFlag) |
35 | 35 | { |
36 | 36 | switch(capturedPacket.data_packet.packet_id) |
37 | | - { |
| 37 | + { |
38 | 38 | case BLE_ROBOT_NAME: // gelen robot id "0x00" ve data değeri "0xFF" ise robot id'sini gönderir |
39 | 39 | if(capturedPacket.data_packet.robot_id == 0x00 && capturedPacket.data_packet.data[0] == 0xFF) |
40 | 40 | { |
41 | 41 | sendFlyingCarData(BLE_ROBOT_NAME, 0xFF); |
42 | 42 | } |
43 | | - break; |
44 | | - |
| 43 | + break; |
| 44 | + |
45 | 45 | case BLE_MOVE_FORWARD: |
46 | 46 | setMotion(0x140, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ |
47 | 47 | setMotion(0x141, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ |
48 | 48 | break; |
49 | | - |
| 49 | + |
50 | 50 | case BLE_MOVE_BACKWARD: |
51 | 51 | setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ |
52 | 52 | setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ |
53 | 53 | break; |
54 | | - |
| 54 | + |
55 | 55 | case BLE_MOVE_RIGHT: |
56 | 56 | setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ |
57 | 57 | setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Right Wheel*/ |
58 | 58 | break; |
59 | | - |
| 59 | + |
60 | 60 | case BLE_MOVE_LEFT: |
61 | 61 | setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])/2,motorDriverEnable); /*Front_Left Wheel*/ |
62 | 62 | setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ |
63 | 63 | break; |
64 | | - |
| 64 | + |
65 | 65 | case BLE_MOVE_FORWARD_RIGHT: |
66 | 66 | setMotion(0x140,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Left Wheel*/ |
67 | 67 | setMotion(0x141,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Right Wheel*/ |
68 | 68 | break; |
69 | | - |
| 69 | + |
70 | 70 | case BLE_MOVE_FORWARD_LEFT: |
71 | 71 | setMotion(0x140,motorDirectionForward,(capturedPacket.data_packet.data[0])*0.75,motorDriverEnable); /*Front_Left Wheel*/ |
72 | 72 | setMotion(0x141,motorDirectionForward,capturedPacket.data_packet.data[0],motorDriverEnable); /*Front_Right Wheel*/ |
73 | 73 | break; |
74 | | - |
| 74 | + |
75 | 75 | case BLE_MOVE_BACKWARD_RIGHT: |
76 | 76 | setMotion(0x140, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Left Wheel*/ |
77 | 77 | setMotion(0x141, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Right Wheel*/ |
78 | 78 | break; |
79 | | - |
| 79 | + |
80 | 80 | case BLE_MOVE_BACKWARD_LEFT: |
81 | 81 | setMotion(0x140, motorDirectionBackward, (capturedPacket.data_packet.data[0])*0.75, motorDriverEnable); /*Front_Left Wheel*/ |
82 | 82 | setMotion(0x141, motorDirectionBackward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Front_Right Wheel*/ |
83 | 83 | break; |
84 | | - |
85 | | - case BLE STOP: |
| 84 | + |
| 85 | + case BLE_STOP: |
86 | 86 | setMotion(0x140, motorDirectionForward, 0, motorDriverEnable); /*Front_Left Wheel*/ |
87 | 87 | setMotion(0x141, motorDirectionForward, 0, motorDriverEnable); /*Front_Right Wheel*/ |
88 | 88 | break; |
89 | | - |
| 89 | + |
90 | 90 | case BLE_TURN_360CW: |
91 | 91 | setMotion(0x140, motorDirectionForward, 255, motorDriverEnable); /*Front_Left Wheel*/ |
92 | 92 | setMotion(0x141, motorDirectionBackward, 255, motorDriverEnable); /*Front_Right Wheel*/ |
93 | 93 | break; |
94 | | - |
| 94 | + |
95 | 95 | case BLE_TURN_360CCW: |
96 | 96 | setMotion(0x140, motorDirectionBackward, 255, motorDriverEnable); /*Front_Left Wheel*/ |
97 | 97 | setMotion(0x141, motorDirectionForward, 255, motorDriverEnable); /*Front_Right Wheel*/ |
98 | 98 | break; |
99 | | - |
| 99 | + |
100 | 100 | case BLE_FLIP: |
101 | 101 | setMotion(0x142, motorDirectionForward, capturedPacket.data_packet.data[0], motorDriverEnable); /*Propeller*/ |
102 | 102 |
|
103 | 103 | break; |
104 | | - |
| 104 | + |
105 | 105 | case BLE_DETECT_DATA: |
106 | 106 | sendFlyingCarData(BLE_DETECT_DATA, getDetect(0x020)); |
107 | 107 | break; |
108 | | - |
| 108 | + |
109 | 109 | case BLE_BIPP: |
110 | 110 | setBipp(0x0E0,capturedPacket.data_packet.data[0]); |
111 | 111 | break; |
112 | | - |
| 112 | + |
113 | 113 | case BLE_LIGHT: |
114 | 114 | setLight(0x120,capturedPacket.data_packet.data[0]); |
115 | 115 | break; |
116 | | - |
| 116 | + } |
117 | 117 | } |
118 | 118 | } |
0 commit comments