Added new pattern plasma
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:d1_minid1_mini]
|
||||
[env:d1_mini]
|
||||
platform = espressif8266
|
||||
board = d1_mini
|
||||
framework = arduino
|
||||
|
@@ -9,7 +9,7 @@ INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduinoespressif8266/
|
||||
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include"
|
||||
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduinoespressif8266/cores/esp8266"
|
||||
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip2/include"
|
||||
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduinoespressif8266/variants/generic"
|
||||
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduinoespressif8266/variants/d1_mini"
|
||||
INCLUDEPATH += "$${HOMEDIR}/LedController/lib/FastLED"
|
||||
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduinoespressif8266/libraries/SoftwareSerial"
|
||||
INCLUDEPATH += "$${HOMEDIR}/.platformio/packages/framework-arduinoespressif8266/libraries/ESP8266WebServer/src"
|
||||
@@ -49,13 +49,13 @@ INCLUDEPATH += "$${HOMEDIR}/LedController/src"
|
||||
DEFINES += "PLATFORMIO=30603"
|
||||
DEFINES += "ESP8266"
|
||||
DEFINES += "ARDUINO_ARCH_ESP8266"
|
||||
DEFINES += "ARDUINO_ESP8266_ESP01"
|
||||
DEFINES += "ARDUINO_ESP8266_WEMOS_D1MINI"
|
||||
DEFINES += "F_CPU=80000000L"
|
||||
DEFINES += "__ets__"
|
||||
DEFINES += "ICACHE_FLASH"
|
||||
DEFINES += "ARDUINO=10805"
|
||||
DEFINES += "ARDUINO_BOARD="PLATFORMIO_ESP01""
|
||||
DEFINES += "FLASHMODE_QIO"
|
||||
DEFINES += "ARDUINO_BOARD="PLATFORMIO_D1_MINI""
|
||||
DEFINES += "FLASHMODE_DIO"
|
||||
DEFINES += "LWIP_OPEN_SRC"
|
||||
DEFINES += "TCP_MSS=536"
|
||||
DEFINES += "LWIP_FEATURES=1"
|
||||
@@ -64,14 +64,15 @@ DEFINES += "VTABLES_IN_FLASH"
|
||||
|
||||
OTHER_FILES += platformio.ini
|
||||
|
||||
HEADERS += src/pattern.h
|
||||
HEADERS += src/ledsettings.h
|
||||
HEADERS += src/ledcontroller.h
|
||||
HEADERS += src/pattern.h
|
||||
SOURCES += src/main.cpp
|
||||
HEADERS += src/patterns/confettipattern.h
|
||||
HEADERS += src/patterns/fire2012pattern.h
|
||||
HEADERS += src/patterns/sineleonpattern.h
|
||||
HEADERS += src/patterns/rainbowpattern.h
|
||||
HEADERS += src/patterns/jugglepattern.h
|
||||
HEADERS += src/patterns/bpmpattern.h
|
||||
HEADERS += src/patterns/rainbowwithglitterpattern.h
|
||||
HEADERS += src/patterns/bpmpattern.h
|
||||
HEADERS += src/patterns/plasmapattern.h
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "patterns/jugglepattern.h"
|
||||
#include "patterns/bpmpattern.h"
|
||||
#include "patterns/fire2012pattern.h"
|
||||
#include "patterns/plasmapattern.h"
|
||||
|
||||
FASTLED_USING_NAMESPACE
|
||||
|
||||
@@ -68,8 +69,9 @@ public:
|
||||
m_juggle(leds),
|
||||
m_bpm(leds),
|
||||
m_fire2012(leds),
|
||||
m_plasma(leds),
|
||||
m_rgbtest(leds),
|
||||
patterns { &m_rainbow, &m_rainbowWithGlitter, &m_confetti, &m_sineleon, &m_juggle, &m_bpm, &m_fire2012, &m_rgbtest },
|
||||
patterns { &m_rainbow, &m_rainbowWithGlitter, &m_confetti, &m_sineleon, &m_juggle, &m_bpm, &m_fire2012, &m_plasma, &m_rgbtest },
|
||||
iter(patterns.begin())
|
||||
{
|
||||
controller.setCorrection(TypicalLEDStrip);
|
||||
@@ -103,10 +105,11 @@ private:
|
||||
JugglePattern m_juggle;
|
||||
BpmPattern m_bpm;
|
||||
Fire2012Pattern m_fire2012;
|
||||
PlasmaPattern m_plasma;
|
||||
RGBTest m_rgbtest;
|
||||
|
||||
public:
|
||||
using PatternContainer = std::array<Pattern*, 8>;
|
||||
using PatternContainer = std::array<Pattern*, 9>;
|
||||
const PatternContainer patterns;
|
||||
PatternContainer::const_iterator iter;
|
||||
};
|
||||
|
17
src/main.cpp
17
src/main.cpp
@@ -14,6 +14,7 @@ constexpr auto WIFI_PASSWD = "Passwort_123";
|
||||
LedController ledController;
|
||||
|
||||
ESP8266WebServer server(80);
|
||||
WiFiClient m_client;
|
||||
|
||||
bool power = true;
|
||||
bool rotatePattern = true;
|
||||
@@ -138,7 +139,7 @@ void setup()
|
||||
server.on("/update", HTTP_GET, []() {
|
||||
server.sendHeader("Connection", "close");
|
||||
server.send(200, "text/html",
|
||||
"<form method=\"POST\" action=\"/update\" enctype=\"multipart/form-data\">"
|
||||
"<form method=\"POST\" enctype=\"multipart/form-data\">"
|
||||
"<input type=\"file\" name=\"update\" />"
|
||||
"<button type=\"submit\">Install</button>"
|
||||
"</form>");
|
||||
@@ -174,6 +175,20 @@ void setup()
|
||||
yield();
|
||||
});
|
||||
|
||||
server.on("/reboot", HTTP_GET, []() {
|
||||
server.sendHeader("Connection", "close");
|
||||
server.send(200, "text/html",
|
||||
"<form method=\"POST\">"
|
||||
"<button type=\"submit\">Perform reboot</button>"
|
||||
"</form>");
|
||||
});
|
||||
|
||||
server.on("/reboot", HTTP_POST, []() {
|
||||
server.sendHeader("Connection", "close");
|
||||
server.send(200, "text/plain", "OK");
|
||||
ESP.restart();
|
||||
});
|
||||
|
||||
server.on("/status", HTTP_GET, []()
|
||||
{
|
||||
server.sendHeader("Connection", "close");
|
||||
|
62
src/patterns/plasmapattern.h
Normal file
62
src/patterns/plasmapattern.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include "pattern.h"
|
||||
|
||||
#include <FastLED.h>
|
||||
|
||||
#include "ledsettings.h"
|
||||
#include "ledcontroller.h"
|
||||
|
||||
FASTLED_USING_NAMESPACE
|
||||
|
||||
class PlasmaPattern : public Pattern {
|
||||
// Use qsuba for smooth pixel colouring and qsubd for non-smooth pixel colouring
|
||||
template<typename T1, typename T2>
|
||||
auto qsubd(T1 x, T2 b)
|
||||
{
|
||||
return (x > b) ? b : 0; // Digital unsigned subtraction macro. if result <0, then => 0. Otherwise, take on fixed value.
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
auto qsuba(T1 x, T2 b)
|
||||
{
|
||||
return (x > b) ? x - b : 0; // Analog Unsigned subtraction macro. if result <0, then => 0
|
||||
}
|
||||
|
||||
public:
|
||||
using Pattern::Pattern;
|
||||
|
||||
const char *name() const override
|
||||
{
|
||||
return "plasma";
|
||||
}
|
||||
|
||||
void run() override
|
||||
{
|
||||
int thisPhase = beatsin8(6,-64,64); // Setting phase change for a couple of waves.
|
||||
int thatPhase = beatsin8(7,-64,64);
|
||||
|
||||
for (int k=0; k<leds.size(); k++) { // For each of the LED's in the strand, set a brightness based on a wave as follows:
|
||||
|
||||
int colorIndex = cubicwave8((k*23)+thisPhase)/2 + cos8((k*15)+thatPhase)/2; // Create a wave and add a phase change and add another wave with its own phase change.. Hey, you can even change the frequencies if you wish.
|
||||
int thisBright = qsuba(colorIndex, beatsin8(7,0,96)); // qsub gives it a bit of 'black' dead space by setting sets a minimum value. If colorIndex < current value of beatsin8(), then bright = 0. Otherwise, bright = colorIndex..
|
||||
|
||||
leds[k] = ColorFromPalette(currentPalette, colorIndex, thisBright, currentBlending); // Let's now add the foreground colour.
|
||||
}
|
||||
|
||||
EVERY_N_MILLISECONDS(100) {
|
||||
uint8_t maxChanges = 24;
|
||||
nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges); // AWESOME palette blending capability.
|
||||
}
|
||||
|
||||
EVERY_N_SECONDS(5) { // Change the target palette to a random one every 5 seconds.
|
||||
uint8_t baseC = random8(); // You can use this as a baseline colour if you want similar hues in the next line.
|
||||
targetPalette = CRGBPalette16(CHSV(baseC+random8(32), 192, random8(128,255)), CHSV(baseC+random8(32), 255, random8(128,255)), CHSV(baseC+random8(32), 192, random8(128,255)), CHSV(baseC+random8(32), 255, random8(128,255)));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
CRGBPalette16 currentPalette { OceanColors_p };
|
||||
CRGBPalette16 targetPalette;
|
||||
TBlendType currentBlending = LINEARBLEND;
|
||||
};
|
Reference in New Issue
Block a user