X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_config.c;h=88b52dc05950ebfe37f950bdb7673551387b63b2;hp=4349bca856ac3a18e97aba1fe62f0939f3dc251d;hb=8d8980f56a4f2c7d6f2ce667130706e0f04f8ded;hpb=5481082b18226a0de6b377215b3b330bdbc4a6c6 diff --git a/src/ao_config.c b/src/ao_config.c index 4349bca8..88b52dc0 100644 --- a/src/ao_config.c +++ b/src/ao_config.c @@ -27,29 +27,23 @@ __xdata uint8_t ao_config_mutex; #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; @@ -147,8 +141,11 @@ ao_config_radio_channel_set(void) __reentrant 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 { @@ -259,6 +256,8 @@ ao_config_apogee_delay_set(void) __reentrant ao_config_apogee_delay_show(); } +#endif /* HAS_ADC */ + void ao_config_radio_cal_show(void) __reentrant { @@ -296,25 +295,31 @@ void 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 Set height above launch for main deploy (in meters)" }, { 'd', ao_config_apogee_delay_set, ao_config_apogee_delay_show, "d Set apogee igniter delay (in seconds)" }, +#endif /* HAS_ADC */ { 'r', ao_config_radio_channel_set, ao_config_radio_channel_show, "r Set radio channel (freq = 434.550 + channel * .1)" }, { 'c', ao_config_callsign_set, ao_config_callsign_show, "c 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 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 }, }; @@ -359,17 +364,24 @@ ao_config_show(void) __reentrant (*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 Set config variable (? for help, s to show)" },