2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 #include <ao_config.h>
23 #include <ao_sample.h>
30 #include <ao_tracker.h>
33 __xdata struct ao_config ao_config;
34 __pdata uint8_t ao_config_loaded;
35 __pdata uint8_t ao_config_dirty;
36 __xdata uint8_t ao_config_mutex;
39 __xdata uint8_t ao_force_freq;
42 #ifndef AO_CONFIG_DEFAULT_APRS_INTERVAL
43 #define AO_CONFIG_DEFAULT_APRS_INTERVAL 0
45 #define AO_CONFIG_DEFAULT_MAIN_DEPLOY 250
46 #define AO_CONFIG_DEFAULT_RADIO_CHANNEL 0
47 #define AO_CONFIG_DEFAULT_CALLSIGN "N0CALL"
48 #define AO_CONFIG_DEFAULT_ACCEL_ZERO_G 16000
49 #define AO_CONFIG_DEFAULT_APOGEE_DELAY 0
50 #define AO_CONFIG_DEFAULT_IGNITE_MODE AO_IGNITE_MODE_DUAL
51 #define AO_CONFIG_DEFAULT_PAD_ORIENTATION AO_PAD_ORIENTATION_ANTENNA_UP
52 #define AO_CONFIG_DEFAULT_PYRO_TIME AO_MS_TO_TICKS(50)
54 #ifndef USE_INTERNAL_FLASH
55 #error Please define USE_INTERNAL_FLASH
59 #ifndef AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX
60 # if FLIGHT_LOG_APPEND
61 # define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ao_storage_log_max
63 # if USE_INTERNAL_FLASH
64 # define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ao_storage_config
66 # define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ((uint32_t) 192 * (uint32_t) 1024)
71 #ifndef AO_CONFIG_DEFAULT_RADIO_POWER
72 #define AO_CONFIG_DEFAULT_RADIO_POWER 0x60
74 #define AO_CONFIG_DEFAULT_RADIO_AMP 0
75 #define AO_CONFIG_DEFAULT_APRS_SSID (ao_serial_number % 10)
76 #define AO_CONFIG_DEFAULT_RADIO_RATE AO_RADIO_RATE_38400
84 ao_config_write(0, &ao_config, sizeof (ao_config));
86 ao_log_write_erase(0);
94 ao_mutex_get(&ao_config_mutex);
96 ao_mutex_put(&ao_config_mutex);
102 #if HAS_RADIO_FORWARD
103 __xdata uint32_t ao_send_radio_setting;
107 ao_config_set_radio(void)
109 ao_config.radio_setting = ao_freq_to_set(ao_config.frequency, ao_config.radio_cal);
110 #if HAS_RADIO_FORWARD
111 ao_send_radio_setting = ao_freq_to_set(ao_config.send_frequency, ao_config.radio_cal);
114 #endif /* HAS_RADIO */
121 if (ao_config_loaded)
124 /* Yes, I know ao_storage_read calls ao_storage_setup,
125 * but ao_storage_setup *also* sets ao_storage_config, which we
126 * need before calling ao_storage_read here
129 ao_config_read(0, &ao_config, sizeof (ao_config));
131 if (ao_config.major != AO_CONFIG_MAJOR) {
132 ao_config.major = AO_CONFIG_MAJOR;
135 /* Version 0 stuff */
136 ao_config.main_deploy = AO_CONFIG_DEFAULT_MAIN_DEPLOY;
137 ao_xmemset(&ao_config.callsign, '\0', sizeof (ao_config.callsign));
138 ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN),
139 sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
140 ao_config._legacy_radio_channel = 0;
142 minor = ao_config.minor;
143 if (minor != AO_CONFIG_MINOR) {
144 /* Fixups for minor version 1 */
146 ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
147 /* Fixups for minor version 2 */
149 ao_config.accel_plus_g = 0;
150 ao_config.accel_minus_g = 0;
152 /* Fixups for minor version 3 */
155 ao_config.radio_cal = ao_radio_cal;
157 /* Fixups for minor version 4 */
160 ao_config.flight_log_max = AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX;
162 /* Fixupes for minor version 5 */
164 ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE;
166 ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION;
168 ao_config.radio_enable = AO_RADIO_ENABLE_CORE;
170 ao_xmemset(&ao_config.aes_key, '\0', AO_AES_LEN);
172 ao_config.frequency = 434550 + ao_config._legacy_radio_channel * 100;
174 ao_config.apogee_lockout = 0;
177 memset(&ao_config.pyro, '\0', sizeof (ao_config.pyro));
180 ao_config.aprs_interval = AO_CONFIG_DEFAULT_APRS_INTERVAL;
183 ao_config.radio_power = AO_CONFIG_DEFAULT_RADIO_POWER;
187 ao_config.radio_amp = AO_CONFIG_DEFAULT_RADIO_AMP;
191 ao_config.accel_zero_along = 0;
192 ao_config.accel_zero_across = 0;
193 ao_config.accel_zero_through = 0;
195 /* Reset the main accel offsets to force
198 ao_config.accel_plus_g = 0;
199 ao_config.accel_minus_g = 0;
204 ao_config.mid_beep = AO_BEEP_MID_DEFAULT;
208 ao_config.tracker_motion = AO_TRACKER_MOTION_DEFAULT;
209 ao_config.tracker_interval = AO_TRACKER_INTERVAL_DEFAULT;
214 ao_config.pyro_time = AO_CONFIG_DEFAULT_PYRO_TIME;
218 ao_config.aprs_ssid = AO_CONFIG_DEFAULT_APRS_SSID;
222 ao_config.radio_rate = AO_CONFIG_DEFAULT_RADIO_RATE;
224 #if HAS_RADIO_FORWARD
226 ao_config.send_frequency = 434550;
230 ao_config.aprs_format = AO_CONFIG_DEFAULT_APRS_FORMAT;
234 #if HAS_FIXED_PAD_BOX
235 ao_config.pad_box = 1;
237 ao_config.pad_box = 0;
241 ao_config.pad_idle = 120;
243 ao_config.minor = AO_CONFIG_MINOR;
249 ao_config.frequency = 434550;
250 ao_config.radio_cal = ao_radio_cal;
252 ao_config.radio_rate = AO_CONFIG_DEFAULT_RADIO_RATE;
254 ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN),
255 sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
258 ao_config_set_radio();
260 ao_config_loaded = 1;
264 _ao_config_edit_start(void)
266 ao_mutex_get(&ao_config_mutex);
271 _ao_config_edit_finish(void)
274 ao_mutex_put(&ao_config_mutex);
280 _ao_config_edit_start();
281 ao_mutex_put(&ao_config_mutex);
285 ao_config_callsign_show(void)
287 printf ("Callsign: \"%s\"\n", ao_config.callsign);
291 ao_config_callsign_set(void) __reentrant
294 static __xdata char callsign[AO_MAX_CALLSIGN + 1];
296 ao_xmemset(callsign, '\0', sizeof callsign);
299 while (ao_cmd_lex_c != '\n') {
300 if (c < AO_MAX_CALLSIGN)
301 callsign[c++] = ao_cmd_lex_c;
303 ao_cmd_status = ao_cmd_lex_error;
306 if (ao_cmd_status != ao_cmd_success)
308 _ao_config_edit_start();
309 ao_xmemcpy(&ao_config.callsign, &callsign,
310 AO_MAX_CALLSIGN + 1);
311 _ao_config_edit_finish();
317 ao_config_frequency_show(void) __reentrant
319 printf("Frequency: %ld\n",
320 ao_config.frequency);
324 ao_config_frequency_set(void) __reentrant
327 if (ao_cmd_status != ao_cmd_success)
329 _ao_config_edit_start();
330 ao_config.frequency = ao_cmd_lex_u32;
331 ao_config_set_radio();
332 _ao_config_edit_finish();
334 ao_radio_recv_abort();
340 #if HAS_RADIO_FORWARD
342 ao_config_send_frequency_show(void) __reentrant
344 printf("Send frequency: %ld\n",
345 ao_config.send_frequency);
349 ao_config_send_frequency_set(void) __reentrant
352 if (ao_cmd_status != ao_cmd_success)
354 _ao_config_edit_start();
355 ao_config.send_frequency = ao_cmd_lex_u32;
356 ao_config_set_radio();
357 _ao_config_edit_finish();
359 ao_radio_recv_abort();
368 ao_config_main_deploy_show(void) __reentrant
370 printf("Main deploy: %d meters\n",
371 ao_config.main_deploy);
375 ao_config_main_deploy_set(void) __reentrant
378 if (ao_cmd_status != ao_cmd_success)
380 _ao_config_edit_start();
381 ao_config.main_deploy = ao_cmd_lex_i;
382 _ao_config_edit_finish();
387 ao_config_accel_calibrate_show(void) __reentrant
389 printf("Accel cal +1g: %d -1g: %d\n",
390 ao_config.accel_plus_g, ao_config.accel_minus_g);
392 printf ("IMU cal along %d across %d through %d\n",
393 ao_config.accel_zero_along,
394 ao_config.accel_zero_across,
395 ao_config.accel_zero_through);
399 #define ACCEL_CALIBRATE_SAMPLES 1024
400 #define ACCEL_CALIBRATE_SHIFT 10
403 static int16_t accel_cal_along;
404 static int16_t accel_cal_across;
405 static int16_t accel_cal_through;
409 ao_config_accel_calibrate_auto(char *orientation) __reentrant
413 uint8_t cal_data_ring;
415 int32_t accel_along_total = 0;
416 int32_t accel_across_total = 0;
417 int32_t accel_through_total = 0;
420 printf("Orient antenna %s and press a key...", orientation);
423 puts("\r\n"); flush();
424 puts("Calibrating..."); flush();
425 i = ACCEL_CALIBRATE_SAMPLES;
427 cal_data_ring = ao_sample_data;
429 ao_sleep(DATA_TO_XDATA(&ao_sample_data));
430 while (i && cal_data_ring != ao_sample_data) {
431 accel_total += (int32_t) ao_data_accel(&ao_data_ring[cal_data_ring]);
433 accel_along_total += (int32_t) ao_data_along(&ao_data_ring[cal_data_ring]);
434 accel_across_total += (int32_t) ao_data_across(&ao_data_ring[cal_data_ring]);
435 accel_through_total += (int32_t) ao_data_through(&ao_data_ring[cal_data_ring]);
437 cal_data_ring = ao_data_ring_next(cal_data_ring);
442 accel_cal_along = accel_along_total >> ACCEL_CALIBRATE_SHIFT;
443 accel_cal_across = accel_across_total >> ACCEL_CALIBRATE_SHIFT;
444 accel_cal_through = accel_through_total >> ACCEL_CALIBRATE_SHIFT;
446 return accel_total >> ACCEL_CALIBRATE_SHIFT;
450 ao_config_accel_calibrate_set(void) __reentrant
454 int16_t accel_along_up = 0, accel_along_down = 0;
455 int16_t accel_across_up = 0, accel_across_down = 0;
456 int16_t accel_through_up = 0, accel_through_down = 0;
460 if (ao_cmd_status != ao_cmd_success)
462 if (ao_cmd_lex_i == 0) {
463 up = ao_config_accel_calibrate_auto("up");
465 accel_along_up = accel_cal_along;
466 accel_across_up = accel_cal_across;
467 accel_through_up = accel_cal_through;
469 down = ao_config_accel_calibrate_auto("down");
471 accel_along_down = accel_cal_along;
472 accel_across_down = accel_cal_across;
473 accel_through_down = accel_cal_through;
478 if (ao_cmd_status != ao_cmd_success)
483 printf("Invalid accel: up (%d) down (%d)\n",
487 _ao_config_edit_start();
488 ao_config.accel_plus_g = up;
489 ao_config.accel_minus_g = down;
491 if (ao_cmd_lex_i == 0) {
492 ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2;
493 ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2;
494 ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2;
497 _ao_config_edit_finish();
499 #endif /* HAS_ACCEL */
502 ao_config_apogee_delay_show(void) __reentrant
504 printf("Apogee delay: %d seconds\n",
505 ao_config.apogee_delay);
509 ao_config_apogee_delay_set(void) __reentrant
512 if (ao_cmd_status != ao_cmd_success)
514 _ao_config_edit_start();
515 ao_config.apogee_delay = ao_cmd_lex_i;
516 _ao_config_edit_finish();
520 ao_config_apogee_lockout_show(void) __reentrant
522 printf ("Apogee lockout: %d seconds\n",
523 ao_config.apogee_lockout);
527 ao_config_apogee_lockout_set(void) __reentrant
530 if (ao_cmd_status != ao_cmd_success)
532 _ao_config_edit_start();
533 ao_config.apogee_lockout = ao_cmd_lex_i;
534 _ao_config_edit_finish();
537 #endif /* HAS_FLIGHT */
541 ao_config_radio_cal_show(void) __reentrant
543 printf("Radio cal: %ld\n", ao_config.radio_cal);
547 ao_config_radio_cal_set(void) __reentrant
550 if (ao_cmd_status != ao_cmd_success)
552 _ao_config_edit_start();
553 ao_config.radio_cal = ao_cmd_lex_u32;
554 ao_config_set_radio();
555 _ao_config_edit_finish();
561 #ifndef HAS_TELEMETRY
562 #error Please define HAS_TELEMETRY
566 ao_config_radio_rate_show(void) __reentrant
568 printf("Telemetry rate: %d\n", ao_config.radio_rate);
572 ao_config_radio_rate_set(void) __reentrant
575 if (ao_cmd_status != ao_cmd_success)
577 if (AO_RADIO_RATE_MAX < ao_cmd_lex_i) {
578 ao_cmd_status = ao_cmd_lex_error;
581 _ao_config_edit_start();
582 ao_config.radio_rate = ao_cmd_lex_i;
583 _ao_config_edit_finish();
585 ao_telemetry_reset_interval();
588 ao_radio_recv_abort();
596 ao_config_log_show(void) __reentrant
598 printf("Max flight log: %d kB\n", (int16_t) (ao_config.flight_log_max >> 10));
599 #if FLIGHT_LOG_APPEND
600 printf("Log fixed: 1\n");
604 #if FLIGHT_LOG_APPEND
606 ao_config_log_fix_append(void)
608 _ao_config_edit_start();
609 ao_config.flight_log_max = ao_storage_log_max;
610 _ao_config_edit_finish();
611 ao_mutex_get(&ao_config_mutex);
614 ao_mutex_put(&ao_config_mutex);
619 ao_config_log_set(void) __reentrant
621 #if FLIGHT_LOG_APPEND
622 printf("Flight log fixed size %d kB\n", ao_storage_log_max >> 10);
624 uint16_t block = (uint16_t) (ao_storage_block >> 10);
625 uint16_t log_max = (uint16_t) (ao_storage_log_max >> 10);
628 if (ao_cmd_status != ao_cmd_success)
630 if (ao_log_present())
631 printf("Storage must be empty before changing log size\n");
632 else if (block > 1024 && (ao_cmd_lex_i & (block - 1)))
633 printf("Flight log size must be multiple of %d kB\n", block);
634 else if (ao_cmd_lex_i > log_max)
635 printf("Flight log max %d kB\n", log_max);
637 _ao_config_edit_start();
638 ao_config.flight_log_max = (uint32_t) ao_cmd_lex_i << 10;
639 _ao_config_edit_finish();
647 ao_config_ignite_mode_show(void) __reentrant
649 printf("Ignite mode: %d\n", ao_config.ignite_mode);
653 ao_config_ignite_mode_set(void) __reentrant
656 if (ao_cmd_status != ao_cmd_success)
658 _ao_config_edit_start();
659 ao_config.ignite_mode = ao_cmd_lex_i;
660 _ao_config_edit_finish();
666 ao_config_pad_orientation_show(void) __reentrant
668 printf("Pad orientation: %d\n", ao_config.pad_orientation);
671 #ifndef AO_ACCEL_INVERT
672 #define AO_ACCEL_INVERT 0x7fff
676 ao_config_pad_orientation_set(void) __reentrant
679 if (ao_cmd_status != ao_cmd_success)
681 _ao_config_edit_start();
683 if (ao_config.pad_orientation != ao_cmd_lex_i) {
685 t = ao_config.accel_plus_g;
686 ao_config.accel_plus_g = AO_ACCEL_INVERT - ao_config.accel_minus_g;
687 ao_config.accel_minus_g = AO_ACCEL_INVERT - t;
689 ao_config.pad_orientation = ao_cmd_lex_i;
690 _ao_config_edit_finish();
696 ao_config_radio_enable_show(void) __reentrant
698 printf("Radio enable: %d\n", ao_config.radio_enable);
702 ao_config_radio_enable_set(void) __reentrant
705 if (ao_cmd_status != ao_cmd_success)
707 _ao_config_edit_start();
708 ao_config.radio_enable = ao_cmd_lex_i;
709 _ao_config_edit_finish();
710 #if HAS_TELEMETRY && HAS_RADIO_RATE
711 ao_telemetry_reset_interval();
714 #endif /* HAS_RADIO */
718 __xdata uint8_t ao_config_aes_seq = 1;
721 ao_config_key_show(void) __reentrant
725 for (i = 0; i < AO_AES_LEN; i++)
726 printf ("%02x", ao_config.aes_key[i]);
731 ao_config_key_set(void) __reentrant
735 _ao_config_edit_start();
736 for (i = 0; i < AO_AES_LEN; i++) {
738 if (ao_cmd_status != ao_cmd_success)
740 ao_config.aes_key[i] = ao_cmd_lex_i;
743 _ao_config_edit_finish();
750 ao_config_aprs_show(void)
752 printf ("APRS interval: %d\n", ao_config.aprs_interval);
756 ao_config_aprs_set(void)
759 if (ao_cmd_status != ao_cmd_success)
761 _ao_config_edit_start();
762 ao_config.aprs_interval = ao_cmd_lex_i;
763 _ao_config_edit_finish();
764 ao_telemetry_reset_interval();
767 #endif /* HAS_APRS */
772 ao_config_radio_amp_show(void)
774 printf ("Radio amp setting: %d\n", ao_config.radio_amp);
778 ao_config_radio_amp_set(void)
781 if (ao_cmd_status != ao_cmd_success)
783 _ao_config_edit_start();
784 ao_config.radio_amp = ao_cmd_lex_i;
785 _ao_config_edit_finish();
793 ao_config_radio_power_show(void)
795 printf ("Radio power setting: %d\n", ao_config.radio_power);
799 ao_config_radio_power_set(void)
802 if (ao_cmd_status != ao_cmd_success)
804 _ao_config_edit_start();
805 ao_config.radio_power = ao_cmd_lex_i;
806 _ao_config_edit_finish();
813 ao_config_beep_show(void)
815 printf ("Beeper setting: %d\n", ao_config.mid_beep);
819 ao_config_beep_set(void)
822 if (ao_cmd_status != ao_cmd_success)
824 _ao_config_edit_start();
825 ao_config.mid_beep = ao_cmd_lex_i;
826 _ao_config_edit_finish();
832 ao_config_tracker_show(void)
834 printf ("Tracker setting: %d %d\n",
835 ao_config.tracker_motion,
836 ao_config.tracker_interval);
840 ao_config_tracker_set(void)
844 if (ao_cmd_status != ao_cmd_success)
848 if (ao_cmd_status != ao_cmd_success)
851 _ao_config_edit_start();
852 ao_config.tracker_motion = m;
853 ao_config.tracker_interval = i;
854 _ao_config_edit_finish();
856 ao_telemetry_reset_interval();
859 #endif /* HAS_TRACKER */
863 ao_config_pyro_time_show(void)
865 printf ("Pyro time: %d\n", ao_config.pyro_time);
869 ao_config_pyro_time_set(void)
872 if (ao_cmd_status != ao_cmd_success)
874 _ao_config_edit_start();
875 ao_config.pyro_time = ao_cmd_lex_i;
876 _ao_config_edit_finish();
882 ao_config_aprs_ssid_show(void)
884 printf ("APRS SSID: %d\n",
885 ao_config.aprs_ssid);
889 ao_config_aprs_ssid_set(void)
892 if (ao_cmd_status != ao_cmd_success)
894 if (15 < ao_cmd_lex_i) {
895 ao_cmd_status = ao_cmd_lex_error;
898 _ao_config_edit_start();
899 ao_config.aprs_ssid = ao_cmd_lex_i;
900 _ao_config_edit_finish();
904 ao_config_aprs_format_set(void)
907 if (ao_cmd_status != ao_cmd_success)
909 _ao_config_edit_start();
910 ao_config.aprs_format = ao_cmd_lex_i != 0;
911 _ao_config_edit_finish();
915 ao_config_aprs_format_show(void)
917 printf ("APRS format: %d\n", ao_config.aprs_format);
919 #endif /* HAS_APRS */
923 ao_config_pad_box_show(void)
925 printf ("Pad box: %d\n", ao_config.pad_box);
929 ao_config_pad_box_set(void)
932 if (ao_cmd_status != ao_cmd_success)
934 _ao_config_edit_start();
935 ao_config.pad_box = ao_cmd_lex_i;
936 _ao_config_edit_finish();
940 ao_config_pad_idle_show(void)
942 printf ("Idle timeout: %d\n", ao_config.pad_idle);
946 ao_config_pad_idle_set(void)
949 if (ao_cmd_status != ao_cmd_success)
951 _ao_config_edit_start();
952 ao_config.pad_idle = ao_cmd_lex_i;
953 _ao_config_edit_finish();
957 struct ao_config_var {
959 void (*set)(void) __reentrant;
960 void (*show)(void) __reentrant;
964 ao_config_help(void) __reentrant;
967 ao_config_show(void) __reentrant;
971 ao_config_save(void) __reentrant;
974 __code struct ao_config_var ao_config_vars[] = {
976 { "m <meters>\0Main deploy (m)",
977 ao_config_main_deploy_set, ao_config_main_deploy_show, },
978 { "d <delay>\0Apogee delay (s)",
979 ao_config_apogee_delay_set, ao_config_apogee_delay_show },
980 { "L <seconds>\0Apogee detect lockout (s)",
981 ao_config_apogee_lockout_set, ao_config_apogee_lockout_show, },
982 #endif /* HAS_FLIGHT */
984 { "F <freq>\0Frequency (kHz)",
985 ao_config_frequency_set, ao_config_frequency_show },
986 #if HAS_RADIO_FORWARD
987 { "R <freq>\0Repeater output frequency (kHz)",
988 ao_config_send_frequency_set, ao_config_send_frequency_show },
990 { "c <call>\0Callsign (8 char max)",
991 ao_config_callsign_set, ao_config_callsign_show },
992 { "e <0 disable, 1 enable>\0Enable telemetry and RDF",
993 ao_config_radio_enable_set, ao_config_radio_enable_show },
994 { "f <cal>\0Radio calib (cal = rf/(xtal/2^16))",
995 ao_config_radio_cal_set, ao_config_radio_cal_show },
997 { "T <rate>\0Telemetry rate (0=38.4, 1=9.6, 2=2.4)",
998 ao_config_radio_rate_set, ao_config_radio_rate_show },
1001 { "p <setting>\0Radio power setting (0-255)",
1002 ao_config_radio_power_set, ao_config_radio_power_show },
1005 { "d <setting>\0Radio amplifier setting (0-3)",
1006 ao_config_radio_amp_set, ao_config_radio_amp_show },
1008 #endif /* HAS_RADIO */
1010 { "a <+g> <-g>\0Accel calib (0 for auto)",
1011 ao_config_accel_calibrate_set,ao_config_accel_calibrate_show },
1012 { "o <0 antenna up, 1 antenna down>\0Pad orientation",
1013 ao_config_pad_orientation_set,ao_config_pad_orientation_show },
1014 #endif /* HAS_ACCEL */
1016 { "l <size>\0Flight log size (kB)",
1017 ao_config_log_set, ao_config_log_show },
1020 { "i <0 dual, 1 apogee, 2 main>\0Igniter mode",
1021 ao_config_ignite_mode_set, ao_config_ignite_mode_show },
1024 { "k <32 hex digits>\0AES encryption key",
1025 ao_config_key_set, ao_config_key_show },
1028 { "P <n,?>\0Pyro channels",
1029 ao_pyro_set, ao_pyro_show },
1030 { "I <ticks>\0Pyro firing time",
1031 ao_config_pyro_time_set, ao_config_pyro_time_show },
1034 { "A <secs>\0APRS packet interval (0 disable)",
1035 ao_config_aprs_set, ao_config_aprs_show },
1038 { "b <val>\0Beeper tone (freq = 1/2 (24e6/32) / beep",
1039 ao_config_beep_set, ao_config_beep_show },
1042 { "t <motion> <interval>\0Tracker configuration",
1043 ao_config_tracker_set, ao_config_tracker_show },
1046 { "S <ssid>\0Set APRS SSID (0-15)",
1047 ao_config_aprs_ssid_set, ao_config_aprs_ssid_show },
1048 { "C <0 compressed, 1 uncompressed>\0APRS format",
1049 ao_config_aprs_format_set, ao_config_aprs_format_show },
1052 { "B <box>\0Set pad box (1-99)",
1053 ao_config_pad_box_set, ao_config_pad_box_show },
1054 { "i <seconds>\0Set idle timeout (0 disable)",
1055 ao_config_pad_idle_set, ao_config_pad_idle_show },
1058 ao_config_show, 0 },
1060 { "w\0Write to eeprom",
1061 ao_config_save, 0 },
1064 ao_config_help, 0 },
1077 for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++)
1078 if (ao_config_vars[cmd].str[0] == c) {
1079 (*ao_config_vars[cmd].set)();
1082 ao_cmd_status = ao_cmd_syntax_error;
1086 ao_config_help(void) __reentrant
1089 for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++)
1090 printf("%-20s %s\n",
1091 ao_config_vars[cmd].str,
1092 ao_config_vars[cmd].str+1+
1093 strlen(ao_config_vars[cmd].str));
1097 ao_config_show(void) __reentrant
1101 printf("Config version: %d.%d\n",
1102 ao_config.major, ao_config.minor);
1103 for (cmd = 0; ao_config_vars[cmd].str != NULL; cmd++)
1104 if (ao_config_vars[cmd].show)
1105 (*ao_config_vars[cmd].show)();
1113 ao_config_save(void) __reentrant
1116 ao_mutex_get(&ao_config_mutex);
1117 if (ao_config_dirty) {
1119 ao_config_dirty = 0;
1122 ao_mutex_put(&ao_config_mutex);
1126 puts("Nothing to save");
1130 __code struct ao_cmds ao_config_cmds[] = {
1131 { ao_config_set, "c <var> <value>\0Set config (? for help, s to show)" },
1136 ao_config_init(void)
1138 ao_cmd_register(&ao_config_cmds[0]);