summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-12-09 18:33:31 -0800
committerKeith Packard <keithp@keithp.com>2012-12-09 18:33:31 -0800
commitb26e837a6f18641aae9372aab22168849ff10812 (patch)
treec8562489c7aaec44e32f67613c0480c56f9320a9
parent1489c7f75f7b9ce547ac49c157b440c4f9131ef4 (diff)
parentc233ef67f42c14cb1d0e0542a9523b279f826af5 (diff)
Merge branch 'micropeak-1.1'
-rw-r--r--src/core/ao_convert_pa.c8
-rw-r--r--src/micropeak/ao_pins.h3
-rw-r--r--src/micropeak/ao_report_tiny.c4
3 files changed, 8 insertions, 7 deletions
diff --git a/src/core/ao_convert_pa.c b/src/core/ao_convert_pa.c
index 55fe6e7d..fe6e0ef6 100644
--- a/src/core/ao_convert_pa.c
+++ b/src/core/ao_convert_pa.c
@@ -43,13 +43,13 @@ ao_pa_to_altitude(int32_t pa)
if (pa < 0)
pa = 0;
- if (pa > 120000)
- pa = 120000;
+ if (pa > 120000L)
+ pa = 120000L;
o = pa >> ALT_SHIFT;
part = pa & ALT_MASK;
- low = (alt_t) FETCH_ALT(o) * (ALT_SCALE - part);
- high = (alt_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1);
+ low = (int32_t) FETCH_ALT(o) * (ALT_SCALE - part);
+ high = (int32_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1);
return (low + high) >> ALT_SHIFT;
}
diff --git a/src/micropeak/ao_pins.h b/src/micropeak/ao_pins.h
index 257b8694..63e9cb1b 100644
--- a/src/micropeak/ao_pins.h
+++ b/src/micropeak/ao_pins.h
@@ -57,8 +57,9 @@
#define I2C_PIN_SDA PINB0
#define AO_CONST_ATTRIB PROGMEM
+typedef int32_t alt_t;
#define FETCH_ALT(o) ((alt_t) pgm_read_dword(&altitude_table[o]))
-#define AO_ALT_VALUE(x) ((x) * 10)
+#define AO_ALT_VALUE(x) ((x) * (alt_t) 10)
#endif /* _AO_PINS_H_ */
diff --git a/src/micropeak/ao_report_tiny.c b/src/micropeak/ao_report_tiny.c
index 109af1ed..bdcc131e 100644
--- a/src/micropeak/ao_report_tiny.c
+++ b/src/micropeak/ao_report_tiny.c
@@ -38,8 +38,8 @@ ao_report_digit(uint8_t digit) __reentrant
void
ao_report_altitude(void)
{
- __pdata int16_t agl = ao_max_height;
- __xdata uint8_t digits[10];
+ __pdata alt_t agl = ao_max_height;
+ static __xdata uint8_t digits[11];
__pdata uint8_t ndigits, i;
if (agl < 0)