From 1e98199e7be6ebc12b7983c36e46093ef486246c Mon Sep 17 00:00:00 2001 From: tunix Date: Mon, 11 Jun 2012 22:13:00 +0200 Subject: [PATCH] r0ket can be made asleep while showing the "accomplished" screen --- firmware/applications/poem.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/applications/poem.c b/firmware/applications/poem.c index bd86214..49e6333 100644 --- a/firmware/applications/poem.c +++ b/firmware/applications/poem.c @@ -10,7 +10,7 @@ #include "funk/nrf24l01p.h" -#define POEM_ID 4 +#define POEM_ID 2 #define BTN_WAKEUP (1 << 5) #define BTN_STANDBY (1 << 6) @@ -397,10 +397,11 @@ uint8_t poem_getInputBlocking(uint8_t filter) { uint8_t poem_getInputNonBlocking(void) { uint8_t pkt[32]; uint8_t input; - if (nrf_rcv_pkt_poll(sizeof(pkt), pkt) == 32) { + // wait up to 200 ms for a packet + if (nrf_rcv_pkt_time(200, sizeof(pkt), pkt) == 32) { input = poem_identifyPacket(pkt); if (input == BTN_NONE) - input == getInput(); + input = getInput(); } else { input = getInput(); @@ -515,17 +516,18 @@ static void poem_sendSuccessMessage(packet_type_t pktWinner) { // send our winner information packet static uint8_t pkt[32]; - nrf_rcv_pkt_start(); while (1) { memcpy(pkt, poem_gPackets[pktWinner], sizeof(pkt)); nrf_snd_pkt_crc(sizeof(pkt), pkt); - delayms_queue(80 + (getRandom() % 50)); + // wait between 100 and 500 ms (including a potential 200 ms timeout of + // poem_getInputNonBlocking) to prevent polluting the channel with + // winner packets + delayms(100 + (getRandom() % 200)); uint8_t input = poem_getInputNonBlocking(); if (input == BTN_STANDBY) { break; } } - nrf_rcv_pkt_end(); }