mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 02:13:34 +08:00
cuav gps:Add Beep indication
This commit is contained in:
committed by
Daniel Agar
parent
3b26b7adaf
commit
ab650373d6
@@ -3,6 +3,7 @@
|
||||
# board specific defaults
|
||||
#------------------------------------------------------------------------------
|
||||
neopixel start
|
||||
tone_alarm start
|
||||
|
||||
if [ $AUTOCNF = yes ]
|
||||
then
|
||||
|
||||
@@ -36,8 +36,11 @@
|
||||
#include <uavcan_stm32/uavcan_stm32.hpp>
|
||||
#include "indication_controller.hpp"
|
||||
#include <uavcan/equipment/indication/LightsCommand.hpp>
|
||||
#include <uavcan/equipment/indication/BeepCommand.hpp>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/topics/led_control.h>
|
||||
#include <uORB/topics/tune_control.h>
|
||||
#include <lib/tunes/tunes.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -108,10 +111,25 @@ void cb_light_command(const uavcan::ReceivedDataStructure<uavcan::equipment::ind
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cb_beep_command(const uavcan::ReceivedDataStructure<uavcan::equipment::indication::BeepCommand> &msg)
|
||||
{
|
||||
tune_control_s tune_control{};
|
||||
tune_control.tune_id = 0;
|
||||
tune_control.frequency = (uint16_t)msg.frequency;
|
||||
tune_control.duration = uavcan::uint32_t(1000000 * msg.duration);
|
||||
tune_control.volume = 0xff;
|
||||
uORB::Publication<tune_control_s> tune_control_pub{ORB_ID(tune_control)};
|
||||
tune_control.timestamp = hrt_absolute_time();
|
||||
tune_control_pub.publish(tune_control);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
int init_indication_controller(uavcan::INode &node)
|
||||
{
|
||||
static uavcan::Subscriber<uavcan::equipment::indication::LightsCommand> sub_light(node);
|
||||
static uavcan::Subscriber<uavcan::equipment::indication::BeepCommand> sub_beep(node);
|
||||
|
||||
self_light_index = 0;
|
||||
|
||||
@@ -123,5 +141,11 @@ int init_indication_controller(uavcan::INode &node)
|
||||
return res;
|
||||
}
|
||||
|
||||
res = sub_beep.start(cb_beep_command);
|
||||
|
||||
if (res != 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user