mirror of https://github.com/ArduPilot/ardupilot
HAL_PX4: cleanup whitespace
This commit is contained in:
parent
6b4e5304cf
commit
1bd9d0b7f9
|
@ -14,16 +14,16 @@ extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
void PX4RCInput::init()
|
void PX4RCInput::init()
|
||||||
{
|
{
|
||||||
_perf_rcin = perf_alloc(PC_ELAPSED, "APM_rcin");
|
_perf_rcin = perf_alloc(PC_ELAPSED, "APM_rcin");
|
||||||
_rc_sub = orb_subscribe(ORB_ID(input_rc));
|
_rc_sub = orb_subscribe(ORB_ID(input_rc));
|
||||||
if (_rc_sub == -1) {
|
if (_rc_sub == -1) {
|
||||||
AP_HAL::panic("Unable to subscribe to input_rc");
|
AP_HAL::panic("Unable to subscribe to input_rc");
|
||||||
}
|
}
|
||||||
clear_overrides();
|
clear_overrides();
|
||||||
pthread_mutex_init(&rcin_mutex, nullptr);
|
pthread_mutex_init(&rcin_mutex, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PX4RCInput::new_input()
|
bool PX4RCInput::new_input()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&rcin_mutex);
|
pthread_mutex_lock(&rcin_mutex);
|
||||||
bool valid = _rcin.timestamp_last_signal != _last_read || _override_valid;
|
bool valid = _rcin.timestamp_last_signal != _last_read || _override_valid;
|
||||||
|
@ -33,7 +33,7 @@ bool PX4RCInput::new_input()
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PX4RCInput::num_channels()
|
uint8_t PX4RCInput::num_channels()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&rcin_mutex);
|
pthread_mutex_lock(&rcin_mutex);
|
||||||
uint8_t n = _rcin.channel_count;
|
uint8_t n = _rcin.channel_count;
|
||||||
|
@ -41,80 +41,80 @@ uint8_t PX4RCInput::num_channels()
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t PX4RCInput::read(uint8_t ch)
|
uint16_t PX4RCInput::read(uint8_t ch)
|
||||||
{
|
{
|
||||||
if (ch >= RC_INPUT_MAX_CHANNELS) {
|
if (ch >= RC_INPUT_MAX_CHANNELS) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pthread_mutex_lock(&rcin_mutex);
|
pthread_mutex_lock(&rcin_mutex);
|
||||||
if (_override[ch]) {
|
if (_override[ch]) {
|
||||||
uint16_t v = _override[ch];
|
uint16_t v = _override[ch];
|
||||||
pthread_mutex_unlock(&rcin_mutex);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
if (ch >= _rcin.channel_count) {
|
|
||||||
pthread_mutex_unlock(&rcin_mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
uint16_t v = _rcin.values[ch];
|
|
||||||
pthread_mutex_unlock(&rcin_mutex);
|
pthread_mutex_unlock(&rcin_mutex);
|
||||||
return v;
|
return v;
|
||||||
|
}
|
||||||
|
if (ch >= _rcin.channel_count) {
|
||||||
|
pthread_mutex_unlock(&rcin_mutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
uint16_t v = _rcin.values[ch];
|
||||||
|
pthread_mutex_unlock(&rcin_mutex);
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PX4RCInput::read(uint16_t* periods, uint8_t len)
|
uint8_t PX4RCInput::read(uint16_t* periods, uint8_t len)
|
||||||
{
|
{
|
||||||
if (len > RC_INPUT_MAX_CHANNELS) {
|
if (len > RC_INPUT_MAX_CHANNELS) {
|
||||||
len = RC_INPUT_MAX_CHANNELS;
|
len = RC_INPUT_MAX_CHANNELS;
|
||||||
}
|
}
|
||||||
for (uint8_t i = 0; i < len; i++){
|
for (uint8_t i = 0; i < len; i++){
|
||||||
periods[i] = read(i);
|
periods[i] = read(i);
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PX4RCInput::set_overrides(int16_t *overrides, uint8_t len)
|
bool PX4RCInput::set_overrides(int16_t *overrides, uint8_t len)
|
||||||
{
|
{
|
||||||
bool res = false;
|
bool res = false;
|
||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
res |= set_override(i, overrides[i]);
|
res |= set_override(i, overrides[i]);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PX4RCInput::set_override(uint8_t channel, int16_t override) {
|
bool PX4RCInput::set_override(uint8_t channel, int16_t override) {
|
||||||
if (override < 0) {
|
if (override < 0) {
|
||||||
return false; /* -1: no change. */
|
return false; /* -1: no change. */
|
||||||
}
|
}
|
||||||
if (channel >= RC_INPUT_MAX_CHANNELS) {
|
if (channel >= RC_INPUT_MAX_CHANNELS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_override[channel] = override;
|
_override[channel] = override;
|
||||||
if (override != 0) {
|
if (override != 0) {
|
||||||
_override_valid = true;
|
_override_valid = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PX4RCInput::clear_overrides()
|
void PX4RCInput::clear_overrides()
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < RC_INPUT_MAX_CHANNELS; i++) {
|
for (uint8_t i = 0; i < RC_INPUT_MAX_CHANNELS; i++) {
|
||||||
set_override(i, 0);
|
set_override(i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PX4RCInput::_timer_tick(void)
|
void PX4RCInput::_timer_tick(void)
|
||||||
{
|
{
|
||||||
perf_begin(_perf_rcin);
|
perf_begin(_perf_rcin);
|
||||||
bool rc_updated = false;
|
bool rc_updated = false;
|
||||||
if (orb_check(_rc_sub, &rc_updated) == 0 && rc_updated) {
|
if (orb_check(_rc_sub, &rc_updated) == 0 && rc_updated) {
|
||||||
pthread_mutex_lock(&rcin_mutex);
|
pthread_mutex_lock(&rcin_mutex);
|
||||||
orb_copy(ORB_ID(input_rc), _rc_sub, &_rcin);
|
orb_copy(ORB_ID(input_rc), _rc_sub, &_rcin);
|
||||||
pthread_mutex_unlock(&rcin_mutex);
|
pthread_mutex_unlock(&rcin_mutex);
|
||||||
}
|
}
|
||||||
// note, we rely on the vehicle code checking new_input()
|
// note, we rely on the vehicle code checking new_input()
|
||||||
// and a timeout for the last valid input to handle failsafe
|
// and a timeout for the last valid input to handle failsafe
|
||||||
perf_end(_perf_rcin);
|
perf_end(_perf_rcin);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PX4RCInput::rc_bind(int dsmMode)
|
bool PX4RCInput::rc_bind(int dsmMode)
|
||||||
|
@ -127,7 +127,7 @@ bool PX4RCInput::rc_bind(int dsmMode)
|
||||||
hal.console->printf("RCInput: failed to open /dev/px4io or /dev/px4fmu\n");
|
hal.console->printf("RCInput: failed to open /dev/px4io or /dev/px4fmu\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mode = (dsmMode == 0) ? DSM2_BIND_PULSES : ((dsmMode == 1) ? DSMX_BIND_PULSES : DSMX8_BIND_PULSES);
|
uint32_t mode = (dsmMode == 0) ? DSM2_BIND_PULSES : ((dsmMode == 1) ? DSMX_BIND_PULSES : DSMX8_BIND_PULSES);
|
||||||
int ret = ioctl(fd, DSM_BIND_START, mode);
|
int ret = ioctl(fd, DSM_BIND_START, mode);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
Loading…
Reference in New Issue