- Fix the Visual Studio Project Structure with the e131 lib change to async

- Add 3 New Effects: Police, Police All, Multi Dynamic
This commit is contained in:
thomas.stockklauser 2019-11-22 19:19:48 +01:00
parent 095429a7df
commit 9e00177d76
7 changed files with 130 additions and 32 deletions

View File

@ -2346,6 +2346,95 @@ uint16_t WS2812FX::mode_static_pattern()
return FRAMETIME; return FRAMETIME;
} }
//Police Lights Red and Blue
uint16_t WS2812FX::mode_police()
{
SEGENV.step += 1;
if (SEGENV.step >= SEGLEN) {
SEGENV.step = 0;
}
uint16_t idexR = SEGENV.step;
uint16_t topindex = SEGLEN / 2;
uint16_t antipodal;
antipodal = idexR + topindex;
if (idexR >= topindex) {
antipodal = (idexR + topindex) % SEGLEN;
}
uint16_t idexB = antipodal;
uint8_t thathue = (thishuepolice + 160) % 255;
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
if (i == idexR) {
CRGB newcolor = CHSV(thishuepolice, thissat, 255);
setPixelColor(idexR, newcolor.r, newcolor.g, newcolor.b, 0x00);
}
else if (i == idexB) {
CRGB newcolor = CHSV(thathue, thissat, 255);
setPixelColor(idexB, newcolor.r, newcolor.g, newcolor.b, 0x00);
}
else {
setPixelColor(i, 0, 0, 0, 0);
}
}
return SPEED_FORMULA_L;
}
//American Police Light with all LED´s Red and Blue
uint16_t WS2812FX::mode_policeall()
{
SEGENV.step += 1;
if (SEGENV.step >= SEGLEN) {
SEGENV.step = 0;
}
uint16_t idexR = SEGENV.step;
uint16_t topindex = SEGLEN / 2;
uint16_t antipodal;
antipodal = idexR + topindex;
if (idexR >= topindex) {
antipodal = (idexR + topindex) % SEGLEN;
}
uint16_t idexB = antipodal;
uint8_t thathue = (thishuepolice + 160) % 255;
CRGB indexRCol = CHSV(thishuepolice, thissat, 255);
CRGB indexBCol = CHSV(thathue, thissat, 255);
setPixelColor(idexR, indexRCol.r, indexRCol.g, indexRCol.b, 0x00);
setPixelColor(idexB, indexBCol.r, indexBCol.g, indexBCol.b, 0x00);
return SPEED_FORMULA_L;
}
/*
* Lights every LED in a random color. Changes all LED at the same time
* to new random colors.
*/
uint16_t WS2812FX::mode_multi_dynamic()
{
for (uint16_t i = SEGMENT.start; i <= SEGMENT.stop; i++) {
setPixelColor(i, color_wheel(random8(SEGMENT.intensity)));
}
return (SEGMENT.speed);
}
//Speed slider sets number of "lights", intensity sets LEDs per light //Speed slider sets number of "lights", intensity sets LEDs per light
/*uint16_t WS2812FX::mode_static_pattern2() /*uint16_t WS2812FX::mode_static_pattern2()

View File

@ -84,7 +84,7 @@
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
#define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED ) #define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED )
#define MODE_COUNT 84 #define MODE_COUNT 87
#define FX_MODE_STATIC 0 #define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1 #define FX_MODE_BLINK 1
@ -171,7 +171,9 @@
#define FX_MODE_TWINKLECAT 81 #define FX_MODE_TWINKLECAT 81
#define FX_MODE_HALLOWEEN_EYES 82 #define FX_MODE_HALLOWEEN_EYES 82
#define FX_MODE_STATIC_PATTERN 83 #define FX_MODE_STATIC_PATTERN 83
#define FX_MODE_POLICE 84
#define FX_MODE_POLICE_ALL 85
#define FX_MODE_MULTI_DYNAMIC 86
class WS2812FX { class WS2812FX {
typedef uint16_t (WS2812FX::*mode_ptr)(void); typedef uint16_t (WS2812FX::*mode_ptr)(void);
@ -310,7 +312,9 @@ class WS2812FX {
_mode[FX_MODE_TWINKLECAT] = &WS2812FX::mode_twinklecat; _mode[FX_MODE_TWINKLECAT] = &WS2812FX::mode_twinklecat;
_mode[FX_MODE_HALLOWEEN_EYES] = &WS2812FX::mode_halloween_eyes; _mode[FX_MODE_HALLOWEEN_EYES] = &WS2812FX::mode_halloween_eyes;
_mode[FX_MODE_STATIC_PATTERN] = &WS2812FX::mode_static_pattern; _mode[FX_MODE_STATIC_PATTERN] = &WS2812FX::mode_static_pattern;
_mode[FX_MODE_POLICE] = &WS2812FX::mode_police;
_mode[FX_MODE_POLICE_ALL] = &WS2812FX::mode_policeall;
_mode[FX_MODE_MULTI_DYNAMIC] = &WS2812FX::mode_multi_dynamic;
_brightness = DEFAULT_BRIGHTNESS; _brightness = DEFAULT_BRIGHTNESS;
currentPalette = CRGBPalette16(CRGB::Black); currentPalette = CRGBPalette16(CRGB::Black);
@ -487,7 +491,10 @@ class WS2812FX {
mode_twinklefox(void), mode_twinklefox(void),
mode_twinklecat(void), mode_twinklecat(void),
mode_halloween_eyes(void), mode_halloween_eyes(void),
mode_static_pattern(void); mode_static_pattern(void),
mode_police(void),
mode_policeall(void),
mode_multi_dynamic(void);
private: private:
NeoPixelWrapper *bus; NeoPixelWrapper *bus;
@ -520,6 +527,10 @@ class WS2812FX {
mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element
/*Define Variables for the Police Effects*/
int thissat = 255; //-FX LOOPS DELAY VAR
uint8_t thishuepolice = 0;
// mode helper functions // mode helper functions
uint16_t uint16_t
blink(uint32_t, uint32_t, bool strobe, bool), blink(uint32_t, uint32_t, bool strobe, bool),
@ -558,7 +569,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([
"Out Out","Out In","Circus","Halloween","Tri Chase","Tri Wipe","Tri Fade","Lightning","ICU","Multi Comet", "Out Out","Out In","Circus","Halloween","Tri Chase","Tri Wipe","Tri Fade","Lightning","ICU","Multi Comet",
"Dual Scanner","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","BPM","Fill Noise", "Dual Scanner","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","BPM","Fill Noise",
"Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Smooth Meteor","Railway","Ripple", "Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Smooth Meteor","Railway","Ripple",
"Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern" "Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Police","Police All","Multi Dynamic"
])====="; ])=====";

View File

@ -18,7 +18,7 @@
#define ESP_PLATFORM #define ESP_PLATFORM
#define HAVE_CONFIG_H #define HAVE_CONFIG_H
#define F_CPU 240000000L #define F_CPU 240000000L
#define ARDUINO 10807 #define ARDUINO 10809
#define ARDUINO_ESP32_DEV #define ARDUINO_ESP32_DEV
#define ARDUINO_ARCH_ESP32 #define ARDUINO_ARCH_ESP32
#define ESP32 #define ESP32

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -62,9 +62,6 @@
<ClInclude Include="palettes.h"> <ClInclude Include="palettes.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="WS2812FX.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\dependencies\async-mqtt-client\AsyncMqttClient.h"> <ClInclude Include="src\dependencies\async-mqtt-client\AsyncMqttClient.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -179,9 +176,6 @@
<ClInclude Include="src\dependencies\blynk\Blynk\BlynkWiFiCommon.h"> <ClInclude Include="src\dependencies\blynk\Blynk\BlynkWiFiCommon.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\dependencies\e131\E131.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\dependencies\espalexa\Espalexa.h"> <ClInclude Include="src\dependencies\espalexa\Espalexa.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -203,14 +197,14 @@
<ClInclude Include="src\dependencies\timezone\Timezone.h"> <ClInclude Include="src\dependencies\timezone\Timezone.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="FX.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\dependencies\e131\ESPAsyncE131.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="WS2812FX.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WS2812FX_fcn.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\dependencies\async-mqtt-client\AsyncMqttClient.cpp"> <ClCompile Include="src\dependencies\async-mqtt-client\AsyncMqttClient.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -253,9 +247,6 @@
<ClCompile Include="src\dependencies\blynk\Blynk\utility.cpp"> <ClCompile Include="src\dependencies\blynk\Blynk\utility.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\dependencies\e131\E131.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\dependencies\espalexa\EspalexaDevice.cpp"> <ClCompile Include="src\dependencies\espalexa\EspalexaDevice.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -268,5 +259,14 @@
<ClCompile Include="src\dependencies\timezone\Timezone.cpp"> <ClCompile Include="src\dependencies\timezone\Timezone.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="FX.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FX_fcn.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\dependencies\e131\ESPAsyncE131.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>