Merge branch 'master' of https://git.frank-ebner.de/kazu/ESP8266lib
This commit is contained in:
@@ -13,12 +13,22 @@ struct Color {
|
||||
;
|
||||
}
|
||||
|
||||
void set(const uint8_t r, const uint8_t g, const uint8_t b) {
|
||||
Color(const uint8_t r, const uint8_t g, const uint8_t b) : r(r), g(g), b(b) {
|
||||
;
|
||||
}
|
||||
|
||||
void setRGB(const uint8_t r, const uint8_t g, const uint8_t b) {
|
||||
this->r = r;
|
||||
this->g = g;
|
||||
this->b = b;
|
||||
}
|
||||
|
||||
void setOff() {
|
||||
this->r = 0;
|
||||
this->g = 0;
|
||||
this->b = 0;
|
||||
}
|
||||
|
||||
void setHSV(const uint8_t h, const uint8_t s, const uint8_t v) {
|
||||
|
||||
uint8_t region, remainder, p, q, t;
|
||||
@@ -66,18 +76,29 @@ template <int numLEDs> class WS2812B {
|
||||
/** color-value for each attached LED */
|
||||
Color colors[numLEDs];
|
||||
|
||||
/** enable/disable each led */
|
||||
bool enabled[numLEDs] = {true};
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
WS2812B() {
|
||||
|
||||
LED_SET_PIN_TO_OUTPUT;
|
||||
|
||||
}
|
||||
|
||||
/** set the color for the given LED */
|
||||
void setColor(const uint8_t idx, const Color rgb) {
|
||||
colors[idx] = rgb;
|
||||
colors[idx] = rgb;
|
||||
}
|
||||
|
||||
/** enable/disable the given LED */
|
||||
void setEnabled(const uint8_t idx, const bool en) {
|
||||
enabled[idx] = en;
|
||||
}
|
||||
|
||||
/** is the given LED enabled? */
|
||||
bool isEnabled(const uint8_t idx) const {
|
||||
return enabled[idx];
|
||||
}
|
||||
|
||||
Color& getColor(const uint8_t idx) {
|
||||
@@ -125,19 +146,24 @@ template <int numLEDs> class WS2812B {
|
||||
// send0();
|
||||
*/
|
||||
|
||||
// process each LED
|
||||
for (uint8_t i = 0; i < numLEDs; ++i) {
|
||||
|
||||
const Color rgb = colors[i];
|
||||
// process each LED
|
||||
for (uint8_t i = 0; i < numLEDs; ++i) {
|
||||
|
||||
// send each LEDs 24-bit GRB data
|
||||
sendByte(rgb.g);
|
||||
sendByte(rgb.r);
|
||||
sendByte(rgb.b);
|
||||
if (enabled[i]) {
|
||||
const Color rgb = colors[i];
|
||||
sendByte(rgb.g);
|
||||
sendByte(rgb.r);
|
||||
sendByte(rgb.b);
|
||||
} else {
|
||||
sendByte(0);
|
||||
sendByte(0);
|
||||
sendByte(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
reset();
|
||||
reset();
|
||||
|
||||
|
||||
// sei();
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#define GPIO0_OUTPUT_SET do { GPIO0_CONF; GPIO_OUTPUT_SET(0, 0); } while(0)
|
||||
#define GPIO0_INPUT_SET do { GPIO0_CONF; GPIO_DIS_OUTPUT(0); } while(0)
|
||||
#define GPIO0_INPUT_PULLUP_SET do { GPIO0_INPUT_SET; PIN_PULLUP_EN(GPIO0_MUX); } while(0)
|
||||
#define GPIO0_IN (GPIO_INPUT_GET(BIT0))
|
||||
#define GPIO0_IN (GPIO_INPUT_GET(0))
|
||||
#define GPIO0_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT0))
|
||||
#define GPIO0_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT0))
|
||||
#define GPIO0(x) ((x)?GPIO0_H:GPIO0_L)
|
||||
@@ -45,7 +45,7 @@
|
||||
#define GPIO1_OUTPUT_SET do { GPIO1_CONF; GPIO_OUTPUT_SET(1, 0); } while(0)
|
||||
#define GPIO1_INPUT_SET do { GPIO1_CONF; GPIO_DIS_OUTPUT(1); } while(0)
|
||||
#define GPIO1_INPUT_PULLUP_SET do { GPIO1_INPUT_SET; PIN_PULLUP_EN(GPIO1_MUX); } while(0)
|
||||
#define GPIO1_IN (GPIO_INPUT_GET(BIT1))
|
||||
#define GPIO1_IN (GPIO_INPUT_GET(1))
|
||||
#define GPIO1_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT1))
|
||||
#define GPIO1_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT1))
|
||||
#define GPIO1(x) ((x)?GPIO1_H:GPIO1_L)
|
||||
@@ -56,7 +56,7 @@
|
||||
#define GPIO2_OUTPUT_SET do { GPIO2_CONF; GPIO_OUTPUT_SET(2, 0); } while(0)
|
||||
#define GPIO2_INPUT_SET do { GPIO2_CONF; GPIO_DIS_OUTPUT(2); } while(0)
|
||||
#define GPIO2_INPUT_PULLUP_SET do { GPIO2_INPUT_SET; PIN_PULLUP_EN(GPIO2_MUX); } while(0)
|
||||
#define GPIO2_IN (GPIO_INPUT_GET(BIT2))
|
||||
#define GPIO2_IN (GPIO_INPUT_GET(2))
|
||||
#define GPIO2_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT2))
|
||||
#define GPIO2_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT2))
|
||||
#define GPIO2(x) ((x)?GPIO2_H:GPIO2_L)
|
||||
@@ -67,7 +67,7 @@
|
||||
#define GPIO3_OUTPUT_SET do { GPIO3_CONF; GPIO_OUTPUT_SET(3, 0); } while(0)
|
||||
#define GPIO3_INPUT_SET do { GPIO3_CONF; GPIO_DIS_OUTPUT(3); } while(0)
|
||||
#define GPIO3_INPUT_PULLUP_SET do { GPIO3_INPUT_SET; PIN_PULLUP_EN(GPIO3_MUX); } while(0)
|
||||
#define GPIO3_IN (GPIO_INPUT_GET(BIT3))
|
||||
#define GPIO3_IN (GPIO_INPUT_GET(3))
|
||||
#define GPIO3_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT3))
|
||||
#define GPIO3_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT3))
|
||||
#define GPIO3(x) ((x)?GPIO3_H:GPIO3_L)
|
||||
@@ -78,7 +78,7 @@
|
||||
#define GPIO4_OUTPUT_SET do { GPIO4_CONF; GPIO_OUTPUT_SET(4, 0); } while(0)
|
||||
#define GPIO4_INPUT_SET do { GPIO4_CONF; GPIO_DIS_OUTPUT(4); } while(0)
|
||||
#define GPIO4_INPUT_PULLUP_SET do { GPIO4_INPUT_SET; PIN_PULLUP_EN(GPIO4_MUX); } while(0)
|
||||
#define GPIO4_IN (GPIO_INPUT_GET(BIT4))
|
||||
#define GPIO4_IN (GPIO_INPUT_GET(4))
|
||||
#define GPIO4_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT4))
|
||||
#define GPIO4_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT4))
|
||||
#define GPIO4(x) ((x)?GPIO4_H:GPIO4_L)
|
||||
@@ -89,7 +89,7 @@
|
||||
#define GPIO5_OUTPUT_SET do { GPIO5_CONF; GPIO_OUTPUT_SET(5, 0); } while(0)
|
||||
#define GPIO5_INPUT_SET do { GPIO5_CONF; GPIO_DIS_OUTPUT(5); } while(0)
|
||||
#define GPIO5_INPUT_PULLUP_SET do { GPIO5_INPUT_SET; PIN_PULLUP_EN(GPIO5_MUX); } while(0)
|
||||
#define GPIO5_IN (GPIO_INPUT_GET(BIT5))
|
||||
#define GPIO5_IN (GPIO_INPUT_GET(5))
|
||||
#define GPIO5_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT5))
|
||||
#define GPIO5_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT5))
|
||||
#define GPIO5(x) ((x)?GPIO5_H:GPIO5_L)
|
||||
@@ -102,7 +102,7 @@
|
||||
#define GPIO9_OUTPUT_SET do { GPIO9_CONF; GPIO_OUTPUT_SET(9, 0); } while(0)
|
||||
#define GPIO9_INPUT_SET do { GPIO9_CONF; GPIO_DIS_OUTPUT(9); } while(0)
|
||||
#define GPIO9_INPUT_PULLUP_SET do { GPIO9_INPUT_SET; PIN_PULLUP_EN(GPIO9_MUX); } while(0)
|
||||
#define GPIO9_IN (GPIO_INPUT_GET(BIT9))
|
||||
#define GPIO9_IN (GPIO_INPUT_GET(9))
|
||||
#define GPIO9_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT9))
|
||||
#define GPIO9_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT9))
|
||||
#define GPIO9(x) ((x)?GPIO9_H:GPIO9_L)
|
||||
@@ -113,7 +113,7 @@
|
||||
#define GPIO10_OUTPUT_SET do { GPIO10_CONF; GPIO_OUTPUT_SET(10, 0); } while(0)
|
||||
#define GPIO10_INPUT_SET do { GPIO10_CONF; GPIO_DIS_OUTPUT(10); } while(0)
|
||||
#define GPIO10_INPUT_PULLUP_SET do { GPIO10_INPUT_SET; PIN_PULLUP_EN(GPIO10_MUX); } while(0)
|
||||
#define GPIO10_IN (GPIO_INPUT_GET(BIT10))
|
||||
#define GPIO10_IN (GPIO_INPUT_GET(10))
|
||||
#define GPIO10_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT10))
|
||||
#define GPIO10_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT10))
|
||||
#define GPIO10(x) ((x)?GPIO10_H:GPIO10_L)
|
||||
@@ -138,7 +138,7 @@
|
||||
#define GPIO13_OUTPUT_SET do { GPIO13_CONF; GPIO_OUTPUT_SET(13, 0); } while(0)
|
||||
#define GPIO13_INPUT_SET do { GPIO13_CONF; GPIO_DIS_OUTPUT(13); } while(0)
|
||||
#define GPIO13_INPUT_PULLUP_SET do { GPIO13_INPUT_SET; PIN_PULLUP_EN(GPIO13_MUX); } while(0)
|
||||
#define GPIO13_IN (GPIO_INPUT_GET(BIT13))
|
||||
#define GPIO13_IN (GPIO_INPUT_GET(13))
|
||||
#define GPIO13_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT13))
|
||||
#define GPIO13_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT13))
|
||||
#define GPIO13(x) ((x)?GPIO13_H:GPIO13_L)
|
||||
@@ -160,7 +160,7 @@
|
||||
#define GPIO15_OUTPUT_SET do { GPIO15_CONF; GPIO_OUTPUT_SET(15, 0); } while(0)
|
||||
#define GPIO15_INPUT_SET do { GPIO15_CONF; GPIO_DIS_OUTPUT(15); } while(0)
|
||||
#define GPIO15_INPUT_PULLUP_SET do { GPIO15_INPUT_SET; PIN_PULLUP_EN(GPIO15_MUX); } while(0)
|
||||
#define GPIO15_IN (GPIO_INPUT_GET(BIT15))
|
||||
#define GPIO15_IN (GPIO_INPUT_GET(15))
|
||||
#define GPIO15_H (GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, BIT15))
|
||||
#define GPIO15_L (GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, BIT15))
|
||||
#define GPIO15(x) ((x)?GPIO15_H:GPIO15_L)
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace WiFiRaw {
|
||||
memcpy(this, data, 6);
|
||||
}
|
||||
|
||||
/** convert to pointer */
|
||||
const uint8_t* asPtr() const {
|
||||
return (uint8_t*) this;
|
||||
}
|
||||
|
||||
/** equal to the given mac? */
|
||||
bool operator == (const MACAddress& o) const {
|
||||
return (a == o.a) && (b == o.b) && (c == o.c) && (d == o.d) && (e == o.e) && (f == o.f);
|
||||
|
||||
Reference in New Issue
Block a user