Merge pull request #182 from ledvinap/fix-smartport

Fixed SmartPort units for heading; small improvements
This commit is contained in:
Dominic Clifton 2014-11-24 14:52:52 +00:00
commit a71ef8fb80
1 changed files with 5 additions and 8 deletions

View File

@ -72,7 +72,8 @@ enum
FSSP_SENSOR_ID2 = 0x0D,
FSSP_SENSOR_ID3 = 0x34,
FSSP_SENSOR_ID4 = 0x67,
// reverse engineering tells me that there are plenty more IDs
// there are 32 ID's polled by smartport master
// remaining 3 bits are crc (according to comments in openTx code)
};
// these data identifiers are obtained from http://diydrones.com/forum/topics/amp-to-frsky-x8r-sport-converter
@ -181,8 +182,6 @@ static void smartPortSendByte(uint8_t c, uint16_t *crcp)
crc += c;
crc += crc >> 8;
crc &= 0x00FF;
crc += crc >> 8;
crc &= 0x00FF;
*crcp = crc;
}
@ -315,7 +314,6 @@ void handleSmartPortTelemetry(void)
}
smartPortIdCnt++;
float tmpf;
int32_t tmpi;
uint32_t tmpui;
static uint8_t t1Cnt = 0;
@ -323,9 +321,8 @@ void handleSmartPortTelemetry(void)
switch(id) {
case FSSP_DATAID_SPEED :
if (sensors(SENSOR_GPS) && STATE(GPS_FIX)) {
tmpf = GPS_speed;
tmpf *= 0.36f;
smartPortSendPackage(id, (uint32_t)lroundf(tmpf)); // given in 0.1 m/s, provide in KM/H
tmpui = (GPS_speed * 36 + 36 / 2) / 100;
smartPortSendPackage(id, tmpui); // given in 0.1 m/s, provide in KM/H
smartPortHasRequest = 0;
}
break;
@ -380,7 +377,7 @@ void handleSmartPortTelemetry(void)
smartPortHasRequest = 0;
break;
case FSSP_DATAID_HEADING :
smartPortSendPackage(id, heading / 10); // given in 0.1 deg, requested in 10000 = 100 deg
smartPortSendPackage(id, heading * 100); // given in deg, requested in 10000 = 100 deg
smartPortHasRequest = 0;
break;
case FSSP_DATAID_ACCX :