Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
constrain rssi before dBm2range().
  • Loading branch information
githubDLG committed Aug 26, 2020
1 parent fa15955 commit 0827f5a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/io/spektrum_rssi.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static const dbm_table_t dbmTable[] = {

// Convert dBm to Range %
static int8_t dBm2range (int8_t dBm) {
int8_t retval = 0;
int8_t retval = dbmTable[0].reportAs;

for ( uint8_t i = 1; i < ARRAYLEN(dbmTable); i++ ) {
if (dBm >= dbmTable[i].dBm) {
Expand Down Expand Up @@ -144,7 +144,7 @@ void spektrumHandleRSSI(volatile uint8_t spekFrame[]) {
#ifdef USE_SPEKTRUM_RSSI_PERCENT_CONVERSION
// Do an dBm to percent conversion with an approxatelly linear distance
// and map the percentage to RSSI RC channel range
spekChannelData[rssi_channel] = (uint16_t)(map(dBm2range (rssi),
spekChannelData[rssi_channel] = (uint16_t)(map(dBm2range (constrain(rssi, SPEKTRUM_RSSI_MIN, SPEKTRUM_RSSI_MAX)),
0, 100,
0,resolution));
#else
Expand Down

0 comments on commit 0827f5a

Please sign in to comment.