Rev 1566 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1566 | Rev 1698 | ||
---|---|---|---|
1 | package dongfang.mkt.frames; |
1 | package dongfang.mkt.frames; |
2 | 2 | ||
3 | import java.io.IOException; |
3 | import java.io.IOException; |
4 | 4 | ||
5 | import dongfang.mkt.RequestFrameVisitor; |
5 | import dongfang.mkt.RequestFrameVisitor; |
6 | 6 | ||
7 | 7 | ||
8 | /* |
8 | /* |
9 | uint8_t digital[2]; |
9 | uint8_t digital[2]; |
10 | uint8_t remoteButtons; |
10 | uint8_t remoteButtons; |
11 | int8_t pitch; |
11 | int8_t pitch; |
12 | int8_t roll; |
12 | int8_t roll; |
13 | int8_t yaw; |
13 | int8_t yaw; |
14 | uint8_t throttle; |
14 | uint8_t throttle; |
15 | int8_t height; |
15 | int8_t height; |
16 | uint8_t free; |
16 | uint8_t free; |
17 | uint8_t frame; |
17 | uint8_t frame; |
18 | uint8_t config; |
18 | uint8_t config; |
19 | */ |
19 | */ |
20 | public class ExternalControlRequestFrame extends RequestFrame { |
20 | public class ExternalControlRequestFrame extends RequestFrame { |
21 | public static final int COMMAND_NONE = 0; |
21 | public static final int COMMAND_NONE = 0; |
22 | public static final int COMMAND_START = 6; |
22 | public static final int COMMAND_START = 6; |
23 | public static final int COMMAND_STOP = 8; |
23 | public static final int COMMAND_STOP = 8; |
24 | public static final int COMMAND_GYROCAL = 2; |
24 | public static final int COMMAND_GYROCAL = 2; |
25 | public static final int COMMAND_ACCCAL = 4; |
25 | public static final int COMMAND_ACCCAL = 4; |
26 | 26 | ||
27 | int[] digital = new int[2];// unsigned byte. |
27 | int[] digital = new int[2];// unsigned byte. |
28 | int remoteButtons; // unsigned byte. |
28 | int remoteButtons; // unsigned byte. |
29 | int pitch; // signed byte. |
29 | int pitch; // signed byte. |
30 | int roll; // signed byte. |
30 | int roll; // signed byte. |
31 | int yaw; // signed byte. |
31 | int yaw; // signed byte. |
32 | int throttle; // unsigned byte. |
32 | int throttle; // unsigned byte. |
33 | int height; // signed byte (!). |
33 | int height; // signed byte (!). |
34 | int command; // unsigned byte. Called "free" in MK code. |
34 | int command; // unsigned byte. Called "free" in MK code. |
35 | int frameNum; // unsigned byte. |
35 | int frameNum; // unsigned byte. |
36 | int argument; // unsigned byte. Called "config" in MK code. |
36 | int argument; // unsigned byte. Called "config" in MK code. |
37 | 37 | ||
38 | ExternalControlRequestFrame(int address) { |
38 | public ExternalControlRequestFrame() { |
39 | super(address); |
39 | super(FC_ADDRESS); |
40 | } |
40 | } |
41 | 41 | ||
42 | public int[] getDigital() { |
42 | public int[] getDigital() { |
43 | return digital; |
43 | return digital; |
44 | } |
44 | } |
45 | 45 | ||
46 | public void setDigital(int[] digital) { |
46 | public void setDigital(int[] digital) { |
47 | this.digital = digital; |
47 | this.digital = digital; |
48 | } |
48 | } |
49 | 49 | ||
50 | public int getRemoteButtons() { |
50 | public int getRemoteButtons() { |
51 | return remoteButtons; |
51 | return remoteButtons; |
52 | } |
52 | } |
53 | 53 | ||
54 | public void setRemoteButtons(int remoteButtons) { |
54 | public void setRemoteButtons(int remoteButtons) { |
55 | this.remoteButtons = remoteButtons; |
55 | this.remoteButtons = remoteButtons; |
56 | } |
56 | } |
57 | 57 | ||
58 | public int getPitch() { |
58 | public int getPitch() { |
59 | return pitch; |
59 | return pitch; |
60 | } |
60 | } |
61 | 61 | ||
62 | public void setPitch(int pitch) { |
62 | public void setPitch(int pitch) { |
63 | this.pitch = pitch; |
63 | this.pitch = pitch; |
64 | } |
64 | } |
65 | 65 | ||
66 | public int getRoll() { |
66 | public int getRoll() { |
67 | return roll; |
67 | return roll; |
68 | } |
68 | } |
69 | 69 | ||
70 | public void setRoll(int roll) { |
70 | public void setRoll(int roll) { |
71 | this.roll = roll; |
71 | this.roll = roll; |
72 | } |
72 | } |
73 | 73 | ||
74 | public int getYaw() { |
74 | public int getYaw() { |
75 | return yaw; |
75 | return yaw; |
76 | } |
76 | } |
77 | 77 | ||
78 | public void setYaw(int yaw) { |
78 | public void setYaw(int yaw) { |
79 | this.yaw = yaw; |
79 | this.yaw = yaw; |
80 | } |
80 | } |
81 | 81 | ||
82 | public int getThrottle() { |
82 | public int getThrottle() { |
83 | return throttle; |
83 | return throttle; |
84 | } |
84 | } |
85 | 85 | ||
86 | public void setThrottle(int throttle) { |
86 | public void setThrottle(int throttle) { |
87 | this.throttle = throttle; |
87 | this.throttle = throttle; |
88 | } |
88 | } |
89 | 89 | ||
90 | public int getHeight() { |
90 | public int getHeight() { |
91 | return height; |
91 | return height; |
92 | } |
92 | } |
93 | 93 | ||
94 | public void setHeight(int height) { |
94 | public void setHeight(int height) { |
95 | this.height = height; |
95 | this.height = height; |
96 | } |
96 | } |
97 | 97 | ||
98 | public int getCommand() { |
98 | public int getCommand() { |
99 | return command; |
99 | return command; |
100 | } |
100 | } |
101 | 101 | ||
102 | public void setCommand(int command) { |
102 | public void setCommand(int command) { |
103 | this.command = command; |
103 | this.command = command; |
104 | } |
104 | } |
105 | 105 | ||
106 | public int getFrameNum() { |
106 | public int getFrameNum() { |
107 | return frameNum; |
107 | return frameNum; |
108 | } |
108 | } |
109 | 109 | ||
110 | public void setFrameNum(int frameNum) { |
110 | public void setFrameNum(int frameNum) { |
111 | this.frameNum = frameNum; |
111 | this.frameNum = frameNum; |
112 | } |
112 | } |
113 | 113 | ||
114 | public int getArgument() { |
114 | public int getArgument() { |
115 | return argument; |
115 | return argument; |
116 | } |
116 | } |
117 | 117 | ||
118 | public void setArgument(int argument) { |
118 | public void setArgument(int argument) { |
119 | this.argument = argument; |
119 | this.argument = argument; |
120 | } |
120 | } |
121 | 121 | ||
122 | public void start() { |
122 | public void start() { |
123 | command = COMMAND_START; |
123 | command = COMMAND_START; |
124 | } |
124 | } |
125 | 125 | ||
126 | public void stop() { |
126 | public void stop() { |
127 | command = COMMAND_STOP; |
127 | command = COMMAND_STOP; |
128 | } |
128 | } |
129 | 129 | ||
130 | public void gyroCal() { |
130 | public void gyroCal() { |
131 | command = COMMAND_GYROCAL; |
131 | command = COMMAND_GYROCAL; |
132 | } |
132 | } |
133 | 133 | ||
134 | public void accCal() { |
134 | public void accCal() { |
135 | command = COMMAND_ACCCAL; |
135 | command = COMMAND_ACCCAL; |
136 | } |
136 | } |
137 | 137 | ||
138 | @Override |
138 | @Override |
139 | public void accept(RequestFrameVisitor o) throws IOException { |
139 | public void accept(RequestFrameVisitor o) throws IOException { |
140 | o.visit(this); |
140 | o.visit(this); |
141 | } |
141 | } |
142 | } |
142 | } |