Extend UAVCAN light control

Adds automatic control of more light types via UAVCAN. Publishes
commands for beacon, strobe, nav, and landings lights. Each is
automatically controlled based on arming state and this behavior is
configurable per light type via params. For example, nav lights can be
set to be always on while beacons turn on when the system is prearmed
and strobes turn on only when armed.
This commit is contained in:
Avionics Anonymous
2020-11-02 23:29:50 +01:00
committed by Lorenz Meier
parent 67a0e1993a
commit cc96468fad
3 changed files with 191 additions and 1 deletions
+19
View File
@@ -33,6 +33,8 @@
#pragma once
#include <uORB/topics/actuator_armed.h>
#include <uavcan/uavcan.hpp>
#include <uavcan/equipment/indication/LightsCommand.hpp>
@@ -53,6 +55,8 @@ private:
void periodic_update(const uavcan::TimerEvent &);
uavcan::equipment::indication::RGB565 brightness_to_rgb565(uint8_t brightness);
typedef uavcan::MethodBinder<UavcanRGBController *, void (UavcanRGBController::*)(const uavcan::TimerEvent &)>
TimerCbBinder;
@@ -60,5 +64,20 @@ private:
uavcan::Publisher<uavcan::equipment::indication::LightsCommand> _uavcan_pub_lights_cmd;
uavcan::TimerEventForwarder<TimerCbBinder> _timer;
uORB::Subscription _armed_sub{ORB_ID(actuator_armed)};
LedController _led_controller;
// Enum defining light activation condition. Must match UAVCAN_LGT_* param values.
enum light_control_mode {
ALWAYS_OFF = 0,
PREARMED,
ARMED,
ALWAYS_ON
};
light_control_mode _mode_anti_col{ALWAYS_OFF};
light_control_mode _mode_strobe{ALWAYS_OFF};
light_control_mode _mode_nav{ALWAYS_OFF};
light_control_mode _mode_land{ALWAYS_OFF};
};