2011-03-19 07:20:11 -03:00
|
|
|
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-07-17 07:34:05 -03:00
|
|
|
#if CLI_ENABLED == ENABLED
|
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
// Functions called from the setup menu
|
|
|
|
static int8_t setup_radio (uint8_t argc, const Menu::arg *argv);
|
2011-01-09 22:21:09 -04:00
|
|
|
static int8_t setup_motors (uint8_t argc, const Menu::arg *argv);
|
2010-12-19 12:40:33 -04:00
|
|
|
static int8_t setup_accel (uint8_t argc, const Menu::arg *argv);
|
2011-05-18 20:38:24 -03:00
|
|
|
static int8_t setup_frame (uint8_t argc, const Menu::arg *argv);
|
2010-12-19 12:40:33 -04:00
|
|
|
static int8_t setup_factory (uint8_t argc, const Menu::arg *argv);
|
|
|
|
static int8_t setup_erase (uint8_t argc, const Menu::arg *argv);
|
|
|
|
static int8_t setup_flightmodes (uint8_t argc, const Menu::arg *argv);
|
2011-05-09 12:46:56 -03:00
|
|
|
static int8_t setup_batt_monitor (uint8_t argc, const Menu::arg *argv);
|
2011-02-20 19:09:28 -04:00
|
|
|
static int8_t setup_sonar (uint8_t argc, const Menu::arg *argv);
|
2010-12-19 12:40:33 -04:00
|
|
|
static int8_t setup_compass (uint8_t argc, const Menu::arg *argv);
|
2011-07-10 21:47:08 -03:00
|
|
|
//static int8_t setup_mag_offset (uint8_t argc, const Menu::arg *argv);
|
2011-01-09 22:21:09 -04:00
|
|
|
static int8_t setup_declination (uint8_t argc, const Menu::arg *argv);
|
2011-05-06 19:46:57 -03:00
|
|
|
static int8_t setup_esc (uint8_t argc, const Menu::arg *argv);
|
2011-07-21 20:14:53 -03:00
|
|
|
#ifdef OPTFLOW_ENABLED
|
|
|
|
static int8_t setup_optflow (uint8_t argc, const Menu::arg *argv);
|
|
|
|
#endif
|
2011-01-09 22:21:09 -04:00
|
|
|
static int8_t setup_show (uint8_t argc, const Menu::arg *argv);
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
#if FRAME_CONFIG == HELI_FRAME
|
2011-06-16 14:03:26 -03:00
|
|
|
static int8_t setup_heli (uint8_t argc, const Menu::arg *argv);
|
|
|
|
static int8_t setup_gyro (uint8_t argc, const Menu::arg *argv);
|
2011-06-12 09:14:10 -03:00
|
|
|
#endif
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-02-19 17:04:05 -04:00
|
|
|
// Command/function table for the setup menu
|
2010-12-19 12:40:33 -04:00
|
|
|
const struct Menu::command setup_menu_commands[] PROGMEM = {
|
|
|
|
// command function called
|
|
|
|
// ======= ===============
|
|
|
|
{"erase", setup_erase},
|
2011-01-09 22:21:09 -04:00
|
|
|
{"reset", setup_factory},
|
2010-12-19 12:40:33 -04:00
|
|
|
{"radio", setup_radio},
|
2011-05-18 20:38:24 -03:00
|
|
|
{"frame", setup_frame},
|
2011-01-02 16:34:42 -04:00
|
|
|
{"motors", setup_motors},
|
2011-05-06 19:46:57 -03:00
|
|
|
{"esc", setup_esc},
|
2010-12-19 12:40:33 -04:00
|
|
|
{"level", setup_accel},
|
|
|
|
{"modes", setup_flightmodes},
|
2011-05-09 12:46:56 -03:00
|
|
|
{"battery", setup_batt_monitor},
|
2011-02-20 19:09:28 -04:00
|
|
|
{"sonar", setup_sonar},
|
2010-12-19 12:40:33 -04:00
|
|
|
{"compass", setup_compass},
|
2011-07-10 21:47:08 -03:00
|
|
|
// {"offsets", setup_mag_offset},
|
2010-12-19 12:40:33 -04:00
|
|
|
{"declination", setup_declination},
|
2011-07-21 20:14:53 -03:00
|
|
|
#ifdef OPTFLOW_ENABLED
|
|
|
|
{"optflow", setup_optflow},
|
|
|
|
#endif
|
2011-06-16 14:03:26 -03:00
|
|
|
#if FRAME_CONFIG == HELI_FRAME
|
2011-06-12 09:14:10 -03:00
|
|
|
{"heli", setup_heli},
|
|
|
|
{"gyro", setup_gyro},
|
|
|
|
#endif
|
2011-02-25 01:33:39 -04:00
|
|
|
{"show", setup_show}
|
2010-12-19 12:40:33 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Create the setup menu object.
|
|
|
|
MENU(setup_menu, "setup", setup_menu_commands);
|
|
|
|
|
|
|
|
// Called from the top-level menu to run the setup menu.
|
2011-07-17 07:32:00 -03:00
|
|
|
static int8_t
|
2010-12-19 12:40:33 -04:00
|
|
|
setup_mode(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
// Give the user some guidance
|
2011-04-21 20:07:31 -03:00
|
|
|
Serial.printf_P(PSTR("Setup Mode\n\n\n"));
|
2011-03-26 03:35:52 -03:00
|
|
|
//"\n"
|
|
|
|
//"IMPORTANT: if you have not previously set this system up, use the\n"
|
|
|
|
//"'reset' command to initialize the EEPROM to sensible default values\n"
|
|
|
|
//"and then the 'radio' command to configure for your radio.\n"
|
|
|
|
//"\n"));
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-03-26 18:03:20 -03:00
|
|
|
if(g.rc_1.radio_min >= 1300){
|
|
|
|
delay(1000);
|
2011-05-02 01:13:27 -03:00
|
|
|
Serial.printf_P(PSTR("\n!Warning, your radio is not configured!"));
|
2011-03-26 18:03:20 -03:00
|
|
|
delay(1000);
|
|
|
|
Serial.printf_P(PSTR("\n Type 'radio' to configure now.\n\n"));
|
|
|
|
}
|
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
// Run the setup menu. When the menu exits, we will return to the main menu.
|
|
|
|
setup_menu.run();
|
2011-07-17 07:30:21 -03:00
|
|
|
return 0;
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print the current configuration.
|
|
|
|
// Called by the setup menu 'show' command.
|
|
|
|
static int8_t
|
|
|
|
setup_show(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
2011-01-20 03:11:21 -04:00
|
|
|
// clear the area
|
|
|
|
print_blanks(8);
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-04-02 16:56:35 -03:00
|
|
|
report_version();
|
2011-01-20 03:11:21 -04:00
|
|
|
report_radio();
|
|
|
|
report_frame();
|
2011-05-09 12:46:56 -03:00
|
|
|
report_batt_monitor();
|
2011-02-20 19:09:28 -04:00
|
|
|
report_sonar();
|
2011-07-10 21:47:08 -03:00
|
|
|
//report_gains();
|
|
|
|
//report_xtrack();
|
|
|
|
//report_throttle();
|
2011-01-20 03:11:21 -04:00
|
|
|
report_flight_modes();
|
|
|
|
report_imu();
|
|
|
|
report_compass();
|
2011-07-21 20:14:53 -03:00
|
|
|
#ifdef OPTFLOW_ENABLED
|
|
|
|
report_optflow();
|
|
|
|
#endif
|
2011-06-12 09:14:10 -03:00
|
|
|
#if FRAME_CONFIG == HELI_FRAME
|
|
|
|
report_heli();
|
|
|
|
report_gyro();
|
|
|
|
#endif
|
2011-02-25 01:33:39 -04:00
|
|
|
|
|
|
|
AP_Var_menu_show(argc, argv);
|
2010-12-19 12:40:33 -04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialise the EEPROM to 'factory' settings (mostly defined in APM_Config.h or via defaults).
|
|
|
|
// Called by the setup menu 'factoryreset' command.
|
|
|
|
static int8_t
|
|
|
|
setup_factory(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
2011-05-06 21:21:16 -03:00
|
|
|
int c;
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-03-26 03:35:52 -03:00
|
|
|
Serial.printf_P(PSTR("\n'Y' + Enter to factory reset, any other key to abort:\n"));
|
2010-12-19 12:40:33 -04:00
|
|
|
|
|
|
|
do {
|
|
|
|
c = Serial.read();
|
|
|
|
} while (-1 == c);
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
if (('y' != c) && ('Y' != c))
|
|
|
|
return(-1);
|
2011-03-26 18:03:20 -03:00
|
|
|
|
2011-02-19 18:44:52 -04:00
|
|
|
AP_Var::erase_all();
|
2011-03-26 03:35:52 -03:00
|
|
|
Serial.printf_P(PSTR("\nFACTORY RESET complete - reboot APM"));
|
2011-03-10 22:49:12 -04:00
|
|
|
|
2011-03-11 17:37:37 -04:00
|
|
|
delay(1000);
|
2011-04-13 13:33:06 -03:00
|
|
|
//default_gains();
|
2011-03-10 22:49:12 -04:00
|
|
|
|
2011-02-19 18:44:52 -04:00
|
|
|
for (;;) {
|
|
|
|
}
|
|
|
|
// note, cannot actually return here
|
|
|
|
return(0);
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Perform radio setup.
|
|
|
|
// Called by the setup menu 'radio' command.
|
|
|
|
static int8_t
|
|
|
|
setup_radio(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
Serial.println("\n\nRadio Setup:");
|
|
|
|
uint8_t i;
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
for(i = 0; i < 100;i++){
|
|
|
|
delay(20);
|
|
|
|
read_radio();
|
|
|
|
}
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-02-17 03:09:13 -04:00
|
|
|
if(g.rc_1.radio_in < 500){
|
2010-12-19 12:40:33 -04:00
|
|
|
while(1){
|
2011-03-26 03:35:52 -03:00
|
|
|
//Serial.printf_P(PSTR("\nNo radio; Check connectors."));
|
2010-12-19 12:40:33 -04:00
|
|
|
delay(1000);
|
|
|
|
// stop here
|
|
|
|
}
|
|
|
|
}
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-02-17 03:09:13 -04:00
|
|
|
g.rc_1.radio_min = g.rc_1.radio_in;
|
|
|
|
g.rc_2.radio_min = g.rc_2.radio_in;
|
|
|
|
g.rc_3.radio_min = g.rc_3.radio_in;
|
|
|
|
g.rc_4.radio_min = g.rc_4.radio_in;
|
|
|
|
g.rc_5.radio_min = g.rc_5.radio_in;
|
|
|
|
g.rc_6.radio_min = g.rc_6.radio_in;
|
|
|
|
g.rc_7.radio_min = g.rc_7.radio_in;
|
|
|
|
g.rc_8.radio_min = g.rc_8.radio_in;
|
|
|
|
|
|
|
|
g.rc_1.radio_max = g.rc_1.radio_in;
|
|
|
|
g.rc_2.radio_max = g.rc_2.radio_in;
|
|
|
|
g.rc_3.radio_max = g.rc_3.radio_in;
|
|
|
|
g.rc_4.radio_max = g.rc_4.radio_in;
|
|
|
|
g.rc_5.radio_max = g.rc_5.radio_in;
|
|
|
|
g.rc_6.radio_max = g.rc_6.radio_in;
|
|
|
|
g.rc_7.radio_max = g.rc_7.radio_in;
|
|
|
|
g.rc_8.radio_max = g.rc_8.radio_in;
|
|
|
|
|
|
|
|
g.rc_1.radio_trim = g.rc_1.radio_in;
|
|
|
|
g.rc_2.radio_trim = g.rc_2.radio_in;
|
|
|
|
g.rc_4.radio_trim = g.rc_4.radio_in;
|
2010-12-27 19:09:08 -04:00
|
|
|
// 3 is not trimed
|
2011-02-17 03:09:13 -04:00
|
|
|
g.rc_5.radio_trim = 1500;
|
|
|
|
g.rc_6.radio_trim = 1500;
|
|
|
|
g.rc_7.radio_trim = 1500;
|
|
|
|
g.rc_8.radio_trim = 1500;
|
2011-01-16 23:44:12 -04:00
|
|
|
|
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
Serial.printf_P(PSTR("\nMove all controls to each extreme. Hit Enter to save: "));
|
|
|
|
while(1){
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
delay(20);
|
|
|
|
// Filters radio input - adjust filters in the radio.pde file
|
|
|
|
// ----------------------------------------------------------
|
|
|
|
read_radio();
|
|
|
|
|
2011-02-17 03:09:13 -04:00
|
|
|
g.rc_1.update_min_max();
|
|
|
|
g.rc_2.update_min_max();
|
|
|
|
g.rc_3.update_min_max();
|
|
|
|
g.rc_4.update_min_max();
|
|
|
|
g.rc_5.update_min_max();
|
|
|
|
g.rc_6.update_min_max();
|
|
|
|
g.rc_7.update_min_max();
|
|
|
|
g.rc_8.update_min_max();
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
if(Serial.available() > 0){
|
2011-03-26 18:03:20 -03:00
|
|
|
delay(20);
|
2010-12-19 12:40:33 -04:00
|
|
|
Serial.flush();
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-05-14 23:02:09 -03:00
|
|
|
g.rc_1.save_eeprom();
|
|
|
|
g.rc_2.save_eeprom();
|
|
|
|
g.rc_3.save_eeprom();
|
|
|
|
g.rc_4.save_eeprom();
|
|
|
|
g.rc_5.save_eeprom();
|
|
|
|
g.rc_6.save_eeprom();
|
|
|
|
g.rc_7.save_eeprom();
|
|
|
|
g.rc_8.save_eeprom();
|
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
print_done();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-20 03:11:21 -04:00
|
|
|
report_radio();
|
2010-12-19 12:40:33 -04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int8_t
|
2011-05-06 19:46:57 -03:00
|
|
|
setup_esc(uint8_t argc, const Menu::arg *argv)
|
2010-12-19 12:40:33 -04:00
|
|
|
{
|
2011-07-30 17:42:54 -03:00
|
|
|
Serial.printf_P(PSTR("\nESC Calibration:\n"
|
|
|
|
"-1 Unplug USB and battery\n"
|
|
|
|
"-2 Move CLI/FLY switch to FLY mode\n"
|
|
|
|
"-3 Move throttle to max, connect battery\n"
|
|
|
|
"-4 After two long beeps, throttle to 0, then test\n\n"
|
|
|
|
" Press Enter to cancel.\n"));
|
2011-05-06 21:21:16 -03:00
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
|
2011-05-06 19:46:57 -03:00
|
|
|
g.esc_calibrate.set_and_save(1);
|
2011-01-20 03:11:21 -04:00
|
|
|
|
2011-05-06 19:46:57 -03:00
|
|
|
while(1){
|
|
|
|
delay(20);
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-05-06 19:46:57 -03:00
|
|
|
if(Serial.available() > 0){
|
|
|
|
g.esc_calibrate.set_and_save(0);
|
2011-05-06 21:21:16 -03:00
|
|
|
return(0);
|
2011-05-06 19:46:57 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-05-06 19:46:57 -03:00
|
|
|
static int8_t
|
|
|
|
setup_motors(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
2010-12-19 12:40:33 -04:00
|
|
|
while(1){
|
2011-05-31 02:29:06 -03:00
|
|
|
delay(20);
|
|
|
|
read_radio();
|
2011-05-14 23:02:09 -03:00
|
|
|
output_motor_test();
|
2010-12-19 12:40:33 -04:00
|
|
|
if(Serial.available() > 0){
|
2011-05-14 23:02:09 -03:00
|
|
|
g.esc_calibrate.set_and_save(0);
|
|
|
|
return(0);
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-04 02:06:26 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
static int8_t
|
|
|
|
setup_accel(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
imu.init_accel();
|
2011-02-18 23:59:58 -04:00
|
|
|
print_accel_offsets();
|
2011-01-20 03:11:21 -04:00
|
|
|
report_imu();
|
2010-12-19 12:40:33 -04:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2011-05-18 20:38:24 -03:00
|
|
|
static int8_t
|
|
|
|
setup_frame(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
if (!strcmp_P(argv[1].str, PSTR("x"))) {
|
2011-05-19 09:40:17 -03:00
|
|
|
g.frame_orientation.set_and_save(X_FRAME);
|
2011-05-18 20:38:24 -03:00
|
|
|
} else if (!strcmp_P(argv[1].str, PSTR("p"))) {
|
2011-05-19 09:40:17 -03:00
|
|
|
g.frame_orientation.set_and_save(PLUS_FRAME);
|
2011-05-27 15:21:55 -03:00
|
|
|
} else if (!strcmp_P(argv[1].str, PSTR("+"))) {
|
|
|
|
g.frame_orientation.set_and_save(PLUS_FRAME);
|
2011-06-24 14:09:59 -03:00
|
|
|
} else if (!strcmp_P(argv[1].str, PSTR("v"))) {
|
|
|
|
g.frame_orientation.set_and_save(V_FRAME);
|
2011-05-18 20:38:24 -03:00
|
|
|
}else{
|
2011-06-24 14:09:59 -03:00
|
|
|
Serial.printf_P(PSTR("\nOptions:[x,+,v]\n"));
|
2011-05-18 20:38:24 -03:00
|
|
|
report_frame();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
report_frame();
|
|
|
|
return 0;
|
|
|
|
}
|
2011-05-06 19:46:57 -03:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
static int8_t
|
|
|
|
setup_flightmodes(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
2011-06-16 14:03:26 -03:00
|
|
|
byte _switchPosition = 0;
|
|
|
|
byte _oldSwitchPosition = 0;
|
|
|
|
byte mode = 0;
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
Serial.printf_P(PSTR("\nMove RC toggle switch to each position to edit, move aileron stick to select modes."));
|
|
|
|
print_hit_enter();
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
while(1){
|
|
|
|
delay(20);
|
2011-02-19 17:04:05 -04:00
|
|
|
read_radio();
|
2011-06-16 14:03:26 -03:00
|
|
|
_switchPosition = readSwitch();
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
// look for control switch change
|
2011-06-16 14:03:26 -03:00
|
|
|
if (_oldSwitchPosition != _switchPosition){
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-07-17 07:30:53 -03:00
|
|
|
mode = flight_modes[_switchPosition];
|
2010-12-19 12:40:33 -04:00
|
|
|
mode = constrain(mode, 0, NUM_MODES-1);
|
|
|
|
|
|
|
|
// update the user
|
2011-06-16 14:03:26 -03:00
|
|
|
print_switch(_switchPosition, mode);
|
2010-12-19 12:40:33 -04:00
|
|
|
|
|
|
|
// Remember switch position
|
2011-06-16 14:03:26 -03:00
|
|
|
_oldSwitchPosition = _switchPosition;
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// look for stick input
|
2011-03-26 03:35:52 -03:00
|
|
|
if (radio_input_switch() == true){
|
2011-02-19 17:04:05 -04:00
|
|
|
mode++;
|
2010-12-19 12:40:33 -04:00
|
|
|
if(mode >= NUM_MODES)
|
|
|
|
mode = 0;
|
|
|
|
|
|
|
|
// save new mode
|
2011-07-17 07:30:53 -03:00
|
|
|
flight_modes[_switchPosition] = mode;
|
2010-12-19 12:40:33 -04:00
|
|
|
|
|
|
|
// print new mode
|
2011-06-16 14:03:26 -03:00
|
|
|
print_switch(_switchPosition, mode);
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
// escape hatch
|
|
|
|
if(Serial.available() > 0){
|
2011-07-17 07:30:53 -03:00
|
|
|
for (mode=0; mode<6; mode++)
|
|
|
|
flight_modes[mode].save();
|
2010-12-19 12:40:33 -04:00
|
|
|
print_done();
|
2011-01-20 03:11:21 -04:00
|
|
|
report_flight_modes();
|
2010-12-19 12:40:33 -04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int8_t
|
|
|
|
setup_declination(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
2011-02-18 23:59:58 -04:00
|
|
|
compass.set_declination(radians(argv[1].f));
|
2011-01-20 03:11:21 -04:00
|
|
|
report_compass();
|
2011-06-16 14:03:26 -03:00
|
|
|
return 0;
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
2011-03-26 03:35:52 -03:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
static int8_t
|
|
|
|
setup_erase(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
zero_eeprom();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int8_t
|
2011-01-09 22:21:09 -04:00
|
|
|
setup_compass(uint8_t argc, const Menu::arg *argv)
|
2010-12-19 12:40:33 -04:00
|
|
|
{
|
2011-01-09 22:21:09 -04:00
|
|
|
if (!strcmp_P(argv[1].str, PSTR("on"))) {
|
2011-05-19 09:40:17 -03:00
|
|
|
g.compass_enabled.set_and_save(true);
|
2011-01-09 22:21:09 -04:00
|
|
|
init_compass();
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-01-09 22:21:09 -04:00
|
|
|
} else if (!strcmp_P(argv[1].str, PSTR("off"))) {
|
2011-06-01 02:50:17 -03:00
|
|
|
clear_offsets();
|
2011-05-19 09:40:17 -03:00
|
|
|
g.compass_enabled.set_and_save(false);
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-02-24 01:56:59 -04:00
|
|
|
}else{
|
2011-01-20 03:11:21 -04:00
|
|
|
Serial.printf_P(PSTR("\nOptions:[on,off]\n"));
|
|
|
|
report_compass();
|
|
|
|
return 0;
|
2011-01-09 22:21:09 -04:00
|
|
|
}
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-02-25 01:33:39 -04:00
|
|
|
g.compass_enabled.save();
|
2011-01-20 03:11:21 -04:00
|
|
|
report_compass();
|
2010-12-19 12:40:33 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
static int8_t
|
2011-05-09 12:46:56 -03:00
|
|
|
setup_batt_monitor(uint8_t argc, const Menu::arg *argv)
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
2011-06-03 02:36:39 -03:00
|
|
|
if (!strcmp_P(argv[1].str, PSTR("off"))) {
|
|
|
|
g.battery_monitoring.set_and_save(0);
|
|
|
|
|
|
|
|
} else if(argv[1].i > 0 && argv[1].i <= 4){
|
2011-05-09 12:46:56 -03:00
|
|
|
g.battery_monitoring.set_and_save(argv[1].i);
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-05-09 12:46:56 -03:00
|
|
|
} else {
|
2011-06-03 02:36:39 -03:00
|
|
|
Serial.printf_P(PSTR("\nOptions: off, 1-4"));
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-05-09 12:46:56 -03:00
|
|
|
report_batt_monitor();
|
2011-01-20 03:11:21 -04:00
|
|
|
return 0;
|
|
|
|
}
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-02-20 19:09:28 -04:00
|
|
|
static int8_t
|
|
|
|
setup_sonar(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
if (!strcmp_P(argv[1].str, PSTR("on"))) {
|
|
|
|
g.sonar_enabled.set_and_save(true);
|
|
|
|
|
|
|
|
} else if (!strcmp_P(argv[1].str, PSTR("off"))) {
|
|
|
|
g.sonar_enabled.set_and_save(false);
|
|
|
|
|
2011-02-24 01:56:59 -04:00
|
|
|
}else{
|
2011-02-20 19:09:28 -04:00
|
|
|
Serial.printf_P(PSTR("\nOptions:[on, off]\n"));
|
|
|
|
report_sonar();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
report_sonar();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
#if FRAME_CONFIG == HELI_FRAME
|
|
|
|
|
|
|
|
// Perform heli setup.
|
|
|
|
// Called by the setup menu 'radio' command.
|
|
|
|
static int8_t
|
|
|
|
setup_heli(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
uint8_t active_servo = 0;
|
|
|
|
int value = 0;
|
|
|
|
int temp;
|
|
|
|
int state = 0; // 0 = set rev+pos, 1 = capture min/max
|
|
|
|
int max_roll, max_pitch, min_coll, max_coll, min_tail, max_tail;
|
|
|
|
|
|
|
|
// initialise swash plate
|
|
|
|
heli_init_swash();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
|
|
|
// source swash plate movements directly from
|
2011-06-12 09:14:10 -03:00
|
|
|
heli_manual_override = true;
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// display initial settings
|
|
|
|
report_heli();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// display help
|
|
|
|
Serial.printf_P(PSTR("Instructions:"));
|
|
|
|
print_divider();
|
|
|
|
Serial.printf_P(PSTR("\td\t\tdisplay settings\n"));
|
|
|
|
Serial.printf_P(PSTR("\t1~4\t\tselect servo\n"));
|
|
|
|
Serial.printf_P(PSTR("\ta or z\t\tmove mid up/down\n"));
|
|
|
|
Serial.printf_P(PSTR("\tc\t\tset coll when blade pitch zero\n"));
|
|
|
|
Serial.printf_P(PSTR("\tm\t\tset roll, pitch, coll min/max\n"));
|
|
|
|
Serial.printf_P(PSTR("\tp<angle>\tset pos (i.e. p0 = front, p90 = right)\n"));
|
|
|
|
Serial.printf_P(PSTR("\tr\t\treverse servo\n"));
|
|
|
|
Serial.printf_P(PSTR("\tt<angle>\tset trim (-500 ~ 500)\n"));
|
|
|
|
Serial.printf_P(PSTR("\tx\t\texit & save\n"));
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// start capturing
|
|
|
|
while( value != 'x' ) {
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// read radio although we don't use it yet
|
|
|
|
read_radio();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
|
|
|
// record min/max
|
2011-06-12 09:14:10 -03:00
|
|
|
if( state == 1 ) {
|
|
|
|
if( abs(g.rc_1.control_in) > max_roll )
|
|
|
|
max_roll = abs(g.rc_1.control_in);
|
|
|
|
if( abs(g.rc_2.control_in) > max_pitch )
|
|
|
|
max_pitch = abs(g.rc_2.control_in);
|
|
|
|
if( g.rc_3.radio_in < min_coll )
|
|
|
|
min_coll = g.rc_3.radio_in;
|
|
|
|
if( g.rc_3.radio_in > max_coll )
|
|
|
|
max_coll = g.rc_3.radio_in;
|
|
|
|
min_tail = min(g.rc_4.radio_in, min_tail);
|
|
|
|
max_tail = max(g.rc_4.radio_in, max_tail);
|
|
|
|
//Serial.printf_P(PSTR("4: ri:%d \tro:%d \tso:%d \n"), (int)g.rc_4.radio_in, (int)g.rc_4.radio_out, (int)g.rc_4.servo_out);
|
|
|
|
}
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
if( Serial.available() ) {
|
|
|
|
value = Serial.read();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// process the user's input
|
|
|
|
switch( value ) {
|
|
|
|
case '1':
|
|
|
|
active_servo = CH_1;
|
|
|
|
break;
|
|
|
|
case '2':
|
|
|
|
active_servo = CH_2;
|
|
|
|
break;
|
|
|
|
case '3':
|
|
|
|
active_servo = CH_3;
|
|
|
|
break;
|
|
|
|
case '4':
|
|
|
|
active_servo = CH_4;
|
|
|
|
break;
|
2011-06-16 14:03:26 -03:00
|
|
|
case 'a':
|
2011-06-12 09:14:10 -03:00
|
|
|
case 'A':
|
|
|
|
heli_get_servo(active_servo)->radio_trim += 10;
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
case 'C':
|
|
|
|
if( g.rc_3.radio_in >= 900 && g.rc_3.radio_in <= 2100 ) {
|
|
|
|
g.heli_coll_mid = g.rc_3.radio_in;
|
|
|
|
Serial.printf_P(PSTR("Collective when blade pitch at zero: %d\n"),(int)g.heli_coll_mid);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
case 'D':
|
|
|
|
// display settings
|
|
|
|
report_heli();
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
case 'M':
|
|
|
|
if( state == 0 ) {
|
|
|
|
state = 1; // switch to capture min/max mode
|
|
|
|
Serial.printf_P(PSTR("Move coll, roll, pitch and tail to extremes, press 'm' when done\n"),active_servo+1, temp);
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// reset servo ranges
|
|
|
|
g.heli_roll_max = g.heli_pitch_max = 4500;
|
|
|
|
g.heli_coll_min = 1000;
|
|
|
|
g.heli_coll_max = 2000;
|
|
|
|
g.heli_servo_4.radio_min = 1000;
|
|
|
|
g.heli_servo_4.radio_max = 2000;
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// set sensible values in temp variables
|
|
|
|
max_roll = abs(g.rc_1.control_in);
|
|
|
|
max_pitch = abs(g.rc_2.control_in);
|
|
|
|
min_coll = 2000;
|
|
|
|
max_coll = 1000;
|
|
|
|
min_tail = max_tail = abs(g.rc_4.radio_in);
|
|
|
|
}else{
|
|
|
|
state = 0; // switch back to normal mode
|
|
|
|
// double check values aren't totally terrible
|
|
|
|
if( max_roll <= 1000 || max_pitch <= 1000 || (max_coll - min_coll < 200) || (max_tail - min_tail < 200) || min_tail < 1000 || max_tail > 2000 )
|
|
|
|
Serial.printf_P(PSTR("Invalid min/max captured roll:%d, pitch:%d, collective min: %d max: %d, tail min:%d max:%d\n"),max_roll,max_pitch,min_coll,max_coll,min_tail,max_tail);
|
|
|
|
else{
|
|
|
|
g.heli_roll_max = max_roll;
|
|
|
|
g.heli_pitch_max = max_pitch;
|
|
|
|
g.heli_coll_min = min_coll;
|
|
|
|
g.heli_coll_max = max_coll;
|
|
|
|
g.heli_servo_4.radio_min = min_tail;
|
|
|
|
g.heli_servo_4.radio_max = max_tail;
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// reinitialise swash
|
|
|
|
heli_init_swash();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// display settings
|
|
|
|
report_heli();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
case 'P':
|
|
|
|
temp = read_num_from_serial();
|
|
|
|
if( temp >= -360 && temp <= 360 ) {
|
|
|
|
if( active_servo == CH_1 )
|
|
|
|
g.heli_servo1_pos = temp;
|
|
|
|
if( active_servo == CH_2 )
|
|
|
|
g.heli_servo2_pos = temp;
|
|
|
|
if( active_servo == CH_3 )
|
|
|
|
g.heli_servo3_pos = temp;
|
|
|
|
heli_init_swash();
|
2011-06-16 14:03:26 -03:00
|
|
|
Serial.printf_P(PSTR("Servo %d\t\tpos:%d\n"),active_servo+1, temp);
|
2011-06-12 09:14:10 -03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
case 'R':
|
|
|
|
heli_get_servo(active_servo)->set_reverse(!heli_get_servo(active_servo)->get_reverse());
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
case 'T':
|
|
|
|
temp = read_num_from_serial();
|
|
|
|
if( temp > 1000 )
|
|
|
|
temp -= 1500;
|
|
|
|
if( temp > -500 && temp < 500 ) {
|
|
|
|
heli_get_servo(active_servo)->radio_trim = 1500 + temp;
|
|
|
|
heli_init_swash();
|
2011-06-16 14:03:26 -03:00
|
|
|
Serial.printf_P(PSTR("Servo %d\t\ttrim:%d\n"),active_servo+1, 1500 + temp);
|
2011-06-12 09:14:10 -03:00
|
|
|
}
|
|
|
|
break;
|
2011-06-16 14:03:26 -03:00
|
|
|
case 'z':
|
2011-06-12 09:14:10 -03:00
|
|
|
case 'Z':
|
|
|
|
heli_get_servo(active_servo)->radio_trim -= 10;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// allow swash plate to move
|
|
|
|
output_motors_armed();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
delay(20);
|
|
|
|
}
|
|
|
|
|
|
|
|
// display final settings
|
|
|
|
report_heli();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// save to eeprom
|
|
|
|
g.heli_servo_1.save_eeprom();
|
|
|
|
g.heli_servo_2.save_eeprom();
|
|
|
|
g.heli_servo_3.save_eeprom();
|
|
|
|
g.heli_servo_4.save_eeprom();
|
|
|
|
g.heli_servo1_pos.save();
|
|
|
|
g.heli_servo2_pos.save();
|
|
|
|
g.heli_servo3_pos.save();
|
|
|
|
g.heli_roll_max.save();
|
|
|
|
g.heli_pitch_max.save();
|
|
|
|
g.heli_coll_min.save();
|
|
|
|
g.heli_coll_max.save();
|
|
|
|
g.heli_coll_mid.save();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// return swash plate movements to attitude controller
|
|
|
|
heli_manual_override = false;
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup for external tail gyro (for heli only)
|
|
|
|
static int8_t
|
|
|
|
setup_gyro(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
if (!strcmp_P(argv[1].str, PSTR("on"))) {
|
|
|
|
g.heli_ext_gyro_enabled.set_and_save(true);
|
|
|
|
|
|
|
|
// optionally capture the gain
|
|
|
|
if( argc >= 2 && argv[2].i >= 1000 && argv[2].i <= 2000 ) {
|
|
|
|
g.heli_ext_gyro_gain = argv[2].i;
|
|
|
|
g.heli_ext_gyro_gain.save();
|
|
|
|
}
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
} else if (!strcmp_P(argv[1].str, PSTR("off"))) {
|
|
|
|
g.heli_ext_gyro_enabled.set_and_save(false);
|
|
|
|
|
|
|
|
// capture gain if user simply provides a number
|
|
|
|
} else if( argv[1].i >= 1000 && argv[1].i <= 2000 ) {
|
|
|
|
g.heli_ext_gyro_enabled.set_and_save(true);
|
|
|
|
g.heli_ext_gyro_gain = argv[1].i;
|
|
|
|
g.heli_ext_gyro_gain.save();
|
|
|
|
|
|
|
|
}else{
|
|
|
|
Serial.printf_P(PSTR("\nOptions:[on, off] gain\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
report_gyro();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FRAME_CONFIG == HELI
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void clear_offsets()
|
2011-06-01 02:50:17 -03:00
|
|
|
{
|
2011-06-24 01:37:54 -03:00
|
|
|
Vector3f _offsets(0.0,0.0,0.0);
|
2011-06-01 02:50:17 -03:00
|
|
|
compass.set_offsets(_offsets);
|
|
|
|
compass.save_offsets();
|
|
|
|
}
|
|
|
|
|
2011-07-10 21:47:08 -03:00
|
|
|
/*static int8_t
|
2011-05-27 01:59:01 -03:00
|
|
|
setup_mag_offset(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
2011-05-29 01:02:01 -03:00
|
|
|
Vector3f _offsets;
|
|
|
|
|
|
|
|
if (!strcmp_P(argv[1].str, PSTR("c"))) {
|
2011-06-01 02:50:17 -03:00
|
|
|
clear_offsets();
|
2011-05-29 01:02:01 -03:00
|
|
|
report_compass();
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2011-05-27 01:59:01 -03:00
|
|
|
print_hit_enter();
|
|
|
|
init_compass();
|
|
|
|
|
2011-05-29 01:02:01 -03:00
|
|
|
int _min[3] = {0,0,0};
|
|
|
|
int _max[3] = {0,0,0};
|
|
|
|
|
|
|
|
compass.read();
|
|
|
|
compass.calculate(0,0); // roll = 0, pitch = 0
|
2011-05-27 01:59:01 -03:00
|
|
|
|
|
|
|
while(1){
|
2011-05-29 01:02:01 -03:00
|
|
|
delay(50);
|
|
|
|
|
|
|
|
compass.read();
|
|
|
|
compass.calculate(0,0); // roll = 0, pitch = 0
|
|
|
|
|
|
|
|
if(compass.mag_x < _min[0]) _min[0] = compass.mag_x;
|
|
|
|
if(compass.mag_y < _min[1]) _min[1] = compass.mag_y;
|
|
|
|
if(compass.mag_z < _min[2]) _min[2] = compass.mag_z;
|
|
|
|
|
|
|
|
// capture max
|
|
|
|
if(compass.mag_x > _max[0]) _max[0] = compass.mag_x;
|
|
|
|
if(compass.mag_y > _max[1]) _max[1] = compass.mag_y;
|
|
|
|
if(compass.mag_z > _max[2]) _max[2] = compass.mag_z;
|
|
|
|
|
|
|
|
// calculate offsets
|
|
|
|
_offsets.x = (float)(_max[0] + _min[0]) / -2;
|
|
|
|
_offsets.y = (float)(_max[1] + _min[1]) / -2;
|
|
|
|
_offsets.z = (float)(_max[2] + _min[2]) / -2;
|
|
|
|
|
|
|
|
// display all to user
|
|
|
|
Serial.printf_P(PSTR("Heading: %u, \t (%d, %d, %d), (%4.4f, %4.4f, %4.4f)\n"),
|
|
|
|
|
|
|
|
(uint16_t)(wrap_360(ToDeg(compass.heading) * 100)) /100,
|
|
|
|
|
|
|
|
compass.mag_x,
|
|
|
|
compass.mag_y,
|
|
|
|
compass.mag_z,
|
|
|
|
|
|
|
|
_offsets.x,
|
|
|
|
_offsets.y,
|
|
|
|
_offsets.z);
|
|
|
|
|
|
|
|
if(Serial.available() > 1){
|
|
|
|
compass.set_offsets(_offsets);
|
|
|
|
//compass.set_offsets(mag_offset_x, mag_offset_y, mag_offset_z);
|
|
|
|
report_compass();
|
2011-06-16 14:03:26 -03:00
|
|
|
return 0;
|
2011-05-27 01:59:01 -03:00
|
|
|
}
|
|
|
|
}
|
2011-07-10 21:47:08 -03:00
|
|
|
return 0;
|
2011-05-27 01:59:01 -03:00
|
|
|
}
|
2011-07-10 21:47:08 -03:00
|
|
|
*/
|
2011-05-27 01:59:01 -03:00
|
|
|
|
2011-07-21 20:14:53 -03:00
|
|
|
#ifdef OPTFLOW_ENABLED
|
|
|
|
static int8_t
|
|
|
|
setup_optflow(uint8_t argc, const Menu::arg *argv)
|
|
|
|
{
|
|
|
|
if (!strcmp_P(argv[1].str, PSTR("on"))) {
|
|
|
|
g.optflow_enabled = true;
|
|
|
|
init_optflow();
|
|
|
|
|
|
|
|
} else if (!strcmp_P(argv[1].str, PSTR("off"))) {
|
|
|
|
g.optflow_enabled = false;
|
|
|
|
|
|
|
|
//} else if(argv[1].i > 10){
|
|
|
|
// g.optflow_fov.set_and_save(argv[1].i);
|
|
|
|
// optflow.set_field_of_view(g.optflow_fov.get());
|
|
|
|
|
|
|
|
}else{
|
|
|
|
Serial.printf_P(PSTR("\nOptions:[on, off]\n"));
|
|
|
|
report_optflow();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g.optflow_enabled.save();
|
|
|
|
report_optflow();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2011-05-27 01:59:01 -03:00
|
|
|
|
2011-07-30 17:42:54 -03:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
default_log_bitmask()
|
|
|
|
{
|
|
|
|
// convenience macro for testing LOG_* and setting LOGBIT_*
|
|
|
|
#define LOGBIT(_s) (LOG_##_s ? MASK_LOG_##_s : 0)
|
|
|
|
|
|
|
|
g.log_bitmask =
|
|
|
|
LOGBIT(ATTITUDE_FAST) |
|
|
|
|
LOGBIT(ATTITUDE_MED) |
|
|
|
|
LOGBIT(GPS) |
|
|
|
|
LOGBIT(PM) |
|
|
|
|
LOGBIT(CTUN) |
|
|
|
|
LOGBIT(NTUN) |
|
|
|
|
LOGBIT(MODE) |
|
|
|
|
LOGBIT(RAW) |
|
|
|
|
LOGBIT(CMD) |
|
|
|
|
LOGBIT(CUR) |
|
|
|
|
LOGBIT(MOTORS) |
|
|
|
|
LOGBIT(OPTFLOW);
|
|
|
|
#undef LOGBIT
|
|
|
|
|
|
|
|
g.log_bitmask.save();
|
|
|
|
}
|
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
/***************************************************************************/
|
2011-02-24 01:56:59 -04:00
|
|
|
// CLI reports
|
2011-01-20 03:11:21 -04:00
|
|
|
/***************************************************************************/
|
2011-05-09 12:46:56 -03:00
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_batt_monitor()
|
2011-05-09 12:46:56 -03:00
|
|
|
{
|
2011-05-14 23:02:09 -03:00
|
|
|
Serial.printf_P(PSTR("\nBatt Mointor\n"));
|
2011-05-09 12:46:56 -03:00
|
|
|
print_divider();
|
2011-05-14 23:02:09 -03:00
|
|
|
if(g.battery_monitoring == 0) print_enabled(false);
|
2011-05-09 12:46:56 -03:00
|
|
|
if(g.battery_monitoring == 1) Serial.printf_P(PSTR("3 cells"));
|
|
|
|
if(g.battery_monitoring == 2) Serial.printf_P(PSTR("4 cells"));
|
|
|
|
if(g.battery_monitoring == 3) Serial.printf_P(PSTR("batt volts"));
|
|
|
|
if(g.battery_monitoring == 4) Serial.printf_P(PSTR("volts and cur"));
|
|
|
|
print_blanks(2);
|
|
|
|
}
|
2011-05-14 23:02:09 -03:00
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_wp(byte index = 255)
|
2011-03-26 03:35:52 -03:00
|
|
|
{
|
|
|
|
if(index == 255){
|
|
|
|
for(byte i = 0; i <= g.waypoint_total; i++){
|
2011-04-25 02:12:59 -03:00
|
|
|
struct Location temp = get_command_with_index(i);
|
2011-03-26 03:35:52 -03:00
|
|
|
print_wp(&temp, i);
|
|
|
|
}
|
|
|
|
}else{
|
2011-04-25 02:12:59 -03:00
|
|
|
struct Location temp = get_command_with_index(index);
|
2011-03-26 03:35:52 -03:00
|
|
|
print_wp(&temp, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_sonar()
|
2011-02-20 19:09:28 -04:00
|
|
|
{
|
|
|
|
g.sonar_enabled.load();
|
2011-03-26 03:35:52 -03:00
|
|
|
Serial.printf_P(PSTR("Sonar\n"));
|
2011-02-20 19:09:28 -04:00
|
|
|
print_divider();
|
|
|
|
print_enabled(g.sonar_enabled.get());
|
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_frame()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("Frame\n"));
|
|
|
|
print_divider();
|
|
|
|
|
2011-05-18 20:38:24 -03:00
|
|
|
#if FRAME_CONFIG == QUAD_FRAME
|
|
|
|
Serial.printf_P(PSTR("Quad frame\n"));
|
2011-05-14 23:02:09 -03:00
|
|
|
#elif FRAME_CONFIG == TRI_FRAME
|
|
|
|
Serial.printf_P(PSTR("TRI frame\n"));
|
2011-05-18 20:38:24 -03:00
|
|
|
#elif FRAME_CONFIG == HEXA_FRAME
|
|
|
|
Serial.printf_P(PSTR("Hexa frame\n"));
|
2011-05-14 23:02:09 -03:00
|
|
|
#elif FRAME_CONFIG == Y6_FRAME
|
|
|
|
Serial.printf_P(PSTR("Y6 frame\n"));
|
2011-05-23 23:14:18 -03:00
|
|
|
#elif FRAME_CONFIG == OCTA_FRAME
|
|
|
|
Serial.printf_P(PSTR("Octa frame\n"));
|
2011-06-12 09:14:10 -03:00
|
|
|
#elif FRAME_CONFIG == HELI_FRAME
|
|
|
|
Serial.printf_P(PSTR("Heli frame\n"));
|
2011-05-14 23:02:09 -03:00
|
|
|
#endif
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
#if FRAME_CONFIG != HELI_FRAME
|
2011-05-18 20:38:24 -03:00
|
|
|
if(g.frame_orientation == X_FRAME)
|
|
|
|
Serial.printf_P(PSTR("X mode\n"));
|
|
|
|
else if(g.frame_orientation == PLUS_FRAME)
|
|
|
|
Serial.printf_P(PSTR("+ mode\n"));
|
2011-06-24 14:09:59 -03:00
|
|
|
else if(g.frame_orientation == V_FRAME)
|
|
|
|
Serial.printf_P(PSTR("V mode\n"));
|
2011-06-12 09:14:10 -03:00
|
|
|
#endif
|
2011-05-18 20:38:24 -03:00
|
|
|
|
2011-02-20 19:09:28 -04:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_radio()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("Radio\n"));
|
|
|
|
print_divider();
|
|
|
|
// radio
|
|
|
|
print_radio_values();
|
2011-02-20 19:09:28 -04:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2011-07-10 21:47:08 -03:00
|
|
|
/*
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_gains()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("Gains\n"));
|
|
|
|
print_divider();
|
|
|
|
|
2011-07-10 21:47:08 -03:00
|
|
|
// Rate
|
|
|
|
Serial.printf_P(PSTR("Rate:\nroll:\n"));
|
|
|
|
print_PID(&g.pid_rate_roll);
|
2011-01-20 03:11:21 -04:00
|
|
|
Serial.printf_P(PSTR("pitch:\n"));
|
2011-07-10 21:47:08 -03:00
|
|
|
print_PID(&g.pid_rate_pitch);
|
2011-01-20 03:11:21 -04:00
|
|
|
Serial.printf_P(PSTR("yaw:\n"));
|
2011-07-10 21:47:08 -03:00
|
|
|
print_PID(&g.pid_rate_yaw);
|
2011-01-20 03:11:21 -04:00
|
|
|
|
|
|
|
// Stabilize
|
|
|
|
Serial.printf_P(PSTR("\nStabilize:\nroll:\n"));
|
2011-02-17 03:09:13 -04:00
|
|
|
print_PID(&g.pid_stabilize_roll);
|
2011-01-20 03:11:21 -04:00
|
|
|
Serial.printf_P(PSTR("pitch:\n"));
|
2011-02-17 03:09:13 -04:00
|
|
|
print_PID(&g.pid_stabilize_pitch);
|
2011-01-20 03:11:21 -04:00
|
|
|
Serial.printf_P(PSTR("yaw:\n"));
|
2011-07-10 21:47:08 -03:00
|
|
|
print_PID(&g.pid_stabilize_yaw);
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-05-18 20:38:24 -03:00
|
|
|
//Serial.printf_P(PSTR("Stab D: %4.3f\n"), (float)g.stabilize_dampener);
|
|
|
|
//Serial.printf_P(PSTR("Yaw D: %4.3f\n\n"), (float)g.hold_yaw_dampener);
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
// Nav
|
|
|
|
Serial.printf_P(PSTR("Nav:\nlat:\n"));
|
2011-02-17 03:09:13 -04:00
|
|
|
print_PID(&g.pid_nav_lat);
|
2011-01-20 03:11:21 -04:00
|
|
|
Serial.printf_P(PSTR("long:\n"));
|
2011-02-17 03:09:13 -04:00
|
|
|
print_PID(&g.pid_nav_lon);
|
2011-07-10 21:47:08 -03:00
|
|
|
Serial.printf_P(PSTR("throttle:\n"));
|
|
|
|
print_PID(&g.pid_throttle);
|
2011-02-20 19:09:28 -04:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
2011-07-10 21:47:08 -03:00
|
|
|
*/
|
2011-01-20 03:11:21 -04:00
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
/*static void report_xtrack()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
2011-03-26 03:35:52 -03:00
|
|
|
Serial.printf_P(PSTR("XTrack\n"));
|
2011-01-20 03:11:21 -04:00
|
|
|
print_divider();
|
|
|
|
// radio
|
|
|
|
Serial.printf_P(PSTR("XTRACK: %4.2f\n"
|
|
|
|
"XTRACK angle: %d\n"
|
2011-01-29 22:36:03 -04:00
|
|
|
"PITCH_MAX: %ld"),
|
2011-02-19 17:04:05 -04:00
|
|
|
(float)g.crosstrack_gain,
|
|
|
|
(int)g.crosstrack_entry_angle,
|
|
|
|
(long)g.pitch_max);
|
2011-02-20 19:09:28 -04:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
2011-07-10 21:47:08 -03:00
|
|
|
*/
|
2011-01-20 03:11:21 -04:00
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
/*static void report_throttle()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("Throttle\n"));
|
|
|
|
print_divider();
|
|
|
|
|
|
|
|
Serial.printf_P(PSTR("min: %d\n"
|
|
|
|
"max: %d\n"
|
|
|
|
"cruise: %d\n"
|
|
|
|
"failsafe_enabled: %d\n"
|
|
|
|
"failsafe_value: %d"),
|
2011-02-19 17:04:05 -04:00
|
|
|
(int)g.throttle_min,
|
|
|
|
(int)g.throttle_max,
|
|
|
|
(int)g.throttle_cruise,
|
2011-02-19 22:03:01 -04:00
|
|
|
(int)g.throttle_fs_enabled,
|
|
|
|
(int)g.throttle_fs_value);
|
2011-02-20 19:09:28 -04:00
|
|
|
print_blanks(2);
|
2011-07-10 21:47:08 -03:00
|
|
|
}*/
|
2011-01-20 03:11:21 -04:00
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_imu()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("IMU\n"));
|
|
|
|
print_divider();
|
|
|
|
|
2011-02-18 23:59:58 -04:00
|
|
|
print_gyro_offsets();
|
|
|
|
print_accel_offsets();
|
2011-02-20 19:09:28 -04:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_compass()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("Compass\n"));
|
|
|
|
print_divider();
|
|
|
|
|
2011-02-17 03:09:13 -04:00
|
|
|
print_enabled(g.compass_enabled);
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
// mag declination
|
2011-03-26 03:35:52 -03:00
|
|
|
Serial.printf_P(PSTR("Mag Dec: %4.4f\n"),
|
2011-02-18 23:59:58 -04:00
|
|
|
degrees(compass.get_declination()));
|
2011-02-19 22:03:01 -04:00
|
|
|
|
2011-02-18 23:59:58 -04:00
|
|
|
Vector3f offsets = compass.get_offsets();
|
2011-02-17 05:36:33 -04:00
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
// mag offsets
|
|
|
|
Serial.printf_P(PSTR("Mag offsets: %4.4f, %4.4f, %4.4f"),
|
2011-02-18 23:59:58 -04:00
|
|
|
offsets.x,
|
|
|
|
offsets.y,
|
|
|
|
offsets.z);
|
2011-02-20 19:09:28 -04:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_flight_modes()
|
2011-01-20 03:11:21 -04:00
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("Flight modes\n"));
|
|
|
|
print_divider();
|
2011-02-19 17:04:05 -04:00
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
for(int i = 0; i < 6; i++ ){
|
2011-07-17 07:30:53 -03:00
|
|
|
print_switch(i, flight_modes[i]);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
2011-02-20 19:09:28 -04:00
|
|
|
print_blanks(2);
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
|
|
|
|
2011-07-21 20:14:53 -03:00
|
|
|
#ifdef OPTFLOW_ENABLED
|
|
|
|
void report_optflow()
|
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("OptFlow\n"));
|
|
|
|
print_divider();
|
|
|
|
|
|
|
|
print_enabled(g.optflow_enabled);
|
|
|
|
|
|
|
|
// field of view
|
|
|
|
//Serial.printf_P(PSTR("FOV: %4.0f\n"),
|
|
|
|
// degrees(g.optflow_fov));
|
|
|
|
|
|
|
|
print_blanks(2);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
#if FRAME_CONFIG == HELI_FRAME
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_heli()
|
2011-06-12 09:14:10 -03:00
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("Heli\n"));
|
|
|
|
print_divider();
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
// main servo settings
|
|
|
|
Serial.printf_P(PSTR("Servo \tpos \tmin \tmax \trev\n"));
|
|
|
|
Serial.printf_P(PSTR("1:\t%d \t%d \t%d \t%d\n"),(int)g.heli_servo1_pos, (int)g.heli_servo_1.radio_min, (int)g.heli_servo_1.radio_max, (int)g.heli_servo_1.get_reverse());
|
|
|
|
Serial.printf_P(PSTR("2:\t%d \t%d \t%d \t%d\n"),(int)g.heli_servo2_pos, (int)g.heli_servo_2.radio_min, (int)g.heli_servo_2.radio_max, (int)g.heli_servo_2.get_reverse());
|
|
|
|
Serial.printf_P(PSTR("3:\t%d \t%d \t%d \t%d\n"),(int)g.heli_servo3_pos, (int)g.heli_servo_3.radio_min, (int)g.heli_servo_3.radio_max, (int)g.heli_servo_3.get_reverse());
|
|
|
|
Serial.printf_P(PSTR("tail:\t\t%d \t%d \t%d\n"), (int)g.heli_servo_4.radio_min, (int)g.heli_servo_4.radio_max, (int)g.heli_servo_4.get_reverse());
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
Serial.printf_P(PSTR("roll max: \t%d\n"), (int)g.heli_roll_max);
|
|
|
|
Serial.printf_P(PSTR("pitch max: \t%d\n"), (int)g.heli_pitch_max);
|
|
|
|
Serial.printf_P(PSTR("coll min:\t%d\t mid:%d\t max:%d\n"),(int)g.heli_coll_min, (int)g.heli_coll_mid, (int)g.heli_coll_max);
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
print_blanks(2);
|
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void report_gyro()
|
2011-06-12 09:14:10 -03:00
|
|
|
{
|
|
|
|
|
|
|
|
Serial.printf_P(PSTR("External Gyro:\n"));
|
|
|
|
print_divider();
|
|
|
|
|
|
|
|
print_enabled( g.heli_ext_gyro_enabled );
|
|
|
|
if( g.heli_ext_gyro_enabled )
|
|
|
|
Serial.printf_P(PSTR("gain: %d"),(int)g.heli_ext_gyro_gain);
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
print_blanks(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // FRAME_CONFIG == HELI_FRAME
|
|
|
|
|
2011-01-20 03:11:21 -04:00
|
|
|
/***************************************************************************/
|
|
|
|
// CLI utilities
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
/*static void
|
2011-01-20 03:11:21 -04:00
|
|
|
print_PID(PID * pid)
|
|
|
|
{
|
2011-05-14 23:02:09 -03:00
|
|
|
Serial.printf_P(PSTR("P: %4.2f, I:%4.2f, D:%4.2f, IMAX:%ld\n"),
|
2011-03-26 03:35:52 -03:00
|
|
|
pid->kP(),
|
|
|
|
pid->kI(),
|
|
|
|
pid->kD(),
|
|
|
|
(long)pid->imax());
|
2011-01-20 03:11:21 -04:00
|
|
|
}
|
2011-07-10 21:47:08 -03:00
|
|
|
*/
|
2011-01-20 03:11:21 -04:00
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void
|
2011-01-20 03:11:21 -04:00
|
|
|
print_radio_values()
|
|
|
|
{
|
2011-02-19 17:04:05 -04:00
|
|
|
Serial.printf_P(PSTR("CH1: %d | %d\n"), (int)g.rc_1.radio_min, (int)g.rc_1.radio_max);
|
|
|
|
Serial.printf_P(PSTR("CH2: %d | %d\n"), (int)g.rc_2.radio_min, (int)g.rc_2.radio_max);
|
|
|
|
Serial.printf_P(PSTR("CH3: %d | %d\n"), (int)g.rc_3.radio_min, (int)g.rc_3.radio_max);
|
|
|
|
Serial.printf_P(PSTR("CH4: %d | %d\n"), (int)g.rc_4.radio_min, (int)g.rc_4.radio_max);
|
|
|
|
Serial.printf_P(PSTR("CH5: %d | %d\n"), (int)g.rc_5.radio_min, (int)g.rc_5.radio_max);
|
|
|
|
Serial.printf_P(PSTR("CH6: %d | %d\n"), (int)g.rc_6.radio_min, (int)g.rc_6.radio_max);
|
|
|
|
Serial.printf_P(PSTR("CH7: %d | %d\n"), (int)g.rc_7.radio_min, (int)g.rc_7.radio_max);
|
2011-05-14 23:02:09 -03:00
|
|
|
//Serial.printf_P(PSTR("CH8: %d | %d\n"), (int)g.rc_8.radio_min, (int)g.rc_8.radio_max);
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void
|
2010-12-19 12:40:33 -04:00
|
|
|
print_switch(byte p, byte m)
|
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("Pos %d: "),p);
|
|
|
|
Serial.println(flight_mode_strings[m]);
|
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void
|
2010-12-19 12:40:33 -04:00
|
|
|
print_done()
|
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("\nSaved Settings\n\n"));
|
|
|
|
}
|
|
|
|
|
2011-03-26 03:35:52 -03:00
|
|
|
// read at 50Hz
|
2011-07-17 07:32:00 -03:00
|
|
|
static bool
|
2010-12-19 12:40:33 -04:00
|
|
|
radio_input_switch(void)
|
|
|
|
{
|
2011-02-19 18:44:52 -04:00
|
|
|
static int8_t bouncer = 0;
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-02-19 18:44:52 -04:00
|
|
|
if (int16_t(g.rc_1.radio_in - g.rc_1.radio_trim) > 100) {
|
|
|
|
bouncer = 10;
|
|
|
|
}
|
|
|
|
if (int16_t(g.rc_1.radio_in - g.rc_1.radio_trim) < -100) {
|
|
|
|
bouncer = -10;
|
|
|
|
}
|
|
|
|
if (bouncer >0) {
|
|
|
|
bouncer --;
|
|
|
|
}
|
|
|
|
if (bouncer <0) {
|
|
|
|
bouncer ++;
|
|
|
|
}
|
2010-12-19 12:40:33 -04:00
|
|
|
|
2011-02-19 18:44:52 -04:00
|
|
|
if (bouncer == 1 || bouncer == -1) {
|
|
|
|
return bouncer;
|
2011-02-24 01:56:59 -04:00
|
|
|
}else{
|
2011-02-19 18:44:52 -04:00
|
|
|
return 0;
|
2010-12-19 12:40:33 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void zero_eeprom(void)
|
2010-12-19 12:40:33 -04:00
|
|
|
{
|
2011-06-16 14:03:26 -03:00
|
|
|
byte b = 0;
|
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
Serial.printf_P(PSTR("\nErasing EEPROM\n"));
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
for (int i = 0; i < EEPROM_MAX_ADDR; i++) {
|
|
|
|
eeprom_write_byte((uint8_t *) i, b);
|
|
|
|
}
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2010-12-19 12:40:33 -04:00
|
|
|
Serial.printf_P(PSTR("done\n"));
|
|
|
|
}
|
2011-01-20 03:11:21 -04:00
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void
|
2011-02-18 23:59:58 -04:00
|
|
|
print_accel_offsets(void)
|
|
|
|
{
|
2011-02-21 00:46:26 -04:00
|
|
|
Serial.printf_P(PSTR("Accel offsets: %4.2f, %4.2f, %4.2f\n"),
|
2011-02-20 15:07:35 -04:00
|
|
|
(float)imu.ax(),
|
|
|
|
(float)imu.ay(),
|
2011-02-21 00:46:26 -04:00
|
|
|
(float)imu.az());
|
2011-02-18 23:59:58 -04:00
|
|
|
}
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static void
|
2011-02-18 23:59:58 -04:00
|
|
|
print_gyro_offsets(void)
|
|
|
|
{
|
2011-02-21 00:46:26 -04:00
|
|
|
Serial.printf_P(PSTR("Gyro offsets: %4.2f, %4.2f, %4.2f\n"),
|
2011-02-20 15:07:35 -04:00
|
|
|
(float)imu.gx(),
|
|
|
|
(float)imu.gy(),
|
2011-02-21 00:46:26 -04:00
|
|
|
(float)imu.gz());
|
2011-02-18 23:59:58 -04:00
|
|
|
}
|
|
|
|
|
2011-06-16 14:03:26 -03:00
|
|
|
#if FRAME_CONFIG == HELI_FRAME
|
|
|
|
|
2011-07-17 07:32:00 -03:00
|
|
|
static RC_Channel *
|
2011-06-12 09:14:10 -03:00
|
|
|
heli_get_servo(int servo_num){
|
|
|
|
if( servo_num == CH_1 )
|
|
|
|
return &g.heli_servo_1;
|
|
|
|
if( servo_num == CH_2 )
|
|
|
|
return &g.heli_servo_2;
|
|
|
|
if( servo_num == CH_3 )
|
|
|
|
return &g.heli_servo_3;
|
|
|
|
if( servo_num == CH_4 )
|
|
|
|
return &g.heli_servo_4;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used to read integer values from the serial port
|
2011-07-17 07:32:00 -03:00
|
|
|
static int read_num_from_serial() {
|
2011-06-12 09:14:10 -03:00
|
|
|
byte index = 0;
|
|
|
|
byte timeout = 0;
|
|
|
|
char data[5] = "";
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (Serial.available() == 0) {
|
|
|
|
delay(10);
|
|
|
|
timeout++;
|
|
|
|
}else{
|
|
|
|
data[index] = Serial.read();
|
|
|
|
timeout = 0;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
}while (timeout < 5 && index < 5);
|
2011-06-16 14:03:26 -03:00
|
|
|
|
2011-06-12 09:14:10 -03:00
|
|
|
return atoi(data);
|
|
|
|
}
|
2011-06-24 14:09:59 -03:00
|
|
|
#endif
|
2011-07-17 07:34:05 -03:00
|
|
|
|
|
|
|
#endif // CLI_ENABLED
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_blanks(int num)
|
|
|
|
{
|
|
|
|
while(num > 0){
|
|
|
|
num--;
|
|
|
|
Serial.println("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_divider(void)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 40; i++) {
|
|
|
|
Serial.print("-");
|
|
|
|
}
|
|
|
|
Serial.println("");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_enabled(boolean b)
|
|
|
|
{
|
|
|
|
if(b)
|
|
|
|
Serial.printf_P(PSTR("en"));
|
|
|
|
else
|
|
|
|
Serial.printf_P(PSTR("dis"));
|
|
|
|
Serial.printf_P(PSTR("abled\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_esc()
|
|
|
|
{
|
|
|
|
g.esc_calibrate.set_and_save(0);
|
|
|
|
while(1){
|
|
|
|
read_radio();
|
|
|
|
delay(100);
|
|
|
|
dancing_light();
|
|
|
|
APM_RC.OutputCh(CH_1, g.rc_3.radio_in);
|
|
|
|
APM_RC.OutputCh(CH_2, g.rc_3.radio_in);
|
|
|
|
APM_RC.OutputCh(CH_3, g.rc_3.radio_in);
|
|
|
|
APM_RC.OutputCh(CH_4, g.rc_3.radio_in);
|
|
|
|
APM_RC.OutputCh(CH_7, g.rc_3.radio_in);
|
|
|
|
APM_RC.OutputCh(CH_8, g.rc_3.radio_in);
|
|
|
|
|
|
|
|
#if FRAME_CONFIG == OCTA_FRAME
|
|
|
|
APM_RC.OutputCh(CH_10, g.rc_3.radio_in);
|
|
|
|
APM_RC.OutputCh(CH_11, g.rc_3.radio_in);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_wp(struct Location *cmd, byte index)
|
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("command #: %d id:%d op:%d p1:%d p2:%ld p3:%ld p4:%ld \n"),
|
|
|
|
(int)index,
|
|
|
|
(int)cmd->id,
|
|
|
|
(int)cmd->options,
|
|
|
|
(int)cmd->p1,
|
|
|
|
cmd->alt,
|
|
|
|
cmd->lat,
|
|
|
|
cmd->lng);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void report_gps()
|
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("\nGPS\n"));
|
|
|
|
print_divider();
|
|
|
|
print_enabled(GPS_enabled);
|
|
|
|
print_blanks(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void report_version()
|
|
|
|
{
|
|
|
|
Serial.printf_P(PSTR("FW Version %d\n"),(int)g.format_version.get());
|
|
|
|
print_divider();
|
|
|
|
print_blanks(2);
|
|
|
|
}
|
|
|
|
|