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
{
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));
}
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();
}
{
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);
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;
}
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)
{
/* 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
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:
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