From 2d3024676cc86c6ebeb43e128e6066640e45d572 Mon Sep 17 00:00:00 2001 From: saercnap Date: Mon, 5 Jan 2015 17:06:26 -0800 Subject: [PATCH] Work on the idea in #10 --- apps/dexdrip/dexdrip.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/dexdrip/dexdrip.c b/apps/dexdrip/dexdrip.c index 53054c1..40e69fc 100644 --- a/apps/dexdrip/dexdrip.c +++ b/apps/dexdrip/dexdrip.c @@ -67,6 +67,15 @@ typedef struct _Dexcom_packet { uint8 LQI; } Dexcom_packet; +typedef struct _Buffered_packet { + Dexcom_packet packet; + int16 wixel_battery; + uint32 offset; +} Buffered_packet; + +XDATA Buffered_packet packet_buffer[48]; +uint8 buffered_packets = 0; + void uartEnable() { U1UCR |= 0x40; //CTS/RTS ON delayMs(1000); @@ -182,6 +191,19 @@ void print_packet(Dexcom_packet* pPkt) { uartDisable(); } +void load_buffer(Dexcom_packet* pPkt) { + packet_buffer[buffered_packets].packet.len = pPkt->len; + packet_buffer[buffered_packets].offset = getMs(); + buffered_packets++; +} + +void unload_buffer() { + while (buffered_packets > 0) { + // do stuff + buffered_packets--; + } +} + void makeAllOutputs() { int XDATA i; for (i=0; i < 16; i++) { @@ -343,7 +365,9 @@ void main() { if(!get_packet(&Pkt)) continue; + load_buffer(&Pkt); print_packet(&Pkt); + unload_buffer(); RFST = 4; delayMs(80);