}
}
implementation {
- uint16_t m_compass[sectors];
+ uint8_t m_compass[sectors];
bool m_overflow;
wind_vane_t* m_data;
}
/* 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;
}
/* 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;
return pos;
}
- bool isCompassEmpty(uint16_t* compass)
+ bool isCompassEmpty(uint8_t* compass)
{
int i;
/* 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;
* 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;
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;
task void readCompass()
{
bool overflow;
- uint16_t compass[sectors];
+ uint8_t compass[sectors];
wind_vane_t* data = m_data;
atomic {