Fix compile error in leds.h

This commit is contained in:
Scott Lahteine 2018-10-20 16:48:28 -05:00
parent 9969c06cb5
commit eeef4e630a

View File

@ -27,6 +27,8 @@
#include "../../inc/MarlinConfigPre.h" #include "../../inc/MarlinConfigPre.h"
#include <string.h>
#if ENABLED(NEOPIXEL_LED) #if ENABLED(NEOPIXEL_LED)
#include "neopixel.h" #include "neopixel.h"
#endif #endif
@ -45,6 +47,7 @@ typedef struct LEDColor {
#endif #endif
#endif #endif
; ;
LEDColor() : r(255), g(255), b(255) LEDColor() : r(255), g(255), b(255)
#if HAS_WHITE_LED #if HAS_WHITE_LED
, w(255) , w(255)
@ -53,6 +56,7 @@ typedef struct LEDColor {
#endif #endif
#endif #endif
{} {}
LEDColor(uint8_t r, uint8_t g, uint8_t b LEDColor(uint8_t r, uint8_t g, uint8_t b
#if HAS_WHITE_LED #if HAS_WHITE_LED
, uint8_t w=0 , uint8_t w=0
@ -68,6 +72,7 @@ typedef struct LEDColor {
#endif #endif
#endif #endif
{} {}
LEDColor(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2]) LEDColor(const uint8_t (&rgbw)[4]) : r(rgbw[0]), g(rgbw[1]), b(rgbw[2])
#if HAS_WHITE_LED #if HAS_WHITE_LED
, w(rgbw[3]) , w(rgbw[3])
@ -76,6 +81,7 @@ typedef struct LEDColor {
#endif #endif
#endif #endif
{} {}
LEDColor& operator=(const uint8_t (&rgbw)[4]) { LEDColor& operator=(const uint8_t (&rgbw)[4]) {
r = rgbw[0]; g = rgbw[1]; b = rgbw[2]; r = rgbw[0]; g = rgbw[1]; b = rgbw[2];
#if HAS_WHITE_LED #if HAS_WHITE_LED
@ -83,15 +89,19 @@ typedef struct LEDColor {
#endif #endif
return *this; return *this;
} }
LEDColor& operator=(const LEDColor &right) { LEDColor& operator=(const LEDColor &right) {
if (this != &right) memcpy(this, &right, sizeof(LEDColor)); if (this != &right) memcpy(this, &right, sizeof(LEDColor));
return *this; return *this;
} }
bool operator==(const LEDColor &right) { bool operator==(const LEDColor &right) {
if (this == &right) return true; if (this == &right) return true;
return 0 == memcmp(this, &right, sizeof(LEDColor)); return 0 == memcmp(this, &right, sizeof(LEDColor));
} }
bool operator!=(const LEDColor &right) { return !operator==(right); } bool operator!=(const LEDColor &right) { return !operator==(right); }
bool is_off() const { bool is_off() const {
return 3 > r + g + b return 3 > r + g + b
#if HAS_WHITE_LED #if HAS_WHITE_LED