- minimizeCompass(tc);
- if (isCompassEmpty(tc)) {
- /* If there were no readings in the compass, or each compass heading has
- * a number of readings equal to all other compass headings, we have an
- * indeterminate wind direction.
- */
- m_data->left = m_data->avg = m_data->right = WINDVANE_NO_HEADING;
- } else {
- findArc(tc);
- calcAvg(tc);
-
- /* m_data's left, avg and right fields are currently represented in
- * compass positions. We must now convert those fields into units of
- * angular degrees. The order of calculations is to maximize precision
- * using integer arithmetic. Note that using a 16-bit unsigned field
- * for calculations, the largest value of COMPASS_COUNT is 37.
- */
- m_data->left = 1800U * m_data->left / COMPASS_COUNT / 10;
- m_data->right = 1800U * m_data->right / COMPASS_COUNT / 10;
- }
+ if (overflow)
+ m_data->left = m_data->avg = m_data->right = WINDVANE_OVERFLOW;
+ else {
+ minimizeCompass(compass);
+ if (isCompassEmpty(compass)) {
+ /* If there were no readings in the compass, or each compass heading has
+ * a number of readings equal to all other compass headings, we have an
+ * indeterminate wind direction.
+ */
+ m_data->left = m_data->avg = m_data->right = WINDVANE_NO_HEADING;
+ } else {
+ findArc(compass);
+ calcAvg(compass);
+ }