2013-09-19 03:27:31 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-08-11 03:28:44 -03:00
|
|
|
#include "AP_Notify.h"
|
2013-09-19 03:27:31 -03:00
|
|
|
|
2016-01-29 00:38:21 -04:00
|
|
|
#include "AP_BoardLED.h"
|
2017-01-26 08:12:36 -04:00
|
|
|
#include "PixRacerLED.h"
|
2016-01-29 00:38:21 -04:00
|
|
|
#include "Buzzer.h"
|
2017-01-19 03:15:24 -04:00
|
|
|
#include "Display.h"
|
2016-01-29 00:38:21 -04:00
|
|
|
#include "ExternalLED.h"
|
2018-07-18 21:49:35 -03:00
|
|
|
#include "PCA9685LED_I2C.h"
|
2018-07-25 09:07:49 -03:00
|
|
|
#include "NCP5623.h"
|
2016-01-29 00:38:21 -04:00
|
|
|
#include "OreoLED_PX4.h"
|
|
|
|
#include "RCOutputRGBLed.h"
|
2018-07-24 22:30:05 -03:00
|
|
|
#include "ToneAlarm.h"
|
2016-01-29 00:38:21 -04:00
|
|
|
#include "ToshibaLED_I2C.h"
|
|
|
|
#include "VRBoard_LED.h"
|
2016-02-25 09:30:36 -04:00
|
|
|
#include "DiscreteRGBLed.h"
|
2016-10-26 05:26:59 -03:00
|
|
|
#include "DiscoLED.h"
|
2017-11-01 13:11:44 -03:00
|
|
|
#include "Led_Sysfs.h"
|
2018-02-13 03:08:47 -04:00
|
|
|
#include "UAVCAN_RGB_LED.h"
|
2017-01-20 01:39:49 -04:00
|
|
|
#include <stdio.h>
|
2018-01-22 05:11:14 -04:00
|
|
|
#include "AP_BoardLED2.h"
|
2016-09-30 04:21:28 -03:00
|
|
|
|
2018-01-29 17:33:57 -04:00
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
|
2017-07-08 20:40:45 -03:00
|
|
|
AP_Notify *AP_Notify::_instance;
|
|
|
|
|
2017-09-06 07:12:36 -03:00
|
|
|
#define CONFIG_NOTIFY_DEVICES_MAX 6
|
|
|
|
|
|
|
|
#define TOSHIBA_LED_I2C_BUS_INTERNAL 0
|
|
|
|
#define TOSHIBA_LED_I2C_BUS_EXTERNAL 1
|
2016-01-29 00:38:21 -04:00
|
|
|
|
2018-07-25 09:07:49 -03:00
|
|
|
// all I2C_LEDS
|
|
|
|
#define I2C_LEDS (Notify_LED_ToshibaLED_I2C_Internal | Notify_LED_ToshibaLED_I2C_External | \
|
|
|
|
Notify_LED_NCP5623_I2C_Internal | Notify_LED_NCP5623_I2C_External)
|
|
|
|
|
2018-07-18 21:49:35 -03:00
|
|
|
#ifndef BUILD_DEFAULT_LED_TYPE
|
|
|
|
// PX4 boards
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
|
|
|
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3 // Has enough memory for Oreo LEDs
|
2018-07-25 09:07:49 -03:00
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS | Notify_LED_OreoLED)
|
2018-10-06 05:56:02 -03:00
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V4
|
|
|
|
#define HAL_HAVE_PIXRACER_LED
|
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS)
|
2018-07-18 21:49:35 -03:00
|
|
|
#else // All other px4 boards use standard devices
|
2018-07-25 09:07:49 -03:00
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS)
|
2018-07-18 21:49:35 -03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ChibiOS and VRBrain boards
|
|
|
|
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS || \
|
|
|
|
CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
2018-07-25 09:07:49 -03:00
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS)
|
2018-07-18 21:49:35 -03:00
|
|
|
|
|
|
|
// Linux boards
|
|
|
|
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
|
|
|
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO
|
2018-07-25 09:07:49 -03:00
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS |\
|
2018-07-18 21:49:35 -03:00
|
|
|
Notify_LED_PCA9685LED_I2C_External)
|
|
|
|
|
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2
|
2018-07-25 09:07:49 -03:00
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS)
|
2018-07-18 21:49:35 -03:00
|
|
|
|
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
|
2018-07-25 09:07:49 -03:00
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS |\
|
2018-07-18 21:49:35 -03:00
|
|
|
Notify_LED_UAVCAN)
|
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board)
|
|
|
|
|
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ
|
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_ToshibaLED_I2C_External)
|
|
|
|
|
|
|
|
#else // other linux
|
2018-07-25 09:07:49 -03:00
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS)
|
2018-07-18 21:49:35 -03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// F4Light
|
|
|
|
#elif CONFIG_HAL_BOARD == HAL_BOARD_F4LIGHT
|
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | Notify_LED_ToshibaLED_I2C_External)
|
|
|
|
|
|
|
|
// All other builds
|
|
|
|
#else
|
2018-07-25 09:07:49 -03:00
|
|
|
#define BUILD_DEFAULT_LED_TYPE (Notify_LED_Board | I2C_LEDS)
|
2018-07-18 21:49:35 -03:00
|
|
|
|
|
|
|
#endif // board selection
|
|
|
|
|
|
|
|
#endif // BUILD_DEFAULT_LED_TYPE
|
|
|
|
|
2015-12-01 16:22:26 -04:00
|
|
|
// table of user settable parameters
|
|
|
|
const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
|
|
|
|
2015-12-30 22:11:00 -04:00
|
|
|
// @Param: LED_BRIGHT
|
|
|
|
// @DisplayName: LED Brightness
|
|
|
|
// @Description: Select the RGB LED brightness level. When USB is connected brightness will never be higher than low regardless of the setting.
|
2015-12-01 16:22:26 -04:00
|
|
|
// @Values: 0:Off,1:Low,2:Medium,3:High
|
|
|
|
// @User: Advanced
|
|
|
|
AP_GROUPINFO("LED_BRIGHT", 0, AP_Notify, _rgb_led_brightness, RGB_LED_HIGH),
|
|
|
|
|
2016-03-31 15:18:52 -03:00
|
|
|
// @Param: BUZZ_ENABLE
|
|
|
|
// @DisplayName: Buzzer enable
|
|
|
|
// @Description: Enable or disable the buzzer. Only for Linux and PX4 based boards.
|
|
|
|
// @Values: 0:Disable,1:Enable
|
|
|
|
// @User: Advanced
|
|
|
|
AP_GROUPINFO("BUZZ_ENABLE", 1, AP_Notify, _buzzer_enable, BUZZER_ON),
|
|
|
|
|
2018-01-22 05:11:14 -04:00
|
|
|
|
2016-07-16 03:02:27 -03:00
|
|
|
// @Param: LED_OVERRIDE
|
|
|
|
// @DisplayName: Setup for MAVLink LED override
|
|
|
|
// @Description: This sets up the board RGB LED for override by MAVLink. Normal notify LED control is disabled
|
|
|
|
// @Values: 0:Disable,1:Enable
|
|
|
|
// @User: Advanced
|
|
|
|
AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, 0),
|
2016-09-30 04:21:28 -03:00
|
|
|
|
|
|
|
// @Param: DISPLAY_TYPE
|
|
|
|
// @DisplayName: Type of on-board I2C display
|
|
|
|
// @Description: This sets up the type of on-board I2C display. Disabled by default.
|
|
|
|
// @Values: 0:Disable,1:ssd1306,2:sh1106
|
|
|
|
// @User: Advanced
|
|
|
|
AP_GROUPINFO("DISPLAY_TYPE", 3, AP_Notify, _display_type, 0),
|
|
|
|
|
2018-06-26 14:05:10 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3
|
2017-06-01 19:08:07 -03:00
|
|
|
// @Param: OREO_THEME
|
|
|
|
// @DisplayName: OreoLED Theme
|
|
|
|
// @Description: Enable/Disable Solo Oreo LED driver, 0 to disable, 1 for Aircraft theme, 2 for Rover theme
|
|
|
|
// @Values: 0:Disabled,1:Aircraft,2:Rover
|
|
|
|
// @User: Advanced
|
|
|
|
AP_GROUPINFO("OREO_THEME", 4, AP_Notify, _oreo_theme, 0),
|
2018-06-26 14:05:10 -03:00
|
|
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_PX4 && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3
|
2017-06-01 19:08:07 -03:00
|
|
|
|
2018-05-10 04:01:29 -03:00
|
|
|
#if !defined(HAL_BUZZER_PIN)
|
2018-01-22 05:11:14 -04:00
|
|
|
// @Param: BUZZ_PIN
|
|
|
|
// @DisplayName: Buzzer pin
|
|
|
|
// @Description: Enables to connect active buzzer to arbitrary pin. Requires 3-pin buzzer or additional MOSFET!
|
2018-03-25 22:35:39 -03:00
|
|
|
// @Values: 0:Disabled
|
2018-01-22 05:11:14 -04:00
|
|
|
// @User: Advanced
|
|
|
|
AP_GROUPINFO("BUZZ_PIN", 5, AP_Notify, _buzzer_pin, 0),
|
|
|
|
#endif
|
|
|
|
|
2018-07-18 21:49:35 -03:00
|
|
|
// @Param: LED_TYPES
|
|
|
|
// @DisplayName: LED Driver Types
|
|
|
|
// @Description: Controls what types of LEDs will be enabled
|
2018-07-25 09:07:49 -03:00
|
|
|
// @Bitmask: 0:Build in LED, 1:Internal ToshibaLED, 2:External ToshibaLED, 3:External PCA9685, 4:Oreo LED, 5:UAVCAN, 6:NCP5623 External, 7:NCP5623 Internal
|
2018-07-18 21:49:35 -03:00
|
|
|
// @User: Advanced
|
|
|
|
AP_GROUPINFO("LED_TYPES", 6, AP_Notify, _led_type, BUILD_DEFAULT_LED_TYPE),
|
|
|
|
|
2015-12-01 16:22:26 -04:00
|
|
|
AP_GROUPEND
|
|
|
|
};
|
|
|
|
|
|
|
|
// Default constructor
|
|
|
|
AP_Notify::AP_Notify()
|
|
|
|
{
|
2018-07-18 21:49:35 -03:00
|
|
|
AP_Param::setup_object_defaults(this, var_info);
|
2017-07-08 20:40:45 -03:00
|
|
|
if (_instance != nullptr) {
|
|
|
|
AP_HAL::panic("AP_Notify must be singleton");
|
|
|
|
}
|
|
|
|
_instance = this;
|
2015-12-01 16:22:26 -04:00
|
|
|
}
|
|
|
|
|
2013-09-19 03:27:31 -03:00
|
|
|
// static flags, to allow for direct class update from device drivers
|
2016-09-30 04:21:28 -03:00
|
|
|
struct AP_Notify::notify_flags_and_values_type AP_Notify::flags;
|
2014-10-23 09:04:34 -03:00
|
|
|
struct AP_Notify::notify_events_type AP_Notify::events;
|
2013-09-19 03:27:31 -03:00
|
|
|
|
2017-09-06 07:12:36 -03:00
|
|
|
NotifyDevice *AP_Notify::_devices[CONFIG_NOTIFY_DEVICES_MAX];
|
|
|
|
uint8_t AP_Notify::_num_devices;
|
2016-01-22 16:03:07 -04:00
|
|
|
|
2018-06-26 14:50:11 -03:00
|
|
|
void AP_Notify::add_backend_helper(NotifyDevice *backend)
|
|
|
|
{
|
|
|
|
_devices[_num_devices] = backend;
|
|
|
|
_devices[_num_devices]->pNotify = this;
|
|
|
|
if(!_devices[_num_devices]->init()) {
|
|
|
|
delete _devices[_num_devices];
|
|
|
|
_devices[_num_devices] = nullptr;
|
|
|
|
} else {
|
|
|
|
_num_devices++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ADD_BACKEND(backend) do { add_backend_helper(backend); if (_num_devices >= CONFIG_NOTIFY_DEVICES_MAX) return;} while(0)
|
2017-09-06 07:12:36 -03:00
|
|
|
|
|
|
|
// add notify backends to _devices array
|
|
|
|
void AP_Notify::add_backends(void)
|
2017-06-01 19:08:07 -03:00
|
|
|
{
|
2017-09-06 07:12:36 -03:00
|
|
|
if (_num_devices != 0) {
|
|
|
|
return;
|
|
|
|
}
|
2016-01-22 16:02:08 -04:00
|
|
|
|
2018-07-22 16:45:39 -03:00
|
|
|
for (uint32_t i = 1; i < Notify_LED_MAX; i = i << 1) {
|
2018-07-18 21:49:35 -03:00
|
|
|
switch(_led_type & i) {
|
|
|
|
case Notify_LED_None:
|
|
|
|
break;
|
|
|
|
case Notify_LED_Board:
|
|
|
|
// select the most appropriate built in LED driver type
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
|
|
|
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2
|
|
|
|
ADD_BACKEND(new Led_Sysfs("rgb_led0", "rgb_led2", "rgb_led1"));
|
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE
|
|
|
|
ADD_BACKEND(new RCOutputRGBLedInverted(12, 13, 14));
|
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH
|
|
|
|
ADD_BACKEND(new RCOutputRGBLed(HAL_RCOUT_RGBLED_RED, HAL_RCOUT_RGBLED_GREEN, HAL_RCOUT_RGBLED_BLUE));
|
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
|
|
|
ADD_BACKEND(new DiscoLED());
|
|
|
|
#endif
|
|
|
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
2017-09-06 07:12:36 -03:00
|
|
|
|
2018-07-25 22:09:34 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
|
|
|
ADD_BACKEND(new AP_ExternalLED()); // despite the name this is a built in set of onboard LED's
|
|
|
|
#endif // CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
|
|
|
|
2018-07-18 21:49:35 -03:00
|
|
|
#if defined(HAL_HAVE_PIXRACER_LED)
|
|
|
|
ADD_BACKEND(new PixRacerLED());
|
|
|
|
#elif (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN) && defined(HAL_GPIO_C_LED_PIN))
|
|
|
|
#if CONFIG_HAL_BOARD != HAL_BOARD_VRBRAIN || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_VRBRAIN_V45
|
|
|
|
ADD_BACKEND(new AP_BoardLED());
|
|
|
|
#else
|
|
|
|
ADD_BACKEND(new VRBoard_LED());
|
|
|
|
#endif // CONFIG_HAL_BOARD != HAL_BOARD_VRBRAIN || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_VRBRAIN_V45
|
|
|
|
#elif (defined(HAL_GPIO_A_LED_PIN) && defined(HAL_GPIO_B_LED_PIN))
|
|
|
|
ADD_BACKEND(new AP_BoardLED2());
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case Notify_LED_ToshibaLED_I2C_Internal:
|
|
|
|
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
|
|
|
break;
|
|
|
|
case Notify_LED_ToshibaLED_I2C_External:
|
|
|
|
ADD_BACKEND(new ToshibaLED_I2C(TOSHIBA_LED_I2C_BUS_EXTERNAL));
|
|
|
|
break;
|
2018-07-25 09:07:49 -03:00
|
|
|
#if !HAL_MINIMIZE_FEATURES
|
|
|
|
case Notify_LED_NCP5623_I2C_External:
|
2018-08-07 05:28:13 -03:00
|
|
|
FOREACH_I2C_EXTERNAL(b) {
|
|
|
|
ADD_BACKEND(new NCP5623(b));
|
|
|
|
}
|
2018-07-25 09:07:49 -03:00
|
|
|
break;
|
|
|
|
case Notify_LED_NCP5623_I2C_Internal:
|
|
|
|
ADD_BACKEND(new NCP5623(TOSHIBA_LED_I2C_BUS_INTERNAL));
|
|
|
|
break;
|
|
|
|
#endif
|
2018-07-18 21:49:35 -03:00
|
|
|
case Notify_LED_PCA9685LED_I2C_External:
|
|
|
|
ADD_BACKEND(new PCA9685LED_I2C());
|
|
|
|
break;
|
|
|
|
case Notify_LED_OreoLED:
|
|
|
|
// OreoLED's are PX4-v3 build only
|
|
|
|
#if (CONFIG_HAL_BOARD == HAL_BOARD_PX4) && (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3)
|
|
|
|
if (_oreo_theme) {
|
|
|
|
ADD_BACKEND(new OreoLED_PX4(_oreo_theme));
|
|
|
|
}
|
|
|
|
#endif // (CONFIG_HAL_BOARD == HAL_BOARD_PX4) && (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_PX4_V3)
|
|
|
|
break;
|
|
|
|
case Notify_LED_UAVCAN:
|
|
|
|
#if HAL_WITH_UAVCAN
|
|
|
|
ADD_BACKEND(new UAVCAN_RGB_LED(0));
|
|
|
|
#endif // HAL_WITH_UAVCAN
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2017-09-06 07:12:36 -03:00
|
|
|
}
|
2017-06-01 19:08:07 -03:00
|
|
|
|
2018-07-18 21:49:35 -03:00
|
|
|
|
|
|
|
// Always try and add a display backend
|
2017-09-06 07:12:36 -03:00
|
|
|
ADD_BACKEND(new Display());
|
2017-06-01 19:08:07 -03:00
|
|
|
|
2018-07-18 21:49:35 -03:00
|
|
|
// Add noise making devices
|
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || \
|
2018-07-25 13:53:33 -03:00
|
|
|
CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
|
|
|
ADD_BACKEND(new AP_ToneAlarm());
|
2016-01-22 16:02:08 -04:00
|
|
|
|
2018-07-18 21:49:35 -03:00
|
|
|
// ChibiOS noise makers
|
2018-01-29 17:33:57 -04:00
|
|
|
#elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
|
2018-06-26 15:30:53 -03:00
|
|
|
#ifdef HAL_BUZZER_PIN
|
|
|
|
ADD_BACKEND(new Buzzer());
|
|
|
|
#endif
|
|
|
|
#ifdef HAL_PWM_ALARM
|
2018-07-25 13:53:33 -03:00
|
|
|
ADD_BACKEND(new AP_ToneAlarm());
|
2018-06-26 15:30:53 -03:00
|
|
|
#endif
|
2016-07-05 12:25:23 -03:00
|
|
|
|
2018-07-18 21:49:35 -03:00
|
|
|
// Linux noise makers
|
2014-11-14 10:14:40 -04:00
|
|
|
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
2018-07-18 21:49:35 -03:00
|
|
|
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2 || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE
|
|
|
|
// No noise makers, keep this though to ensure that the final else is safe
|
|
|
|
|
|
|
|
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
|
|
|
|
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET
|
2017-09-06 07:12:36 -03:00
|
|
|
ADD_BACKEND(new Buzzer());
|
2017-10-30 06:03:04 -03:00
|
|
|
|
2017-09-06 07:12:36 -03:00
|
|
|
#else // other linux
|
2018-07-25 13:53:33 -03:00
|
|
|
ADD_BACKEND(new AP_ToneAlarm());
|
2017-09-06 07:12:36 -03:00
|
|
|
#endif
|
2017-06-01 19:08:07 -03:00
|
|
|
|
2018-07-18 21:49:35 -03:00
|
|
|
// F4Light noise makers
|
2018-02-20 07:48:57 -04:00
|
|
|
#elif CONFIG_HAL_BOARD == HAL_BOARD_F4LIGHT
|
|
|
|
ADD_BACKEND(new Buzzer());
|
2018-07-18 21:49:35 -03:00
|
|
|
#endif // Noise makers
|
|
|
|
|
2017-09-06 07:12:36 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// initialisation
|
2018-07-25 22:09:34 -03:00
|
|
|
void AP_Notify::init(void)
|
2017-09-06 07:12:36 -03:00
|
|
|
{
|
2015-02-02 17:14:44 -04:00
|
|
|
// clear all flags and events
|
|
|
|
memset(&AP_Notify::flags, 0, sizeof(AP_Notify::flags));
|
|
|
|
memset(&AP_Notify::events, 0, sizeof(AP_Notify::events));
|
|
|
|
|
2018-06-26 14:47:00 -03:00
|
|
|
// add all the backends
|
|
|
|
add_backends();
|
2013-09-19 03:27:31 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// main update function, called at 50Hz
|
|
|
|
void AP_Notify::update(void)
|
|
|
|
{
|
2017-09-06 07:12:36 -03:00
|
|
|
for (uint8_t i = 0; i < _num_devices; i++) {
|
2017-06-01 19:08:07 -03:00
|
|
|
if (_devices[i] != nullptr) {
|
|
|
|
_devices[i]->update();
|
|
|
|
}
|
2014-11-14 10:14:40 -04:00
|
|
|
}
|
2014-10-23 09:04:34 -03:00
|
|
|
|
|
|
|
//reset the events
|
|
|
|
memset(&AP_Notify::events, 0, sizeof(AP_Notify::events));
|
2013-09-19 03:27:31 -03:00
|
|
|
}
|
2015-02-26 03:07:33 -04:00
|
|
|
|
|
|
|
// handle a LED_CONTROL message
|
|
|
|
void AP_Notify::handle_led_control(mavlink_message_t *msg)
|
|
|
|
{
|
2017-09-06 07:12:36 -03:00
|
|
|
for (uint8_t i = 0; i < _num_devices; i++) {
|
2017-06-01 19:08:07 -03:00
|
|
|
if (_devices[i] != nullptr) {
|
|
|
|
_devices[i]->handle_led_control(msg);
|
|
|
|
}
|
2015-02-26 03:07:33 -04:00
|
|
|
}
|
|
|
|
}
|
2016-07-22 00:37:25 -03:00
|
|
|
|
|
|
|
// handle a PLAY_TUNE message
|
|
|
|
void AP_Notify::handle_play_tune(mavlink_message_t *msg)
|
|
|
|
{
|
2017-09-06 07:12:36 -03:00
|
|
|
for (uint8_t i = 0; i < _num_devices; i++) {
|
2017-06-01 19:08:07 -03:00
|
|
|
if (_devices[i] != nullptr) {
|
|
|
|
_devices[i]->handle_play_tune(msg);
|
|
|
|
}
|
2016-07-22 00:37:25 -03:00
|
|
|
}
|
|
|
|
}
|
2016-09-30 04:21:28 -03:00
|
|
|
|
2017-01-20 06:13:37 -04:00
|
|
|
// set flight mode string
|
|
|
|
void AP_Notify::set_flight_mode_str(const char *str)
|
|
|
|
{
|
|
|
|
strncpy(_flight_mode_str, str, 4);
|
|
|
|
_flight_mode_str[sizeof(_flight_mode_str)-1] = 0;
|
|
|
|
}
|
|
|
|
|
2016-09-30 04:21:28 -03:00
|
|
|
void AP_Notify::send_text(const char *str)
|
|
|
|
{
|
|
|
|
strncpy(_send_text, str, sizeof(_send_text));
|
|
|
|
_send_text[sizeof(_send_text)-1] = 0;
|
2017-02-17 03:19:16 -04:00
|
|
|
_send_text_updated_millis = AP_HAL::millis();
|
2016-09-30 04:21:28 -03:00
|
|
|
}
|