The wind vane infrastructure works with 128 sectors, the max, which offers
approximately a 3 degree resolution. This comes at the cost of an additional
129 bytes of RAM over using 32 sectors.
/* Convert a degree heading into a sector */
uint16_t degreeToSector(uint16_t degree)
{
/* Convert a degree heading into a sector */
uint16_t degreeToSector(uint16_t degree)
{
- return ((degree * sectors + 180) / 360) % 32;
+ return ((degree * sectors + 180) / 360) % sectors;
}
/* Return the # of sectors clockwise along the compass from start to end. */
}
/* Return the # of sectors clockwise along the compass from start to end. */