AP_Notify: Convert the ENUM definition to a class

This commit is contained in:
muramura 2024-05-27 03:25:47 +09:00 committed by Randy Mackay
parent 396865223f
commit dfc04cd53a
2 changed files with 10 additions and 10 deletions

View File

@ -47,15 +47,15 @@ void RGBLed::_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
} }
} }
RGBLed::rgb_source_t RGBLed::rgb_source() const RGBLed::Source RGBLed::rgb_source() const
{ {
return rgb_source_t(pNotify->_rgb_led_override.get()); return Source(pNotify->_rgb_led_override.get());
} }
// set_rgb - set color as a combination of red, green and blue values // set_rgb - set color as a combination of red, green and blue values
void RGBLed::set_rgb(uint8_t red, uint8_t green, uint8_t blue) void RGBLed::set_rgb(uint8_t red, uint8_t green, uint8_t blue)
{ {
if (rgb_source() == mavlink) { if (rgb_source() == Source::mavlink) {
// don't set if in override mode // don't set if in override mode
return; return;
} }
@ -196,16 +196,16 @@ void RGBLed::update()
uint32_t current_colour_sequence = 0; uint32_t current_colour_sequence = 0;
switch (rgb_source()) { switch (rgb_source()) {
case mavlink: case Source::mavlink:
update_override(); update_override();
return; // note this is a return not a break! return; // note this is a return not a break!
case standard: case Source::standard:
current_colour_sequence = get_colour_sequence(); current_colour_sequence = get_colour_sequence();
break; break;
case obc: case Source::obc:
current_colour_sequence = get_colour_sequence_obc(); current_colour_sequence = get_colour_sequence_obc();
break; break;
case traffic_light: case Source::traffic_light:
current_colour_sequence = get_colour_sequence_traffic_light(); current_colour_sequence = get_colour_sequence_traffic_light();
break; break;
} }
@ -235,7 +235,7 @@ void RGBLed::update()
*/ */
void RGBLed::handle_led_control(const mavlink_message_t &msg) void RGBLed::handle_led_control(const mavlink_message_t &msg)
{ {
if (rgb_source() != mavlink) { if (rgb_source() != Source::mavlink) {
// ignore LED_CONTROL commands if not in LED_OVERRIDE mode // ignore LED_CONTROL commands if not in LED_OVERRIDE mode
return; return;
} }

View File

@ -105,12 +105,12 @@ private:
const uint32_t sequence_disarmed_bad_gps = DEFINE_COLOUR_SEQUENCE_SLOW(BLUE); const uint32_t sequence_disarmed_bad_gps = DEFINE_COLOUR_SEQUENCE_SLOW(BLUE);
uint8_t last_step; uint8_t last_step;
enum rgb_source_t { enum class Source {
standard = 0, standard = 0,
mavlink = 1, mavlink = 1,
obc = 2, obc = 2,
traffic_light = 3, traffic_light = 3,
}; };
rgb_source_t rgb_source() const; Source rgb_source() const;
}; };