Rev 399 | Rev 442 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 399 | Rev 440 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include<Handler.h> |
1 | #include<Handler.h> |
Line 2... | Line 2... | ||
2 | 2 | ||
3 | /** |
3 | /** |
4 | * Constructor that gets a communication instance |
4 | * Constructor that gets a communication instance |
5 | */ |
5 | */ |
6 | Handler::Handler(Communication * com) { |
6 | Handler::Handler(Communication * com, KopterData * data) { |
- | 7 | this->com = com; |
|
7 | this->com = com; |
8 | this->data = data; |
Line 8... | Line 9... | ||
8 | } |
9 | } |
9 | 10 | ||
10 | //-------------FlightCtrl commands-------------------- |
11 | //-------------FlightCtrl commands-------------------- |
Line 33... | Line 34... | ||
33 | tx_data[z] = motor.Speed[z]; |
34 | tx_data[z] = motor.Speed[z]; |
34 | } |
35 | } |
35 | com->send_cmd('t', ADDRESS_FC, tx_data, 12, false); |
36 | com->send_cmd('t', ADDRESS_FC, tx_data, 12, false); |
36 | } |
37 | } |
Line -... | Line 38... | ||
- | 38 | ||
- | 39 | void Handler::reset_motor() { |
|
- | 40 | sMotor motor; |
|
- | 41 | for (int z = 0; z<12; z++) |
|
- | 42 | { |
|
- | 43 | motor.Speed[z] = 0; |
|
- | 44 | } |
|
- | 45 | ||
- | 46 | motor_test(motor); |
|
- | 47 | } |
|
37 | 48 | ||
38 | /** |
49 | /** |
39 | * read mixer values from FlightCtrl |
50 | * read mixer values from FlightCtrl |
40 | */ |
51 | */ |
41 | void Handler::read_mixer() { |
52 | void Handler::read_motor_mixer() { |
42 | char tx_data[1] = {0}; |
53 | char tx_data[1] = {0}; |
43 | //com->log("read motor mixer"); |
54 | //com->log("read motor mixer"); |
44 | com->send_cmd('n', ADDRESS_FC, tx_data, 1, true); |
55 | com->send_cmd('n', ADDRESS_FC, tx_data, 1, true); |
Line 45... | Line 56... | ||
45 | } |
56 | } |
46 | 57 | ||
47 | /** |
58 | /** |
48 | * write motor mixer values to FlightCtrl |
59 | * write motor mixer values to FlightCtrl |
49 | */ |
60 | */ |
50 | void Handler::write_mixer(char * tx_data, int length) { |
61 | void Handler::write_motor_mixer(char * tx_data, int length) { |
Line 51... | Line 62... | ||
51 | com->send_cmd('m', ADDRESS_FC, tx_data, length, true); |
62 | com->send_cmd('m', ADDRESS_FC, tx_data, length, true); |
- | 63 | } |
|
52 | } |
64 | |
Line 53... | Line 65... | ||
53 | 65 | int Handler::get_motor_config(char * tx_data) { |
|
54 | void Handler::get_motor_config() { |
66 | return -1; |
55 | } |
67 | } |
Line 147... | Line 159... | ||
147 | /** |
159 | /** |
148 | * got to next LCD Page |
160 | * got to next LCD Page |
149 | */ |
161 | */ |
150 | void Handler::lcd_up() { |
162 | void Handler::lcd_up() { |
151 | char tx_data[2] = { 0, 0 }; |
163 | char tx_data[2] = { 0, 0 }; |
152 | if (lcd_cur != lcd_max) |
164 | if (data->lcd_cur != data->lcd_max) |
153 | tx_data[0] = lcd_cur+1; |
165 | tx_data[0] = data->lcd_cur+1; |
154 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
166 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
155 | } |
167 | } |
Line 156... | Line 168... | ||
156 | 168 | ||
157 | /** |
169 | /** |
158 | * got to previous LCD Page |
170 | * got to previous LCD Page |
159 | */ |
171 | */ |
160 | void Handler::lcd_down() { |
172 | void Handler::lcd_down() { |
161 | char tx_data[2] = { 0, 0 }; |
173 | char tx_data[2] = { 0, 0 }; |
162 | if (lcd_cur != 0) |
174 | if (data->lcd_cur != 0) |
163 | tx_data[0] = lcd_cur-1; |
175 | tx_data[0] = data->lcd_cur-1; |
164 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
176 | com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
Line 165... | Line 177... | ||
165 | } |
177 | } |
166 | 178 |