Merge pull request #6971 from etracer65/osd_ah_div0

Fix OSD artificial horizon division by zero
This commit is contained in:
Michael Keller 2018-10-24 01:36:47 +13:00 committed by GitHub
commit 6adfd345db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -712,7 +712,10 @@ static bool osdDrawSingleElement(uint8_t item)
int pitchAngle = constrain(attitude.values.pitch, -maxPitch, maxPitch);
// Convert pitchAngle to y compensation value
// (maxPitch / 25) divisor matches previous settings of fixed divisor of 8 and fixed max AHI pitch angle of 20.0 degrees
pitchAngle = ((pitchAngle * 25) / maxPitch) - 41; // 41 = 4 * AH_SYMBOL_COUNT + 5
if (maxPitch > 0) {
pitchAngle = ((pitchAngle * 25) / maxPitch);
}
pitchAngle -= 41; // 41 = 4 * AH_SYMBOL_COUNT + 5
for (int x = -4; x <= 4; x++) {
const int y = ((-rollAngle * x) / 64) - pitchAngle;