36 #include <uavcan/equipment/indication/LightsCommand.hpp> 41 unsigned self_light_index = 0;
43 void cb_light_command(
const uavcan::ReceivedDataStructure<uavcan::equipment::indication::LightsCommand> &
msg)
45 uavcan::uint32_t red = 0;
46 uavcan::uint32_t green = 0;
47 uavcan::uint32_t blue = 0;
49 for (
auto &cmd : msg.commands) {
50 if (cmd.light_id == self_light_index) {
51 using uavcan::equipment::indication::RGB565;
53 red = uavcan::uint32_t(
float(cmd.color.red) *
56 green = uavcan::uint32_t(
float(cmd.color.green) *
59 blue = uavcan::uint32_t(
float(cmd.color.blue) *
62 red = uavcan::min<uavcan::uint32_t>(red, 0xFFU);
63 green = uavcan::min<uavcan::uint32_t>(green, 0xFFU);
64 blue = uavcan::min<uavcan::uint32_t>(blue, 0xFFU);
67 if (cmd.light_id == self_light_index + 1) {
71 ::syslog(LOG_INFO,
"rgb:%d %d %d hz %d\n", red, green, blue,
int(cmd.color.red));
74 rgb_led(red, green, blue,
int(cmd.color.red));
83 static uavcan::Subscriber<uavcan::equipment::indication::LightsCommand> sub_light(node);
89 res = sub_light.start(cb_light_command);
static char msg[NUM_MSG][CONFIG_USART1_TXBUFSIZE]
int init_indication_controller(uavcan::INode &node)
constexpr _Tp max(_Tp a, _Tp b)
void rgb_led(int r, int g, int b, int freqs)