效果:qgroundcontrol或者mission planner 的参数里面增加,flag,r,g,b值,
flag=0代表默认变化
flag=1代表手动修改r,g,b颜色值,在无人机中体现
libraries/AP_Notify/AP_Notify.cpp
// @Param: BUZZ_VOLUME
// @DisplayName: Buzzer volume
// @Description: Enable or disable the buzzer.
// @Range: 0 100
// @Units: %
AP_GROUPINFO("BUZZ_VOLUME", 8, AP_Notify, _buzzer_volume, 100),
// @Param: RGBFLAG
// @DisplayName:RGBFLAG
// @Description: Enable or disable the RGB.
// @Values: 0:Disable,1:Enable
// @User: Advanced
AP_GROUPINFO("RGBFLAG", 9, AP_Notify, _rgb_led_lib_flag, 0),
// @Param: RGB-R
// @DisplayName:RGB-R
// @Description: the RGB-R.
// @Range: 0 255
// @User: Advanced
AP_GROUPINFO("RGB-R", 10, AP_Notify,_rgb_led_lib_r_value, 3),
// @Param: RGB-G
// @DisplayName:RGB-G
// @Description: the RGB-G.
// @Range: 0 255
// @User: Advanced
AP_GROUPINFO("RGB-G", 11, AP_Notify,_rgb_led_lib_g_value, 3),
// @Param: RGB-B
// @DisplayName:RGB-B
// @Description: the RGB-B.
// @Range: 0 255
// @User: Advanced
AP_GROUPINFO("RGB-B", 12, AP_Notify,_rgb_led_lib_b_value, 3),
libraries/AP_Notify/AP_Notify.h
// parameters
AP_Int8 _rgb_led_brightness;
AP_Int8 _rgb_led_override;
AP_Int8 _buzzer_enable;
AP_Int8 _display_type;
AP_Int8 _oreo_theme;
AP_Int8 _buzzer_pin;
AP_Int32 _led_type;
AP_Int8 _buzzer_level;
AP_Int8 _buzzer_volume;
AP_Int8 _rgb_led_lib_flag;
AP_Int8 _rgb_led_lib_r_value;
AP_Int8 _rgb_led_lib_g_value;
AP_Int8 _rgb_led_lib_b_value;
libraries/AP_Notify/RGBLed.cpp
// update - updates led according to timed_updated. Should be called
// at 50Hz
void RGBLed::update()
{
uint32_t current_colour_sequence = 0;
switch (rgb_source()) {
case mavlink:
update_override();
return; // note this is a return not a break!
case standard:
current_colour_sequence = get_colour_sequence();
break;
case obc:
current_colour_sequence = get_colour_sequence_obc();
break;
case traffic_light:
current_colour_sequence = get_colour_sequence_traffic_light();
break;
}
const uint8_t brightness = get_brightness();
uint8_t step = (AP_HAL::millis()/100) % 10;
// ensure we can't skip a step even with awful timing
if (step != last_step) {
step = (last_step+1) % 10;
last_step = step;
}
const uint8_t colour = (current_colour_sequence >> (step*3)) & 7;
_red_des = (colour & RED) ? brightness : 0;
_green_des = (colour & GREEN) ? brightness : 0;
_blue_des = (colour & BLUE) ? brightness : 0;
switch (pNotify->_rgb_led_lib_flag) {
case 0:
set_rgb(_red_des, _green_des, _blue_des);
break;
case 1:
set_rgb(pNotify->_rgb_led_lib_r_value,pNotify->_rgb_led_lib_g_value, pNotify->_rgb_led_lib_b_value);
break;
case 2:
set_rgb(RED,0,0);
break;
case 3:
set_rgb(0,GREEN,0);
break;
case 4:
set_rgb(0,0,BLUE);
break;
}
}