7,7 → 7,35 |
this->com = com; |
} |
|
//-------------FlightCtrl commands-------------------- |
/** |
* read settings from FlightCtrl (settings index 0x00-0x05) |
*/ |
void Handler::get_flightctrl_settings(int index) { |
char tx_data[2] = {index, 0}; |
com->send_cmd('q', ADDRESS_FC, tx_data, 1, true); |
} |
|
/** |
* write settings to FlightCtrl |
*/ |
void Handler::set_flightctrl_settings(char * tx_data) { |
com->send_cmd('s', ADDRESS_FC, tx_data, MaxParameter+2, true); |
} |
|
/** |
* test one or more motors |
*/ |
void Handler::motor_test(sMotor motor) { |
char tx_data[12]; |
for (int z = 0; z<12; z++) |
{ |
tx_data[z] = motor.Speed[z]; |
} |
com->send_cmd('t', ADDRESS_FC, tx_data, 12, false); |
} |
|
/** |
* read mixer values from FlightCtrl |
*/ |
void Handler::read_mixer() { |
16,9 → 44,140 |
com->send_cmd('n', ADDRESS_FC, tx_data, 1, true); |
} |
|
/** |
* write motor mixer values to FlightCtrl |
*/ |
void Handler::write_mixer(char * tx_data, int length) { |
com->send_cmd('m', ADDRESS_FC, tx_data, length, true); |
} |
|
void Handler::get_motor_config() { |
} |
|
//-------------NaviCtrl commands-------------------- |
/** |
* set debug values for NaviCtrl |
*/ |
void Handler::set_navictrl_debug(int speed) { |
char tx_data[1] = { speed }; |
com->send_cmd('o', ADDRESS_NC, tx_data, 1, false); |
} |
|
/** |
* stop debug for NaviCtrl |
*/ |
void Handler::stop_navictrl_debug() { |
set_navictrl_debug(0); |
} |
|
/** |
* send a waypoint to the NaviCtrl (the copter will fly to the position emidiately) |
*/ |
void Handler::send_waypoint(Waypoint_t desired_pos) { |
com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
} |
|
/** |
* add waypoint to waypoint list |
*/ |
void Handler::add_waypoint(Waypoint_t wp) { |
com->send_cmd('w', ADDRESS_NC, (char *)&wp, sizeof(wp), false); |
} |
|
/** |
* clear waypoint list on MK |
*/ |
void Handler::delete_waypoints() { |
Waypoint_t wp; |
wp.Position.Status = INVALID; |
send_waypoint(wp); |
} |
//-------------switch between Hardware-------------------- |
void Handler::switch_navictrl() { |
char tx_data[6] = { 0x1B, 0x1B, 0x55, 0xAA, 0x00, '\r'}; |
com->send_cmd('#', ADDRESS_NC, tx_data, 6, false); |
} |
|
void Handler::switch_flightctrl() { |
char tx_data[1] = { 0 }; |
com->send_cmd('u', ADDRESS_NC, tx_data, 1, false); |
} |
|
void Handler::switch_mk3mag() { |
char tx_data[1] = { 1 }; |
com->send_cmd('u', ADDRESS_NC, tx_data, 1, false); |
} |
|
//-------------commands for MK3MAG----------------- |
|
|
//-------------commands for all-------------------- |
|
/** |
* set debug values for all components |
*/ |
void Handler::set_all_debug(int speed) { |
char tx_data[1] = { speed }; |
com->send_cmd('d', ADDRESS_ALL, tx_data, 1, false); |
} |
|
/** |
* stop debug for all components |
*/ |
void Handler::stop_all_debug() { |
set_all_debug(0); |
} |
|
/** |
* get all analog labels |
*/ |
void Handler::get_analog() { |
char tx_data[1] = { 0 }; |
com->send_cmd('a', ADDRESS_ALL, tx_data, 1, true); |
} |
|
/** |
* get values from LCD / show LCD |
*/ |
void Handler::show_lcd() { |
char tx_data[1] = {0}; |
com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
} |
|
/** |
* got to next LCD Page |
*/ |
void Handler::lcd_up() { |
char tx_data[2] = { 0, 0 }; |
if (lcd_cur != lcd_max) |
tx_data[0] = lcd_cur+1; |
com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
} |
|
/** |
* got to previous LCD Page |
*/ |
void Handler::lcd_down() { |
char tx_data[2] = { 0, 0 }; |
if (lcd_cur != 0) |
tx_data[0] = lcd_cur-1; |
com->send_cmd('l', ADDRESS_ALL, tx_data, 1, true); |
} |
|
void Handler::get_version() { |
//TODO: Check if is this correct or do we need data from switch_... |
char tx_data[1] = { 0 }; |
com->send_cmd('v', ADDRESS_ALL, tx_data, 0, true); |
} |
|
void Handler::get_ppm_channels() { |
char tx_data[1] = { 0 }; |
com->send_cmd('p', ADDRESS_ALL, tx_data, 0, false); |
} |
|
/** |
* receive data |
*/ |
void Handler::receive_data(sRxData RX) { |
//extract hardware ID from received Data |
int hardwareID = RX.input[1] - 'a'; |