mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
PiOS RCVR: Make the public API use a 1 based indexing for channel numbers.
This may or may not get into next, but if so anyone following it MUST reconfigure their inputs.
This commit is contained in:
parent
8f7712435f
commit
72625d9971
@ -398,8 +398,9 @@ static void resetRcvrActivity(struct rcvr_activity_fsm * fsm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void updateRcvrActivitySample(uint32_t rcvr_id, uint16_t samples[], uint8_t max_channels) {
|
static void updateRcvrActivitySample(uint32_t rcvr_id, uint16_t samples[], uint8_t max_channels) {
|
||||||
for (uint8_t channel = 0; channel < max_channels; channel++) {
|
for (uint8_t channel = 1; channel <= max_channels; channel++) {
|
||||||
samples[channel] = PIOS_RCVR_Read(rcvr_id, channel);
|
// Subtract 1 because channels are 1 indexed
|
||||||
|
samples[channel - 1] = PIOS_RCVR_Read(rcvr_id, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,11 +409,11 @@ static bool updateRcvrActivityCompare(uint32_t rcvr_id, struct rcvr_activity_fsm
|
|||||||
bool activity_updated = false;
|
bool activity_updated = false;
|
||||||
|
|
||||||
/* Compare the current value to the previous sampled value */
|
/* Compare the current value to the previous sampled value */
|
||||||
for (uint8_t channel = 0;
|
for (uint8_t channel = 1;
|
||||||
channel < RCVR_ACTIVITY_MONITOR_CHANNELS_PER_GROUP;
|
channel <= RCVR_ACTIVITY_MONITOR_CHANNELS_PER_GROUP;
|
||||||
channel++) {
|
channel++) {
|
||||||
uint16_t delta;
|
uint16_t delta;
|
||||||
uint16_t prev = fsm->prev[channel];
|
uint16_t prev = fsm->prev[channel - 1]; // Subtract 1 because channels are 1 indexed
|
||||||
uint16_t curr = PIOS_RCVR_Read(rcvr_id, channel);
|
uint16_t curr = PIOS_RCVR_Read(rcvr_id, channel);
|
||||||
if (curr > prev) {
|
if (curr > prev) {
|
||||||
delta = curr - prev;
|
delta = curr - prev;
|
||||||
|
@ -87,6 +87,12 @@ out_fail:
|
|||||||
*/
|
*/
|
||||||
int32_t PIOS_RCVR_Read(uint32_t rcvr_id, uint8_t channel)
|
int32_t PIOS_RCVR_Read(uint32_t rcvr_id, uint8_t channel)
|
||||||
{
|
{
|
||||||
|
// Publicly facing API uses channel 1 for first channel
|
||||||
|
if(channel == 0)
|
||||||
|
return PIOS_RCVR_INVALID;
|
||||||
|
else
|
||||||
|
channel--;
|
||||||
|
|
||||||
if (rcvr_id == 0)
|
if (rcvr_id == 0)
|
||||||
return PIOS_RCVR_NODRIVER;
|
return PIOS_RCVR_NODRIVER;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user