#define AO_CONFIG_DEFAULT_CALLSIGN "N0CALL"
#define AO_CONFIG_DEFAULT_ACCEL_ZERO_G 16000
#define AO_CONFIG_DEFAULT_APOGEE_DELAY 0
-/*
- * For 434.550MHz, the frequency value is:
- *
- * 434.550e6 / (24e6 / 2**16) = 1186611.2
- *
- * This value is stored in a const variable so that
- * ao-load can change it during programming for
- * devices that have no eeprom for config data.
- */
-const uint32_t ao_radio_cal = 1186611;
+#if HAS_EEPROM
static void
_ao_config_put(void)
{
ao_ee_write_config((uint8_t *) &ao_config, sizeof (ao_config));
}
+#endif
static void
_ao_config_get(void)
{
if (ao_config_loaded)
return;
+#if HAS_EEPROM
ao_ee_read_config((uint8_t *) &ao_config, sizeof (ao_config));
+#endif
if (ao_config.major != AO_CONFIG_MAJOR) {
ao_config.major = AO_CONFIG_MAJOR;
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
ao_mutex_put(&ao_config_mutex);
ao_config_radio_channel_show();
+ ao_radio_abort();
}
+#if HAS_ADC
+
void
ao_config_main_deploy_show(void) __reentrant
{
ao_config_apogee_delay_show();
}
+#endif /* HAS_ADC */
+
void
ao_config_radio_cal_show(void) __reentrant
{
ao_config_write(void) __reentrant;
__code struct ao_config_var ao_config_vars[] = {
+#if HAS_ADC
{ 'm', ao_config_main_deploy_set, ao_config_main_deploy_show,
"m <meters> Set height above launch for main deploy (in meters)" },
{ 'd', ao_config_apogee_delay_set, ao_config_apogee_delay_show,
"d <delay> Set apogee igniter delay (in seconds)" },
+#endif /* HAS_ADC */
{ 'r', ao_config_radio_channel_set, ao_config_radio_channel_show,
"r <channel> Set radio channel (freq = 434.550 + channel * .1)" },
{ 'c', ao_config_callsign_set, ao_config_callsign_show,
"c <call> Set callsign broadcast in each packet (8 char max)" },
+#if HAS_ADC
{ 'a', ao_config_accel_calibrate_set, ao_config_accel_calibrate_show,
"a <+g> <-g> Set accelerometer calibration (0 for auto)" },
+#endif /* HAS_ADC */
{ 'f', ao_config_radio_cal_set, ao_config_radio_cal_show,
"f <cal> Set radio calibration value (cal = rf/(xtal/2^16))" },
{ 's', ao_config_show, ao_config_show,
"s Show current config values" },
+#if HAS_EEPROM
{ 'w', ao_config_write, ao_config_write,
"w Write current values to eeprom" },
+#endif
{ '?', ao_config_help, ao_config_help,
"? Show available config variables" },
- { 0, ao_config_main_deploy_set, ao_config_main_deploy_show,
+ { 0, ao_config_help, ao_config_help,
NULL },
};
(*ao_config_vars[cmd].show)();
}
+#if HAS_EEPROM
void
ao_config_write(void) __reentrant
{
+ uint8_t saved = 0;
ao_mutex_get(&ao_config_mutex);
if (ao_config_dirty) {
_ao_config_put();
ao_config_dirty = 0;
- printf("Saved\n");
+ saved = 1;
}
ao_mutex_put(&ao_config_mutex);
+ if (saved)
+ puts("Saved");
+ else
+ puts("Nothing to save");
}
+#endif
__code struct ao_cmds ao_config_cmds[] = {
{ 'c', ao_config_set, "c <var> <value> Set config variable (? for help, s to show)" },