AP_RCProtocol: added multi-channel read() API
and use pulse_input_enable() to disable pulse input when not needed
This commit is contained in:
parent
3ca8b7b40f
commit
07ee3b4c5e
@ -25,6 +25,8 @@
|
|||||||
#include "AP_RCProtocol_ST24.h"
|
#include "AP_RCProtocol_ST24.h"
|
||||||
#include <AP_Math/AP_Math.h>
|
#include <AP_Math/AP_Math.h>
|
||||||
|
|
||||||
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
void AP_RCProtocol::init()
|
void AP_RCProtocol::init()
|
||||||
{
|
{
|
||||||
backend[AP_RCProtocol::PPM] = new AP_RCProtocol_PPMSum(*this);
|
backend[AP_RCProtocol::PPM] = new AP_RCProtocol_PPMSum(*this);
|
||||||
@ -148,6 +150,9 @@ void AP_RCProtocol::process_byte(uint8_t byte, uint32_t baudrate)
|
|||||||
memset(_good_frames, 0, sizeof(_good_frames));
|
memset(_good_frames, 0, sizeof(_good_frames));
|
||||||
_last_input_ms = now;
|
_last_input_ms = now;
|
||||||
_detected_with_bytes = true;
|
_detected_with_bytes = true;
|
||||||
|
|
||||||
|
// stop decoding pulses to save CPU
|
||||||
|
hal.rcin->pulse_input_enable(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,6 +245,13 @@ uint16_t AP_RCProtocol::read(uint8_t chan)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AP_RCProtocol::read(uint16_t *pwm, uint8_t n)
|
||||||
|
{
|
||||||
|
if (_detected_protocol != AP_RCProtocol::NONE) {
|
||||||
|
backend[_detected_protocol]->read(pwm, n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ask for bind start on supported receivers (eg spektrum satellite)
|
ask for bind start on supported receivers (eg spektrum satellite)
|
||||||
*/
|
*/
|
||||||
|
@ -64,6 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
uint8_t num_channels();
|
uint8_t num_channels();
|
||||||
uint16_t read(uint8_t chan);
|
uint16_t read(uint8_t chan);
|
||||||
|
void read(uint16_t *pwm, uint8_t n);
|
||||||
bool new_input();
|
bool new_input();
|
||||||
void start_bind(void);
|
void start_bind(void);
|
||||||
|
|
||||||
|
@ -46,6 +46,14 @@ uint16_t AP_RCProtocol_Backend::read(uint8_t chan)
|
|||||||
return _pwm_values[chan];
|
return _pwm_values[chan];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AP_RCProtocol_Backend::read(uint16_t *pwm, uint8_t n)
|
||||||
|
{
|
||||||
|
if (n >= MAX_RCIN_CHANNELS) {
|
||||||
|
n = MAX_RCIN_CHANNELS;
|
||||||
|
}
|
||||||
|
memcpy(pwm, _pwm_values, n*sizeof(pwm[0]));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
provide input from a backend
|
provide input from a backend
|
||||||
*/
|
*/
|
||||||
|
@ -28,6 +28,7 @@ public:
|
|||||||
virtual void process_pulse(uint32_t width_s0, uint32_t width_s1) {}
|
virtual void process_pulse(uint32_t width_s0, uint32_t width_s1) {}
|
||||||
virtual void process_byte(uint8_t byte, uint32_t baudrate) {}
|
virtual void process_byte(uint8_t byte, uint32_t baudrate) {}
|
||||||
uint16_t read(uint8_t chan);
|
uint16_t read(uint8_t chan);
|
||||||
|
void read(uint16_t *pwm, uint8_t n);
|
||||||
bool new_input();
|
bool new_input();
|
||||||
uint8_t num_channels();
|
uint8_t num_channels();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user