-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplicationFunctionSet_xxx0_MotorControl.cpp
79 lines (71 loc) · 3.45 KB
/
ApplicationFunctionSet_xxx0_MotorControl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "DeviceDriverSet_xxx0_MotorControl.h"
extern DeviceDriverSet_Motor AppMotor;
/*运动方向控制序列*/
enum SmartRobotCarMotionControl
{
Forward, //(1)
Backward, //(2)
Left, //(3)
Right, //(4)
LeftForward, //(5)
LeftBackward, //(6)
RightForward, //(7)
RightBackward, //(8)
stop_it //(9)
}; //direction方向:(1)、(2)、 (3)、(4)、(5)、(6)
struct Application_xxx
{
SmartRobotCarMotionControl Motion_Control;
};
extern Application_xxx Application_SmartRobotCarxxx0;
static void ApplicationFunctionSet_SmartRobotCarMotionControl(SmartRobotCarMotionControl direction, uint8_t is_speed)
{
static uint8_t directionRecord = 0;
uint8_t Kp, UpperLimit;
uint8_t speed = is_speed;
switch (direction)
{
case /* constant-expression */
Forward:
/* code */
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_just, /*speed_A*/ speed,
/*direction_B*/ direction_just, /*speed_B*/ speed, /*controlED*/ control_enable); //Motor control
break;
case /* constant-expression */ Backward:
/* code */
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_back, /*speed_A*/ speed,
/*direction_B*/ direction_back, /*speed_B*/ speed, /*controlED*/ control_enable); //Motor control
break;
case /* constant-expression */ Left:
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_just, /*speed_A*/ speed,
/*direction_B*/ direction_back, /*speed_B*/ speed, /*controlED*/ control_enable); //Motor control
break;
case /* constant-expression */ Right:
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_back, /*speed_A*/ speed,
/*direction_B*/ direction_just, /*speed_B*/ speed, /*controlED*/ control_enable); //Motor control
break;
case /* constant-expression */ LeftForward:
/* code */
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_just, /*speed_A*/ speed,
/*direction_B*/ direction_just, /*speed_B*/ speed / 2, /*controlED*/ control_enable); //Motor control
break;
case /* constant-expression */ LeftBackward:
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_back, /*speed_A*/ speed,
/*direction_B*/ direction_back, /*speed_B*/ speed / 2, /*controlED*/ control_enable); //Motor control
break;
case /* constant-expression */ RightForward:
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_just, /*speed_A*/ speed / 2,
/*direction_B*/ direction_just, /*speed_B*/ speed, /*controlED*/ control_enable); //Motor control
break;
case /* constant-expression */ RightBackward:
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_back, /*speed_A*/ speed / 2,
/*direction_B*/ direction_back, /*speed_B*/ speed, /*controlED*/ control_enable); //Motor control
break;
case /* constant-expression */ stop_it:
AppMotor.DeviceDriverSet_Motor_control(/*direction_A*/ direction_void, /*speed_A*/ 0,
/*direction_B*/ direction_void, /*speed_B*/ 0, /*controlED*/ control_enable); //Motor control
break;
default:
break;
}
}