Skip to content

Commit

Permalink
Merge pull request AeroQuad#348 from norem/patch-1
Browse files Browse the repository at this point in the history
Mod function not displaying 180 degrees for some reason
  • Loading branch information
Kenny9999 committed Jan 11, 2013
2 parents fb9b45d + deb641f commit 0aafbc3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Libraries/AQ_OSD/MAX7456_Heading.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
int lastHeading = 361; // bogus to force update

void displayHeading(float currentHeading) {
int currentHeadingDeg = ((int)(currentHeading / M_PI * 180.0) + 360) % 360;
int currentHeadingDeg = ((int)(currentHeading * 180/M_PI));

if (currentHeadingDeg < 0 ){
currentHeadingDeg = map(currentHeadingDeg, -179, -1, 180, 359);
}

if (currentHeadingDeg != lastHeading) {
char buf[6];
snprintf(buf,6,"\026%3d\027",currentHeadingDeg); // \026 is compass \027 is degree symbol
Expand Down

0 comments on commit 0aafbc3

Please sign in to comment.