From 026ab589d0ade3dd59d26888fffd8699ef534671 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 19 Jan 2023 12:18:46 -0800 Subject: [PATCH] altos/telelco: Add some debug aids for TeleLCO event stuff Use (debug & 2) to select just event debugging. Add 'pretend' mode to cycle through all possible pad boxes. Signed-off-by: Keith Packard --- src/drivers/ao_lco.h | 3 +++ src/drivers/ao_lco_bits.c | 33 ++++++++++++++++++++++++++++----- src/telelco-v2.0/ao_lco_v2.c | 12 +++++++++--- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/drivers/ao_lco.h b/src/drivers/ao_lco.h index 65e9a8c9..03c810be 100644 --- a/src/drivers/ao_lco.h +++ b/src/drivers/ao_lco.h @@ -87,6 +87,9 @@ ao_lco_set_armed(uint8_t armed); void ao_lco_set_firing(uint8_t firing); +void +ao_lco_pretend(void); + void ao_lco_toggle_drag(void); diff --git a/src/drivers/ao_lco_bits.c b/src/drivers/ao_lco_bits.c index c88170b8..acdea87e 100644 --- a/src/drivers/ao_lco_bits.c +++ b/src/drivers/ao_lco_bits.c @@ -26,6 +26,8 @@ uint8_t ao_lco_firing; /* fire active */ uint16_t ao_lco_min_box, ao_lco_max_box; +uint8_t ao_lco_pretending; + #if AO_LCO_DRAG uint8_t ao_lco_drag_race; #endif @@ -197,6 +199,7 @@ ao_lco_box_reset_present(void) { ao_lco_min_box = 0xff; ao_lco_max_box = 0x00; + ao_lco_pretending = 0; memset(ao_lco_box_mask, 0, sizeof (ao_lco_box_mask)); } @@ -223,8 +226,12 @@ void ao_lco_set_box(uint16_t new_box) { ao_lco_box = new_box; - if (ao_lco_box < AO_PAD_MAX_BOXES) - ao_lco_channels[ao_lco_box] = 0; + if (ao_lco_box < AO_PAD_MAX_BOXES) { + if (ao_lco_pretending) + ao_lco_channels[ao_lco_box] = 0xff; + else + ao_lco_channels[ao_lco_box] = 0; + } ao_lco_pad = 1; ao_lco_show(); } @@ -288,8 +295,8 @@ ao_lco_search(void) { int8_t r; int8_t try; - uint8_t box; - uint8_t boxes = 0; + uint16_t box; + uint16_t boxes = 0; ao_lco_box_reset_present(); ao_lco_show_box(0); @@ -304,7 +311,7 @@ ao_lco_search(void) if (r == AO_RADIO_CMAC_OK) { ++boxes; ao_lco_box_set_present(box); - ao_lco_show_pad(boxes % 10); + ao_lco_show_pad((uint8_t) (boxes % 10)); ao_delay(AO_MS_TO_TICKS(30)); break; } @@ -319,6 +326,22 @@ ao_lco_search(void) ao_lco_set_box(ao_lco_min_box); } +void +ao_lco_pretend(void) +{ + uint16_t box; + + ao_lco_pretending = 1; + ao_lco_min_box = 1; + ao_lco_max_box = AO_PAD_MAX_BOXES - 1; + for (box = ao_lco_min_box; box < ao_lco_max_box; box++) + ao_lco_box_set_present(box); + ao_lco_box = ao_lco_min_box; + memset(ao_lco_valid, 0, sizeof (ao_lco_valid)); + memset(ao_lco_channels, 0, sizeof (ao_lco_channels)); + ao_lco_set_box(ao_lco_min_box); +} + void ao_lco_monitor(void) { diff --git a/src/telelco-v2.0/ao_lco_v2.c b/src/telelco-v2.0/ao_lco_v2.c index 3583be98..78849bc9 100644 --- a/src/telelco-v2.0/ao_lco_v2.c +++ b/src/telelco-v2.0/ao_lco_v2.c @@ -33,6 +33,9 @@ /* UI values */ static uint8_t ao_lco_select_mode; +static uint8_t ao_lco_event_debug; + +#define PRINTE(...) do { if (!ao_lco_debug && !ao_lco_event_debug) break; printf ("\r%5lu %s: ", (unsigned long) ao_tick_count, __func__); printf(__VA_ARGS__); flush(); } while(0) #define AO_LCO_SELECT_PAD 0 #define AO_LCO_SELECT_BOX 1 @@ -176,7 +179,7 @@ ao_lco_input(void) for (;;) { ao_event_get(&event); - PRINTD("event type %d unit %d value %ld\n", + PRINTE("event type %d unit %d value %ld\n", event.type, event.unit, (long) event.value); switch (event.type) { case AO_EVENT_QUADRATURE: @@ -283,13 +286,16 @@ static void ao_lco_set_debug(void) { uint32_t r = ao_cmd_decimal(); - if (ao_cmd_status == ao_cmd_success) - ao_lco_debug = r != 0; + if (ao_cmd_status == ao_cmd_success){ + ao_lco_debug = r & 1; + ao_lco_event_debug = (r & 2) >> 1; + } } const struct ao_cmds ao_lco_cmds[] = { { ao_lco_set_debug, "D <0 off, 1 on>\0Debug" }, { ao_lco_search, "s\0Search for pad boxes" }, + { ao_lco_pretend, "p\0Pretend there are lots of pad boxes" }, { 0, NULL } }; #endif -- 2.30.2