Qualify leds::Mode in LED to fix build

pull/35/head
Yuri D'Elia 2021-06-27 14:31:33 +02:00 committed by DRracer
parent 4d6d6fe0af
commit f097aecbaa
2 changed files with 8 additions and 8 deletions

View File

@ -11,13 +11,13 @@ void LED::SetMode(leds::Mode mode) {
state.mode = mode; state.mode = mode;
// set initial state of LEDs correctly - transition from one mode to another // set initial state of LEDs correctly - transition from one mode to another
switch (state.mode) { switch (state.mode) {
case Mode::blink1: case leds::Mode::blink1:
case Mode::off: case leds::Mode::off:
state.on = 0; state.on = 0;
break; break;
case Mode::blink0: case leds::Mode::blink0:
case Mode::on: case leds::Mode::on:
state.on = 1; state.on = 1;
break; break;
default: default:
@ -28,10 +28,10 @@ void LED::SetMode(leds::Mode mode) {
bool LED::Step(bool oddPeriod) { bool LED::Step(bool oddPeriod) {
switch (state.mode) { switch (state.mode) {
// on and off don't change while stepping // on and off don't change while stepping
case Mode::blink0: case leds::Mode::blink0:
state.on = oddPeriod; state.on = oddPeriod;
break; break;
case Mode::blink1: case leds::Mode::blink1:
state.on = !oddPeriod; state.on = !oddPeriod;
break; break;
default: // do nothing default: // do nothing

View File

@ -31,7 +31,7 @@ enum Color {
class LED { class LED {
public: public:
constexpr inline LED() = default; constexpr inline LED() = default;
void SetMode(Mode mode); void SetMode(leds::Mode mode);
inline leds::Mode Mode() const { return (leds::Mode)state.mode; } inline leds::Mode Mode() const { return (leds::Mode)state.mode; }
/// @returns true if the LED shines /// @returns true if the LED shines
@ -44,7 +44,7 @@ private:
uint8_t mode : 2; uint8_t mode : 2;
constexpr inline State() constexpr inline State()
: on(0) : on(0)
, mode(Mode::off) {} , mode(leds::Mode::off) {}
}; };
State state; State state;