]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/platforms/tmirws/sensors/WindVaneP.nc
Chagne the wind vane compass accumulator from an uint16_t to an uint8_t array.
[tinyos-2.x.git] / tos / platforms / tmirws / sensors / WindVaneP.nc
index 65716f63f7718ccf800c50f043ded67591f150c8..8557c8cc2eba34b6352544fe9e12c8a5805a8b1a 100644 (file)
  
 /**
  * WindVane sensor.  The compass is a number of sectors, 0...(sectors - 1).
- * sectors must be a power of 2.  Sector zero is North, and sectors/2 is South.
- * Like any compass, the heading increases as one traverses the compass
- * clockwise.  The number of sectors are contrained by the uint8_t data members
- * of wind_vane_t to 128.
+ * Sector zero is North, and sectors/2 is South.  Like any compass, the heading
+ * increases as one traverses the compass clockwise.  The number of sectors are
+ * contrained by the uint8_t data members of wind_vane_t to no more than 255.
  * 
  * @author R. Steve McKown <rsmckown@gmail.com>
  */
@@ -50,7 +49,7 @@ generic module WindVaneP(uint8_t sectors) {
   }
 }
 implementation {
-  uint16_t m_compass[sectors];
+  uint8_t m_compass[sectors];
   bool m_overflow;
   wind_vane_t* m_data;
 
@@ -70,7 +69,7 @@ implementation {
   }
 
   /* Convert a degree heading into a sector */
-  uint16_t degreeToSector(uint16_t degree)
+  uint8_t degreeToSector(uint16_t degree)
   {
     return ((degree * sectors + 180) / 360) % sectors;
   }
@@ -84,7 +83,7 @@ implementation {
   /* circularly examine compass, starting with pos + 1, for the next compass
    * position having a value of zero.
    */
-  uint8_t nextNonZero(uint16_t* compass, uint8_t pos)
+  uint8_t nextNonZero(uint8_t* compass, uint8_t pos)
   {
     do {
       pos = (pos + 1) % sectors;
@@ -92,7 +91,7 @@ implementation {
     return pos;
   }
 
-  bool isCompassEmpty(uint16_t* compass)
+  bool isCompassEmpty(uint8_t* compass)
   {
     int i;
 
@@ -106,7 +105,7 @@ implementation {
   /* Reduce all compass headings equally until a compass heading has a value
    * of zero.
    */
-  void minimizeCompass(uint16_t* compass)
+  void minimizeCompass(uint8_t* compass)
   {
     uint8_t min = 255;
     int i;
@@ -125,7 +124,7 @@ implementation {
    * that arc in m_data's left and right fields.  The compass arc is always
    * defined clockwise, from left to right.
    */
-  void findArc(uint16_t* compass)
+  void findArc(uint8_t* compass)
   {
     uint8_t begin;
     uint8_t save = 255;
@@ -147,7 +146,7 @@ implementation {
     m_data->left = (save + dist) % sectors;
   }
 
-  void calcAvg(uint16_t* compass)
+  void calcAvg(uint8_t* compass)
   {
     /* Find the average compass heading */
     uint32_t sum = 0;
@@ -209,7 +208,7 @@ implementation {
   task void readCompass()
   {
     bool overflow;
-    uint16_t compass[sectors];
+    uint8_t compass[sectors];
     wind_vane_t* data = m_data;
 
     atomic {