PiSlingers library for AHRC competitions

Revision:
0:d4427d048a98
Child:
2:a9351d7f92b4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Beacon.cpp	Sun Sep 09 22:28:06 2012 +0000
@@ -0,0 +1,49 @@
+#include "Beacon.h"
+
+void
+Beacon::scan(void)
+{
+    valL = ainL.read_u16() >> 8;
+    valR = ainR.read_u16() >> 8;
+//    valR = ainL.read_u16() >> 8;
+//    valL = ainR.read_u16() >> 8;
+    
+    valL > valR ?  max = valL : max = valR;
+    
+    calc_centeroid();
+}
+
+void
+Beacon::calc_centeroid(void)
+{
+    float sumA, sumB;
+    
+    sumB = (valL * 1) + (valR * 2);
+    sumA = valL + valR;
+    
+    centeroid = sumB / sumA - 1.5f;
+}
+
+float
+Beacon::get_centeroid(void)
+{
+    return centeroid;
+}
+
+uint8_t
+Beacon::get_max_rssi(void)
+{
+    return max;
+}
+
+uint8_t
+Beacon::getL(void)
+{
+    return valL;
+}
+
+uint8_t
+Beacon::getR(void)
+{
+    return valR;
+}
\ No newline at end of file