Skip to content

Commit

Permalink
conversion factors changed to more precise value fixes Seeed-Studio#26 (
Browse files Browse the repository at this point in the history
  • Loading branch information
Neumi authored Feb 16, 2023
1 parent 9313abe commit 105a97a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions examples/fullFunction/fullFunction.ino
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void printMenu()
float convertRawAngleToDegrees(word newAngle)
{
/* Raw data reports 0 - 4095 segments, which is 0.087 of a degree */
float retVal = newAngle * 0.087;
float retVal = newAngle * 0.087890625;
return retVal;
}

Expand All @@ -102,20 +102,20 @@ float convertScaledAngleToDegrees(word newAngle)
if(maxAngle >0)
{
if(startPos == 0)
multipler = (maxAngle*0.0878)/4096;
multipler = (maxAngle*0.087890625)/4096;
else /*startPos is set to something*/
multipler = ((maxAngle*0.0878)-(startPos * 0.0878))/4096;
multipler = ((maxAngle*0.087890625)-(startPos * 0.087890625))/4096;
}
else
{
if((startPos == 0) && (endPos == 0))
multipler = 0.0878;
multipler = 0.087890625;
else if ((startPos > 0 ) && (endPos == 0))
multipler = ((360 * 0.0878) - (startPos * 0.0878)) / 4096;
multipler = ((360 * 0.087890625) - (startPos * 0.087890625)) / 4096;
else if ((startPos == 0 ) && (endPos > 0))
multipler = (endPos*0.0878) / 4096;
multipler = (endPos*0.087890625) / 4096;
else if ((startPos > 0 ) && (endPos > 0))
multipler = ((endPos*0.0878)-(startPos * 0.0878))/ 4096;
multipler = ((endPos*0.087890625)-(startPos * 0.087890625))/ 4096;
}
return (newAngle * multipler);
}
Expand Down Expand Up @@ -330,4 +330,4 @@ void loop()
/*end of menu processing */
printMenu();
}
}
}
4 changes: 2 additions & 2 deletions examples/readAngle/readAngle.ino
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void setup()
/*******************************************************/
float convertRawAngleToDegrees(word newAngle)
{
/* Raw data reports 0 - 4095 segments, which is 0.087 of a degree */
float retVal = newAngle * 0.087;
/* Raw data reports 0 - 4095 segments, which is 0.087890625 of a degree */
float retVal = newAngle * 0.087890625;
return retVal;
}
void loop()
Expand Down

0 comments on commit 105a97a

Please sign in to comment.