Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2233 | - | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Diagnostics; |
||
6 | |||
7 | namespace MKLiveView |
||
8 | { |
||
9 | class ExternControl |
||
10 | { |
||
11 | byte digital0; |
||
12 | byte digital1; |
||
13 | byte remoteVisualization; |
||
14 | sbyte pitch; |
||
15 | sbyte yaw; |
||
16 | sbyte roll; |
||
17 | byte throttle; |
||
18 | sbyte high; // affects the pressure sensor according to the MoteCtrl project comments |
||
19 | byte unused; // free unused byte |
||
20 | byte frameConfirmation; // confimation |
||
21 | byte config; // set to 1 to signal new command |
||
22 | |||
23 | public ExternControl(byte[] data) |
||
24 | { |
||
25 | Bytes = data; |
||
26 | } |
||
27 | |||
28 | public ExternControl(sbyte yaw, sbyte pitch, sbyte roll, byte throttle) |
||
29 | { |
||
30 | digital0 = 0; |
||
31 | digital1 = 0; |
||
32 | remoteVisualization = 0; |
||
33 | this.pitch = pitch; |
||
34 | this.roll = roll; |
||
35 | this.yaw = yaw; |
||
36 | this.throttle = throttle; |
||
37 | high = 0; |
||
38 | unused = 0; |
||
39 | frameConfirmation = 0; |
||
40 | config = 1; |
||
41 | } |
||
42 | |||
43 | public sbyte Pitch |
||
44 | { |
||
45 | get { return pitch; } |
||
46 | set { pitch = value; } |
||
47 | } |
||
48 | |||
49 | public sbyte Roll |
||
50 | { |
||
51 | get { return roll; } |
||
52 | set { roll = value; } |
||
53 | } |
||
54 | |||
55 | public sbyte Yaw |
||
56 | { |
||
57 | get { return yaw; } |
||
58 | set { yaw = value; } |
||
59 | } |
||
60 | |||
61 | public byte Throttle |
||
62 | { |
||
63 | get { return throttle; } |
||
64 | set { throttle = value; } |
||
65 | } |
||
66 | |||
67 | public byte[] Bytes |
||
68 | { |
||
69 | get |
||
70 | { |
||
71 | byte[] data = new byte[11]; |
||
72 | |||
73 | data[0] = digital0; |
||
74 | data[1] = digital1; |
||
75 | data[2] = remoteVisualization; |
||
76 | data[3] = (byte)pitch; |
||
77 | data[4] = (byte)roll; |
||
78 | data[5] = (byte)yaw; |
||
79 | data[6] = throttle; |
||
80 | data[7] = (byte)high; |
||
81 | data[8] = unused; |
||
82 | data[9] = frameConfirmation; |
||
83 | data[10] = config; |
||
84 | |||
85 | return data; |
||
86 | } |
||
87 | set |
||
88 | { |
||
89 | Debug.Assert(value.Length >= 11); |
||
90 | |||
91 | digital0 = value[0]; |
||
92 | digital1 = value[1]; |
||
93 | remoteVisualization = value[2]; |
||
94 | pitch = (sbyte)value[3]; |
||
95 | roll = (sbyte)value[4]; |
||
96 | yaw = (sbyte)value[5]; |
||
97 | throttle = value[6]; |
||
98 | high = (sbyte)value[7]; |
||
99 | unused = value[8]; |
||
100 | frameConfirmation = value[9]; |
||
101 | config = value[10]; |
||
102 | } |
||
103 | } |
||
104 | } |
||
105 | } |