Merge remote-tracking branch 'multiwii/master'

Conflicts:
	obj/baseflight.hex
	src/main/io/serial_msp.c
	src/mw.c
	src/mw.h
This commit is contained in:
Dominic Clifton 2014-06-01 16:54:54 +01:00
commit 3f7960849a
5 changed files with 11 additions and 5411 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ uint16_t batteryWarningVoltage; // annoying buzzer after this one, battery r
uint8_t vbat = 0; // battery voltage in 0.1V steps
int32_t amperage = 0; // amperage read by current sensor in centiampere (1/100th A)
uint32_t mAhdrawn = 0; // milliampere hours drawn from the battery since start
int32_t mAhDrawn = 0; // milliampere hours drawn from the battery since start
static batteryConfig_t *batteryConfig;
@ -82,15 +82,15 @@ int32_t currentSensorToCentiamps(uint16_t src)
return (millivolts * 1000) / (int32_t)batteryConfig->currentMeterScale; // current in 0.01A steps
}
void updateCurrentMeter(uint32_t lastUpdateAt)
void updateCurrentMeter(int32_t lastUpdateAt)
{
static int32_t amperageRaw = 0;
static uint32_t mAhdrawnRaw = 0;
static int64_t mAhdrawnRaw = 0;
amperageRaw -= amperageRaw / 8;
amperageRaw += adcGetChannel(ADC_CURRENT);
amperage = currentSensorToCentiamps(amperageRaw / 8);
mAhdrawnRaw += (amperage * lastUpdateAt) / 1000; // will overflow at ~11000mAh
mAhdrawn = mAhdrawnRaw / (3600 * 100);
mAhdrawnRaw += (amperage * lastUpdateAt) / 1000;
mAhDrawn = mAhdrawnRaw / (3600 * 100);
}

View File

@ -16,12 +16,12 @@ extern uint8_t vbat;
extern uint8_t batteryCellCount;
extern uint16_t batteryWarningVoltage;
extern int32_t amperage;
extern uint32_t mAhdrawn;
extern int32_t mAhDrawn;
uint16_t batteryAdcToVoltage(uint16_t src);
bool shouldSoundBatteryAlarm(void);
void updateBatteryVoltage(void);
void batteryInit(batteryConfig_t *initialBatteryConfig);
void updateCurrentMeter(uint32_t lastUpdateAt);
void updateCurrentMeter(int32_t lastUpdateAt);
int32_t currentMeterToCentiamps(uint16_t src);

View File

@ -619,12 +619,12 @@ static void evaluateCommand(void)
case MSP_ANALOG:
headSerialReply(7);
serialize8((uint8_t)constrain(vbat, 0, 255));
serialize16(mAhdrawn); // milliamphours drawn from battery
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((abs(amperage) * 10), 0, 0xFFFF)); // send amperage in 0.001 A steps
} else
serialize16((uint16_t)abs(amperage)); // send amperage in 0.01 A steps
serialize16((uint16_t)constrain(abs(amperage), 0, 0xFFFF)); // send amperage in 0.01 A steps
break;
case MSP_RC_TUNING:
headSerialReply(7);

View File

@ -160,7 +160,7 @@ void annexCode(void)
static uint8_t batteryWarningEnabled = false;
static uint8_t vbatTimer = 0;
static uint32_t vbatCycleTime = 0;
static int32_t vbatCycleTime = 0;
// PITCH & ROLL only dynamic PID adjustemnt, depending on throttle value
if (rcData[THROTTLE] < currentProfile.tpa_breakpoint) {