Improvements and Bugfixes.
This commit is contained in:
@@ -19,40 +19,40 @@
|
||||
<builder buildPath="${workspace_loc:/MyNotificationLight}/Release" id="io.sloeber.sketch.builder.1906713543" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Arduino sketch builder" superClass="io.sloeber.sketch.builder"/>
|
||||
<tool id="io.sloeber.tool.sketch.compiler.cpp.1045458791" name="Arduino C++ Compiler" superClass="io.sloeber.tool.sketch.compiler.cpp">
|
||||
<option id="io.sloeber.compiler.cpp.sketch.option.incpath.259978641" name="Include Paths (-I)" superClass="io.sloeber.compiler.cpp.sketch.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/Adafruit_NeoPixel}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/SPI/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/NodeManager}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/MyNodeManager}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/Adafruit_NeoPixel}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/SPI/src}""/>
|
||||
</option>
|
||||
<inputType id="io.sloeber.compiler.cpp.sketch.input.1657978941" name="CPP source files" superClass="io.sloeber.compiler.cpp.sketch.input"/>
|
||||
</tool>
|
||||
<tool id="io.sloeber.tool.compiler.c.375258991" name="Arduino C Compiler" superClass="io.sloeber.tool.compiler.c">
|
||||
<option id="io.sloeber.compiler.c.sketch.option.incpath.284715339" name="Include Paths (-I)" superClass="io.sloeber.compiler.c.sketch.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/Adafruit_NeoPixel}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/SPI/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/NodeManager}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/MyNodeManager}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/Adafruit_NeoPixel}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/SPI/src}""/>
|
||||
</option>
|
||||
<inputType id="io.sloeber.compiler.c.sketch.input.2017913156" name="C Source Files" superClass="io.sloeber.compiler.c.sketch.input"/>
|
||||
</tool>
|
||||
<tool id="io.sloeber.tool.sketch.compiler.s.1694325362" name="Arduino Assembler" superClass="io.sloeber.tool.sketch.compiler.s">
|
||||
<option id="io.sloeber.compiler.asm.sketch.option.incpath.1470678493" name="Include Paths (-I)" superClass="io.sloeber.compiler.asm.sketch.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/Adafruit_NeoPixel}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/SPI/src}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationClock/libraries/NodeManager}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/MyNodeManager}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/core/core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/core/variant}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/Adafruit_NeoPixel}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/MySensors}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/SPI}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MyNotificationLight/libraries/SPI/src}""/>
|
||||
</option>
|
||||
<inputType id="io.sloeber.compiler.S.sketch.input.1051869875" name="Assembly source files" superClass="io.sloeber.compiler.S.sketch.input"/>
|
||||
</tool>
|
||||
@@ -63,7 +63,7 @@
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="libraries/MySensors/.git|libraries/Adafruit_GFX_Library/fontconvert|libraries/Adafruit_GFX_Library/Fonts|libraries/MySensors/projects|libraries/MySensors/initscripts|libraries/MySensors/hal|libraries/MySensors/examples_linux|libraries/MySensors/drivers|libraries/MySensors/Documentation|libraries/MySensors/core|libraries/MySensors/.mystools|libraries/MySensors/.ci|libraries/?*/**/?xamples/**|libraries/?*/**/?xtras/**|libraries/?*/**/test*/**|libraries/?*/**/third-party/**|libraries/**/._*|libraries/?*/utility/*/*" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
|
||||
<entry excluding="libraries/MyNodeManager/.git|libraries/MySensors/.git|libraries/Adafruit_GFX_Library/fontconvert|libraries/Adafruit_GFX_Library/Fonts|libraries/MySensors/projects|libraries/MySensors/initscripts|libraries/MySensors/hal|libraries/MySensors/examples_linux|libraries/MySensors/drivers|libraries/MySensors/Documentation|libraries/MySensors/core|libraries/MySensors/.mystools|libraries/MySensors/.ci|libraries/?*/**/?xamples/**|libraries/?*/**/?xtras/**|libraries/?*/**/test*/**|libraries/?*/**/third-party/**|libraries/**/._*|libraries/?*/utility/*/*" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
|
||||
@@ -34,17 +34,22 @@
|
||||
<link>
|
||||
<name>core/core</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.21/cores/arduino</locationURI>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/cores/arduino</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>core/variant</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.21/variants/eightanaloginputs</locationURI>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/variants/eightanaloginputs</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/Adafruit_NeoPixel</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/Adafruit_NeoPixel/1.1.6</locationURI>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/Adafruit_NeoPixel/1.0.6</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/MyNodeManager</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/libraries/MyNodeManager/1.0.0</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>libraries/MySensors</name>
|
||||
@@ -59,7 +64,7 @@
|
||||
<link>
|
||||
<name>libraries/SPI</name>
|
||||
<type>2</type>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.21/libraries/SPI</locationURI>
|
||||
<locationURI>ECLIPSE_HOME/arduinoPlugin/packages/arduino/hardware/avr/1.6.18/libraries/SPI</locationURI>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
|
||||
+26
-13
@@ -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
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+103
-103
@@ -1,103 +1,103 @@
|
||||
#ifndef SCENEPULSE_H_
|
||||
#define SCENEPULSE_H_
|
||||
|
||||
#include <nodemanager_config.h>
|
||||
#include <MySensors.h>
|
||||
#include <NodeManager.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#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<typename T>
|
||||
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<float>(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 <nodemanager_config.h>
|
||||
#include <MySensors.h>
|
||||
#include <NodeManager.h>
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
#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<typename T>
|
||||
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<float>(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_ */
|
||||
|
||||
+70
-70
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user