telefire: Make 'good' RSSI value configurable
[fw/altos] / src / drivers / ao_pad.c
index 144cbd70a8834e4053e67c6bebec423e68ae8175..3ad239cced3e3c62f07545ba51277982668face2 100644 (file)
@@ -29,6 +29,10 @@ static __pdata uint8_t       ao_pad_box;
 static __xdata uint8_t ao_pad_disabled;
 static __pdata uint16_t        ao_pad_packet_time;
 
+#ifndef AO_PAD_RSSI_MINIMUM
+#define AO_PAD_RSSI_MINIMUM    -90
+#endif
+
 #define DEBUG  1
 
 #if DEBUG
@@ -36,8 +40,8 @@ static __pdata uint8_t        ao_pad_debug;
 #define PRINTD(...) (ao_pad_debug ? (printf(__VA_ARGS__), 0) : 0)
 #define FLUSHD()    (ao_pad_debug ? (flush(), 0) : 0)
 #else
-#define PRINTD(...) 
-#define FLUSHD()    
+#define PRINTD(...)
+#define FLUSHD()
 #endif
 
 static void
@@ -138,7 +142,7 @@ ao_pad_monitor(void)
                }
                if ((ao_time() - ao_pad_packet_time) > AO_SEC_TO_TICKS(2))
                        cur |= AO_LED_RED;
-               else if (ao_radio_cmac_rssi < -90)
+               else if (ao_radio_cmac_rssi < AO_PAD_RSSI_MINIMUM)
                        cur |= AO_LED_AMBER;
                else
                        cur |= AO_LED_GREEN;
@@ -255,7 +259,7 @@ ao_pad(void)
                if (ret != AO_RADIO_CMAC_OK)
                        continue;
                ao_pad_packet_time = ao_time();
-               
+
                ao_pad_box = ao_pad_read_box();
 
                PRINTD ("tick %d box %d (me %d) cmd %d channels %02x\n",
@@ -362,14 +366,26 @@ ao_pad_test(void)
 void
 ao_pad_manual(void)
 {
+       uint8_t ignite;
+       int     repeat;
        ao_cmd_white();
        if (!ao_match_word("DoIt"))
                return;
        ao_cmd_decimal();
        if (ao_cmd_status != ao_cmd_success)
                return;
-       ao_pad_ignite = 1 << ao_cmd_lex_i;
-       ao_wakeup(&ao_pad_ignite);
+       ignite = 1 << ao_cmd_lex_i;
+       ao_cmd_decimal();
+       if (ao_cmd_status != ao_cmd_success) {
+               repeat = 1;
+               ao_cmd_status = ao_cmd_success;
+       } else
+               repeat = ao_cmd_lex_i;
+       while (repeat-- > 0) {
+               ao_pad_ignite = ignite;
+               ao_wakeup(&ao_pad_ignite);
+               ao_delay(AO_PAD_FIRE_TIME>>1);
+       }
 }
 
 static __xdata struct ao_task ao_pad_task;