diff --git a/include/IRLight.h b/include/IRLight.h index 7baa893..e76c432 100644 --- a/include/IRLight.h +++ b/include/IRLight.h @@ -13,38 +13,19 @@ private: IRsend *irsend; - const uint16_t RDOn[67] = { - 9080,4270, 680,470, 680,420, 680,420, 680,470, 680,420, 680,420, 680,420, 730,1470, 730,1520, 680,1520, 730,1470, 730,1470, 730,1520, 680,1520, 730,1470, 730,420, 680,1520, 730,420, 680,420, 680,420, 730,420, 680,420, 680,420, 730,420, 680,420, 680,1520, 680,1520, 730,1470, 730,1470, 730,1520, 730,1470, 730,1470, 730}; + const uint32_t RDOn = irsend->encodeNEC(0x80, 0x1); - const uint16_t RDOff[67] = { - 9030,4320, 630,470, 680,420, 680,470, 630,470, 680,420, 680,470, 630,470, 680,1520, 680,1570, 630,1570, 630,1570, 680,1520, 680,1570, 630,1570, 680,1520, 680,470, 630,470, 680,1520, 680,370, 730,1570, 630,1570, 680,420, 680,470, 630,470, 680,1520, 680,470, 630,1570, 680,420, 680,470, 630,1570, 680,1520, 680,1570, 630}; + const uint32_t RDOff = irsend->encodeNEC(0x80, 0x1A); - const uint16_t RDButtonCenter[67] = { - 9030, 4320, 680, 470, 630, 470, 680, 420, 680, 470, 630, 470, - 680, 420, 680, 470, 630, 1570, 680, 1520, 680, 1520, 680, 1520, - 730, 1520, 680, 1520, 680, 1520, 680, 1570, 680, 420, 680, 1520, - 680, 470, 680, 1520, 680, 470, 630, 470, 680, 420, 680, 470, - 630, 470, 630, 470, 680, 1520, 680, 470, 680, 1520, 630, 1570, - 680, 1520, 680, 1570, 680, 1520, 680}; + const uint32_t RDButtonCenter = irsend->encodeNEC(0x80, 0x5); - const uint16_t RDBrightnessUp[67] = { - 9080,4270, 730,420, 680,420, 680,420, 730,420, 680,420, 680,420, 730,420, - 680,1520, 680,1520, 730,1470, 730,1470, 730,1520, 680,1520, 730,1470, - 730,1520, 680,420, 680,470, 580,1620, 580,520, 630,520, 580,1620, 580,520, - 630,520, 580,520, 630,1570, 580,570, 580,1570, 630,1620, 630,520, 580,1570, - 730,1520, 680,1520, 730}; + const uint32_t RDBrightnessUp = irsend->encodeNEC(0x80, 0x12); - const uint16_t RDBrightnessDown[67] = { - 9030, 4320, 630, 520, 630, 470, 630, 470, 630, 520, 630, 470, - 630, 470, 630, 520, 630, 1570, 630, 1570, 630, 1620, 630, 1570, - 630, 1570, 630, 1620, 630, 1570, 630, 1570, 630, 470, 680, 470, - 630, 1570, 630, 1570, 680, 1570, 630, 1570, 630, 470, 680, 470, - 630, 470, 630, 1570, 680, 470, 630, 470, 630, 470, 680, 470, - 630, 1570, 630, 1570, 680, 1570, 630}; + const uint32_t RDBrightnessDown = irsend->encodeNEC(0x80, 0x1E); - const uint16_t RDButtonA[67] = {8980,4370, 630,470, 680,470, 630,470, 630,470, 630,520, 630,470, 630,470, 630,1620, 630,1570, 630,1620, 580,1570, 630,1620, 630,1570, 630,1570, 630,1570, 680,470, 630,1570, 630,1570, 630,1620, 630,470, 630,470, 630,470, 680,470, 630,470, 630,470, 680,470, 630,470, 630,1570, 630,1620, 630,1570, 630,1570, 630,1570, 630}; + const uint32_t RDButtonA = irsend->encodeNEC(0x80, 0x7); - const uint16_t RDButtonB[67] = {9030,4320, 630,520, 580,520, 630,470, 630,470, 680,470, 580,520, 630,470, 680,1570, 630,1570, 630,1570, 630,1570, 630,1620, 580,1620, 630,1570, 630,1620, 580,520, 580,520, 630,470, 680,470, 630,1570, 630,470, 630,520, 580,520, 630,470, 630,1620, 630,1570, 630,1570, 630,470, 680,1570, 630,1570, 630,1570, 630,1570, 680}; + const uint32_t RDButtonB = irsend->encodeNEC(0x80, 0x8); public: explicit IRLight(int pin); diff --git a/src/IRLight.cpp b/src/IRLight.cpp index a775d2d..4c27088 100644 --- a/src/IRLight.cpp +++ b/src/IRLight.cpp @@ -19,12 +19,12 @@ void IRLight::setState(bool state) { void IRLight::on() { state = true; - irsend->sendRaw(RDOn, 67, 38); + irsend->sendNEC(RDOn); } void IRLight::off() { state = false; - irsend->sendRaw(RDOff, 67, 38); + irsend->sendNEC(RDOff); } void IRLight::setBrightness(int newBrightness) { @@ -46,15 +46,15 @@ void IRLight::setColorTemperature(int color) { if (color < 208) { color_temp = 2; brightness = 14; - irsend->sendRaw(RDButtonB, 67, 38); + irsend->sendNEC(RDButtonB); } else if (color < 294) { color_temp = 1; brightness = 14; - irsend->sendRaw(RDButtonCenter, 67, 38); + irsend->sendNEC(RDButtonCenter); } else { color_temp = 0; brightness = 14; - irsend->sendRaw(RDButtonA, 67, 38); + irsend->sendNEC(RDButtonA); } } @@ -74,14 +74,14 @@ int IRLight::getColorTemperature() { void IRLight::brightnessUp() { if (brightness < getBrightnessScale()) { brightness++; - irsend->sendRaw(RDBrightnessUp, 67, 38); + irsend->sendNEC(RDBrightnessUp); } } void IRLight::brightnessDown() { if (brightness > 0) { brightness--; - irsend->sendRaw(RDBrightnessDown, 67, 38); + irsend->sendNEC(RDBrightnessDown); } } @@ -89,7 +89,7 @@ void IRLight::begin() { irsend->begin(); brightness = 14; color_temp = 1; - irsend->sendRaw(RDButtonCenter, 67, 38); + irsend->sendNEC(RDButtonCenter); delay(500); off(); }