mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
AP_Notify: add public accessor and param defaults
This commit is contained in:
parent
6f4bfed82d
commit
7dde981de6
@ -95,6 +95,22 @@ AP_Notify *AP_Notify::_singleton;
|
||||
#define BUZZER_ENABLE_DEFAULT 1
|
||||
#endif
|
||||
|
||||
#ifndef NOTIFY_LED_BRIGHT_DEFAULT
|
||||
#define NOTIFY_LED_BRIGHT_DEFAULT RGB_LED_HIGH
|
||||
#endif
|
||||
|
||||
#ifndef NOTIFY_LED_OVERRIDE_DEFAULT
|
||||
#ifdef HAL_BUILD_AP_PERIPH
|
||||
#define NOTIFY_LED_OVERRIDE_DEFAULT 1 // rgb_source_t::mavlink
|
||||
#else
|
||||
#define NOTIFY_LED_OVERRIDE_DEFAULT 0 // rgb_source_t::standard
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NOTIFY_LED_LEN_DEFAULT
|
||||
#define NOTIFY_LED_LEN_DEFAULT 1
|
||||
#endif
|
||||
|
||||
// table of user settable parameters
|
||||
const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||
|
||||
@ -103,7 +119,7 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||
// @Description: Select the RGB LED brightness level. When USB is connected brightness will never be higher than low regardless of the setting.
|
||||
// @Values: 0:Off,1:Low,2:Medium,3:High
|
||||
// @User: Advanced
|
||||
AP_GROUPINFO("LED_BRIGHT", 0, AP_Notify, _rgb_led_brightness, RGB_LED_HIGH),
|
||||
AP_GROUPINFO("LED_BRIGHT", 0, AP_Notify, _rgb_led_brightness, NOTIFY_LED_BRIGHT_DEFAULT),
|
||||
|
||||
// @Param: BUZZ_ENABLE
|
||||
// @DisplayName: Buzzer enable
|
||||
@ -115,9 +131,9 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||
// @Param: LED_OVERRIDE
|
||||
// @DisplayName: Specifies colour source for the RGBLed
|
||||
// @Description: Specifies the source for the colours and brightness for the LED. OutbackChallenge conforms to the MedicalExpress (https://uavchallenge.org/medical-express/) rules, essentially "Green" is disarmed (safe-to-approach), "Red" is armed (not safe-to-approach). Traffic light is a simplified color set, red when armed, yellow when the safety switch is not surpressing outputs (but disarmed), and green when outputs are surpressed and disarmed, the LED will blink faster if disarmed and failing arming checks.
|
||||
// @Values: 0:Standard,1:MAVLink/Scripting,2:OutbackChallenge,3:TrafficLight
|
||||
// @Values: 0:Standard,1:MAVLink/Scripting/AP_Periph,2:OutbackChallenge,3:TrafficLight
|
||||
// @User: Advanced
|
||||
AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, 0),
|
||||
AP_GROUPINFO("LED_OVERRIDE", 2, AP_Notify, _rgb_led_override, NOTIFY_LED_OVERRIDE_DEFAULT),
|
||||
|
||||
// @Param: DISPLAY_TYPE
|
||||
// @DisplayName: Type of on-board I2C display
|
||||
@ -172,7 +188,7 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = {
|
||||
// @Description: The number of Serial LED's to use for notifications (NeoPixel's and ProfiLED)
|
||||
// @Range: 1 32
|
||||
// @User: Advanced
|
||||
AP_GROUPINFO("LED_LEN", 9, AP_Notify, _led_len, 1),
|
||||
AP_GROUPINFO("LED_LEN", 9, AP_Notify, _led_len, NOTIFY_LED_LEN_DEFAULT),
|
||||
|
||||
AP_GROUPEND
|
||||
};
|
||||
@ -372,7 +388,7 @@ void AP_Notify::handle_led_control(const mavlink_message_t &msg)
|
||||
}
|
||||
}
|
||||
|
||||
// handle RGB from Scripting
|
||||
// handle RGB from Scripting or AP_Periph
|
||||
void AP_Notify::handle_rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz)
|
||||
{
|
||||
for (uint8_t i = 0; i < _num_devices; i++) {
|
||||
@ -415,6 +431,22 @@ void AP_Notify::send_text(const char *str)
|
||||
_send_text_updated_millis = AP_HAL::millis();
|
||||
}
|
||||
|
||||
// convert 0-3 to 0-100
|
||||
int8_t AP_Notify::get_rgb_led_brightness_percent() const
|
||||
{
|
||||
switch (_rgb_led_brightness) {
|
||||
default:
|
||||
case RGB_LED_OFF:
|
||||
return 0;
|
||||
case RGB_LED_LOW:
|
||||
return 33;
|
||||
case RGB_LED_MEDIUM:
|
||||
return 66;
|
||||
case RGB_LED_HIGH:
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AP {
|
||||
|
||||
AP_Notify ¬ify()
|
||||
|
@ -141,7 +141,7 @@ public:
|
||||
// handle a LED_CONTROL message
|
||||
static void handle_led_control(const mavlink_message_t &msg);
|
||||
|
||||
// handle RGB from Scripting
|
||||
// handle RGB from Scripting or AP_Periph
|
||||
static void handle_rgb(uint8_t r, uint8_t g, uint8_t b, uint8_t rate_hz = 0);
|
||||
|
||||
// handle a PLAY_TUNE message
|
||||
@ -165,7 +165,8 @@ public:
|
||||
uint8_t get_buzz_pin() const { return _buzzer_pin; }
|
||||
uint8_t get_buzz_level() const { return _buzzer_level; }
|
||||
uint8_t get_buzz_volume() const { return _buzzer_volume; }
|
||||
uint8_t get_led_len() const {return _led_len; }
|
||||
uint8_t get_led_len() const { return _led_len; }
|
||||
int8_t get_rgb_led_brightness_percent() const;
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||
HAL_Semaphore sf_window_mutex;
|
||||
|
Loading…
Reference in New Issue
Block a user