1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

various: use float instead of double.

Add 'f' suffixes to some constants so they don't get silently promoted
to double.  Use roundf() instead of round().

Saves 208 bytes of flash.

Signed-off-by: Michael Hope <mlhx@google.com>
This commit is contained in:
Michael Hope 2015-05-20 05:10:24 +02:00 committed by Dominic Clifton
parent 084626a70f
commit 48024e512e
3 changed files with 5 additions and 5 deletions

View file

@ -184,10 +184,10 @@ static void autotuneLogAngleTargets(float currentAngle)
eventData.targetAngleAtPeak = (int) targetAngleAtPeak; eventData.targetAngleAtPeak = (int) targetAngleAtPeak;
// currentAngle is integer decidegrees divided by 10, so just reverse that process to get an integer again: // currentAngle is integer decidegrees divided by 10, so just reverse that process to get an integer again:
eventData.currentAngle = round(currentAngle * 10); eventData.currentAngle = roundf(currentAngle * 10);
// the peak angles are only ever set to currentAngle, so they get the same treatment: // the peak angles are only ever set to currentAngle, so they get the same treatment:
eventData.firstPeakAngle = round(firstPeakAngle * 10); eventData.firstPeakAngle = roundf(firstPeakAngle * 10);
eventData.secondPeakAngle = round(secondPeakAngle * 10); eventData.secondPeakAngle = roundf(secondPeakAngle * 10);
blackboxLogEvent(FLIGHT_LOG_EVENT_AUTOTUNE_TARGETS, (flightLogEventData_t*)&eventData); blackboxLogEvent(FLIGHT_LOG_EVENT_AUTOTUNE_TARGETS, (flightLogEventData_t*)&eventData);
} }

View file

@ -154,5 +154,5 @@ uint8_t calculateBatteryCapacityRemainingPercentage(void)
{ {
uint16_t batteryCapacity = batteryConfig->batteryCapacity; uint16_t batteryCapacity = batteryConfig->batteryCapacity;
return constrain((batteryCapacity - constrain(mAhDrawn, 0, 0xFFFF)) * 100.0 / batteryCapacity , 0, 100); return constrain((batteryCapacity - constrain(mAhDrawn, 0, 0xFFFF)) * 100.0f / batteryCapacity , 0, 100);
} }

View file

@ -230,7 +230,7 @@ static void sendSatalliteSignalQualityAsTemperature2(void)
if (telemetryConfig->frsky_unit == FRSKY_UNIT_METRICS) { if (telemetryConfig->frsky_unit == FRSKY_UNIT_METRICS) {
serialize16(satellite); serialize16(satellite);
} else { } else {
float tmp = (satellite - 32) / 1.8; float tmp = (satellite - 32) / 1.8f;
//Round the value //Round the value
tmp += (tmp < 0) ? -0.5f : 0.5f; tmp += (tmp < 0) ? -0.5f : 0.5f;
serialize16(tmp); serialize16(tmp);