Skip to content

Commit

Permalink
Use scaleRange() instead
Browse files Browse the repository at this point in the history
  • Loading branch information
iphong committed Jun 26, 2019
1 parent caf4dfd commit 0c2ac46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/Telemetry.md
Expand Up @@ -174,7 +174,7 @@ The following sensors are transmitted :
| Hdg | heading, North is 0°, South is 180°. |
| AccX,Y,Z | accelerometers values. |
| Tmp1 | actual flight mode, sent as 4 digits. Number is sent as (1)1234. Please ignore the leading 1, it is just there to ensure the number as always 5 digits (the 1 + 4 digits of actual data) the numbers are aditives (for example, if first digit after the leading 1 is 6, it means GPS Home and Headfree are both active) <ol><li>1 is GPS Hold, 2 is GPS Home, 4 is Headfree</li><li>1 is mag enabled, 2 is baro enabled, 4 is sonar enabled</li><li>3. 1 is angle, 2 is horizon, 4 is passthrough</li><li>4. 1 is ok to arm, 2 is arming is prevented, 4 is armed</li></ol> |
| Tmp2 | GPS lock status, Number is sent as 1234, the numbers are aditives<ol><li>1 is GPS Fix, 2 is GPS Home fix</li><li>HDOP (0-9, 0 = 5.5 = lowest, 9 = 1.0 = highest)</li><li>number of sats</li><li>number of sats</li></ol> |
| Tmp2 | GPS lock status, Number is sent as 1234, the numbers are aditives<ol><li>1 is GPS Fix, 2 is GPS Home fix</li><li>HDOP (0-9, 0 is HDOP >= 5.5m, 9 is HDOP <= 1.0m)</li><li>number of sats</li><li>number of sats</li></ol> |
| VFAS | actual vbat value. |
| GAlt | GPS altitude, sea level is zero. |
| GSpd | current speed, calculated by GPS. |
Expand Down
4 changes: 2 additions & 2 deletions src/main/telemetry/smartport.c
Expand Up @@ -762,8 +762,8 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear
case FSSP_DATAID_T2 :
#ifdef USE_GPS
if (sensors(SENSOR_GPS)) {
// HDOP 0-9 (0 = 5.5 = lowest, 9 = 1 = highest)
uint8_t hdop = (9 - constrain((gpsSol.hdop - 51) / 50, 0, 9)) * 100;
// satellite accuracy HDOP: 0 = worst [HDOP > 5.5m], 9 = best [HDOP <= 1.0m]
uint8_t hdop = constrain(scaleRange(gpsSol.hdop, 100, 550, 900, 0), 0, 900);
smartPortSendPackage(id, (STATE(GPS_FIX) ? 1000 : 0) + (STATE(GPS_FIX_HOME) ? 2000 : 0) + hdop + gpsSol.numSat);
*clearToSend = false;
} else if (featureIsEnabled(FEATURE_GPS)) {
Expand Down

0 comments on commit 0c2ac46

Please sign in to comment.