Minor code cleanup
This commit is contained in:
parent
6b37b96048
commit
1ecbdf3dae
|
@ -1437,16 +1437,16 @@ static void cliSetVar(const clivalue_t *var, const int_float_value_t value)
|
|||
switch (var->type & VALUE_TYPE_MASK) {
|
||||
case VAR_UINT8:
|
||||
case VAR_INT8:
|
||||
*(char *)ptr = (char)value.int_value;
|
||||
*(int8_t *)ptr = value.int_value;
|
||||
break;
|
||||
|
||||
case VAR_UINT16:
|
||||
case VAR_INT16:
|
||||
*(short *)ptr = (short)value.int_value;
|
||||
*(int16_t *)ptr = value.int_value;
|
||||
break;
|
||||
|
||||
case VAR_UINT32:
|
||||
*(int *)ptr = (int)value.int_value;
|
||||
*(uint32_t *)ptr = value.int_value;
|
||||
break;
|
||||
|
||||
case VAR_FLOAT:
|
||||
|
@ -1639,7 +1639,7 @@ void cliProcess(void)
|
|||
}
|
||||
for (; i < bufferIndex; i++)
|
||||
cliWrite(cliBuffer[i]);
|
||||
} else if (!bufferIndex && c == 4) {
|
||||
} else if (!bufferIndex && c == 4) { // CTRL-D
|
||||
cliExit(cliBuffer);
|
||||
return;
|
||||
} else if (c == 12) {
|
||||
|
|
|
@ -92,23 +92,20 @@ void batteryInit(batteryConfig_t *initialBatteryConfig)
|
|||
delay((32 / BATTERY_SAMPLE_COUNT) * 10);
|
||||
}
|
||||
|
||||
// autodetect cell count, going from 1S..8S
|
||||
for (i = 1; i < 8; i++) {
|
||||
if (vbat < i * batteryConfig->vbatmaxcellvoltage)
|
||||
break;
|
||||
}
|
||||
|
||||
batteryCellCount = i;
|
||||
unsigned cells = (vbat / batteryConfig->vbatmaxcellvoltage) + 1;
|
||||
if(cells > 8) // something is wrong, we expect 8 cells maximum (and autodetection will be problematic at 6+ cells)
|
||||
cells = 8;
|
||||
batteryCellCount = cells;
|
||||
batteryWarningVoltage = batteryCellCount * batteryConfig->vbatwarningcellvoltage;
|
||||
batteryCriticalVoltage = batteryCellCount * batteryConfig->vbatmincellvoltage;
|
||||
}
|
||||
|
||||
#define ADCVREF 33L
|
||||
#define ADCVREF 3300 // in mV
|
||||
int32_t currentSensorToCentiamps(uint16_t src)
|
||||
{
|
||||
int32_t millivolts;
|
||||
|
||||
millivolts = ((uint32_t)src * ADCVREF * 100) / 4095;
|
||||
millivolts = ((uint32_t)src * ADCVREF) / 4096;
|
||||
millivolts -= batteryConfig->currentMeterOffset;
|
||||
|
||||
return (millivolts * 1000) / (int32_t)batteryConfig->currentMeterScale; // current in 0.01A steps
|
||||
|
|
|
@ -322,13 +322,12 @@ void handleSmartPortTelemetry(void)
|
|||
smartPortIdCnt++;
|
||||
|
||||
int32_t tmpi;
|
||||
uint32_t tmpui;
|
||||
static uint8_t t1Cnt = 0;
|
||||
|
||||
switch(id) {
|
||||
case FSSP_DATAID_SPEED :
|
||||
if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
|
||||
tmpui = (GPS_speed * 36 + 36 / 2) / 100;
|
||||
uint32_t tmpui = (GPS_speed * 36 + 36 / 2) / 100;
|
||||
smartPortSendPackage(id, tmpui); // given in 0.1 m/s, provide in KM/H
|
||||
smartPortHasRequest = 0;
|
||||
}
|
||||
|
@ -355,7 +354,7 @@ void handleSmartPortTelemetry(void)
|
|||
//case FSSP_DATAID_ADC2 :
|
||||
case FSSP_DATAID_LATLONG :
|
||||
if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
|
||||
tmpui = 0;
|
||||
uint32_t tmpui = 0;
|
||||
// the same ID is sent twice, one for longitude, one for latitude
|
||||
// the MSB of the sent uint32_t helps FrSky keep track
|
||||
// the even/odd bit of our counter helps us keep track
|
||||
|
|
Loading…
Reference in New Issue