AP_Notify: support playing tunes by string on ChibiOS
This commit is contained in:
parent
4244daeb2d
commit
d93964b319
@ -21,6 +21,7 @@
|
|||||||
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
||||||
#include "ToneAlarm_ChibiOS.h"
|
#include "ToneAlarm_ChibiOS.h"
|
||||||
#include <AP_HAL_ChibiOS/ToneAlarm.h>
|
#include <AP_HAL_ChibiOS/ToneAlarm.h>
|
||||||
|
#include <AP_Math/AP_Math.h>
|
||||||
#include "AP_Notify.h"
|
#include "AP_Notify.h"
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
@ -102,4 +103,26 @@ void ToneAlarm_ChibiOS::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
handle a PLAY_TUNE message
|
||||||
|
*/
|
||||||
|
void ToneAlarm_ChibiOS::handle_play_tune(mavlink_message_t *msg)
|
||||||
|
{
|
||||||
|
// decode mavlink message
|
||||||
|
mavlink_play_tune_t packet;
|
||||||
|
|
||||||
|
mavlink_msg_play_tune_decode(msg, &packet);
|
||||||
|
|
||||||
|
char str[100];
|
||||||
|
strncpy(str, packet.tune, MIN(sizeof(packet.tune), sizeof(str)-1));
|
||||||
|
str[sizeof(str)-1] = 0;
|
||||||
|
uint8_t len = strlen(str);
|
||||||
|
uint8_t len2 = strnlen(packet.tune2, sizeof(packet.tune2));
|
||||||
|
len2 = MIN((sizeof(str)-1)-len, len2);
|
||||||
|
strncpy(str+len, packet.tune2, len2);
|
||||||
|
str[sizeof(str)-1] = 0;
|
||||||
|
|
||||||
|
hal.util->toneAlarm_set_tune_string(str);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
||||||
|
@ -28,6 +28,9 @@ public:
|
|||||||
/// update - updates led according to timed_updated. Should be called at 50Hz
|
/// update - updates led according to timed_updated. Should be called at 50Hz
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
// handle a PLAY_TUNE message
|
||||||
|
void handle_play_tune(mavlink_message_t *msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// play_tune - play one of the pre-defined tunes
|
/// play_tune - play one of the pre-defined tunes
|
||||||
bool play_tune(uint8_t tune_number);
|
bool play_tune(uint8_t tune_number);
|
||||||
|
Loading…
Reference in New Issue
Block a user