diff --git a/.cproject b/.cproject
index b1266e5..1c2a0ae 100644
--- a/.cproject
+++ b/.cproject
@@ -19,40 +19,40 @@
@@ -63,7 +63,7 @@
-
+
diff --git a/.project b/.project
index 97747a4..a806bba 100644
--- a/.project
+++ b/.project
@@ -34,17 +34,22 @@
core/core
2
- ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.21/cores/arduino
+ ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/cores/arduino
core/variant
2
- ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.21/variants/eightanaloginputs
+ ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/variants/eightanaloginputs
libraries/Adafruit_NeoPixel
2
- ECLIPSE_HOME/arduinoPlugin/libraries/Adafruit_NeoPixel/1.1.6
+ ECLIPSE_HOME/arduinoPlugin/libraries/Adafruit_NeoPixel/1.0.6
+
+
+ libraries/MyNodeManager
+ 2
+ ECLIPSE_HOME/arduinoPlugin/libraries/MyNodeManager/1.0.0
libraries/MySensors
@@ -59,7 +64,7 @@
libraries/SPI
2
- ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.21/libraries/SPI
+ ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/libraries/SPI
diff --git a/NotificationLEDs.h b/NotificationLEDs.h
index d64b5c8..68512c5 100644
--- a/NotificationLEDs.h
+++ b/NotificationLEDs.h
@@ -14,7 +14,7 @@
union _eeprom_NotificationLEDs_StatusTable {
struct {
- int hourOffset : 1;
+ unsigned hourOffset : 1;
} status;
uint8_t data;
};
@@ -329,8 +329,12 @@ template<
retval = true;
} else if (msg.type == V_RGBW) {
uint32_t color = strtoul(msg.data, NULL, 16);
- // MySensors uses "RGBW" format, but the NeoPixel library uses "WRGB" format
- setStaticColor((color & 0xFFFFFF00) >> 8 | ((color & 0xFF) << 24));
+ if (color == 0) {
+ enableDefaultScene();
+ } else {
+ // MySensors uses "RGBW" format, but the NeoPixel library uses "WRGB" format
+ setStaticColor((color & 0xFFFFFF00) >> 8 | ((color & 0xFF) << 24));
+ }
retval = true;
}
if (retval) {
@@ -352,21 +356,30 @@ template<
if (msg.type == V_PERCENTAGE) {
auto b = msg.getByte();
if (sceneMode == 0) {
- brightness = b;
- sceneData.analogClock.lastUnixTime = 0;
+ if (b == 0) {
+ powerOff();
+ } else {
+ brightness = b;
+ sceneData.analogClock.lastUnixTime = 0;
+ }
} else {
- uint16_t cb = max(staticColor.wrgb[0], max(staticColor.wrgb[1], max(staticColor.wrgb[2], staticColor.wrgb[3]))) * 100 / 255;
- uint16_t nb = msg.getByte();
- for (auto i = 0; i < 4; i++) {
- uint16_t newcolor = ((uint16_t)staticColor.wrgb[i] * nb) / cb;
- if (newcolor > 255) {
- newcolor = 255;
+ if (b == 0) {
+ enableDefaultScene();
+ } else {
+ uint16_t cb = max(staticColor.wrgb[0], max(staticColor.wrgb[1], max(staticColor.wrgb[2], staticColor.wrgb[3]))) * 100 / 255;
+ for (auto i = 0; i < 4; i++) {
+ uint16_t newcolor = ((uint16_t)staticColor.wrgb[i] * b) / cb;
+ if (newcolor > 255) {
+ newcolor = 255;
+ }
+ staticColor.wrgb[i] = newcolor;
}
- staticColor.wrgb[i] = newcolor;
+ setStaticColor(staticColor.color);
}
- setStaticColor(staticColor.color);
}
retval = true;
+ sendPowerSwitchStatus();
+ sendRGBWStatus();
sendDimmerStatus();
}
// Request Message
diff --git a/SceneAnalogClock.h b/SceneAnalogClock.h
index ccc7f84..afa7a1b 100644
--- a/SceneAnalogClock.h
+++ b/SceneAnalogClock.h
@@ -20,7 +20,7 @@ template<
::analogClock_setup() noexcept {
_eeprom_NotificationLEDs_StatusTable statusTable;
statusTable.data = loadState(EEPROM_POS_STATUSTABLE);
- if (statusTable.status.hourOffset == 1) {
+ if (statusTable.status.hourOffset) {
sceneData.analogClock.hourOffset = (int8_t)loadState(EEPROM_POS_HOUROFFSET);
}
}
diff --git a/SceneFollow.h b/SceneFollow.h
index e38dd00..a43b02f 100644
--- a/SceneFollow.h
+++ b/SceneFollow.h
@@ -87,13 +87,23 @@ template<
}
} else {
pixels.setPixelColor(sceneData.follow1.followPos, sceneData.follow1.color.color);
+ for (auto i = 1; i < 4; i++) {
+ auto pos = MOD(sceneData.follow1.followPos-sceneData.follow1.followDir*i, 12);
+ auto color = sceneData.follow1.color;
+ color.wrgb[0] = (uint16_t)color.wrgb[0]*(4-i)/4;
+ color.wrgb[1] = (uint16_t)color.wrgb[1]*(4-i)/4;
+ color.wrgb[2] = (uint16_t)color.wrgb[2]*(4-i)/4;
+ color.wrgb[3] = (uint16_t)color.wrgb[3]*(4-i)/4;
+ pixels.setPixelColor(pos, color.color);
+ }
auto delPos = MOD(sceneData.follow1.followPos-sceneData.follow1.followDir*4, 12);
pixels.setPixelColor(delPos, 0);
pixels.show();
sceneData.follow1.followPos += sceneData.follow1.followDir;
if (sceneData.follow1.followPos < 0 || sceneData.follow1.followPos > 11) {
sceneData.follow1.followPos = MOD(sceneData.follow1.followPos, 12);
- if (sceneData.follow1.maxCycles > 0 && sceneData.follow1.currentCycles > sceneData.follow1.maxCycles) {
+ sceneData.follow1.currentCycles++;
+ if (sceneData.follow1.maxCycles > 0 && sceneData.follow1.currentCycles >= sceneData.follow1.maxCycles) {
sceneData.follow1.finishing = true;
}
}
diff --git a/ScenePulse.h b/ScenePulse.h
index 519145d..7ffa157 100644
--- a/ScenePulse.h
+++ b/ScenePulse.h
@@ -1,103 +1,103 @@
-#ifndef SCENEPULSE_H_
-#define SCENEPULSE_H_
-
-#include
-#include
-#include
-#include
-#include "NotificationLEDs.h"
-
-
-template<
- uint8_t _tpin,
- uint8_t _trgbwId,
- uint8_t _tdimmerId,
- uint8_t _tpowerSwitchId,
- uint8_t _tcommandId,
- uint16_t _tpixelCount,
- unsigned long _msgSendInterval
-> void NotificationLEDs<_tpin, _trgbwId, _tdimmerId, _tpowerSwitchId, _tcommandId, _tpixelCount, _msgSendInterval>
-::pulse1_config() noexcept {
- auto token = strtok(NULL, _configDelims);
- if (token && token[0] != ' ') {
- auto color = strtoul(token, NULL, 16);
- sceneData.pulse1.color.color = color;
- }
- token = strtok(NULL, _configDelims);
- if (token && token[0] != ' ') {
- auto maxPulses = atoi(token);
- sceneData.pulse1.maxPulses = maxPulses;
- }
- token = strtok(NULL, _configDelims);
- if (token && token[0] != ' ') {
- auto pulseDir = atoi(token);
- sceneData.pulse1.pulseDir = pulseDir;
- }
-}
-
-
-template<
- uint8_t _tpin,
- uint8_t _trgbwId,
- uint8_t _tdimmerId,
- uint8_t _tpowerSwitchId,
- uint8_t _tcommandId,
- uint16_t _tpixelCount,
- unsigned long _msgSendInterval
-> void NotificationLEDs<_tpin, _trgbwId, _tdimmerId, _tpowerSwitchId, _tcommandId, _tpixelCount, _msgSendInterval>
-::pulse1_init() noexcept {
- for (uint8_t i = 0; i < _tpixelCount; i++) {
- pixels.setPixelColor(i, 0);
- }
- pixels.show();
- sceneData.pulse1.pulseValue = 0;
- sceneData.pulse1.lastMillis = 0;
- sceneData.pulse1.currentPulses = 0;
-}
-
-
-template
-T tmap(T x, T in_min, T in_max, T out_min, T out_max) {
- return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
-}
-
-template<
- uint8_t _tpin,
- uint8_t _trgbwId,
- uint8_t _tdimmerId,
- uint8_t _tpowerSwitchId,
- uint8_t _tcommandId,
- uint16_t _tpixelCount,
- unsigned long _msgSendInterval
-> void NotificationLEDs<_tpin, _trgbwId, _tdimmerId, _tpowerSwitchId, _tcommandId, _tpixelCount, _msgSendInterval>
-::pulse1_loop(unsigned long currentUnixTime, unsigned long currentMillis) noexcept {
- if (currentMillis - sceneData.pulse1.lastMillis >= 50) {
- auto color = sceneData.pulse1.color;
- int16_t pulseValue = sceneData.pulse1.pulseValue;
- uint16_t br = 127.5 * (-cos(tmap(pulseValue, 0, 255, 0, 2.0*M_PI))+1.0);
- color.wrgb[0] = (uint16_t)color.wrgb[0]*br/255;
- color.wrgb[1] = (uint16_t)color.wrgb[1]*br/255;
- color.wrgb[2] = (uint16_t)color.wrgb[2]*br/255;
- color.wrgb[3] = (uint16_t)color.wrgb[3]*br/255;
- for (uint16_t i = 0; i < _tpixelCount; i++) {
- pixels.setPixelColor(i, color.color);
- }
- pixels.show();
- pulseValue += sceneData.pulse1.pulseDir;
- if (pulseValue < 0) {
- sceneData.pulse1.pulseDir = -sceneData.pulse1.pulseDir;
- pulseValue = sceneData.pulse1.pulseDir;
- sceneData.pulse1.currentPulses++;
- if (sceneData.pulse1.maxPulses > 0 && sceneData.pulse1.currentPulses > sceneData.pulse1.maxPulses) {
- returnToLastMode();
- }
- } else if (pulseValue > 255) {
- sceneData.pulse1.pulseDir = -sceneData.pulse1.pulseDir;
- pulseValue = 255 + sceneData.pulse1.pulseDir;
- }
- sceneData.pulse1.pulseValue = pulseValue;
- sceneData.pulse1.lastMillis = currentMillis;
- }
-}
-
-#endif /* SCENEPULSE_H_ */
+#ifndef SCENEPULSE_H_
+#define SCENEPULSE_H_
+
+#include
+#include
+#include
+#include
+#include "NotificationLEDs.h"
+
+
+template<
+ uint8_t _tpin,
+ uint8_t _trgbwId,
+ uint8_t _tdimmerId,
+ uint8_t _tpowerSwitchId,
+ uint8_t _tcommandId,
+ uint16_t _tpixelCount,
+ unsigned long _msgSendInterval
+> void NotificationLEDs<_tpin, _trgbwId, _tdimmerId, _tpowerSwitchId, _tcommandId, _tpixelCount, _msgSendInterval>
+::pulse1_config() noexcept {
+ auto token = strtok(NULL, _configDelims);
+ if (token && token[0] != ' ') {
+ auto color = strtoul(token, NULL, 16);
+ sceneData.pulse1.color.color = color;
+ }
+ token = strtok(NULL, _configDelims);
+ if (token && token[0] != ' ') {
+ auto maxPulses = atoi(token);
+ sceneData.pulse1.maxPulses = maxPulses;
+ }
+ token = strtok(NULL, _configDelims);
+ if (token && token[0] != ' ') {
+ auto pulseDir = atoi(token);
+ sceneData.pulse1.pulseDir = pulseDir;
+ }
+}
+
+
+template<
+ uint8_t _tpin,
+ uint8_t _trgbwId,
+ uint8_t _tdimmerId,
+ uint8_t _tpowerSwitchId,
+ uint8_t _tcommandId,
+ uint16_t _tpixelCount,
+ unsigned long _msgSendInterval
+> void NotificationLEDs<_tpin, _trgbwId, _tdimmerId, _tpowerSwitchId, _tcommandId, _tpixelCount, _msgSendInterval>
+::pulse1_init() noexcept {
+ for (uint8_t i = 0; i < _tpixelCount; i++) {
+ pixels.setPixelColor(i, 0);
+ }
+ pixels.show();
+ sceneData.pulse1.pulseValue = 0;
+ sceneData.pulse1.lastMillis = 0;
+ sceneData.pulse1.currentPulses = 0;
+}
+
+
+template
+T tmap(T x, T in_min, T in_max, T out_min, T out_max) {
+ return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
+}
+
+template<
+ uint8_t _tpin,
+ uint8_t _trgbwId,
+ uint8_t _tdimmerId,
+ uint8_t _tpowerSwitchId,
+ uint8_t _tcommandId,
+ uint16_t _tpixelCount,
+ unsigned long _msgSendInterval
+> void NotificationLEDs<_tpin, _trgbwId, _tdimmerId, _tpowerSwitchId, _tcommandId, _tpixelCount, _msgSendInterval>
+::pulse1_loop(unsigned long currentUnixTime, unsigned long currentMillis) noexcept {
+ if (currentMillis - sceneData.pulse1.lastMillis >= 50) {
+ auto color = sceneData.pulse1.color;
+ int16_t pulseValue = sceneData.pulse1.pulseValue;
+ uint16_t br = 127.5 * (-cos(tmap(pulseValue, 0, 255, 0, M_PI))+1.0);
+ color.wrgb[0] = (uint16_t)color.wrgb[0]*br/255;
+ color.wrgb[1] = (uint16_t)color.wrgb[1]*br/255;
+ color.wrgb[2] = (uint16_t)color.wrgb[2]*br/255;
+ color.wrgb[3] = (uint16_t)color.wrgb[3]*br/255;
+ for (uint16_t i = 0; i < _tpixelCount; i++) {
+ pixels.setPixelColor(i, color.color);
+ }
+ pixels.show();
+ pulseValue += sceneData.pulse1.pulseDir;
+ if (pulseValue < 0) {
+ sceneData.pulse1.pulseDir = -sceneData.pulse1.pulseDir;
+ pulseValue = sceneData.pulse1.pulseDir;
+ sceneData.pulse1.currentPulses++;
+ if (sceneData.pulse1.maxPulses > 0 && sceneData.pulse1.currentPulses >= sceneData.pulse1.maxPulses) {
+ returnToLastMode();
+ }
+ } else if (pulseValue > 255) {
+ sceneData.pulse1.pulseDir = -sceneData.pulse1.pulseDir;
+ pulseValue = 255 + sceneData.pulse1.pulseDir;
+ }
+ sceneData.pulse1.pulseValue = pulseValue;
+ sceneData.pulse1.lastMillis = currentMillis;
+ }
+}
+
+#endif /* SCENEPULSE_H_ */
diff --git a/nodemanager_config.h b/nodemanager_config.h
index 31f67c1..a9885c2 100644
--- a/nodemanager_config.h
+++ b/nodemanager_config.h
@@ -1,70 +1,70 @@
-#ifndef config_h
-#define config_h
-
-/**********************************
- * Sketch configuration
- */
-
-#define SKETCH_NAME "Notification01"
-#define SKETCH_VERSION "1.0"
-
-/**********************************
- * MySensors node configuration
- */
-
-#define MY_NODE_ID 1
-
-#define MY_MSG_ACK 1
-#define MY_MSG_RETRIES 3
-#define MY_MSG_RETRY_DELAY 1
-
-
-// Enable debug prints to serial monitor
-#define MY_DEBUG
-//#define MY_DEBUG_VERBOSE_RF24
-//#define MY_SPECIAL_DEBUG
-#define MY_SPLASH_SCREEN_DISABLED
-
-
-// Enable and select radio type attached
-#define MY_RADIO_NRF24
-
-#define MY_RF24_PA_LEVEL RF24_PA_MAX
-#define MY_RF24_DATARATE RF24_250KBPS
-#define MY_RF24_CHANNEL 82
-#define MY_RF24_BASE_RADIO_ID 0x00,0x30,0x08,0x19,0x82
-#define MY_RF24_ENABLE_XTEA
-#define MY_RF24_XTEA_KEY { 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87, 0x78, 0x69, 0x5A, 0x4B, 0x3C, 0x2D, 0x1E, 0x0F }
-#define MY_MESSAGE_ENABLE_NONCE
-#define MY_MESSAGE_ENABLE_HASH
-#define MY_SMART_SLEEP_WAIT_DURATION_MS 60
-
-#define MY_RF24_CE_PIN 9
-#define MY_RF24_CS_PIN 10
-
-
-/***********************************
- * NodeManager configuration
- */
-
-#define DEBUG 0
-
-// if enabled, enable the capability to power on sensors with the arduino's pins to save battery while sleeping
-#define POWER_MANAGER 0
-// if enabled, will load the battery manager library to allow the battery level to be reported automatically or on demand
-#define BATTERY_MANAGER 0
-// if enabled, allow modifying the configuration remotely by interacting with the configuration child id
-#define REMOTE_CONFIGURATION 1
-// if enabled, persist the remote configuration settings on EEPROM
-#define PERSIST 1
-// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
-#define BATTERY_SENSOR 0
-// if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting
-#define SERVICE_MESSAGES 0
-
-#define DISABLE_SLEEP_MODE
-
-
-
-#endif
-
+#ifndef config_h
+#define config_h
+
+/**********************************
+ * Sketch configuration
+ */
+
+#define SKETCH_NAME "Notification01"
+#define SKETCH_VERSION "1.0"
+
+/**********************************
+ * MySensors node configuration
+ */
+
+#define MY_NODE_ID 1
+
+#define MY_MSG_ACK 1
+#define MY_MSG_RETRIES 3
+#define MY_MSG_RETRY_DELAY 1
+
+
+// Enable debug prints to serial monitor
+#define MY_DEBUG
+//#define MY_DEBUG_VERBOSE_RF24
+//#define MY_SPECIAL_DEBUG
+#define MY_SPLASH_SCREEN_DISABLED
+
+
+// Enable and select radio type attached
+#define MY_RADIO_NRF24
+
+#define MY_RF24_PA_LEVEL RF24_PA_MAX
+#define MY_RF24_DATARATE RF24_250KBPS
+#define MY_RF24_CHANNEL 82
+#define MY_RF24_BASE_RADIO_ID 0x00,0x30,0x08,0x19,0x82
+#define MY_RF24_ENABLE_XTEA
+#define MY_RF24_XTEA_KEY { 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87, 0x78, 0x69, 0x5A, 0x4B, 0x3C, 0x2D, 0x1E, 0x0F }
+#define MY_MESSAGE_ENABLE_NONCE
+#define MY_MESSAGE_ENABLE_HASH
+#define MY_SMART_SLEEP_WAIT_DURATION_MS 60
+
+#define MY_RF24_CE_PIN 9
+#define MY_RF24_CS_PIN 10
+
+
+/***********************************
+ * NodeManager configuration
+ */
+
+#define DEBUG 0
+
+// if enabled, enable the capability to power on sensors with the arduino's pins to save battery while sleeping
+#define POWER_MANAGER 0
+// if enabled, will load the battery manager library to allow the battery level to be reported automatically or on demand
+#define BATTERY_MANAGER 0
+// if enabled, allow modifying the configuration remotely by interacting with the configuration child id
+#define REMOTE_CONFIGURATION 1
+// if enabled, persist the remote configuration settings on EEPROM
+#define PERSIST 1
+// if enabled, a battery sensor will be created at BATTERY_CHILD_ID and will report vcc voltage together with the battery level percentage
+#define BATTERY_SENSOR 0
+// if enabled, send a SLEEPING and AWAKE service messages just before entering and just after leaving a sleep cycle and STARTED when starting/rebooting
+#define SERVICE_MESSAGES 0
+
+#define DISABLE_SLEEP_MODE
+
+
+
+#endif
+