2015-05-13 00:16:45 -03:00
|
|
|
#include "Rover.h"
|
|
|
|
|
2012-04-30 04:17:14 -03:00
|
|
|
#if CLI_ENABLED == ENABLED
|
|
|
|
|
|
|
|
// Command/function table for the setup menu
|
2015-10-25 14:03:46 -03:00
|
|
|
static const struct Menu::command setup_menu_commands[] = {
|
2016-12-20 09:33:55 -04:00
|
|
|
// command function called
|
|
|
|
// ======= ===============
|
|
|
|
{"erase", MENU_FUNC(setup_erase)}
|
2012-04-30 04:17:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
// Create the setup menu object.
|
|
|
|
MENU(setup_menu, "setup", setup_menu_commands);
|
|
|
|
|
|
|
|
// Called from the top-level menu to run the setup menu.
|
2015-05-12 04:00:25 -03:00
|
|
|
int8_t Rover::setup_mode(uint8_t argc, const Menu::arg *argv)
|
2012-04-30 04:17:14 -03:00
|
|
|
{
|
2016-12-20 09:33:55 -04:00
|
|
|
// Give the user some guidance
|
|
|
|
cliSerial->printf("Setup Mode\n"
|
|
|
|
"\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");
|
|
|
|
|
|
|
|
// Run the setup menu. When the menu exits, we will return to the main menu.
|
|
|
|
setup_menu.run();
|
2012-04-30 04:17:14 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-12 04:00:25 -03:00
|
|
|
int8_t Rover::setup_erase(uint8_t argc, const Menu::arg *argv)
|
2012-04-30 04:17:14 -03:00
|
|
|
{
|
2016-12-20 09:33:55 -04:00
|
|
|
int c;
|
2012-04-30 04:17:14 -03:00
|
|
|
|
2016-12-20 09:33:55 -04:00
|
|
|
cliSerial->printf("\nType 'Y' and hit Enter to erase all waypoint and parameter data, any other key to abort: ");
|
2012-04-30 04:17:14 -03:00
|
|
|
|
2016-12-20 09:33:55 -04:00
|
|
|
do {
|
|
|
|
c = cliSerial->read();
|
|
|
|
} while (-1 == c);
|
2012-04-30 04:17:14 -03:00
|
|
|
|
2016-12-20 09:33:55 -04:00
|
|
|
if (('y' != c) && ('Y' != c)) {
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
zero_eeprom();
|
|
|
|
return 0;
|
2012-04-30 04:17:14 -03:00
|
|
|
}
|
|
|
|
|
2015-05-12 02:03:23 -03:00
|
|
|
void Rover::zero_eeprom(void)
|
2012-04-30 04:17:14 -03:00
|
|
|
{
|
2016-12-20 09:33:55 -04:00
|
|
|
cliSerial->printf("\nErasing EEPROM\n");
|
2014-08-13 01:44:46 -03:00
|
|
|
StorageManager::erase();
|
2017-01-21 00:33:27 -04:00
|
|
|
cliSerial->printf("done\n");
|
2012-04-30 04:17:14 -03:00
|
|
|
}
|
|
|
|
|
2016-12-20 09:33:55 -04:00
|
|
|
#endif // CLI_ENABLED
|