summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-07-04 12:34:38 -0700
committerKeith Packard <keithp@keithp.com>2018-07-04 12:34:38 -0700
commitad9d6677231ccbfa09a528387f306f5364f9d608 (patch)
treeab354b0803bedc096f9a1355c936d72fc91a8d6b
parent38fb80e5e6af87f8c734448e4aa69b2c39854903 (diff)
altos: Make fewer LCO variables public
The lco common code doesn't need to share its internal values with the world; make most of them static. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/drivers/ao_lco.c3
-rw-r--r--src/drivers/ao_lco.h18
-rw-r--r--src/drivers/ao_lco_bits.c42
3 files changed, 34 insertions, 29 deletions
diff --git a/src/drivers/ao_lco.c b/src/drivers/ao_lco.c
index 47752f1f..e892c8c0 100644
--- a/src/drivers/ao_lco.c
+++ b/src/drivers/ao_lco.c
@@ -34,8 +34,7 @@
#define AO_LCO_DRAG_RACE_START_TIME AO_SEC_TO_TICKS(5)
#define AO_LCO_DRAG_RACE_STOP_TIME AO_SEC_TO_TICKS(2)
-#define AO_LCO_VALID_LAST 1
-#define AO_LCO_VALID_EVER 2
+#define AO_LCO_BOX_DRAG 0x1000
/* UI values */
static uint16_t ao_lco_fire_tick;
diff --git a/src/drivers/ao_lco.h b/src/drivers/ao_lco.h
index e528c2ad..2958fbcc 100644
--- a/src/drivers/ao_lco.h
+++ b/src/drivers/ao_lco.h
@@ -25,10 +25,6 @@
#define AO_LCO_DRAG 1
#endif
-#if AO_LCO_DRAG
-#define AO_LCO_BOX_DRAG 0x1000
-#endif
-
#define DEBUG 1
#if DEBUG
@@ -38,25 +34,21 @@ extern uint8_t ao_lco_debug;
#define PRINTD(...)
#endif
+#if AO_LCO_DRAG
extern uint8_t ao_lco_drag_race; /* TRUE when drag race mode enabled */
+#endif
+
extern uint8_t ao_lco_pad; /* Currently selected pad */
extern int16_t ao_lco_box; /* Currently selected box */
-extern uint8_t ao_lco_armed;
-extern uint8_t ao_lco_firing;
+extern uint8_t ao_lco_armed; /* armed mode active */
+extern uint8_t ao_lco_firing; /* fire button pressed */
extern struct ao_pad_query ao_pad_query; /* Last received QUERY from pad */
-#define AO_LCO_VALID_LAST 1
-#define AO_LCO_VALID_EVER 2
-
#define AO_LCO_PAD_VOLTAGE 0 /* Pad number to show box voltage */
extern uint8_t ao_lco_min_box, ao_lco_max_box;
-extern uint8_t ao_lco_selected[AO_PAD_MAX_BOXES];
-extern uint8_t ao_lco_valid[AO_PAD_MAX_BOXES];
-extern uint8_t ao_lco_channels[AO_PAD_MAX_BOXES];
-extern uint16_t ao_lco_tick_offset[AO_PAD_MAX_BOXES];
#define AO_LCO_MASK_SIZE(n) (((n) + 7) >> 3)
#define AO_LCO_MASK_ID(n) ((n) >> 3)
diff --git a/src/drivers/ao_lco_bits.c b/src/drivers/ao_lco_bits.c
index 197bf8aa..6e50e44d 100644
--- a/src/drivers/ao_lco_bits.c
+++ b/src/drivers/ao_lco_bits.c
@@ -20,20 +20,28 @@ uint8_t ao_lco_debug;
uint8_t ao_lco_pad;
int16_t ao_lco_box;
-uint8_t ao_lco_drag_race;
-uint8_t ao_lco_armed; /* arm active */
-uint8_t ao_lco_firing; /* fire active */
+uint8_t ao_lco_armed; /* arm active */
+uint8_t ao_lco_firing; /* fire active */
uint8_t ao_lco_min_box, ao_lco_max_box;
-uint8_t ao_lco_selected[AO_PAD_MAX_BOXES];
-uint8_t ao_lco_valid[AO_PAD_MAX_BOXES];
-uint8_t ao_lco_channels[AO_PAD_MAX_BOXES];
-uint16_t ao_lco_tick_offset[AO_PAD_MAX_BOXES];
-struct ao_pad_query ao_pad_query;
+#if AO_LCO_DRAG
+uint8_t ao_lco_drag_race;
+#endif
+
+struct ao_pad_query ao_pad_query; /* latest query response */
-static AO_LED_TYPE continuity_led[AO_LED_CONTINUITY_NUM] = {
+static uint8_t ao_lco_channels[AO_PAD_MAX_BOXES]; /* pad channels available on each box */
+static uint16_t ao_lco_tick_offset[AO_PAD_MAX_BOXES]; /* offset from local to remote tick count */
+static uint8_t ao_lco_selected[AO_PAD_MAX_BOXES]; /* pads selected to fire */
+
+#define AO_LCO_VALID_LAST 1
+#define AO_LCO_VALID_EVER 2
+
+static uint8_t ao_lco_valid[AO_PAD_MAX_BOXES]; /* AO_LCO_VALID bits per box */
+
+static const AO_LED_TYPE continuity_led[AO_LED_CONTINUITY_NUM] = {
#ifdef AO_LED_CONTINUITY_0
AO_LED_CONTINUITY_0,
#endif
@@ -68,9 +76,11 @@ ao_lco_igniter_status(void)
uint8_t t = 0;
for (;;) {
+#if AO_LCO_DRAG
if (ao_lco_drag_race)
ao_sleep_for(&ao_pad_query, AO_MS_TO_TICKS(50));
else
+#endif
ao_sleep(&ao_pad_query);
PRINTD("RSSI %d VALID %d\n", ao_radio_cmac_rssi, ao_lco_valid[ao_lco_box]);
if (!(ao_lco_valid[ao_lco_box] & AO_LCO_VALID_LAST)) {
@@ -98,6 +108,7 @@ ao_lco_igniter_status(void)
else
status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN;
+#if AO_LCO_DRAG
if (ao_lco_drag_race && (ao_lco_selected[ao_lco_box] & (1 << c))) {
uint8_t on = 0;
if (status == AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN) {
@@ -111,7 +122,9 @@ ao_lco_igniter_status(void)
ao_led_on(continuity_led[c]);
else
ao_led_off(continuity_led[c]);
- } else {
+ } else
+#endif
+ {
if (status == AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN)
ao_led_on(continuity_led[c]);
else
@@ -210,9 +223,7 @@ void
ao_lco_set_box(uint16_t new_box)
{
ao_lco_box = new_box;
-#if AO_LCO_DRAG
- if (ao_lco_box != AO_LCO_BOX_DRAG)
-#endif
+ if (ao_lco_box < AO_PAD_MAX_BOXES)
ao_lco_channels[ao_lco_box] = 0;
ao_lco_pad = 1;
ao_lco_show();
@@ -242,6 +253,7 @@ ao_lco_set_armed(uint8_t armed)
ao_lco_armed = armed;
PRINTD("Armed %d\n", ao_lco_armed);
if (ao_lco_armed) {
+#if AO_LCO_DRAG
if (ao_lco_drag_race) {
uint8_t box;
@@ -250,7 +262,9 @@ ao_lco_set_armed(uint8_t armed)
break;
if (box > ao_lco_max_box)
ao_lco_armed = 0;
- } else {
+ } else
+#endif
+ {
memset(ao_lco_selected, 0, sizeof (ao_lco_selected));
if (ao_lco_pad != 0)
ao_lco_selected[ao_lco_box] = (1 << (ao_lco_pad - 1));