A few minor space savings in ao_cmd.c and ao_config.c. Don't build
unused conversion functions ao_altitude_to_pres and ao_temp_to_dC
Signed-off-by: Keith Packard <keithp@keithp.com>
+static void
+backspace(void)
+{
+ put_string ("\010 \010");
+}
+
static void
readline(void)
{
static void
readline(void)
{
if (ao_echo())
put_string("> ");
cmd_len = 0;
if (ao_echo())
put_string("> ");
cmd_len = 0;
if (c == '\010' || c == '\177') {
if (cmd_len != 0) {
if (ao_echo())
if (c == '\010' || c == '\177') {
if (cmd_len != 0) {
if (ao_echo())
- put_string("\010 \010");
if (c == '\025') {
while (cmd_len != 0) {
if (ao_echo())
if (c == '\025') {
while (cmd_len != 0) {
if (ao_echo())
- put_string("\010 \010");
- if (cmd_len >= CMD_LEN - 2) {
- if (ao_echo())
- putchar('\007');
+ if (cmd_len >= CMD_LEN - 2)
cmd_line[cmd_len++] = c;
if (ao_echo())
putchar(c);
cmd_line[cmd_len++] = c;
if (ao_echo())
putchar(c);
__pdata uint8_t cmds;
__pdata uint8_t cmd;
__code struct ao_cmds * __pdata cs;
__pdata uint8_t cmds;
__pdata uint8_t cmd;
__code struct ao_cmds * __pdata cs;
for (cmds = 0; cmds < ao_ncmds; cmds++) {
cs = ao_cmds[cmds];
for (cmds = 0; cmds < ao_ncmds; cmds++) {
cs = ao_cmds[cmds];
- for (cmd = 0; cs[cmd].func; cmd++)
- printf("%-45s %s\n",
- cs[cmd].help,
- cs[cmd].help+1+strlen(cs[cmd].help));
+ for (cmd = 0; (h = cs[cmd].help); cmd++)
+ printf("%-45s %s\n", h, h + 1 + strlen(h));
static void
_ao_config_get(void)
{
static void
_ao_config_get(void)
{
if (ao_config_loaded)
return;
#if HAS_EEPROM
if (ao_config_loaded)
return;
#if HAS_EEPROM
ao_xmemset(&ao_config.callsign, '\0', sizeof (ao_config.callsign));
ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN),
sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
ao_xmemset(&ao_config.callsign, '\0', sizeof (ao_config.callsign));
ao_xmemcpy(&ao_config.callsign, CODE_TO_XDATA(AO_CONFIG_DEFAULT_CALLSIGN),
sizeof(AO_CONFIG_DEFAULT_CALLSIGN) - 1);
- if (ao_config.minor != AO_CONFIG_MINOR) {
+ minor = ao_config.minor;
+ if (minor != AO_CONFIG_MINOR) {
/* Fixups for minor version 1 */
/* Fixups for minor version 1 */
- if (ao_config.minor < 1)
ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
/* Fixups for minor version 2 */
ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
/* Fixups for minor version 2 */
- if (ao_config.minor < 2) {
ao_config.accel_plus_g = 0;
ao_config.accel_minus_g = 0;
}
/* Fixups for minor version 3 */
#if HAS_RADIO
ao_config.accel_plus_g = 0;
ao_config.accel_minus_g = 0;
}
/* Fixups for minor version 3 */
#if HAS_RADIO
- if (ao_config.minor < 3)
ao_config.radio_cal = ao_radio_cal;
#endif
/* Fixups for minor version 4 */
ao_config.radio_cal = ao_radio_cal;
#endif
/* Fixups for minor version 4 */
- if (ao_config.minor < 4)
ao_config.flight_log_max = AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX;
/* Fixupes for minor version 5 */
ao_config.flight_log_max = AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX;
/* Fixupes for minor version 5 */
- if (ao_config.minor < 5)
ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE;
ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE;
- if (ao_config.minor < 6)
ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION;
ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION;
- if (ao_config.minor < 8)
ao_config.radio_enable = TRUE;
ao_config.radio_enable = TRUE;
- if (ao_config.minor < 9)
ao_xmemset(&ao_config.aes_key, '\0', AO_AES_LEN);
ao_xmemset(&ao_config.aes_key, '\0', AO_AES_LEN);
- if (ao_config.minor < 10)
ao_config.frequency = 434550;
ao_config.frequency = 434550;
- if (ao_config.minor < 11)
ao_config.apogee_lockout = 0;
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
ao_config.apogee_lockout = 0;
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
(int32_t) altitude_table[o+1] * part + (ALT_FRAC_SCALE >> 1)) >> ALT_FRAC_BITS;
}
(int32_t) altitude_table[o+1] * part + (ALT_FRAC_SCALE >> 1)) >> ALT_FRAC_BITS;
}
+#if AO_NEED_ALTITUDE_TO_PRES
int16_t
ao_altitude_to_pres(int16_t alt) __reentrant
{
int16_t
ao_altitude_to_pres(int16_t alt) __reentrant
{
pres = 0;
return (int16_t) pres;
}
pres = 0;
return (int16_t) pres;
}
int16_t
ao_temp_to_dC(int16_t temp) __reentrant
{
int16_t
ao_temp_to_dC(int16_t temp) __reentrant
{
ret = ((temp - 19791) * 1012L) >> 16;
return ret;
}
ret = ((temp - 19791) * 1012L) >> 16;
return ret;
}
#include <stdint.h>
#define AO_CONVERT_TEST
#include <stdint.h>
#define AO_CONVERT_TEST
+#define AO_NEED_ALTITUDE_TO_PRES 1
#include "ao_host.h"
#include "ao_convert.c"
#define STEP 1
#include "ao_host.h"
#include "ao_convert.c"
#define STEP 1
-static inline i_abs(int i) { return i < 0 ? -i : i; }
+static inline int i_abs(int i) { return i < 0 ? -i : i; }
+int main (int argc, char **argv)
{
int i;
int16_t p_to_a, p_to_a_to_p;
{
int i;
int16_t p_to_a, p_to_a_to_p;
#define ao_xmemset(d,v,c) memset(d,v,c)
#define ao_xmemcmp(d,s,c) memcmp(d,s,c)
#define ao_xmemset(d,v,c) memset(d,v,c)
#define ao_xmemcmp(d,s,c) memcmp(d,s,c)
+#define AO_NEED_ALTITUDE_TO_PRES 1
#include "ao_convert.c"
struct ao_config {
#include "ao_convert.c"
struct ao_config {