Send current meter reading as signed value

Use signed value normally, truncate to 0-0xffff when multiwiiCurrentMeterOutput is active
This commit is contained in:
Petr Ledvina 2015-01-28 17:28:32 +01:00
parent 90b012bc06
commit bf1bc864ae
1 changed files with 2 additions and 2 deletions

View File

@ -830,9 +830,9 @@ static bool processOutCommand(uint8_t cmdMSP)
serialize16((uint16_t)constrain(mAhDrawn, 0, 0xFFFF)); // milliamphours drawn from battery
serialize16(rssi);
if(masterConfig.batteryConfig.multiwiiCurrentMeterOutput) {
serialize16((uint16_t)constrain((ABS(amperage) * 10), 0, 0xFFFF)); // send amperage in 0.001 A steps
serialize16((uint16_t)constrain(amperage * 10, 0, 0xFFFF)); // send amperage in 0.001 A steps. Negative range is truncated to zero
} else
serialize16((uint16_t)constrain(ABS(amperage), 0, 0xFFFF)); // send amperage in 0.01 A steps
serialize16((int16_t)constrain(amperage, -0x8000, 0x7FFF)); // send amperage in 0.01 A steps, range is -320A to 320A
break;
case MSP_RC_TUNING:
headSerialReply(7);