Skip to content

Commit

Permalink
AP_Notify: Convert the ENUM definition to a class
Browse files Browse the repository at this point in the history
  • Loading branch information
muramura committed May 27, 2024
1 parent 33d51d5 commit f2a9ef3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions libraries/AP_Notify/RGBLed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
return;
}
Expand Down Expand Up @@ -196,16 +196,16 @@ void RGBLed::update()
uint32_t current_colour_sequence = 0;

switch (rgb_source()) {
case mavlink:
case Source::mavlink:
update_override();
return; // note this is a return not a break!
case standard:
case Source::standard:
current_colour_sequence = get_colour_sequence();
break;
case obc:
case Source::obc:
current_colour_sequence = get_colour_sequence_obc();
break;
case traffic_light:
case Source::traffic_light:
current_colour_sequence = get_colour_sequence_traffic_light();
break;
}
Expand Down Expand Up @@ -235,7 +235,7 @@ void RGBLed::update()
*/
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
return;
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_Notify/RGBLed.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ class RGBLed: public NotifyDevice {
const uint32_t sequence_disarmed_bad_gps = DEFINE_COLOUR_SEQUENCE_SLOW(BLUE);

uint8_t last_step;
enum rgb_source_t {
enum class Source {
standard = 0,
mavlink = 1,
obc = 2,
traffic_light = 3,
};
rgb_source_t rgb_source() const;
Source rgb_source() const;

};

0 comments on commit f2a9ef3

Please sign in to comment.