2 Commits

74 changed files with 1891 additions and 10640 deletions

View File

@ -1,3 +0,0 @@
{
"CurrentProjectSetting": "Visual Micro"
}

View File

@ -1,9 +0,0 @@
{
"ExpandedNodes": [
"",
"\\data",
"\\data\\images"
],
"SelectedNode": "\\esp8266-fastled-webserver.ino",
"PreviewInSolutionExplorer": false
}

View File

@ -1,113 +0,0 @@
/*
Editor: https://www.visualmicro.com/
visual micro and the arduino ide ignore this code during compilation. this code is automatically maintained by visualmicro, manual changes to this file will be overwritten
the contents of the Visual Micro sketch sub folder can be deleted prior to publishing a project
all non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!).
note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again
Hardware: WeMos D1 R2 & mini, Platform=esp8266, Package=esp8266
*/
#if defined(_VMICRO_INTELLISENSE)
#ifndef _VSARDUINO_H_
#define _VSARDUINO_H_
#define __ESP8266_ESp8266__
#define __ESP8266_ESP8266__
#define __ets__
#define ICACHE_FLASH
#define F_CPU 80000000L
#define LWIP_OPEN_SRC
#define TCP_MSS 536
#define ARDUINO 10807
#define ARDUINO_ESP8266_WEMOS_D1MINI
#define ARDUINO_ARCH_ESP8266
#define ESP8266
#define __cplusplus 201103L
#undef __cplusplus
#define __cplusplus 201103L
#define __STDC__
#define __ARM__
#define __arm__
#define __inline__
#define __asm__(x)
#define __asm__
#define __extension__
#define __ATTR_PURE__
#define __ATTR_CONST__
#define __volatile__
#define __ASM
#define __INLINE
#define __attribute__(noinline)
//#define _STD_BEGIN
//#define EMIT
#define WARNING
#define _Lockit
#define __CLR_OR_THIS_CALL
#define C4005
#define _NEW
//typedef int uint8_t;
//#define __ARMCC_VERSION 400678
//#define PROGMEM
//#define string_literal
//
//#define prog_void
//#define PGM_VOID_P int
//
typedef int _read;
typedef int _seek;
typedef int _write;
typedef int _close;
typedef int __cleanup;
//#define inline
#define __builtin_clz
#define __builtin_clzl
#define __builtin_clzll
#define __builtin_labs
#define __builtin_va_list
typedef int __gnuc_va_list;
#define __ATOMIC_ACQ_REL
#define __CHAR_BIT__
#define _EXFUN()
typedef unsigned char byte;
extern "C" void __cxa_pure_virtual() {;}
typedef long __INTPTR_TYPE__ ;
typedef long __UINTPTR_TYPE__ ;
typedef long __SIZE_TYPE__ ;
typedef long __PTRDIFF_TYPE__;
#include "new"
#include "Esp.h"
#include <arduino.h>
#include <pins_arduino.h>
#include "..\generic\Common.h"
#include "..\generic\pins_arduino.h"
#undef F
#define F(string_literal) ((const PROGMEM char *)(string_literal))
#undef PSTR
#define PSTR(string_literal) ((const PROGMEM char *)(string_literal))
//current vc++ does not understand this syntax so use older arduino example for intellisense
//todo:move to the new clang/gcc project types.
#define interrupts() sei()
#define noInterrupts() cli()
#include "esp8266-fastled-webserver.ino"
#endif
#endif

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,47 +0,0 @@
{
"configurations": [
{
"name": "Visual Micro",
"intelliSenseMode": "msvc-x64",
"includePath": [
"${projectRoot}..\\esp8266-fastled-webserver",
"D:\\Music\\Documents\\Arduino\\libraries\\FastLED",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\libraries\\ESP8266WiFi\\src",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\libraries\\ESP8266WebServer\\src",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\libraries\\ESP8266HTTPUpdateServer\\src",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\libraries\\EEPROM",
"S:\\Software\\Arduino\\libraries",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\libraries",
"D:\\Music\\Documents\\Arduino\\libraries",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\cores\\esp8266",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\cores\\esp8266\\libb64",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\cores\\esp8266\\spiffs",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\cores\\esp8266\\umm_malloc",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\variants\\d1_mini",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\tools\\sdk\\include",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\tools\\sdk\\lwip2\\include",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\tools\\sdk\\libc\\xtensa-lx106-elf\\include",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\1.20.0-26-gb404fb9-2\\xtensa-lx106-elf\\include\\c++\\4.8.2",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\1.20.0-26-gb404fb9-2\\xtensa-lx106-elf\\include\\c++\\4.8.2\\xtensa-lx106-elf",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\1.20.0-26-gb404fb9-2\\xtensa-lx106-elf\\include",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\1.20.0-26-gb404fb9-2\\lib\\gcc\\xtensa-lx106-elf\\4.8.2\\include",
"${projectRoot}..\\..\\..\\..\\AppData\\Local\\arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.1\\tools\\sdk\\include"
],
"defines": [
"__ESP8266_ESp8266__",
"__ESP8266_ESP8266__",
"__ets__",
"ICACHE_FLASH",
"F_CPU=80000000L",
"LWIP_OPEN_SRC",
"TCP_MSS=536",
"ARDUINO=10807",
"ARDUINO_ESP8266_WEMOS_D1MINI",
"ARDUINO_ARCH_ESP8266",
"ESP8266",
"__cplusplus=201103L",
"_VMICRO_INTELLISENSE"
]
}
]
}

View File

@ -1,125 +0,0 @@
//holds the current upload
File fsUploadFile;
//format bytes
String formatBytes(size_t bytes){
if (bytes < 1024){
return String(bytes)+"B";
} else if(bytes < (1024 * 1024)){
return String(bytes/1024.0)+"KB";
} else if(bytes < (1024 * 1024 * 1024)){
return String(bytes/1024.0/1024.0)+"MB";
} else {
return String(bytes/1024.0/1024.0/1024.0)+"GB";
}
}
String getContentType(String filename){
if(webServer.hasArg("download")) return "application/octet-stream";
else if(filename.endsWith(".htm")) return "text/html";
else if(filename.endsWith(".html")) return "text/html";
else if(filename.endsWith(".css")) return "text/css";
else if(filename.endsWith(".js")) return "application/javascript";
else if(filename.endsWith(".png")) return "image/png";
else if(filename.endsWith(".gif")) return "image/gif";
else if(filename.endsWith(".jpg")) return "image/jpeg";
else if(filename.endsWith(".ico")) return "image/x-icon";
else if(filename.endsWith(".xml")) return "text/xml";
else if(filename.endsWith(".pdf")) return "application/x-pdf";
else if(filename.endsWith(".zip")) return "application/x-zip";
else if(filename.endsWith(".gz")) return "application/x-gzip";
return "text/plain";
}
bool handleFileRead(String path){
Serial.println("handleFileRead: " + path);
if(path.endsWith("/")) path += "index.htm";
String contentType = getContentType(path);
String pathWithGz = path + ".gz";
if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)){
if(SPIFFS.exists(pathWithGz))
path += ".gz";
File file = SPIFFS.open(path, "r");
size_t sent = webServer.streamFile(file, contentType);
file.close();
return true;
}
return false;
}
void handleFileUpload(){
if(webServer.uri() != "/edit") return;
HTTPUpload& upload = webServer.upload();
if(upload.status == UPLOAD_FILE_START){
String filename = upload.filename;
if(!filename.startsWith("/")) filename = "/"+filename;
Serial.print("handleFileUpload Name: "); Serial.println(filename);
fsUploadFile = SPIFFS.open(filename, "w");
filename = String();
} else if(upload.status == UPLOAD_FILE_WRITE){
//Serial.print("handleFileUpload Data: "); Serial.println(upload.currentSize);
if(fsUploadFile)
fsUploadFile.write(upload.buf, upload.currentSize);
} else if(upload.status == UPLOAD_FILE_END){
if(fsUploadFile)
fsUploadFile.close();
Serial.print("handleFileUpload Size: "); Serial.println(upload.totalSize);
}
}
void handleFileDelete(){
if(webServer.args() == 0) return webServer.send(500, "text/plain", "BAD ARGS");
String path = webServer.arg(0);
Serial.println("handleFileDelete: " + path);
if(path == "/")
return webServer.send(500, "text/plain", "BAD PATH");
if(!SPIFFS.exists(path))
return webServer.send(404, "text/plain", "FileNotFound");
SPIFFS.remove(path);
webServer.send(200, "text/plain", "");
path = String();
}
void handleFileCreate(){
if(webServer.args() == 0)
return webServer.send(500, "text/plain", "BAD ARGS");
String path = webServer.arg(0);
Serial.println("handleFileCreate: " + path);
if(path == "/")
return webServer.send(500, "text/plain", "BAD PATH");
if(SPIFFS.exists(path))
return webServer.send(500, "text/plain", "FILE EXISTS");
File file = SPIFFS.open(path, "w");
if(file)
file.close();
else
return webServer.send(500, "text/plain", "CREATE FAILED");
webServer.send(200, "text/plain", "");
path = String();
}
void handleFileList() {
if(!webServer.hasArg("dir")) {webServer.send(500, "text/plain", "BAD ARGS"); return;}
String path = webServer.arg("dir");
Serial.println("handleFileList: " + path);
Dir dir = SPIFFS.openDir(path);
path = String();
String output = "[";
while(dir.next()){
File entry = dir.openFile("r");
if (output != "[") output += ',';
bool isDir = false;
output += "{\"type\":\"";
output += (isDir)?"dir":"file";
output += "\",\"name\":\"";
output += String(entry.name()).substring(1);
output += "\"}";
entry.close();
}
output += "]";
webServer.send(200, "text/json", output);
}

130
Field.h
View File

@ -1,130 +0,0 @@
/*
ESP8266 + FastLED + IR Remote: https://github.com/jasoncoon/esp8266-fastled-webserver
Copyright (C) 2016 Jason Coon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
typedef String (*FieldSetter)(String);
typedef String (*FieldGetter)();
const String NumberFieldType = "Number";
const String BooleanFieldType = "Boolean";
const String SelectFieldType = "Select";
const String ColorFieldType = "Color";
const String SectionFieldType = "Section";
typedef struct Field {
String name;
String label;
String type;
uint8_t min;
uint8_t max;
FieldGetter getValue;
FieldGetter getOptions;
FieldSetter setValue;
};
typedef Field FieldList[];
Field getField(String name, FieldList fields, uint8_t count) {
for (uint8_t i = 0; i < count; i++) {
Field field = fields[i];
if (field.name == name) {
return field;
}
}
return Field();
}
String getFieldValue(String name, FieldList fields, uint8_t count) {
Field field = getField(name, fields, count);
if (field.getValue) {
return field.getValue();
}
return String();
}
String setFieldValue(String name, String value, FieldList fields, uint8_t count) {
Field field = getField(name, fields, count);
if (field.setValue) {
return field.setValue(value);
}
return String();
}
String getFieldsJson(FieldList fields, uint8_t count) {
String json = "[";
for (uint8_t i = 0; i < count; i++) {
Field field = fields[i];
json += "{\"name\":\"" + field.name + "\",\"label\":\"" + field.label + "\",\"type\":\"" + field.type + "\"";
if(field.getValue) {
if (field.type == ColorFieldType || field.type == "String") {
json += ",\"value\":\"" + field.getValue() + "\"";
}
else {
json += ",\"value\":" + field.getValue();
}
}
if (field.type == NumberFieldType) {
json += ",\"min\":" + String(field.min);
json += ",\"max\":" + String(field.max);
}
if (field.getOptions) {
json += ",\"options\":[";
json += field.getOptions();
json += "]";
}
json += "}";
if (i < count - 1)
json += ",";
}
json += "]";
return json;
}
/*
String json = "[";
json += "{\"name\":\"power\",\"label\":\"Power\",\"type\":\"Boolean\",\"value\":" + String(power) + "},";
json += "{\"name\":\"brightness\",\"label\":\"Brightness\",\"type\":\"Number\",\"value\":" + String(brightness) + "},";
json += "{\"name\":\"pattern\",\"label\":\"Pattern\",\"type\":\"Select\",\"value\":" + String(currentPatternIndex) + ",\"options\":[";
for (uint8_t i = 0; i < patternCount; i++)
{
json += "\"" + patterns[i].name + "\"";
if (i < patternCount - 1)
json += ",";
}
json += "]},";
json += "{\"name\":\"autoplay\",\"label\":\"Autoplay\",\"type\":\"Boolean\",\"value\":" + String(autoplay) + "},";
json += "{\"name\":\"autoplayDuration\",\"label\":\"Autoplay Duration\",\"type\":\"Number\",\"value\":" + String(autoplayDuration) + "},";
json += "{\"name\":\"solidColor\",\"label\":\"Color\",\"type\":\"Color\",\"value\":\"" + String(solidColor.r) + "," + String(solidColor.g) + "," + String(solidColor.b) +"\"},";
json += "{\"name\":\"cooling\",\"label\":\"Cooling\",\"type\":\"Number\",\"value\":" + String(cooling) + "},";
json += "{\"name\":\"sparking\",\"label\":\"Sparking\",\"type\":\"Number\",\"value\":" + String(sparking) + "}";
json += "]";
*/

138
Fields.h
View File

@ -1,138 +0,0 @@
/*
ESP8266 + FastLED + IR Remote: https://github.com/jasoncoon/esp8266-fastled-webserver
Copyright (C) 2016 Jason Coon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
uint8_t power = 1;
uint8_t brightness = brightnessMap[brightnessIndex];
//String setPower(String value) {
// power = value.toInt();
// if(power < 0) power = 0;
// else if (power > 1) power = 1;
// return String(power);
//}
String getPower() {
return String(power);
}
//String setBrightness(String value) {
// brightness = value.toInt();
// if(brightness < 0) brightness = 0;
// else if (brightness > 255) brightness = 255;
// return String(brightness);
//}
String getBrightness() {
return String(brightness);
}
String getPattern() {
return String(currentPatternIndex);
}
String getPatterns() {
String json = "";
for (uint8_t i = 0; i < patternCount; i++) {
json += "\"" + patterns[i].name + "\"";
if (i < patternCount - 1)
json += ",";
}
return json;
}
String getPalette() {
return String(currentPaletteIndex);
}
String getPalettes() {
String json = "";
for (uint8_t i = 0; i < paletteCount; i++) {
json += "\"" + paletteNames[i] + "\"";
if (i < paletteCount - 1)
json += ",";
}
return json;
}
String getAutoplay() {
return String(autoplay);
}
String getAutoplayDuration() {
return String(autoplayDuration);
}
String getAllLeafs() {
return String(allLeafs);
}
String getSelectedLeaf() {
return String(selectedLeaf);
}
String getSolidColor() {
return String(solidColor.r) + "," + String(solidColor.g) + "," + String(solidColor.b);
}
String getCooling() {
return String(cooling);
}
String getSparking() {
return String(sparking);
}
String getSpeed() {
return String(speed);
}
String getTwinkleSpeed() {
return String(twinkleSpeed);
}
String getTwinkleDensity() {
return String(twinkleDensity);
}
FieldList fields = {
{ "power", "Power", BooleanFieldType, 0, 1, getPower },
{ "brightness", "Brightness", NumberFieldType, 1, 255, getBrightness },
{ "pattern", "Pattern", SelectFieldType, 0, patternCount, getPattern, getPatterns },
{ "palette", "Palette", SelectFieldType, 0, paletteCount, getPalette, getPalettes },
{ "speed", "Speed", NumberFieldType, 1, 255, getSpeed },
{ "autoplay", "Autoplay", SectionFieldType },
{ "autoplay", "Autoplay", BooleanFieldType, 0, 1, getAutoplay },
{ "autoplayDuration", "Autoplay Duration", NumberFieldType, 0, 255, getAutoplayDuration },
{ "allLeafs", "Color Leafs", SectionFieldType },
{ "allLeafs", "Color All Leafs", BooleanFieldType, 0, 1, getAllLeafs },
{ "selectedLeaf", "Select Leaf to Color", NumberFieldType, 1, LEAFCOUNT, getSelectedLeaf },
{ "solidColor", "Solid Color", SectionFieldType },
{ "solidColor", "Color", ColorFieldType, 0, 255, getSolidColor },
{ "fire", "Fire & Water", SectionFieldType },
{ "cooling", "Cooling", NumberFieldType, 0, 255, getCooling },
{ "sparking", "Sparking", NumberFieldType, 0, 255, getSparking },
{ "twinkles", "Twinkles", SectionFieldType },
{ "twinkleSpeed", "Twinkle Speed", NumberFieldType, 0, 8, getTwinkleSpeed },
{ "twinkleDensity", "Twinkle Density", NumberFieldType, 0, 8, getTwinkleDensity },
};
uint8_t fieldCount = ARRAY_SIZE(fields);

View File

@ -10,61 +10,57 @@
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.
DEFINE_GRADIENT_PALETTE(ib_jul01_gp) {
DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
0, 194, 1, 1,
94, 1, 29, 18,
132, 57, 131, 28,
255, 113, 1, 1
};
132, 57,131, 28,
255, 113, 1, 1};
// Gradient palette "es_vintage_57_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_57.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_vintage_57_gp) {
DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) {
0, 2, 1, 1,
53, 18, 1, 0,
104, 69, 29, 1,
153, 167, 135, 10,
255, 46, 56, 4
};
153, 167,135, 10,
255, 46, 56, 4};
// Gradient palette "es_vintage_01_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_01.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_vintage_01_gp) {
DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
0, 4, 1, 1,
51, 16, 0, 1,
76, 97, 104, 3,
101, 255, 131, 19,
76, 97,104, 3,
101, 255,131, 19,
127, 67, 9, 4,
153, 16, 0, 1,
229, 4, 1, 1,
255, 4, 1, 1
};
255, 4, 1, 1};
// Gradient palette "es_rivendell_15_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/rivendell/tn/es_rivendell_15.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_rivendell_15_gp) {
DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) {
0, 1, 14, 5,
101, 16, 36, 14,
165, 56, 68, 30,
242, 150, 156, 99,
255, 150, 156, 99
};
242, 150,156, 99,
255, 150,156, 99};
// Gradient palette "rgi_15_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/rgi/tn/rgi_15.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 36 bytes of program space.
DEFINE_GRADIENT_PALETTE(rgi_15_gp) {
DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
0, 4, 1, 31,
31, 55, 1, 16,
63, 197, 3, 7,
@ -73,256 +69,238 @@ DEFINE_GRADIENT_PALETTE(rgi_15_gp) {
159, 39, 6, 33,
191, 112, 13, 32,
223, 56, 9, 35,
255, 22, 6, 38
};
255, 22, 6, 38};
// Gradient palette "retro2_16_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/retro2/tn/retro2_16.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 8 bytes of program space.
DEFINE_GRADIENT_PALETTE(retro2_16_gp) {
0, 188, 135, 1,
255, 46, 7, 1
};
DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
0, 188,135, 1,
255, 46, 7, 1};
// Gradient palette "Analogous_1_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/red/tn/Analogous_1.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE(Analogous_1_gp) {
0, 3, 0, 255,
63, 23, 0, 255,
127, 67, 0, 255,
DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
0, 3, 0,255,
63, 23, 0,255,
127, 67, 0,255,
191, 142, 0, 45,
255, 255, 0, 0
};
255, 255, 0, 0};
// Gradient palette "es_pinksplash_08_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_08.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_pinksplash_08_gp) {
0, 126, 11, 255,
DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
0, 126, 11,255,
127, 197, 1, 22,
175, 210, 157, 172,
221, 157, 3, 112,
255, 157, 3, 112
};
175, 210,157,172,
221, 157, 3,112,
255, 157, 3,112};
// Gradient palette "es_pinksplash_07_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_07.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_pinksplash_07_gp) {
DEFINE_GRADIENT_PALETTE( es_pinksplash_07_gp ) {
0, 229, 1, 1,
61, 242, 4, 63,
101, 255, 12, 255,
127, 249, 81, 252,
153, 255, 11, 235,
101, 255, 12,255,
127, 249, 81,252,
153, 255, 11,235,
193, 244, 5, 68,
255, 232, 1, 5
};
255, 232, 1, 5};
// Gradient palette "Coral_reef_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/other/tn/Coral_reef.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE(Coral_reef_gp) {
0, 40, 199, 197,
50, 10, 152, 155,
96, 1, 111, 120,
96, 43, 127, 162,
139, 10, 73, 111,
255, 1, 34, 71
};
DEFINE_GRADIENT_PALETTE( Coral_reef_gp ) {
0, 40,199,197,
50, 10,152,155,
96, 1,111,120,
96, 43,127,162,
139, 10, 73,111,
255, 1, 34, 71};
// Gradient palette "es_ocean_breeze_068_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_068.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_ocean_breeze_068_gp) {
0, 100, 156, 153,
51, 1, 99, 137,
DEFINE_GRADIENT_PALETTE( es_ocean_breeze_068_gp ) {
0, 100,156,153,
51, 1, 99,137,
101, 1, 68, 84,
104, 35, 142, 168,
178, 0, 63, 117,
255, 1, 10, 10
};
104, 35,142,168,
178, 0, 63,117,
255, 1, 10, 10};
// Gradient palette "es_ocean_breeze_036_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_036.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_ocean_breeze_036_gp) {
DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
0, 1, 6, 7,
89, 1, 99, 111,
153, 144, 209, 255,
255, 0, 73, 82
};
89, 1, 99,111,
153, 144,209,255,
255, 0, 73, 82};
// Gradient palette "departure_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/mjf/tn/departure.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 88 bytes of program space.
DEFINE_GRADIENT_PALETTE(departure_gp) {
DEFINE_GRADIENT_PALETTE( departure_gp ) {
0, 8, 3, 0,
42, 23, 7, 0,
63, 75, 38, 6,
84, 169, 99, 38,
106, 213, 169, 119,
116, 255, 255, 255,
138, 135, 255, 138,
148, 22, 255, 24,
170, 0, 255, 0,
191, 0, 136, 0,
106, 213,169,119,
116, 255,255,255,
138, 135,255,138,
148, 22,255, 24,
170, 0,255, 0,
191, 0,136, 0,
212, 0, 55, 0,
255, 0, 55, 0
};
255, 0, 55, 0};
// Gradient palette "es_landscape_64_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_64.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 36 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_landscape_64_gp) {
DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
0, 0, 0, 0,
37, 2, 25, 1,
76, 15, 115, 5,
127, 79, 213, 1,
128, 126, 211, 47,
130, 188, 209, 247,
153, 144, 182, 205,
204, 59, 117, 250,
255, 1, 37, 192
};
76, 15,115, 5,
127, 79,213, 1,
128, 126,211, 47,
130, 188,209,247,
153, 144,182,205,
204, 59,117,250,
255, 1, 37,192};
// Gradient palette "es_landscape_33_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_33.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_landscape_33_gp) {
DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
0, 1, 5, 0,
19, 32, 23, 1,
38, 161, 55, 1,
63, 229, 144, 1,
66, 39, 142, 74,
255, 1, 4, 1
};
63, 229,144, 1,
66, 39,142, 74,
255, 1, 4, 1};
// Gradient palette "rainbowsherbet_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/icecream/tn/rainbowsherbet.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE(rainbowsherbet_gp) {
DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
0, 255, 33, 4,
43, 255, 68, 25,
86, 255, 7, 25,
127, 255, 82, 103,
170, 255, 255, 242,
209, 42, 255, 22,
255, 87, 255, 65
};
127, 255, 82,103,
170, 255,255,242,
209, 42,255, 22,
255, 87,255, 65};
// Gradient palette "gr65_hult_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr65_hult.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE(gr65_hult_gp) {
0, 247, 176, 247,
48, 255, 136, 255,
89, 220, 29, 226,
160, 7, 82, 178,
216, 1, 124, 109,
255, 1, 124, 109
};
DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
0, 247,176,247,
48, 255,136,255,
89, 220, 29,226,
160, 7, 82,178,
216, 1,124,109,
255, 1,124,109};
// Gradient palette "gr64_hult_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr64_hult.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.
DEFINE_GRADIENT_PALETTE(gr64_hult_gp) {
0, 1, 124, 109,
DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
0, 1,124,109,
66, 1, 93, 79,
104, 52, 65, 1,
130, 115, 127, 1,
130, 115,127, 1,
150, 52, 65, 1,
201, 1, 86, 72,
239, 0, 55, 45,
255, 0, 55, 45
};
255, 0, 55, 45};
// Gradient palette "GMT_drywet_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/gmt/tn/GMT_drywet.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE(GMT_drywet_gp) {
DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
0, 47, 30, 2,
42, 213, 147, 24,
84, 103, 219, 52,
127, 3, 219, 207,
170, 1, 48, 214,
212, 1, 1, 111,
255, 1, 7, 33
};
42, 213,147, 24,
84, 103,219, 52,
127, 3,219,207,
170, 1, 48,214,
212, 1, 1,111,
255, 1, 7, 33};
// Gradient palette "ib15_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/general/tn/ib15.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE(ib15_gp) {
0, 113, 91, 147,
DEFINE_GRADIENT_PALETTE( ib15_gp ) {
0, 113, 91,147,
72, 157, 88, 78,
89, 208, 85, 33,
107, 255, 29, 11,
141, 137, 31, 39,
255, 59, 33, 89
};
255, 59, 33, 89};
// Gradient palette "Fuschia_7_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/fuschia/tn/Fuschia-7.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE(Fuschia_7_gp) {
0, 43, 3, 153,
63, 100, 4, 103,
DEFINE_GRADIENT_PALETTE( Fuschia_7_gp ) {
0, 43, 3,153,
63, 100, 4,103,
127, 188, 5, 66,
191, 161, 11, 115,
255, 135, 20, 182
};
191, 161, 11,115,
255, 135, 20,182};
// Gradient palette "es_emerald_dragon_08_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/emerald_dragon/tn/es_emerald_dragon_08.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_emerald_dragon_08_gp) {
0, 97, 255, 1,
101, 47, 133, 1,
DEFINE_GRADIENT_PALETTE( es_emerald_dragon_08_gp ) {
0, 97,255, 1,
101, 47,133, 1,
178, 13, 43, 1,
255, 2, 10, 1
};
255, 2, 10, 1};
// Gradient palette "lava_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/lava.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.
DEFINE_GRADIENT_PALETTE(lava_gp) {
DEFINE_GRADIENT_PALETTE( lava_gp ) {
0, 0, 0, 0,
46, 18, 0, 0,
96, 113, 0, 0,
@ -330,173 +308,162 @@ DEFINE_GRADIENT_PALETTE(lava_gp) {
119, 175, 17, 1,
146, 213, 44, 2,
174, 255, 82, 4,
188, 255, 115, 4,
202, 255, 156, 4,
218, 255, 203, 4,
234, 255, 255, 4,
244, 255, 255, 71,
255, 255, 255, 255
};
188, 255,115, 4,
202, 255,156, 4,
218, 255,203, 4,
234, 255,255, 4,
244, 255,255, 71,
255, 255,255,255};
// Gradient palette "fire_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/fire.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE(fire_gp) {
DEFINE_GRADIENT_PALETTE( fire_gp ) {
0, 1, 1, 0,
76, 32, 5, 0,
146, 192, 24, 0,
197, 220, 105, 5,
240, 252, 255, 31,
250, 252, 255, 111,
255, 255, 255, 255
};
197, 220,105, 5,
240, 252,255, 31,
250, 252,255,111,
255, 255,255,255};
// Gradient palette "Colorfull_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Colorfull.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.
DEFINE_GRADIENT_PALETTE(Colorfull_gp) {
DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
0, 10, 85, 5,
25, 29, 109, 18,
60, 59, 138, 42,
25, 29,109, 18,
60, 59,138, 42,
93, 83, 99, 52,
106, 110, 66, 64,
109, 123, 49, 65,
113, 139, 35, 66,
116, 192, 117, 98,
124, 255, 255, 137,
168, 100, 180, 155,
255, 22, 121, 174
};
116, 192,117, 98,
124, 255,255,137,
168, 100,180,155,
255, 22,121,174};
// Gradient palette "Magenta_Evening_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Magenta_Evening.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE(Magenta_Evening_gp) {
DEFINE_GRADIENT_PALETTE( Magenta_Evening_gp ) {
0, 71, 27, 39,
31, 130, 11, 51,
63, 213, 2, 64,
70, 232, 1, 66,
76, 252, 1, 69,
108, 123, 2, 51,
255, 46, 9, 35
};
255, 46, 9, 35};
// Gradient palette "Pink_Purple_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Pink_Purple.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.
DEFINE_GRADIENT_PALETTE(Pink_Purple_gp) {
DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
0, 19, 2, 39,
25, 26, 4, 45,
51, 33, 6, 52,
76, 68, 62, 125,
102, 118, 187, 240,
109, 163, 215, 247,
114, 217, 244, 255,
122, 159, 149, 221,
149, 113, 78, 188,
183, 128, 57, 155,
255, 146, 40, 123
};
76, 68, 62,125,
102, 118,187,240,
109, 163,215,247,
114, 217,244,255,
122, 159,149,221,
149, 113, 78,188,
183, 128, 57,155,
255, 146, 40,123};
// Gradient palette "Sunset_Real_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Real.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE(Sunset_Real_gp) {
DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
0, 120, 0, 0,
22, 179, 22, 0,
51, 255, 104, 0,
51, 255,104, 0,
85, 167, 22, 18,
135, 100, 0, 103,
198, 16, 0, 130,
255, 0, 0, 160
};
135, 100, 0,103,
198, 16, 0,130,
255, 0, 0,160};
// Gradient palette "es_autumn_19_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/autumn/tn/es_autumn_19.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.
DEFINE_GRADIENT_PALETTE(es_autumn_19_gp) {
DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
0, 26, 1, 1,
51, 67, 4, 1,
84, 118, 14, 1,
104, 137, 152, 52,
104, 137,152, 52,
112, 113, 65, 1,
122, 133, 149, 59,
124, 137, 152, 52,
122, 133,149, 59,
124, 137,152, 52,
135, 113, 65, 1,
142, 139, 154, 46,
142, 139,154, 46,
163, 113, 13, 1,
204, 55, 3, 1,
249, 17, 1, 1,
255, 17, 1, 1
};
255, 17, 1, 1};
// Gradient palette "BlacK_Blue_Magenta_White_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Blue_Magenta_White.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE(BlacK_Blue_Magenta_White_gp) {
DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
0, 0, 0, 0,
42, 0, 0, 45,
84, 0, 0, 255,
127, 42, 0, 255,
170, 255, 0, 255,
212, 255, 55, 255,
255, 255, 255, 255
};
84, 0, 0,255,
127, 42, 0,255,
170, 255, 0,255,
212, 255, 55,255,
255, 255,255,255};
// Gradient palette "BlacK_Magenta_Red_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Magenta_Red.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE(BlacK_Magenta_Red_gp) {
DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
0, 0, 0, 0,
63, 42, 0, 45,
127, 255, 0, 255,
127, 255, 0,255,
191, 255, 0, 45,
255, 255, 0, 0
};
255, 255, 0, 0};
// Gradient palette "BlacK_Red_Magenta_Yellow_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Red_Magenta_Yellow.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE(BlacK_Red_Magenta_Yellow_gp) {
DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
0, 0, 0, 0,
42, 42, 0, 0,
84, 255, 0, 0,
127, 255, 0, 45,
170, 255, 0, 255,
170, 255, 0,255,
212, 255, 55, 45,
255, 255, 255, 0
};
255, 255,255, 0};
// Gradient palette "Blue_Cyan_Yellow_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/Blue_Cyan_Yellow.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE(Blue_Cyan_Yellow_gp) {
0, 0, 0, 255,
63, 0, 55, 255,
127, 0, 255, 255,
191, 42, 255, 45,
255, 255, 255, 0
};
DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
0, 0, 0,255,
63, 0, 55,255,
127, 0,255,255,
191, 42,255, 45,
255, 255,255, 0};
// Single array of defined cpt-city color palettes.
@ -547,5 +514,5 @@ const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
// Count of how many cpt-city gradients are defined:
const uint8_t gGradientPaletteCount =
sizeof(gGradientPalettes) / sizeof(TProgmemRGBGradientPalettePtr);
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );

File diff suppressed because one or more lines are too long

421
README.md
View File

@ -1,391 +1,54 @@
Nanoleaf Web Server
FastLED + ESP8266 Web Server
=========
This is a fork of [jasoncoon's esp8266 fastled webserver](https://github.com/jasoncoon/esp8266-fastled-webserver) that was adapted to control the colors of my [DIY-Nanoleaf Replica](https://www.thingiverse.com/thing:3354082).
[![Nanoleafs](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/rgb_preview2.gif?raw=true)](https://www.thingiverse.com/thing:3354082)
Control an addressable LED strip with an ESP8266 via a web browser or infrared remote control.
Hardware
--------
##### ESP8266
##### ESP8266 development board
![Wemos D1 Mini Pro & Headers](https://ae01.alicdn.com/kf/HTB1QYHzJKuSBuNjy1Xcq6AYjFXau/ESP8266-ESP-12-ESP12-WeMos-D1-Mini-Modul-Wemos-D1-Mini-WiFi-Entwicklung-Bord-Micro-USB.jpg)
[![Wemos D1 Mini Pro & Headers](https://ae01.alicdn.com/kf/HTB1P1KVaMsSMeJjSsphq6xuJFXah/WEMOS-D1-mini-Pro-V1-1-0-16M-bytes-external-antenna-connector-ESP8266-WIFI-Internet-of.jpg_200x200.jpg)](https://www.aliexpress.com/item/WEMOS-D1-mini-Pro-16M-bytes-external-antenna-connector-ESP8266-WIFI-Internet-of-Things-development-board/32724692514.html)
[Wemos D1 mini](http://s.click.aliexpress.com/e/cBDdafPw) is recommended, but any other ESP8266 variant should work too, but it might require an additional step-down converter.
[Wemos D1 Mini Pro & Headers](https://www.aliexpress.com/item/WEMOS-D1-mini-Pro-16M-bytes-external-antenna-connector-ESP8266-WIFI-Internet-of-Things-development-board/32724692514.html)
or
[![Adafruit HUZZAH ESP8266 Breakout](https://cdn-shop.adafruit.com/310x233/2471-10.jpg)](https://www.adafruit.com/products/2471)
**Addressable Led Strip**
[Adafruit HUZZAH ESP8266 Breakout](https://www.adafruit.com/products/2471)
![](https://cdn.pixabay.com/photo/2017/02/27/11/36/digital-led-strip-lights-2103020_960_720.jpg)
##### Addressable LED strip
I have used 12 led pixels per leaf → 1m of 60 leds/m = 5 leafs
[![Adafruit NeoPixel Ring](https://www.adafruit.com/images/145x109/1586-00.jpg)](https://www.adafruit.com/product/1586)
I would recommend buying a strip with 60 leds/m or more.
[Adafruit NeoPixel Ring]
[WS2812b led strip](http://s.click.aliexpress.com/e/SkQFQqc), make sure you choose IP30 any other IP rating wouldn't make any sense and might not even fit.
Other hardware:
* [3.3V to 5V Logic Level Shifter](http://www.digikey.com/product-detail/en/texas-instruments/SN74HCT245N/296-1612-5-ND/277258) (required if LEDs "glitch")
Recommended by [Adafruit NeoPixel "Best Practices"](https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices) to help protect LEDs from current onrush:
* [1000µF Capacitor](http://www.digikey.com/product-detail/en/panasonic-electronic-components/ECA-1EM102/P5156-ND/245015)
* [300 to 500 Ohm resistor](https://www.digikey.com/product-detail/en/stackpole-electronics-inc/CF14JT470R/CF14JT470RCT-ND/1830342)
Other (optional) hardware:
Optional shield to make everything more tidy:
* [3.3V to 5V Logic Level Shifter](http://s.click.aliexpress.com/e/buDr0PT2) (required if LEDs "glitch")
[![Wemos D1 Mini ESP8266 LED & Level Shifter Shield](https://d3s5r33r268y59.cloudfront.net/13194/products/thumbs/2017-05-06T15:02:37.208Z-IMG_20170506_100623.jpg.114x76_q85_pad_rcrop.jpg)](https://www.tindie.com/products/jasoncoon/wemos-d1-mini-esp8266-led-and-level-shifter-shield/)
[Wemos D1 Mini ESP8266 LED & Level Shifter Shield](https://www.tindie.com/products/jasoncoon/wemos-d1-mini-esp8266-led-and-level-shifter-shield)
Features
--------
* Control the colors of individual leafs
* Turn the NeoPixel Ring on and off
* Adjust the brightness
* Change the display pattern
* Adjust the color
* Adapted patterns to look great on the [DIY-Nanoleaf Replica](https://www.thingiverse.com/thing:3354082)
* OTA-Update support
* **Node-RED** integration :white_check_mark:
* Simple Amazon **Alexa** integration :white_check_mark:
* Custom pattern designer :white_check_mark:
* **Node-RED** webinterface to store special patterns persistant :white_check_mark:
### Upcoming Features
- **Node-RED** integration :white_check_mark:
- Simple Amazon **Alexa** integration :white_check_mark:
- Nanoleaf voice control :white_check_mark:
- Custom pattern designer :white_check_mark:
- **Node-RED** webinterface to store special patterns persistant :white_check_mark:
- Controlling multiple nanoleafs at once
- Advanced Amazon **Alexa** integration with custom skill (AWS account required, free)
> these features will be optional and require additional hardware (any linux/windows device that is in the same network)
Webinterface
Web App
--------
![Webinterface](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/interface.jpg?raw=true)
The web app is stored in SPIFFS (on-board flash memory).
Installing
-----------
The app is installed via the Arduino IDE which can be [downloaded here](https://www.arduino.cc/en/main/software). The ESP8266 boards will need to be added to the Arduino IDE which is achieved as follows. Click File > Preferences and copy and paste the URL "http://arduino.esp8266.com/stable/package_esp8266com_index.json" into the Additional Boards Manager URLs field. Click OK. Click Tools > Boards: ... > Boards Manager. Find and click on ESP8266 (using the Search function may expedite this). Click on Install. After installation, click on Close and then select your ESP8266 board from the Tools > Board: ... menu.
The app depends on the following libraries. They must either be downloaded from GitHub and placed in the Arduino 'libraries' folder, or installed as [described here](https://www.arduino.cc/en/Guide/Libraries) by using the Arduino library manager.
* [FastLED](https://github.com/FastLED/FastLED)
* [Arduino WebSockets](https://github.com/Links2004/arduinoWebSockets)
Download the app code from GitHub using the green Clone or Download button from [GitHub](https://github.com/NimmLor/esp8266-nanoleaf-webserver) and click Download ZIP. Decompress the ZIP file in your Arduino sketch folder. Rename the folder from *esp8266-nanoleaf-webserver-master* to *esp8266-nanoleaf-webserver*
The web app needs to be uploaded to the ESP8266's SPIFFS. You can do this within the Arduino IDE after installing the [Arduino ESP8266FS tool](http://esp8266.github.io/Arduino/versions/2.3.0/doc/filesystem.html#uploading-files-to-file-system). An alternative would be to install the [Visual Micro](https://www.visualmicro.com/) plugin for Visual Studio.
With ESP8266FS installed upload the web app using `ESP8266 Sketch Data Upload` command in the Arduino Tools menu.
## Configuration
The most important thing to do is to set the amount of 'leafs' and the amount of led pixels that one 'leaf' contains.
For instance I use 12 leafs (triangles) with a total of 12 pixels in one leaf (=4 leds in each corner of the triangle).
```c++
#define LEAFCOUNT 12
#define PIXELS_PER_LEAF 12
```
Next enter the pin where the *Data* line is connected to, in my case it's pin D4 (you can either write D4 or 2).
`#define DATA_PIN D4`
Another **important** step is to create the **Secrets.h** file. Create a new tab (**ctrl**+**shift**+**n**) and name it *Secrets.h*, this file contains your WIFI credentials and it's structure must look like this:
``````c++
// AP mode password
const char WiFiAPPSK[] = "WIFI_NAME_IF_IN_AP_MODE";
// Wi-Fi network to connect to (if not in AP mode)
char* ssid = "YOUR_WIFI_NAME";
char* password = "YOUR_WIFI_PASSWORD";
``````
If colors appear to be swapped you should change the color order. For me, red and green was swapped so i had to change the color order from *RGB* to *GRB*.
You should also set the milli-amps of your power supply to prevent power overloading. I am using a 3A 5V psu so i defined 3000mA.
`#define MILLI_AMPS 3000`
## Circuit
### Without Logic-Level Converter
![circuit without Logic level converter](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/circuit.jpg?raw=true)
### With Logic-Level-Converter (required if leds 'glitch')
![circuit with logic level converter](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/circuit_logic_level_Steckplatine.jpg?raw=true)
# Node-RED & Alexa integration Setup
## Features
### **Amazon Alexa Integration** (optional)
It works with any language that is supported by Alexa and can be easily expanded to support more activities or patterns. How you want to call them (Nanoleaf, Nanoleafs, Nano, Triangles) must be set in the setup of the devices.
#### **Commands**:
- Turn on/off
- Control Brightness
- Control Pattern Speed
- Set Color
- Set into Rainbow mode
- Enable Autoplay and set Duration
- Activate custom activities
> *Alexa, turn Nanoleafs **on/off***
> *Alexa, set Nanoleafs 70%*
> Alexa, dim Nanoleafs
> *Alexa, Nanoleaf speed 20%*
> *Alexa, set Nanoleafs pink*
> *Alexa, turn Nanoleaf rainbow on*
> *Alexa, turn Nanoleaf Autoplay on*
> *Alexa, set Nanoleaf Autoplay 40*
>
> Alexa, Nanoleaf Default
> Alexa, Nanoleaf Mode 1
> Alexa, Nanoleaf Mode 2
> Alexa, Nanoleaf Mode 3
### Node-RED GUI
The Node-RED GUI is an addition to the regular UI that is running on the Wemos D1 mini. It allows to create and save custom patterns and also control all regular parameters same as the ESP8266 webserver. It can be accessed by any device.
![full](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/full.png?raw=true)
#### Nanoleaf Designer
In the Node-RED GUI you can easily create your nanoleaf setup by using the *Nanoleaf Designer*. It's easy to use and allows almost any design that is possible. But it might have still some minor bugs.
![nanoleaf_designer](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/nanoleaf_designer.png?raw=true)
![nanoleaf_designer_2](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/nanoleaf_designer_2.png?raw=true)
#### Nanoleaf Custom Pattern Designer
With the *Nanoleaf Custom Pattern Designer* you can create custom patterns with effects. Currently the individual leafs can be set to *Static* mode and *Breathe* mode that allows to set a phase shift and lets the leafs breathe. Flow-mode follows in the next update.
![pattern_designer](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/pattern_designer.png?raw=true)
![pattern_designer_2](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/pattern_designer_2.png?raw=true)
![patternlist](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/patternlist.png?raw=true)
## What you will need
- Any device that runs Node-RED, examples would be:
- (recommended) [Raspberry Pi](https://www.amazon.de/gp/product/B01CD5VC92?ie=UTF8&tag=surrbradl08-21&camp=1638&linkCode=xm2&creativeASIN=B01CD5VC92)
- Any Linux machine
- (instructions are provided for linux) Any Windows machine
- Any Amazon Alexa device for Alexa integration, works on Android and IOS too (**OPTIONAL**)
## Setup
#### 1. Install Node-RED
```bash
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
```
#### 2. Install npm - this might be already installed
```bash
sudo apt-get install nodejs npm -y
```
#### 3. Install dashboard, alexa-home-skill, color-convert, config
```bash
cd $HOME/.node-red
npm install node-red-dashboard
```
- if you get an error try: `npm install --unsafe-perm node-red-dashboard`
```bash
npm install node-red-contrib-alexa-home-skill
npm install node-red-contrib-color-convert
npm install node-red-contrib-config
```
#### 4. Setup a static IP-Address for your Raspberry Pi (optional)
- (recommended) Setup a static ip on your router
- [or on your Raspberry Pi](http://www.circuitbasics.com/how-to-set-up-a-static-ip-on-the-raspberry-pi/)
#### 6. Run Node-RED
To start Node-RED type into the shell:
```bash
sudo node-red-start
```
Connect to the GUI by typing the following line into your browser:
- http://IP-ADDRESS:1880
#### 3. Import the flow
- Click on the 3 dashes in the top right corner → import → clipboard
![import](D:\OneDrive\3DPrinting\Thingiverse\Node-Red-Leafs\Noderedpart\images\import.png?raw=true)
#### Configure the IP-Address of the Wemos D1 mini
Edit the Nanoleaf-Config node to set the IP-Address.
![config_1](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/config_1.png?raw=true)
![config_2](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/config_2.png?raw=true)
## Amazon Alexa setup
The Alexa integration uses the *Node-RED Alexa Home Skill Bridge* to redirect the commands from alexa to Node-RED.
### 1. Create a new Bridge account
Head to https://alexa-node-red.bm.hardill.me.uk/newuser and create a new account.
Afterwards login into your account.
### 2. Create the Devices
You have to create devices that are called by Alexa.
#### 2.1 Main Nanoleaf Device
First create the devices that control a few devices that are used to turn on/off the nanoleafs and controls the brightness. I've called them "Nanoleafs", "Nanoleaf", "Nano" and "Triangles", but a single one would be enough too.
Click the **Add Device** button and choose. Repeat this step for all your names.
![device_1](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/device_1.png?raw=true)
![device_2](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/device_2.png?raw=true)
#### 2.2 Autoplay control Device (optional)
To control the autoplay functionality, create a device with **On, Off, %, +%, -%, LIGHT**.
#### 2.3 Speed control Device (optional)
To control the speed of the animations, create a device with **%, +%, -%**.
#### 2.4 Activities (optional)
Now create activities by clicking *Add Device* and selecting **On, Off, ACTIVITY**.
I've created one to set the *Rainbow* pattern, one for my default settings and Nanoleaf Mode 1-3 for some custom settings.
![device_3](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/device_3.png?raw=true)
![device_4](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/device_4.png?raw=true)
### 3. Activating the Alexa skill
Open the app on your phone or head to https://alexa.amazon.de and click on **Skills**.
Search for **Node-RED** and activate the skill. Afterwards you are prompted to login into your account that you have created the devices beforehand.
![1551006980428](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/1551006980428.png?raw=true)
### 4. Add a new Alexa-Home-Skill configuration
Click on any Alexa node in the flow, and click *Add new alexa-home-configuration*. Afterwards hit the refresh button next to the devices list.
![conf_1](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/conf_1.png?raw=true)
### 5. Select the devices
Click the alexa skill nodes in the flow and select the corresponding devices. **Delete all unused alexa nodes**.
For me, it looked like this:
![device_config](https://github.com/NimmLor/esp8266-nanoleaf-webserver/blob/master/gallery/NodeRED_UI/device_config.png?raw=true)
### 6. Discover the Smart-Home Devices
Speak to Alexa and say to her: **Alexa, discover devices**. (Just say it in english, it works on every device)
If everything worked correctly she should tell you after around 30 seconds that she has found new devices.
Technical information
-----------------
![Web App](webapp.png)
Patterns are requested by the app from the ESP8266, so as new patterns are added, they're automatically listed in the app.
@ -395,6 +58,44 @@ The web app is a single page app that uses [jQuery](https://jquery.com) and [Boo
The only drawback to SPIFFS that I've found so far is uploading the files can be extremely slow, requiring several minutes, sometimes regardless of how large the files are. It can be so slow that I've been just developing the web app and debugging locally on my desktop (with a hard-coded IP for the ESP8266), before uploading to SPIFFS and testing on the ESP8266.
Installing
-----------
The app is installed via the Arduino IDE which can be [downloaded here](https://www.arduino.cc/en/main/software). The ESP8266 boards will need to be added to the Arduino IDE which is achieved as follows. Click File > Preferences and copy and paste the URL "http://arduino.esp8266.com/stable/package_esp8266com_index.json" into the Additional Boards Manager URLs field. Click OK. Click Tools > Boards: ... > Boards Manager. Find and click on ESP8266 (using the Search function may expedite this). Click on Install. After installation, click on Close and then select your ESP8266 board from the Tools > Board: ... menu.
The app depends on the following libraries. They must either be downloaded from GitHub and placed in the Arduino 'libraries' folder, or installed as [described here](https://www.arduino.cc/en/Guide/Libraries) by using the Arduino library manager.
* [FastLED](https://github.com/FastLED/FastLED)
* [IRremoteESP8266](https://github.com/sebastienwarin/IRremoteESP8266)
* [Arduino WebSockets](https://github.com/Links2004/arduinoWebSockets)
Download the app code from GitHub using the green Clone or Download button from [the GitHub project main page](https://github.com/jasoncoon/esp8266-fastled-webserver) and click Download ZIP. Decompress the ZIP file in your Arduino sketch folder.
The web app needs to be uploaded to the ESP8266's SPIFFS. You can do this within the Arduino IDE after installing the [Arduino ESP8266FS tool](http://esp8266.github.io/Arduino/versions/2.3.0/doc/filesystem.html#uploading-files-to-file-system).
With ESP8266FS installed upload the web app using `ESP8266 Sketch Data Upload` command in the Arduino Tools menu.
Then enter your wi-fi network SSID and password in the .ino file, and upload the sketch using the Upload button.
Compression
-----------
The web app files can be gzip compressed before uploading to SPIFFS by running the following command:
`gzip -r data/`
The ESP8266WebServer will automatically serve any .gz file. The file index.htm.gz will get served as index.htm, with the content-encoding header set to gzip, so the browser knows to decompress it. The ESP8266WebServer doesn't seem to like the Glyphicon fonts gzipped, though, so I decompress them with this command:
`gunzip -r data/fonts/`
REST Web services
-----------------
The firmware implements basic [RESTful web services](https://en.wikipedia.org/wiki/Representational_state_transfer) using the ESP8266WebServer library. Current values are requested with HTTP GETs, and values are set with POSTs using query string parameters. It can run in connected or standalone access point modes.
Infrared Remote Control
-----------------------
Control via infrared remote control is also supported, via the [ESP8266 port of the IRremote library](https://github.com/sebastienwarin/IRremoteESP8266).
[Adafruit NeoPixel Ring]:https://www.adafruit.com/product/1586
[Adafruit HUZZAH ESP8266 Breakout]:https://www.adafruit.com/products/2471

View File

@ -1,5 +0,0 @@
const char WiFiAPPSK[] = "your-password";
// Wi-Fi network to connect to (if not in AP mode)
char* ssid = "WLAN23";
char* password = "57erChevy";

View File

@ -1,479 +0,0 @@
// TwinkleFOX by Mark Kriegsman: https://gist.github.com/kriegsman/756ea6dcae8e30845b5a
//
// TwinkleFOX: Twinkling 'holiday' lights that fade in and out.
// Colors are chosen from a palette; a few palettes are provided.
//
// This December 2015 implementation improves on the December 2014 version
// in several ways:
// - smoother fading, compatible with any colors and any palettes
// - easier control of twinkle speed and twinkle density
// - supports an optional 'background color'
// - takes even less RAM: zero RAM overhead per pixel
// - illustrates a couple of interesting techniques (uh oh...)
//
// The idea behind this (new) implementation is that there's one
// basic, repeating pattern that each pixel follows like a waveform:
// The brightness rises from 0..255 and then falls back down to 0.
// The brightness at any given point in time can be determined as
// as a function of time, for example:
// brightness = sine( time ); // a sine wave of brightness over time
//
// So the way this implementation works is that every pixel follows
// the exact same wave function over time. In this particular case,
// I chose a sawtooth triangle wave (triwave8) rather than a sine wave,
// but the idea is the same: brightness = triwave8( time ).
//
// Of course, if all the pixels used the exact same wave form, and
// if they all used the exact same 'clock' for their 'time base', all
// the pixels would brighten and dim at once -- which does not look
// like twinkling at all.
//
// So to achieve random-looking twinkling, each pixel is given a
// slightly different 'clock' signal. Some of the clocks run faster,
// some run slower, and each 'clock' also has a random offset from zero.
// The net result is that the 'clocks' for all the pixels are always out
// of sync from each other, producing a nice random distribution
// of twinkles.
//
// The 'clock speed adjustment' and 'time offset' for each pixel
// are generated randomly. One (normal) approach to implementing that
// would be to randomly generate the clock parameters for each pixel
// at startup, and store them in some arrays. However, that consumes
// a great deal of precious RAM, and it turns out to be totally
// unnessary! If the random number generate is 'seeded' with the
// same starting value every time, it will generate the same sequence
// of values every time. So the clock adjustment parameters for each
// pixel are 'stored' in a pseudo-random number generator! The PRNG
// is reset, and then the first numbers out of it are the clock
// adjustment parameters for the first pixel, the second numbers out
// of it are the parameters for the second pixel, and so on.
// In this way, we can 'store' a stable sequence of thousands of
// random clock adjustment parameters in literally two bytes of RAM.
//
// There's a little bit of fixed-point math involved in applying the
// clock speed adjustments, which are expressed in eighths. Each pixel's
// clock speed ranges from 8/8ths of the system clock (i.e. 1x) to
// 23/8ths of the system clock (i.e. nearly 3x).
//
// On a basic Arduino Uno or Leonardo, this code can twinkle 300+ pixels
// smoothly at over 50 updates per seond.
//
// -Mark Kriegsman, December 2015
// Overall twinkle speed.
// 0 (VERY slow) to 8 (VERY fast).
// 4, 5, and 6 are recommended, default is 4.
uint8_t twinkleSpeed = 4;
// Overall twinkle density.
// 0 (NONE lit) to 8 (ALL lit at once).
// Default is 5.
uint8_t twinkleDensity = 5;
// Background color for 'unlit' pixels
// Can be set to CRGB::Black if desired.
CRGB gBackgroundColor = CRGB::Black;
// Example of dim incandescent fairy light background color
// CRGB gBackgroundColor = CRGB(CRGB::FairyLight).nscale8_video(16);
// If AUTO_SELECT_BACKGROUND_COLOR is set to 1,
// then for any palette where the first two entries
// are the same, a dimmed version of that color will
// automatically be used as the background color.
#define AUTO_SELECT_BACKGROUND_COLOR 0
// If COOL_LIKE_INCANDESCENT is set to 1, colors will
// fade out slighted 'reddened', similar to how
// incandescent bulbs change color as they get dim down.
#define COOL_LIKE_INCANDESCENT 1
CRGBPalette16 twinkleFoxPalette;
// This function is like 'triwave8', which produces a
// symmetrical up-and-down triangle sawtooth waveform, except that this
// function produces a triangle wave with a faster attack and a slower decay:
//
// / \
// / \
// / \
// / \
//
uint8_t attackDecayWave8(uint8_t i)
{
if (i < 86) {
return i * 3;
}
else {
i -= 86;
return 255 - (i + (i / 2));
}
}
// This function takes a pixel, and if its in the 'fading down'
// part of the cycle, it adjusts the color a little bit like the
// way that incandescent bulbs fade toward 'red' as they dim.
void coolLikeIncandescent(CRGB& c, uint8_t phase)
{
if (phase < 128) return;
uint8_t cooling = (phase - 128) >> 4;
c.g = qsub8(c.g, cooling);
c.b = qsub8(c.b, cooling * 2);
}
// This function takes a time in pseudo-milliseconds,
// figures out brightness = f( time ), and also hue = f( time )
// The 'low digits' of the millisecond time are used as
// input to the brightness wave function.
// The 'high digits' are used to select a color, so that the color
// does not change over the course of the fade-in, fade-out
// of one cycle of the brightness wave function.
// The 'high digits' are also used to determine whether this pixel
// should light at all during this cycle, based on the twinkleDensity.
CRGB computeOneTwinkle(uint32_t ms, uint8_t salt)
{
uint16_t ticks = ms >> (8 - twinkleSpeed);
uint8_t fastcycle8 = ticks;
uint16_t slowcycle16 = (ticks >> 8) + salt;
slowcycle16 += sin8(slowcycle16);
slowcycle16 = (slowcycle16 * 2053) + 1384;
uint8_t slowcycle8 = (slowcycle16 & 0xFF) + (slowcycle16 >> 8);
uint8_t bright = 0;
if (((slowcycle8 & 0x0E) / 2) < twinkleDensity) {
bright = attackDecayWave8(fastcycle8);
}
uint8_t hue = slowcycle8 - salt;
CRGB c;
if (bright > 0) {
c = ColorFromPalette(twinkleFoxPalette, hue, bright, NOBLEND);
if (COOL_LIKE_INCANDESCENT == 1) {
coolLikeIncandescent(c, fastcycle8);
}
}
else {
c = CRGB::Black;
}
return c;
}
// This function loops over each pixel, calculates the
// adjusted 'clock' that this pixel should use, and calls
// "CalculateOneTwinkle" on each pixel. It then displays
// either the twinkle color of the background color,
// whichever is brighter.
void drawTwinkles()
{
// "PRNG16" is the pseudorandom number generator
// It MUST be reset to the same starting value each time
// this function is called, so that the sequence of 'random'
// numbers that it generates is (paradoxically) stable.
uint16_t PRNG16 = 11337;
uint32_t clock32 = millis();
// Set up the background color, "bg".
// if AUTO_SELECT_BACKGROUND_COLOR == 1, and the first two colors of
// the current palette are identical, then a deeply faded version of
// that color is used for the background color
CRGB bg;
if ((AUTO_SELECT_BACKGROUND_COLOR == 1) &&
(twinkleFoxPalette[0] == twinkleFoxPalette[1])) {
bg = twinkleFoxPalette[0];
uint8_t bglight = bg.getAverageLight();
if (bglight > 64) {
bg.nscale8_video(16); // very bright, so scale to 1/16th
}
else if (bglight > 16) {
bg.nscale8_video(64); // not that bright, so scale to 1/4th
}
else {
bg.nscale8_video(86); // dim, scale to 1/3rd.
}
}
else {
bg = gBackgroundColor; // just use the explicitly defined background color
}
uint8_t backgroundBrightness = bg.getAverageLight();
for (uint16_t i = 0; i < LEAFCOUNT; i++) {
CRGB& pixel = leds[i*PIXELS_PER_LEAF];
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
uint16_t myclockoffset16 = PRNG16; // use that number as clock offset
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
// use that number as clock speed adjustment factor (in 8ths, from 8/8ths to 23/8ths)
uint8_t myspeedmultiplierQ5_3 = ((((PRNG16 & 0xFF) >> 4) + (PRNG16 & 0x0F)) & 0x0F) + 0x08;
uint32_t myclock30 = (uint32_t)((clock32 * myspeedmultiplierQ5_3) >> 3) + myclockoffset16;
uint8_t myunique8 = PRNG16 >> 8; // get 'salt' value for this pixel
// We now have the adjusted 'clock' for this pixel, now we call
// the function that computes what color the pixel should be based
// on the "brightness = f( time )" idea.
CRGB c = computeOneTwinkle(myclock30, myunique8);
uint8_t cbright = c.getAverageLight();
int16_t deltabright = cbright - backgroundBrightness;
if (deltabright >= 32 || (!bg)) {
// If the new pixel is significantly brighter than the background color,
// use the new color.
fill_solid(leds + i * PIXELS_PER_LEAF, PIXELS_PER_LEAF, c);
//Serial.printf("rgb: %d, %d, %d\n", c.r,c.g,c.b);
}
else if (deltabright > 0) {
// If the new pixel is just slightly brighter than the background color,
// mix a blend of the new color and the background color
fill_solid(leds + i * PIXELS_PER_LEAF, PIXELS_PER_LEAF, blend(bg, c, deltabright * 8));
//Serial.println("rgb:"+ blend(bg, c, deltabright * 8));
}
else {
// if the new pixel is not at all brighter than the background color,
// just use the background color.
fill_solid(leds + i * PIXELS_PER_LEAF, PIXELS_PER_LEAF, bg);
//Serial.println("rgb:" + bg);
}
}
}
/////// #############################BACKUP####################################
/*
// This function loops over each pixel, calculates the
// adjusted 'clock' that this pixel should use, and calls
// "CalculateOneTwinkle" on each pixel. It then displays
// either the twinkle color of the background color,
// whichever is brighter.
void drawTwinkles()
{
// "PRNG16" is the pseudorandom number generator
// It MUST be reset to the same starting value each time
// this function is called, so that the sequence of 'random'
// numbers that it generates is (paradoxically) stable.
uint16_t PRNG16 = 11337;
uint32_t clock32 = millis();
// Set up the background color, "bg".
// if AUTO_SELECT_BACKGROUND_COLOR == 1, and the first two colors of
// the current palette are identical, then a deeply faded version of
// that color is used for the background color
CRGB bg;
if ((AUTO_SELECT_BACKGROUND_COLOR == 1) &&
(twinkleFoxPalette[0] == twinkleFoxPalette[1])) {
bg = twinkleFoxPalette[0];
uint8_t bglight = bg.getAverageLight();
if (bglight > 64) {
bg.nscale8_video(16); // very bright, so scale to 1/16th
}
else if (bglight > 16) {
bg.nscale8_video(64); // not that bright, so scale to 1/4th
}
else {
bg.nscale8_video(86); // dim, scale to 1/3rd.
}
}
else {
bg = gBackgroundColor; // just use the explicitly defined background color
}
uint8_t backgroundBrightness = bg.getAverageLight();
for (uint16_t i = 0; i < NUM_LEDS; i++) {
CRGB& pixel = leds[i];
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
uint16_t myclockoffset16 = PRNG16; // use that number as clock offset
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
// use that number as clock speed adjustment factor (in 8ths, from 8/8ths to 23/8ths)
uint8_t myspeedmultiplierQ5_3 = ((((PRNG16 & 0xFF) >> 4) + (PRNG16 & 0x0F)) & 0x0F) + 0x08;
uint32_t myclock30 = (uint32_t)((clock32 * myspeedmultiplierQ5_3) >> 3) + myclockoffset16;
uint8_t myunique8 = PRNG16 >> 8; // get 'salt' value for this pixel
// We now have the adjusted 'clock' for this pixel, now we call
// the function that computes what color the pixel should be based
// on the "brightness = f( time )" idea.
CRGB c = computeOneTwinkle(myclock30, myunique8);
uint8_t cbright = c.getAverageLight();
int16_t deltabright = cbright - backgroundBrightness;
if (deltabright >= 32 || (!bg)) {
// If the new pixel is significantly brighter than the background color,
// use the new color.
pixel = c;
}
else if (deltabright > 0) {
// If the new pixel is just slightly brighter than the background color,
// mix a blend of the new color and the background color
pixel = blend(bg, c, deltabright * 8);
}
else {
// if the new pixel is not at all brighter than the background color,
// just use the background color.
pixel = bg;
}
}
}
*/
// A mostly red palette with green accents and white trim.
// "CRGB::Gray" is used as white to keep the brightness more uniform.
const TProgmemRGBPalette16 RedGreenWhite_p FL_PROGMEM =
{ CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
CRGB::Red, CRGB::Red, CRGB::Red, CRGB::Red,
CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
CRGB::Green, CRGB::Green, CRGB::Green, CRGB::Green };
// A mostly (dark) green palette with red berries.
#define Holly_Green 0x00580c
#define Holly_Red 0xB00402
const TProgmemRGBPalette16 Holly_p FL_PROGMEM =
{ Holly_Green, Holly_Green, Holly_Green, Holly_Green,
Holly_Green, Holly_Green, Holly_Green, Holly_Green,
Holly_Green, Holly_Green, Holly_Green, Holly_Green,
Holly_Green, Holly_Green, Holly_Green, Holly_Red
};
// A red and white striped palette
// "CRGB::Gray" is used as white to keep the brightness more uniform.
const TProgmemRGBPalette16 RedWhite_p FL_PROGMEM =
{ CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray,
CRGB::Red, CRGB::Red, CRGB::Gray, CRGB::Gray };
// A mostly blue palette with white accents.
// "CRGB::Gray" is used as white to keep the brightness more uniform.
const TProgmemRGBPalette16 BlueWhite_p FL_PROGMEM =
{ CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
CRGB::Blue, CRGB::Blue, CRGB::Blue, CRGB::Blue,
CRGB::Blue, CRGB::Gray, CRGB::Gray, CRGB::Gray };
// A pure "fairy light" palette with some brightness variations
#define HALFFAIRY ((CRGB::FairyLight & 0xFEFEFE) / 2)
#define QUARTERFAIRY ((CRGB::FairyLight & 0xFCFCFC) / 4)
const TProgmemRGBPalette16 FairyLight_p FL_PROGMEM =
{ CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight,
HALFFAIRY, HALFFAIRY, CRGB::FairyLight, CRGB::FairyLight,
QUARTERFAIRY, QUARTERFAIRY, CRGB::FairyLight, CRGB::FairyLight,
CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight, CRGB::FairyLight };
// A palette of soft snowflakes with the occasional bright one
const TProgmemRGBPalette16 Snow_p FL_PROGMEM =
{ 0x304048, 0x304048, 0x304048, 0x304048,
0x304048, 0x304048, 0x304048, 0x304048,
0x304048, 0x304048, 0x304048, 0x304048,
0x304048, 0x304048, 0x304048, 0xE0F0FF };
// A palette reminiscent of large 'old-school' C9-size tree lights
// in the five classic colors: red, orange, green, blue, and white.
#define C9_Red 0xB80400
#define C9_Orange 0x902C02
#define C9_Green 0x046002
#define C9_Blue 0x070758
#define C9_White 0x606820
const TProgmemRGBPalette16 RetroC9_p FL_PROGMEM =
{ C9_Red, C9_Orange, C9_Red, C9_Orange,
C9_Orange, C9_Red, C9_Orange, C9_Red,
C9_Green, C9_Green, C9_Green, C9_Green,
C9_Blue, C9_Blue, C9_Blue,
C9_White
};
// A cold, icy pale blue palette
#define Ice_Blue1 0x0C1040
#define Ice_Blue2 0x182080
#define Ice_Blue3 0x5080C0
const TProgmemRGBPalette16 Ice_p FL_PROGMEM =
{
Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
Ice_Blue1, Ice_Blue1, Ice_Blue1, Ice_Blue1,
Ice_Blue2, Ice_Blue2, Ice_Blue2, Ice_Blue3
};
void redGreenWhiteTwinkles()
{
twinkleFoxPalette = RedGreenWhite_p;
drawTwinkles();
}
void hollyTwinkles()
{
twinkleFoxPalette = Holly_p;
drawTwinkles();
}
void redWhiteTwinkles()
{
twinkleFoxPalette = RedWhite_p;
drawTwinkles();
}
void blueWhiteTwinkles()
{
twinkleFoxPalette = BlueWhite_p;
drawTwinkles();
}
void fairyLightTwinkles()
{
twinkleFoxPalette = FairyLight_p;
drawTwinkles();
}
void snow2Twinkles()
{
twinkleFoxPalette = Snow_p;
drawTwinkles();
}
void iceTwinkles()
{
twinkleFoxPalette = Ice_p;
drawTwinkles();
}
void retroC9Twinkles()
{
twinkleFoxPalette = RetroC9_p;
drawTwinkles();
}
void partyTwinkles()
{
twinkleFoxPalette = PartyColors_p;
drawTwinkles();
}
void forestTwinkles()
{
twinkleFoxPalette = ForestColors_p;
drawTwinkles();
}
void lavaTwinkles()
{
twinkleFoxPalette = LavaColors_p;
drawTwinkles();
}
void fireTwinkles()
{
twinkleFoxPalette = HeatColors_p;
drawTwinkles();
}
void cloud2Twinkles()
{
twinkleFoxPalette = CloudColors_p;
drawTwinkles();
}
void oceanTwinkles()
{
twinkleFoxPalette = OceanColors_p;
drawTwinkles();
}

View File

@ -1,123 +0,0 @@
// based on ColorTwinkles by Mark Kriegsman: https://gist.github.com/kriegsman/5408ecd397744ba0393e
#define STARTING_BRIGHTNESS 64
#define FADE_IN_SPEED 32
#define FADE_OUT_SPEED 20
#define DENSITY 255
enum { GETTING_DARKER = 0, GETTING_BRIGHTER = 1 };
CRGB makeBrighter(const CRGB& color, fract8 howMuchBrighter)
{
CRGB incrementalColor = color;
incrementalColor.nscale8(howMuchBrighter);
return color + incrementalColor;
}
CRGB makeDarker(const CRGB& color, fract8 howMuchDarker)
{
CRGB newcolor = color;
newcolor.nscale8(255 - howMuchDarker);
return newcolor;
}
// Compact implementation of
// the directionFlags array, using just one BIT of RAM
// per pixel. This requires a bunch of bit wrangling,
// but conserves precious RAM. The cost is a few
// cycles and about 100 bytes of flash program memory.
uint8_t directionFlags[(NUM_LEDS + 7) / 8];
bool getPixelDirection(uint16_t i)
{
uint16_t index = i / 8;
uint8_t bitNum = i & 0x07;
uint8_t andMask = 1 << bitNum;
return (directionFlags[index] & andMask) != 0;
}
void setPixelDirection(uint16_t i, bool dir)
{
uint16_t index = i / 8;
uint8_t bitNum = i & 0x07;
uint8_t orMask = 1 << bitNum;
uint8_t andMask = 255 - orMask;
uint8_t value = directionFlags[index] & andMask;
if (dir) {
value += orMask;
}
directionFlags[index] = value;
}
void brightenOrDarkenEachPixel(fract8 fadeUpAmount, fract8 fadeDownAmount)
{
for (uint16_t i = 0; i < LEAFCOUNT; i++) {
if (getPixelDirection(i*PIXELS_PER_LEAF) == GETTING_DARKER) {
// This pixel is getting darker
for (int i2 = 0; i2 < PIXELS_PER_LEAF; i2++)leds[i*PIXELS_PER_LEAF + i2] = makeDarker(leds[i*PIXELS_PER_LEAF + i2], fadeDownAmount);
}
else {
// This pixel is getting brighter
for (int i2 = 0; i2 < PIXELS_PER_LEAF; i2++)leds[i*PIXELS_PER_LEAF + i2] = makeBrighter(leds[i*PIXELS_PER_LEAF + i2], fadeUpAmount);
// now check to see if we've maxxed out the brightness
if (leds[i*PIXELS_PER_LEAF].r == 255 || leds[i*PIXELS_PER_LEAF].g == 255 || leds[i*PIXELS_PER_LEAF].b == 255) {
// if so, turn around and start getting darker
for (int i2 = 0; i2 < PIXELS_PER_LEAF; i2++)setPixelDirection(i*PIXELS_PER_LEAF + i2, GETTING_DARKER);
}
}
}
}
void colortwinkles()
{
EVERY_N_MILLIS(30)
{
// Make each pixel brighter or darker, depending on
// its 'direction' flag.
brightenOrDarkenEachPixel(FADE_IN_SPEED, FADE_OUT_SPEED);
// Now consider adding a new random twinkle
if (random8() < DENSITY) {
int pos = random16(LEAFCOUNT);
if (!leds[pos]) {
uint8_t rdo = random8();
for (int i = 0; i < PIXELS_PER_LEAF; i++)
{
leds[pos*PIXELS_PER_LEAF + i] = ColorFromPalette(gCurrentPalette, rdo, STARTING_BRIGHTNESS, NOBLEND);
setPixelDirection(pos*PIXELS_PER_LEAF + i, GETTING_BRIGHTER);
}
}
}
}
}
void cloudTwinkles()
{
gCurrentPalette = CloudColors_p; // Blues and whites!
colortwinkles();
}
void rainbowTwinkles()
{
gCurrentPalette = RainbowColors_p;
colortwinkles();
}
void snowTwinkles()
{
CRGB w(85, 85, 85), W(CRGB::White);
gCurrentPalette = CRGBPalette16(W, W, W, W, w, w, w, w, w, w, w, w, w, w, w, w);
colortwinkles();
}
void incandescentTwinkles()
{
CRGB l(0xE1A024);
gCurrentPalette = CRGBPalette16(l, l, l, l, l, l, l, l, l, l, l, l, l, l, l, l);
colortwinkles();
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,18 +0,0 @@
/*body {
padding-bottom: 70px;
}*/
.grid-item-color {
width: 4%;
height: 32px;
cursor: pointer;
}
.grid-item-pattern {
width: 100px;
height: 100px;
margin: 5px;
padding: 6px;
white-space: normal;
cursor: pointer;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -5,141 +5,71 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESP8266 + FastLED by Evil Genius Labs</title>
<!-- request CSS from internet CDN -->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> -->
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jquery.minicolors.min.css" integrity="sha256-4wnSkPYU5B4yngAlx/rEb8LdfMah4teUth4AfhGEuaY=" crossorigin="anonymous" /> -->
<!-- request CSS from the ESP8266 web server -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/minicolors.min.css">
<title>ESP8266 + FastLED</title>
<link rel="stylesheet" href="css/styles.css">
<link rel="icon" href="images/atom196.png">
</head>
<body>
<nav class="navbar navbar-default navbar-static-top" id="top" role="banner">
<header class="navbar navbar-default navbar-static-top" id="top" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank"><img src="/images/atom196.png" style="width: 24px; height: 24px;" /></a>
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank">Evil Genius Labs</a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="/">ESP8266 + FastLED <span class="sr-only">(current)</span></a></li>
<li><a href="/simple.htm" target="_blank" title="Simple Mode">Simple</a></li>
<li><a href="/edit.htm" target="_blank" title="Edit Files">Files</a></li>
<li><a href="/update" target="_blank" title="Update Firmware">Firmware</a></li>
<li><a href="/wifi.htm" target="_blank" title="Wi-Fi Settings">Wi-Fi</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/jasoncoon/esp8266-fastled-webserver">
<img style="height: 16px;" src="/images/github.ico" />
</a>
</li>
</ul>
<a class="navbar-brand" href="/">ESP8266 + FastLED</a>
</div>
</div>
</nav>
<div id="container" class="container">
<form class="form-horizontal" id="form">
</form>
</div>
<div id="templates" style="display: none">
<div id="sectionTemplate" class="form-group">
<div class="col-sm-12">
<hr style="margin-bottom: 5px;margin-top: 5px;" />
</div>
</div>
<div id="numberTemplate" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-2">
<input class="form-control input" type="number" step="1" min="0" max="255" />
</div>
<div class="col-sm-8">
<input class="form-control slider" type="range" step="1" min="0" max="255" />
</div>
</div>
<div id="booleanTemplate" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default" id="btnOn">On</button>
<button type="button" class="btn btn-default" id="btnOff">Off</button>
</div>
</div>
</div>
<div id="selectTemplate" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-8">
<select class="form-control"><select>
</div>
<div class="col-sm-2">
<div class="btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default btn-previous"
aria-label="Previous" title="Previous">
<span class="glyphicon glyphicon-chevron-left"></span>
</button>
<button type="button" class="btn btn-default btn-next"
aria-label="Next" title="Next">
<span class="glyphicon glyphicon-chevron-right"></span>
</header>
<div class="container">
<form class="form-horizontal">
<div class="form-group">
<div class="col-sm-1 col-sm-offset-2">
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-refresh" id="btnRefresh"></span>
</button>
</div>
<div class="col-sm-4">
<p id="status" class="form-control-static">Status</p>
</div>
</div>
<div id="booleanTemplate" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default" id="btnOn">On</button>
<button type="button" class="btn btn-default" id="btnOff">Off</button>
<div class="form-group">
<label class="col-sm-2 control-label">Power</label>
<div class="col-sm-6">
<div class="btn-group" role="group" aria-label="Power">
<button type="button" class="btn btn-default" id="btnPowerOn">On</button>
<button type="button" class="btn btn-default" id="btnPowerOff">Off</button>
</div>
</div>
</div>
<div id="selectTemplate" class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-8">
<select class="form-control"><select>
</div>
<div class="col-sm-2">
<div class="btn-group" role="group" aria-label="...">
<button type="button" class="btn btn-default btn-previous"
aria-label="Previous" title="Previous">
<span class="glyphicon glyphicon-chevron-left"></span>
</button>
<button type="button" class="btn btn-default btn-next"
aria-label="Next" title="Next">
<span class="glyphicon glyphicon-chevron-right"></span>
</button>
<div class="form-group">
<label for="inputBrightness" class="col-sm-2 control-label">Brightness</label>
<div class="col-sm-6">
<div class="input-group">
<span class="input-group-addon" id="spanBrightness">128</span>
<input class="form-control" id="inputBrightness" type="range" step="1" min="0" max="255" />
</div>
</div>
</div>
<div id="colorPaletteTemplate" class="form-group">
<label class="col-sm-2 control-label color-label"></label>
<div class="col-sm-10">
<div class="form-group">
<label for="inputPattern" class="col-sm-2 control-label">Pattern</label>
<div class="col-sm-6">
<select class="form-control" id="inputPattern">
</select>
</div>
</div>
<div class="form-group">
<label for="inputPalette" class="col-sm-2 control-label">Palette</label>
<div class="col-sm-6">
<select class="form-control" id="inputPalette">
</select>
</div>
</div>
<div class="form-group">
<label for="inputColor" class="col-sm-2 control-label">Color</label>
<div class="col-sm-6">
<input id="inputColor" type="text" class="form-control">
</div>
</div>
<div class="form-group">
<div class="col-sm-6 col-sm-offset-2">
<div class="btn-group btn-group-justified" role="group">
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #FF0000;" title="Red">&nbsp;</button>
@ -177,88 +107,12 @@
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #FF0080;" title="Rose">&nbsp;</button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-color" style="background: #FFFFFF;" title="White">&nbsp;</button>
</div>
</div>
</div>
</form>
</div>
<div id="colorTemplate">
<div class="form-group">
<!-- <label class="col-sm-2 control-label color-label"></label> -->
<div class="col-sm-12 col-sm-offset-2">
<input type="text" class="form-control minicolors" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Red</label>
<div class="col-sm-2">
<input class="form-control color-red-input" type="number" step="1" min="0" max="255" />
</div>
<div class="col-sm-8">
<input class="form-control color-red-slider" type="range" step="1" min="0" max="255" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Green</label>
<div class="col-sm-2">
<input class="form-control color-green-input" type="number" step="1" min="0" max="255" />
</div>
<div class="col-sm-8">
<input class="form-control color-green-slider" type="range" step="1" min="0" max="255" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Blue</label>
<div class="col-sm-2">
<input class="form-control color-blue-input" type="number" step="1" min="0" max="255" />
</div>
<div class="col-sm-8">
<input class="form-control color-blue-slider" type="range" step="1" min="0" max="255" />
</div>
</div>
</div>
</div>
<nav class="navbar navbar-default navbar-fixed-bottom">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-2" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-2">
<ul class="nav navbar-nav">
<li>
<a href="/" aria-label="Refresh" title="Refresh">
<span class="glyphicon glyphicon-refresh" id="btnRefresh"></span>
</a>
</li>
<li><p class="navbar-text" id="status">Loading, please wait...</p></li>
</ul>
</div>
</div>
</nav>
<!-- request js from internet CDN -->
<!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> -->
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jquery.minicolors.min.js" integrity="sha256-XAFQ9dZ6hy8p/GRhU8h/8pMvM1etymiJLZW1CiHV3bQ=" crossorigin="anonymous"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js" integrity="sha256-A4JwlcDvqO4JXpvEtvWY1RH8JAEMu5W21wP8GUXLUNs=" crossorigin="anonymous"></script> -->
<!-- request js from the ESP8266 web server -->
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/minicolors.min.js"></script>
<script src="js/r-websocket.min.js"></script>
<script src="js/app.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>

View File

@ -1,462 +0,0 @@
// used when hosting the site on the ESP8266
var address = location.hostname;
var urlBase = "";
// used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS)
// var address = "esp8266-1920f7.local";
// var urlBase = "http://" + address + "/";
var postColorTimer = {};
var postValueTimer = {};
var ignoreColorChange = false;
var ws = new ReconnectingWebSocket('ws://' + address + ':81/', ['arduino']);
ws.debug = true;
ws.onmessage = function(evt) {
if(evt.data != null)
{
var data = JSON.parse(evt.data);
if(data == null) return;
updateFieldValue(data.name, data.value);
}
}
$(document).ready(function() {
$("#status").html("Connecting, please wait...");
$.get(urlBase + "all", function(data) {
$("#status").html("Loading, please wait...");
$.each(data, function(index, field) {
if (field.type == "Number") {
addNumberField(field);
} else if (field.type == "Boolean") {
addBooleanField(field);
} else if (field.type == "Select") {
addSelectField(field);
} else if (field.type == "Color") {
addColorFieldPalette(field);
addColorFieldPicker(field);
} else if (field.type == "Section") {
addSectionField(field);
}
});
$(".minicolors").minicolors({
theme: "bootstrap",
changeDelay: 200,
control: "wheel",
format: "rgb",
inline: true
});
$("#status").html("Ready");
})
.fail(function(errorThrown) {
console.log("error: " + errorThrown);
});
});
function addNumberField(field) {
var template = $("#numberTemplate").clone();
template.attr("id", "form-group-" + field.name);
template.attr("data-field-type", field.type);
var label = template.find(".control-label");
label.attr("for", "input-" + field.name);
label.text(field.label);
var input = template.find(".input");
var slider = template.find(".slider");
slider.attr("id", "input-" + field.name);
if (field.min) {
input.attr("min", field.min);
slider.attr("min", field.min);
}
if (field.max) {
input.attr("max", field.max);
slider.attr("max", field.max);
}
if (field.step) {
input.attr("step", field.step);
slider.attr("step", field.step);
}
input.val(field.value);
slider.val(field.value);
slider.on("change mousemove", function() {
input.val($(this).val());
});
slider.on("change", function() {
var value = $(this).val();
input.val(value);
field.value = value;
delayPostValue(field.name, value);
});
input.on("change", function() {
var value = $(this).val();
slider.val(value);
field.value = value;
delayPostValue(field.name, value);
});
$("#form").append(template);
}
function addBooleanField(field) {
var template = $("#booleanTemplate").clone();
template.attr("id", "form-group-" + field.name);
template.attr("data-field-type", field.type);
var label = template.find(".control-label");
label.attr("for", "btn-group-" + field.name);
label.text(field.label);
var btngroup = template.find(".btn-group");
btngroup.attr("id", "btn-group-" + field.name);
var btnOn = template.find("#btnOn");
var btnOff = template.find("#btnOff");
btnOn.attr("id", "btnOn" + field.name);
btnOff.attr("id", "btnOff" + field.name);
btnOn.attr("class", field.value ? "btn btn-primary" : "btn btn-default");
btnOff.attr("class", !field.value ? "btn btn-primary" : "btn btn-default");
btnOn.click(function() {
setBooleanFieldValue(field, btnOn, btnOff, 1)
});
btnOff.click(function() {
setBooleanFieldValue(field, btnOn, btnOff, 0)
});
$("#form").append(template);
}
function addSelectField(field) {
var template = $("#selectTemplate").clone();
template.attr("id", "form-group-" + field.name);
template.attr("data-field-type", field.type);
var id = "input-" + field.name;
var label = template.find(".control-label");
label.attr("for", id);
label.text(field.label);
var select = template.find(".form-control");
select.attr("id", id);
for (var i = 0; i < field.options.length; i++) {
var optionText = field.options[i];
var option = $("<option></option>");
option.text(optionText);
option.attr("value", i);
select.append(option);
}
select.val(field.value);
select.change(function() {
var value = template.find("#" + id + " option:selected").index();
postValue(field.name, value);
});
var previousButton = template.find(".btn-previous");
var nextButton = template.find(".btn-next");
previousButton.click(function() {
var value = template.find("#" + id + " option:selected").index();
var count = select.find("option").length;
value--;
if(value < 0)
value = count - 1;
select.val(value);
postValue(field.name, value);
});
nextButton.click(function() {
var value = template.find("#" + id + " option:selected").index();
var count = select.find("option").length;
value++;
if(value >= count)
value = 0;
select.val(value);
postValue(field.name, value);
});
$("#form").append(template);
}
function addColorFieldPicker(field) {
var template = $("#colorTemplate").clone();
template.attr("id", "form-group-" + field.name);
template.attr("data-field-type", field.type);
var id = "input-" + field.name;
var input = template.find(".minicolors");
input.attr("id", id);
if(!field.value.startsWith("rgb("))
field.value = "rgb(" + field.value;
if(!field.value.endsWith(")"))
field.value += ")";
input.val(field.value);
var components = rgbToComponents(field.value);
var redInput = template.find(".color-red-input");
var greenInput = template.find(".color-green-input");
var blueInput = template.find(".color-blue-input");
var redSlider = template.find(".color-red-slider");
var greenSlider = template.find(".color-green-slider");
var blueSlider = template.find(".color-blue-slider");
redInput.attr("id", id + "-red");
greenInput.attr("id", id + "-green");
blueInput.attr("id", id + "-blue");
redSlider.attr("id", id + "-red-slider");
greenSlider.attr("id", id + "-green-slider");
blueSlider.attr("id", id + "-blue-slider");
redInput.val(components.r);
greenInput.val(components.g);
blueInput.val(components.b);
redSlider.val(components.r);
greenSlider.val(components.g);
blueSlider.val(components.b);
redInput.on("change", function() {
var value = $("#" + id).val();
var r = $(this).val();
var components = rgbToComponents(value);
field.value = r + "," + components.g + "," + components.b;
$("#" + id).minicolors("value", "rgb(" + field.value + ")");
redSlider.val(r);
});
greenInput.on("change", function() {
var value = $("#" + id).val();
var g = $(this).val();
var components = rgbToComponents(value);
field.value = components.r + "," + g + "," + components.b;
$("#" + id).minicolors("value", "rgb(" + field.value + ")");
greenSlider.val(g);
});
blueInput.on("change", function() {
var value = $("#" + id).val();
var b = $(this).val();
var components = rgbToComponents(value);
field.value = components.r + "," + components.g + "," + b;
$("#" + id).minicolors("value", "rgb(" + field.value + ")");
blueSlider.val(b);
});
redSlider.on("change", function() {
var value = $("#" + id).val();
var r = $(this).val();
var components = rgbToComponents(value);
field.value = r + "," + components.g + "," + components.b;
$("#" + id).minicolors("value", "rgb(" + field.value + ")");
redInput.val(r);
});
greenSlider.on("change", function() {
var value = $("#" + id).val();
var g = $(this).val();
var components = rgbToComponents(value);
field.value = components.r + "," + g + "," + components.b;
$("#" + id).minicolors("value", "rgb(" + field.value + ")");
greenInput.val(g);
});
blueSlider.on("change", function() {
var value = $("#" + id).val();
var b = $(this).val();
var components = rgbToComponents(value);
field.value = components.r + "," + components.g + "," + b;
$("#" + id).minicolors("value", "rgb(" + field.value + ")");
blueInput.val(b);
});
redSlider.on("change mousemove", function() {
redInput.val($(this).val());
});
greenSlider.on("change mousemove", function() {
greenInput.val($(this).val());
});
blueSlider.on("change mousemove", function() {
blueInput.val($(this).val());
});
input.on("change", function() {
if (ignoreColorChange) return;
var value = $(this).val();
var components = rgbToComponents(value);
redInput.val(components.r);
greenInput.val(components.g);
blueInput.val(components.b);
redSlider.val(components.r);
greenSlider.val(components.g);
blueSlider.val(components.b);
field.value = components.r + "," + components.g + "," + components.b;
delayPostColor(field.name, components);
});
$("#form").append(template);
}
function addColorFieldPalette(field) {
var template = $("#colorPaletteTemplate").clone();
var buttons = template.find(".btn-color");
var label = template.find(".control-label");
label.text(field.label);
buttons.each(function(index, button) {
$(button).click(function() {
var rgb = $(this).css('backgroundColor');
var components = rgbToComponents(rgb);
field.value = components.r + "," + components.g + "," + components.b;
postColor(field.name, components);
ignoreColorChange = true;
var id = "#input-" + field.name;
$(id).minicolors("value", "rgb(" + field.value + ")");
$(id + "-red").val(components.r);
$(id + "-green").val(components.g);
$(id + "-blue").val(components.b);
$(id + "-red-slider").val(components.r);
$(id + "-green-slider").val(components.g);
$(id + "-blue-slider").val(components.b);
ignoreColorChange = false;
});
});
$("#form").append(template);
}
function addSectionField(field) {
var template = $("#sectionTemplate").clone();
template.attr("id", "form-group-section-" + field.name);
template.attr("data-field-type", field.type);
$("#form").append(template);
}
function updateFieldValue(name, value) {
var group = $("#form-group-" + name);
var type = group.attr("data-field-type");
if (type == "Number") {
var input = group.find(".form-control");
input.val(value);
} else if (type == "Boolean") {
var btnOn = group.find("#btnOn" + name);
var btnOff = group.find("#btnOff" + name);
btnOn.attr("class", value ? "btn btn-primary" : "btn btn-default");
btnOff.attr("class", !value ? "btn btn-primary" : "btn btn-default");
} else if (type == "Select") {
var select = group.find(".form-control");
select.val(value);
} else if (type == "Color") {
var input = group.find(".form-control");
input.val("rgb(" + value + ")");
}
};
function setBooleanFieldValue(field, btnOn, btnOff, value) {
field.value = value;
btnOn.attr("class", field.value ? "btn btn-primary" : "btn btn-default");
btnOff.attr("class", !field.value ? "btn btn-primary" : "btn btn-default");
postValue(field.name, field.value);
}
function postValue(name, value) {
$("#status").html("Setting " + name + ": " + value + ", please wait...");
var body = { name: name, value: value };
$.post(urlBase + name + "?value=" + value, body, function(data) {
if (data.name != null) {
$("#status").html("Set " + name + ": " + data.name);
} else {
$("#status").html("Set " + name + ": " + data);
}
});
}
function delayPostValue(name, value) {
clearTimeout(postValueTimer);
postValueTimer = setTimeout(function() {
postValue(name, value);
}, 300);
}
function postColor(name, value) {
$("#status").html("Setting " + name + ": " + value.r + "," + value.g + "," + value.b + ", please wait...");
var body = { name: name, r: value.r, g: value.g, b: value.b };
$.post(urlBase + name + "?r=" + value.r + "&g=" + value.g + "&b=" + value.b, body, function(data) {
$("#status").html("Set " + name + ": " + data);
})
.fail(function(textStatus, errorThrown) { $("#status").html("Fail: " + textStatus + " " + errorThrown); });
}
function delayPostColor(name, value) {
clearTimeout(postColorTimer);
postColorTimer = setTimeout(function() {
postColor(name, value);
}, 300);
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function rgbToComponents(rgb) {
var components = {};
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
components.r = parseInt(rgb[1]);
components.g = parseInt(rgb[2]);
components.b = parseInt(rgb[3]);
return components;
}

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

@ -1 +0,0 @@
!function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()}(this,function(){function a(b,c,d){function l(a,b){var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,!1,!1,b),c}var e={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3};d||(d={});for(var f in e)this[f]="undefined"!=typeof d[f]?d[f]:e[f];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var h,g=this,i=!1,j=!1,k=document.createElement("div");k.addEventListener("open",function(a){g.onopen(a)}),k.addEventListener("close",function(a){g.onclose(a)}),k.addEventListener("connecting",function(a){g.onconnecting(a)}),k.addEventListener("message",function(a){g.onmessage(a)}),k.addEventListener("error",function(a){g.onerror(a)}),this.addEventListener=k.addEventListener.bind(k),this.removeEventListener=k.removeEventListener.bind(k),this.dispatchEvent=k.dispatchEvent.bind(k),this.open=function(b){h=new WebSocket(g.url,c||[]),b||k.dispatchEvent(l("connecting")),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",g.url);var d=h,e=setTimeout(function(){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",g.url),j=!0,d.close(),j=!1},g.timeoutInterval);h.onopen=function(){clearTimeout(e),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",g.url),g.protocol=h.protocol,g.readyState=WebSocket.OPEN,g.reconnectAttempts=0;var d=l("open");d.isReconnect=b,b=!1,k.dispatchEvent(d)},h.onclose=function(c){if(clearTimeout(e),h=null,i)g.readyState=WebSocket.CLOSED,k.dispatchEvent(l("close"));else{g.readyState=WebSocket.CONNECTING;var d=l("connecting");d.code=c.code,d.reason=c.reason,d.wasClean=c.wasClean,k.dispatchEvent(d),b||j||((g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",g.url),k.dispatchEvent(l("close")));var e=g.reconnectInterval*Math.pow(g.reconnectDecay,g.reconnectAttempts);setTimeout(function(){g.reconnectAttempts++,g.open(!0)},e>g.maxReconnectInterval?g.maxReconnectInterval:e)}},h.onmessage=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",g.url,b.data);var c=l("message");c.data=b.data,k.dispatchEvent(c)},h.onerror=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",g.url,b),k.dispatchEvent(l("error"))}},1==this.automaticOpen&&this.open(!1),this.send=function(b){if(h)return(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",g.url,b),h.send(b);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a,b){"undefined"==typeof a&&(a=1e3),i=!0,h&&h.close(a,b)},this.refresh=function(){h&&h.close()}}return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=!1,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a});

214
data/js/scripts.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,239 +0,0 @@
// used when hosting the site on the ESP8266
var address = location.hostname;
var urlBase = "";
// used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS)
// var address = "192.168.1.13";
// var urlBase = "http://" + address + "/";
var postColorTimer = {};
var postValueTimer = {};
var ignoreColorChange = false;
var patterns = [
"Pride",
"Color Waves",
"Rainbow Twinkles",
"Snow Twinkles",
"Cloud Twinkles",
"Incandescent Twinkles",
"Retro C9 Twinkles",
"Red & White Twinkles",
"Blue & White Twinkles",
"Red, Green & White Twinkles",
"Fairy Light Twinkles",
"Snow 2 Twinkles",
"Holly Twinkles",
"Ice Twinkles",
"Party Twinkles",
"Forest Twinkles",
"Lava Twinkles",
"Fire Twinkles",
"Cloud 2 Twinkles",
"Ocean Twinkles",
"Rainbow",
"Rainbow With Glitter",
"Solid Rainbow",
"Confetti",
"Sinelon",
"Beat",
"Juggle",
"Fire",
"Water"
];
var ws = new ReconnectingWebSocket('ws://' + address + ':81/', ['arduino']);
ws.debug = true;
ws.onmessage = function(evt) {
if(evt.data != null)
{
var data = JSON.parse(evt.data);
if(data == null) return;
switch(data.name) {
case "power":
if(data.value == 1) {
$("#btnOn").attr("class", "btn btn-primary");
$("#btnOff").attr("class", "btn btn-default");
} else {
$("#btnOff").attr("class", "btn btn-primary");
$("#btnOn").attr("class", "btn btn-default");
}
break;
case "pattern":
$(".grid-item-pattern").attr("class", "grid-item-pattern btn btn-default");
$("#pattern-button-" + data.value).attr("class", "grid-item-pattern btn btn-primary");
break;
}
}
}
$(document).ready(function() {
$("#status").html("Connecting, please wait...");
$.get(urlBase + "all", function(data) {
$("#status").html("Loading, please wait...");
$.each(data, function(index, field) {
switch (field.name) {
case "power":
if(field.value == 1) {
$("#btnOn").attr("class", "btn btn-primary");
} else {
$("#btnOff").attr("class", "btn btn-primary");
}
break;
case "pattern":
addPatternButtons(field);
break;
}
});
});
addColorButtons();
$("#btnOn").click(function() {
postValue("power", 1);
$("#btnOn").attr("class", "btn btn-primary");
$("#btnOff").attr("class", "btn btn-default");
});
$("#btnOff").click(function() {
postValue("power", 0);
$("#btnOff").attr("class", "btn btn-primary");
$("#btnOn").attr("class", "btn btn-default");
});
$("#status").html("Ready");
});
function addColorButtons() {
var hues = 25;
var hueStep = 360 / hues;
var levels = 10;
var levelStep = 60 / levels;
for(var l = 20; l < 80; l += levelStep) {
for(var h = 0; h < hues; h++) {
addColorButton(h * hueStep, 100, l);
}
}
$('.grid-color').isotope({
itemSelector: '.grid-item-color',
layoutMode: 'fitRows'
});
}
var colorButtonIndex = 0;
function addColorButton(h, s, l) {
var color = "hsla(" + h + ", " + s + "%, " + l + "%, 1)"
var template = $("#colorButtonTemplate").clone();
template.attr("id", "color-button-" + colorButtonIndex++);
template.css("background-color", color);
template.click(function() {
var rgb = $(this).css('backgroundColor');
var components = rgbToComponents(rgb);
$(".grid-item-color").css("border", "none");
$(this).css("border", "1px solid");
postColor("solidColor", components);
});
$("#colorButtonsRow").append(template);
}
function addPatternButtons(patternField) {
$.each(patternField.options, function(index, pattern) {
if($.inArray(pattern, patterns) == -1)
return;
var template = $("#patternButtonTemplate").clone();
template.attr("id", "pattern-button-" + index);
template.text(pattern);
template.click(function() {
postValue("patternName", pattern);
$(".grid-item-color").css("border", "none");
$(".grid-item-pattern").attr("class", "grid-item-pattern btn btn-default");
$(this).attr("class", "grid-item-pattern btn btn-primary");
});
$("#patternGrid").append(template);
});
$('.grid-pattern').isotope({
itemSelector: '.grid-item-pattern',
layoutMode: 'fitRows'
});
$("#pattern-button-" + patternField.value).attr("class", "grid-item-pattern btn btn-primary");
}
function postValue(name, value) {
$("#status").html("Setting " + name + ": " + value + ", please wait...");
var body = { name: name, value: value };
$.post(urlBase + name, body, function(data) {
if (data.name != null) {
$("#status").html("Set " + name + ": " + data.name);
} else {
$("#status").html("Set " + name + ": " + data);
}
});
}
function delayPostValue(name, value) {
clearTimeout(postValueTimer);
postValueTimer = setTimeout(function() {
postValue(name, value);
}, 300);
}
function postColor(name, value) {
$("#status").html("Setting " + name + ": " + value.r + "," + value.g + "," + value.b + ", please wait...");
var body = { name: name, r: value.r, g: value.g, b: value.b };
$.post(urlBase + name + "?r=" + value.r + "&g=" + value.g + "&b=" + value.b, body, function(data) {
$("#status").html("Set " + name + ": " + data);
})
.fail(function(textStatus, errorThrown) { $("#status").html("Fail: " + textStatus + " " + errorThrown); });
}
function delayPostColor(name, value) {
clearTimeout(postColorTimer);
postColorTimer = setTimeout(function() {
postColor(name, value);
}, 300);
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function rgbToComponents(rgb) {
var components = {};
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
components.r = parseInt(rgb[1]);
components.g = parseInt(rgb[2]);
components.b = parseInt(rgb[3]);
return components;
}

View File

@ -1,59 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESP8266 + FastLED by Evil Genius Labs</title>
<!-- request CSS from internet CDN -->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> -->
<!-- request CSS from the ESP8266 web server -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/simple.css">
<link rel="icon" href="images/atom196.png">
</head>
<body>
<div id="container" class="container">
<div style="margin: 5px;">
<button type="button" class="btn btn-default" id="btnOn">On</button>
<button type="button" class="btn btn-default" id="btnOff">Off</button>
</div>
<div id="patternGrid" class="grid-pattern"></div>
<div id="colorButtonsRow" class="grid-color"></div>
</div>
<div id="templates" style="display: none">
<div id="colorButtonTemplate" class="grid-item-color"></div>
<button id="patternButtonTemplate" class="grid-item-pattern btn btn-default"></button>
</div>
<!-- request js from internet CDN -->
<!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> -->
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> -->
<!-- <script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js" integrity="sha256-A4JwlcDvqO4JXpvEtvWY1RH8JAEMu5W21wP8GUXLUNs=" crossorigin="anonymous"></script> -->
<!-- request js from the ESP8266 web server -->
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/r-websocket.min.js"></script>
<script src="js/simple.js"></script>
</body>
</html>

View File

@ -1,95 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESP8266 + FastLED by Evil Genius Labs</title>
<!-- request CSS from internet CDN -->
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> -->
<!-- request CSS from the ESP8266 web server -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles.css">
<link rel="icon" href="images/atom196.png">
</head>
<body>
<nav class="navbar navbar-default navbar-static-top" id="top" role="banner">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank"><img src="/images/atom196.png" style="width: 24px; height: 24px;" /></a>
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank">Evil Genius Labs</a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="/">ESP8266 + FastLED <span class="sr-only">(current)</span></a></li>
<li><a href="/simple.htm" target="_blank" title="Simple Mode">Simple</a></li>
<li><a href="/edit.htm" target="_blank" title="Edit Files">Files</a></li>
<li><a href="/update" target="_blank" title="Update Firmware">Firmware</a></li>
<li class="active"><a href="/wifi.htm" target="_blank" title="Wi-Fi Settings">Wi-Fi</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/jasoncoon/esp8266-fastled-webserver">
<img style="height: 16px;" src="/images/github.ico" />
</a>
</li>
</ul>
</div>
</div>
</nav>
<div id="container" class="container">
<form class="form-horizontal" id="form" action="/wifi" method="post">
<div class="form-group">
<label for="inputSSID" class="col-sm-2 control-label">SSID</label>
<div class="col-sm-10">
<input type="text" autocorrect="off" autocapitalize="none"
class="form-control" id="inputSSID" name="ssid" placeholder="SSID (Wi-Fi network name)">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword" name="password" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Connect</button>
</div>
</div>
</form>
</div>
<!-- request js from internet CDN -->
<!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> -->
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> -->
<!-- <script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script> -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js" integrity="sha256-A4JwlcDvqO4JXpvEtvWY1RH8JAEMu5W21wP8GUXLUNs=" crossorigin="anonymous"></script> -->
<!-- request js from the ESP8266 web server -->
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,981 @@
/*
ESP8266 + FastLED + IR Remote + MSGEQ7: https://github.com/jasoncoon/esp8266-fastled-webserver
Copyright (C) 2015 Jason Coon
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define FASTLED_INTERRUPT_RETRY_COUNT 1
// #define FASTLED_ALLOW_INTERRUPTS 0
#include "FastLED.h"
FASTLED_USING_NAMESPACE
extern "C" {
#include "user_interface.h"
}
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <FS.h>
#include <EEPROM.h>
//#include <IRremoteESP8266.h>
#include "GradientPalettes.h"
//#define RECV_PIN 12
//IRrecv irReceiver(RECV_PIN);
//#include "Commands.h"
const bool apMode = false;
// AP mode password
const char WiFiAPPSK[] = "";
// Wi-Fi network to connect to (if not in AP mode)
const char* ssid = "";
const char* password = "";
ESP8266WebServer server(80);
#define DATA_PIN D5 // for Huzzah: Pins w/o special function: #4, #5, #12, #13, #14; // #16 does not work :(
#define LED_TYPE WS2811
#define COLOR_ORDER RGB
#define NUM_LEDS 400
#define MILLI_AMPS 1400 // IMPORTANT: set here the max milli-Amps of your power supply 5V 2A = 2000
#define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower.
CRGB leds[NUM_LEDS];
uint8_t patternIndex = 0;
const uint8_t brightnessCount = 5;
uint8_t brightnessMap[brightnessCount] = { 16, 32, 64, 128, 255 };
int brightnessIndex = 0;
uint8_t brightness = brightnessMap[brightnessIndex];
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
// ten seconds per color palette makes a good demo
// 20-120 is better for deployment
#define SECONDS_PER_PALETTE 10
///////////////////////////////////////////////////////////////////////
// Forward declarations of an array of cpt-city gradient palettes, and
// a count of how many there are. The actual color palette definitions
// are at the bottom of this file.
extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
extern const uint8_t gGradientPaletteCount;
// Current palette number from the 'playlist' of color palettes
uint8_t gCurrentPaletteNumber = 0;
CRGBPalette16 gCurrentPalette( CRGB::Black);
CRGBPalette16 gTargetPalette( gGradientPalettes[0] );
uint8_t currentPatternIndex = 0; // Index number of which pattern is current
bool autoplayEnabled = false;
uint8_t autoPlayDurationSeconds = 10;
unsigned int autoPlayTimeout = 0;
uint8_t currentPaletteIndex = 0;
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
CRGB solidColor = CRGB::Blue;
uint8_t power = 1;
void setup(void) {
Serial.begin(115200);
delay(100);
Serial.setDebugOutput(true);
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); // for WS2812 (Neopixel)
//FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS); // for APA102 (Dotstar)
FastLED.setCorrection(TypicalLEDStrip);
FastLED.setBrightness(brightness);
FastLED.setDither(false);
FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS);
fill_solid(leds, NUM_LEDS, solidColor);
FastLED.show();
EEPROM.begin(512);
loadSettings();
FastLED.setBrightness(brightness);
// irReceiver.enableIRIn(); // Start the receiver
Serial.println();
Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size());
Serial.print( F("Boot Vers: ") ); Serial.println(system_get_boot_version());
Serial.print( F("CPU: ") ); Serial.println(system_get_cpu_freq());
Serial.print( F("SDK: ") ); Serial.println(system_get_sdk_version());
Serial.print( F("Chip ID: ") ); Serial.println(system_get_chip_id());
Serial.print( F("Flash ID: ") ); Serial.println(spi_flash_get_id());
Serial.print( F("Flash Size: ") ); Serial.println(ESP.getFlashChipRealSize());
Serial.print( F("Vcc: ") ); Serial.println(ESP.getVcc());
Serial.println();
SPIFFS.begin();
{
Dir dir = SPIFFS.openDir("/");
while (dir.next()) {
String fileName = dir.fileName();
size_t fileSize = dir.fileSize();
Serial.printf("FS File: %s, size: %s\n", fileName.c_str(), String(fileSize).c_str());
}
Serial.printf("\n");
}
if (apMode)
{
WiFi.mode(WIFI_AP);
// Do a little work to get a unique-ish name. Append the
// last two bytes of the MAC (HEX'd) to "Thing-":
uint8_t mac[WL_MAC_ADDR_LENGTH];
WiFi.softAPmacAddress(mac);
String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
macID.toUpperCase();
String AP_NameString = "ESP8266 Thing " + macID;
char AP_NameChar[AP_NameString.length() + 1];
memset(AP_NameChar, 0, AP_NameString.length() + 1);
for (int i = 0; i < AP_NameString.length(); i++)
AP_NameChar[i] = AP_NameString.charAt(i);
WiFi.softAP(AP_NameChar, WiFiAPPSK);
Serial.printf("Connect to Wi-Fi access point: %s\n", AP_NameChar);
Serial.println("and open http://192.168.4.1 in your browser");
}
else
{
WiFi.mode(WIFI_STA);
Serial.printf("Connecting to %s\n", ssid);
if (String(WiFi.SSID()) != String(ssid)) {
WiFi.begin(ssid, password);
}
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.print("Connected! Open http://");
Serial.print(WiFi.localIP());
Serial.println(" in your browser");
}
// server.serveStatic("/", SPIFFS, "/index.htm"); // ,"max-age=86400"
server.on("/all", HTTP_GET, []() {
sendAll();
});
server.on("/power", HTTP_GET, []() {
sendPower();
});
server.on("/power", HTTP_POST, []() {
String value = server.arg("value");
setPower(value.toInt());
sendPower();
});
server.on("/solidColor", HTTP_GET, []() {
sendSolidColor();
});
server.on("/solidColor", HTTP_POST, []() {
String r = server.arg("r");
String g = server.arg("g");
String b = server.arg("b");
setSolidColor(r.toInt(), g.toInt(), b.toInt());
sendSolidColor();
});
server.on("/pattern", HTTP_GET, []() {
sendPattern();
});
server.on("/pattern", HTTP_POST, []() {
String value = server.arg("value");
setPattern(value.toInt());
sendPattern();
});
server.on("/patternUp", HTTP_POST, []() {
adjustPattern(true);
sendPattern();
});
server.on("/patternDown", HTTP_POST, []() {
adjustPattern(false);
sendPattern();
});
server.on("/brightness", HTTP_GET, []() {
sendBrightness();
});
server.on("/brightness", HTTP_POST, []() {
String value = server.arg("value");
setBrightness(value.toInt());
sendBrightness();
});
server.on("/brightnessUp", HTTP_POST, []() {
adjustBrightness(true);
sendBrightness();
});
server.on("/brightnessDown", HTTP_POST, []() {
adjustBrightness(false);
sendBrightness();
});
server.on("/palette", HTTP_GET, []() {
sendPalette();
});
server.on("/palette", HTTP_POST, []() {
String value = server.arg("value");
setPalette(value.toInt());
sendPalette();
});
server.serveStatic("/index.htm", SPIFFS, "/index.htm");
server.serveStatic("/fonts", SPIFFS, "/fonts", "max-age=86400");
server.serveStatic("/js", SPIFFS, "/js");
server.serveStatic("/css", SPIFFS, "/css", "max-age=86400");
server.serveStatic("/images", SPIFFS, "/images", "max-age=86400");
server.serveStatic("/", SPIFFS, "/index.htm");
server.begin();
Serial.println("HTTP server started");
autoPlayTimeout = millis() + (autoPlayDurationSeconds * 1000);
}
typedef void (*Pattern)();
typedef struct {
Pattern pattern;
String name;
} PatternAndName;
typedef PatternAndName PatternAndNameList[];
// List of patterns to cycle through. Each is defined as a separate function below.
PatternAndNameList patterns = {
{ colorwaves, "Color Waves" },
{ palettetest, "Palette Test" },
{ pride, "Pride" },
{ rainbow, "Rainbow" },
{ rainbowWithGlitter, "Rainbow With Glitter" },
{ confetti, "Confetti" },
{ sinelon, "Sinelon" },
{ juggle, "Juggle" },
{ bpm, "BPM" },
{ showSolidColor, "Solid Color" },
};
const uint8_t patternCount = ARRAY_SIZE(patterns);
typedef struct {
CRGBPalette16 palette;
String name;
} PaletteAndName;
typedef PaletteAndName PaletteAndNameList[];
const CRGBPalette16 palettes[] = {
RainbowColors_p,
RainbowStripeColors_p,
CloudColors_p,
LavaColors_p,
OceanColors_p,
ForestColors_p,
PartyColors_p,
HeatColors_p
};
const uint8_t paletteCount = ARRAY_SIZE(palettes);
const String paletteNames[paletteCount] = {
"Rainbow",
"Rainbow Stripe",
"Cloud",
"Lava",
"Ocean",
"Forest",
"Party",
"Heat",
};
void loop(void) {
// Add entropy to random number generator; we use a lot of it.
random16_add_entropy(random(65535));
server.handleClient();
// handleIrInput();
if (power == 0) {
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
FastLED.delay(15);
return;
}
// EVERY_N_SECONDS(10) {
// Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size());
// }
EVERY_N_MILLISECONDS( 20 ) {
gHue++; // slowly cycle the "base color" through the rainbow
}
// change to a new cpt-city gradient palette
EVERY_N_SECONDS( SECONDS_PER_PALETTE ) {
gCurrentPaletteNumber = addmod8( gCurrentPaletteNumber, 1, gGradientPaletteCount);
gTargetPalette = gGradientPalettes[ gCurrentPaletteNumber ];
}
// slowly blend the current cpt-city gradient palette to the next
EVERY_N_MILLISECONDS(40) {
nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 16);
}
if (autoplayEnabled && millis() > autoPlayTimeout) {
adjustPattern(true);
autoPlayTimeout = millis() + (autoPlayDurationSeconds * 1000);
}
// Call the current pattern function once, updating the 'leds' array
patterns[currentPatternIndex].pattern();
FastLED.show();
// insert a delay to keep the framerate modest
FastLED.delay(1000 / FRAMES_PER_SECOND);
}
//void handleIrInput()
//{
// InputCommand command = readCommand(defaultHoldDelay);
//
// if (command != InputCommand::None) {
// Serial.print("command: ");
// Serial.println((int) command);
// }
//
// switch (command) {
// case InputCommand::Up: {
// adjustPattern(true);
// break;
// }
// case InputCommand::Down: {
// adjustPattern(false);
// break;
// }
// case InputCommand::Power: {
// power = power == 0 ? 1 : 0;
// break;
// }
// case InputCommand::BrightnessUp: {
// adjustBrightness(true);
// break;
// }
// case InputCommand::BrightnessDown: {
// adjustBrightness(false);
// break;
// }
// case InputCommand::PlayMode: { // toggle pause/play
// autoplayEnabled = !autoplayEnabled;
// break;
// }
//
// // pattern buttons
//
// case InputCommand::Pattern1: {
// setPattern(0);
// break;
// }
// case InputCommand::Pattern2: {
// setPattern(1);
// break;
// }
// case InputCommand::Pattern3: {
// setPattern(2);
// break;
// }
// case InputCommand::Pattern4: {
// setPattern(3);
// break;
// }
// case InputCommand::Pattern5: {
// setPattern(4);
// break;
// }
// case InputCommand::Pattern6: {
// setPattern(5);
// break;
// }
// case InputCommand::Pattern7: {
// setPattern(6);
// break;
// }
// case InputCommand::Pattern8: {
// setPattern(7);
// break;
// }
// case InputCommand::Pattern9: {
// setPattern(8);
// break;
// }
// case InputCommand::Pattern10: {
// setPattern(9);
// break;
// }
// case InputCommand::Pattern11: {
// setPattern(10);
// break;
// }
// case InputCommand::Pattern12: {
// setPattern(11);
// break;
// }
//
// // custom color adjustment buttons
//
// case InputCommand::RedUp: {
// solidColor.red += 8;
// setSolidColor(solidColor);
// break;
// }
// case InputCommand::RedDown: {
// solidColor.red -= 8;
// setSolidColor(solidColor);
// break;
// }
// case InputCommand::GreenUp: {
// solidColor.green += 8;
// setSolidColor(solidColor);
// break;
// }
// case InputCommand::GreenDown: {
// solidColor.green -= 8;
// setSolidColor(solidColor);
// break;
// }
// case InputCommand::BlueUp: {
// solidColor.blue += 8;
// setSolidColor(solidColor);
// break;
// }
// case InputCommand::BlueDown: {
// solidColor.blue -= 8;
// setSolidColor(solidColor);
// break;
// }
//
// // color buttons
//
// case InputCommand::Red: {
// setSolidColor(CRGB::Red);
// break;
// }
// case InputCommand::RedOrange: {
// setSolidColor(CRGB::OrangeRed);
// break;
// }
// case InputCommand::Orange: {
// setSolidColor(CRGB::Orange);
// break;
// }
// case InputCommand::YellowOrange: {
// setSolidColor(CRGB::Goldenrod);
// break;
// }
// case InputCommand::Yellow: {
// setSolidColor(CRGB::Yellow);
// break;
// }
//
// case InputCommand::Green: {
// setSolidColor(CRGB::Green);
// break;
// }
// case InputCommand::Lime: {
// setSolidColor(CRGB::Lime);
// break;
// }
// case InputCommand::Aqua: {
// setSolidColor(CRGB::Aqua);
// break;
// }
// case InputCommand::Teal: {
// setSolidColor(CRGB::Teal);
// break;
// }
// case InputCommand::Navy: {
// setSolidColor(CRGB::Navy);
// break;
// }
//
// case InputCommand::Blue: {
// setSolidColor(CRGB::Blue);
// break;
// }
// case InputCommand::RoyalBlue: {
// setSolidColor(CRGB::RoyalBlue);
// break;
// }
// case InputCommand::Purple: {
// setSolidColor(CRGB::Purple);
// break;
// }
// case InputCommand::Indigo: {
// setSolidColor(CRGB::Indigo);
// break;
// }
// case InputCommand::Magenta: {
// setSolidColor(CRGB::Magenta);
// break;
// }
//
// case InputCommand::White: {
// setSolidColor(CRGB::White);
// break;
// }
// case InputCommand::Pink: {
// setSolidColor(CRGB::Pink);
// break;
// }
// case InputCommand::LightPink: {
// setSolidColor(CRGB::LightPink);
// break;
// }
// case InputCommand::BabyBlue: {
// setSolidColor(CRGB::CornflowerBlue);
// break;
// }
// case InputCommand::LightBlue: {
// setSolidColor(CRGB::LightBlue);
// break;
// }
// }
//}
void loadSettings()
{
brightness = EEPROM.read(0);
currentPatternIndex = EEPROM.read(1);
if (currentPatternIndex < 0)
currentPatternIndex = 0;
else if (currentPatternIndex >= patternCount)
currentPatternIndex = patternCount - 1;
byte r = EEPROM.read(2);
byte g = EEPROM.read(3);
byte b = EEPROM.read(4);
if (r == 0 && g == 0 && b == 0)
{
}
else
{
solidColor = CRGB(r, g, b);
}
currentPaletteIndex = EEPROM.read(5);
if (currentPaletteIndex < 0)
currentPaletteIndex = 0;
else if (currentPaletteIndex >= paletteCount)
currentPaletteIndex = paletteCount - 1;
}
void sendAll()
{
String json = "{";
json += "\"power\":" + String(power) + ",";
json += "\"brightness\":" + String(brightness) + ",";
json += "\"currentPattern\":{";
json += "\"index\":" + String(currentPatternIndex);
json += ",\"name\":\"" + patterns[currentPatternIndex].name + "\"}";
json += ",\"currentPalette\":{";
json += "\"index\":" + String(currentPaletteIndex);
json += ",\"name\":\"" + paletteNames[currentPaletteIndex] + "\"}";
json += ",\"solidColor\":{";
json += "\"r\":" + String(solidColor.r);
json += ",\"g\":" + String(solidColor.g);
json += ",\"b\":" + String(solidColor.b);
json += "}";
json += ",\"patterns\":[";
for (uint8_t i = 0; i < patternCount; i++)
{
json += "\"" + patterns[i].name + "\"";
if (i < patternCount - 1)
json += ",";
}
json += "]";
json += ",\"palettes\":[";
for (uint8_t i = 0; i < paletteCount; i++)
{
json += "\"" + paletteNames[i] + "\"";
if (i < paletteCount - 1)
json += ",";
}
json += "]";
json += "}";
server.send(200, "text/json", json);
json = String();
}
void sendPower()
{
String json = String(power);
server.send(200, "text/json", json);
json = String();
}
void sendPattern()
{
String json = "{";
json += "\"index\":" + String(currentPatternIndex);
json += ",\"name\":\"" + patterns[currentPatternIndex].name + "\"";
json += "}";
server.send(200, "text/json", json);
json = String();
}
void sendPalette()
{
String json = "{";
json += "\"index\":" + String(currentPaletteIndex);
json += ",\"name\":\"" + paletteNames[currentPaletteIndex] + "\"";
json += "}";
server.send(200, "text/json", json);
json = String();
}
void sendBrightness()
{
String json = String(brightness);
server.send(200, "text/json", json);
json = String();
}
void sendSolidColor()
{
String json = "{";
json += "\"r\":" + String(solidColor.r);
json += ",\"g\":" + String(solidColor.g);
json += ",\"b\":" + String(solidColor.b);
json += "}";
server.send(200, "text/json", json);
json = String();
}
void setPower(uint8_t value)
{
power = value == 0 ? 0 : 1;
}
void setSolidColor(CRGB color)
{
setSolidColor(color.r, color.g, color.b);
}
void setSolidColor(uint8_t r, uint8_t g, uint8_t b)
{
solidColor = CRGB(r, g, b);
EEPROM.write(2, r);
EEPROM.write(3, g);
EEPROM.write(4, b);
setPattern(patternCount - 1);
}
// increase or decrease the current pattern number, and wrap around at the ends
void adjustPattern(bool up)
{
if (up)
currentPatternIndex++;
else
currentPatternIndex--;
// wrap around at the ends
if (currentPatternIndex < 0)
currentPatternIndex = patternCount - 1;
if (currentPatternIndex >= patternCount)
currentPatternIndex = 0;
if (!autoplayEnabled) {
EEPROM.write(1, currentPatternIndex);
EEPROM.commit();
}
}
void setPattern(int value)
{
// don't wrap around at the ends
if (value < 0)
value = 0;
else if (value >= patternCount)
value = patternCount - 1;
currentPatternIndex = value;
if (!autoplayEnabled) {
EEPROM.write(1, currentPatternIndex);
EEPROM.commit();
}
}
void setPalette(int value)
{
// don't wrap around at the ends
if (value < 0)
value = 0;
else if (value >= paletteCount)
value = paletteCount - 1;
currentPaletteIndex = value;
EEPROM.write(5, currentPaletteIndex);
EEPROM.commit();
}
// adjust the brightness, and wrap around at the ends
void adjustBrightness(bool up)
{
if (up)
brightnessIndex++;
else
brightnessIndex--;
// wrap around at the ends
if (brightnessIndex < 0)
brightnessIndex = brightnessCount - 1;
else if (brightnessIndex >= brightnessCount)
brightnessIndex = 0;
brightness = brightnessMap[brightnessIndex];
FastLED.setBrightness(brightness);
EEPROM.write(0, brightness);
EEPROM.commit();
}
void setBrightness(int value)
{
// don't wrap around at the ends
if (value > 255)
value = 255;
else if (value < 0) value = 0;
brightness = value;
FastLED.setBrightness(brightness);
EEPROM.write(0, brightness);
EEPROM.commit();
}
void showSolidColor()
{
fill_solid(leds, NUM_LEDS, solidColor);
}
void rainbow()
{
// FastLED's built-in rainbow generator
fill_rainbow( leds, NUM_LEDS, gHue, 10);
}
void rainbowWithGlitter()
{
// built-in FastLED rainbow, plus some random sparkly glitter
rainbow();
addGlitter(80);
}
void addGlitter( fract8 chanceOfGlitter)
{
if ( random8() < chanceOfGlitter) {
leds[ random16(NUM_LEDS) ] += CRGB::White;
}
}
void confetti()
{
// random colored speckles that blink in and fade smoothly
fadeToBlackBy( leds, NUM_LEDS, 10);
int pos = random16(NUM_LEDS);
// leds[pos] += CHSV( gHue + random8(64), 200, 255);
leds[pos] += ColorFromPalette(palettes[currentPaletteIndex], gHue + random8(64));
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16(13, 0, NUM_LEDS - 1);
// leds[pos] += CHSV( gHue, 255, 192);
leds[pos] += ColorFromPalette(palettes[currentPaletteIndex], gHue, 192);
}
void bpm()
{
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
uint8_t BeatsPerMinute = 62;
CRGBPalette16 palette = palettes[currentPaletteIndex];
uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
for ( int i = 0; i < NUM_LEDS; i++) { //9948
leds[i] = ColorFromPalette(palette, gHue + (i * 2), beat - gHue + (i * 10));
}
}
void juggle()
{
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, NUM_LEDS, 20);
byte dothue = 0;
for ( int i = 0; i < 8; i++)
{
// leds[beatsin16(i + 7, 0, NUM_LEDS)] |= CHSV(dothue, 200, 255);
leds[beatsin16(i + 7, 0, NUM_LEDS)] |= ColorFromPalette(palettes[currentPaletteIndex], dothue);
dothue += 32;
}
}
// Pride2015 by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5
// This function draws rainbows with an ever-changing,
// widely-varying set of parameters.
void pride() {
static uint16_t sPseudotime = 0;
static uint16_t sLastMillis = 0;
static uint16_t sHue16 = 0;
uint8_t sat8 = beatsin88( 87, 220, 250);
uint8_t brightdepth = beatsin88( 341, 96, 224);
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
uint8_t msmultiplier = beatsin88(147, 23, 60);
uint16_t hue16 = sHue16;//gHue * 256;
uint16_t hueinc16 = beatsin88(113, 1, 3000);
uint16_t ms = millis();
uint16_t deltams = ms - sLastMillis ;
sLastMillis = ms;
sPseudotime += deltams * msmultiplier;
sHue16 += deltams * beatsin88( 400, 5, 9);
uint16_t brightnesstheta16 = sPseudotime;
for ( uint16_t i = 0 ; i < NUM_LEDS; i++) {
hue16 += hueinc16;
uint8_t hue8 = hue16 / 256;
brightnesstheta16 += brightnessthetainc16;
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
bri8 += (255 - brightdepth);
CRGB newcolor = CHSV( hue8, sat8, bri8);
nblend(leds[i], newcolor, 64);
}
}
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
// This function draws color waves with an ever-changing,
// widely-varying set of parameters, using a color palette.
void colorwaves()
{
static uint16_t sPseudotime = 0;
static uint16_t sLastMillis = 0;
static uint16_t sHue16 = 0;
// uint8_t sat8 = beatsin88( 87, 220, 250);
uint8_t brightdepth = beatsin88( 341, 96, 224);
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
uint8_t msmultiplier = beatsin88(147, 23, 60);
uint16_t hue16 = sHue16;//gHue * 256;
uint16_t hueinc16 = beatsin88(113, 300, 1500);
uint16_t ms = millis();
uint16_t deltams = ms - sLastMillis ;
sLastMillis = ms;
sPseudotime += deltams * msmultiplier;
sHue16 += deltams * beatsin88( 400, 5, 9);
uint16_t brightnesstheta16 = sPseudotime;
for ( uint16_t i = 0 ; i < NUM_LEDS; i++) {
hue16 += hueinc16;
uint8_t hue8 = hue16 / 256;
uint16_t h16_128 = hue16 >> 7;
if ( h16_128 & 0x100) {
hue8 = 255 - (h16_128 >> 1);
} else {
hue8 = h16_128 >> 1;
}
brightnesstheta16 += brightnessthetainc16;
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
bri8 += (255 - brightdepth);
uint8_t index = hue8;
//index = triwave8( index);
index = scale8( index, 240);
CRGB newcolor = ColorFromPalette(gCurrentPalette, index, bri8);
nblend(leds[i], newcolor, 128);
}
}
// Alternate rendering function just scrolls the current palette
// across the defined LED strip.
void palettetest()
{
static uint8_t startindex = 0;
startindex--;
fill_palette( leds, NUM_LEDS, startindex, (256 / NUM_LEDS) + 1, gCurrentPalette, 255, LINEARBLEND);
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

BIN
webapp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB