diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index 68712f5..fbeb310 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -15,6 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +#define FASTLED_ALLOW_INTERRUPTS 0 +//#define FASTLED_INTERRUPT_RETRY_COUNT 1 #include FASTLED_USING_NAMESPACE @@ -24,13 +27,13 @@ extern "C" { } #include -#include +//#include #include #include #include #include #include -#include +//#include #include "GradientPalettes.h" #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) @@ -39,10 +42,10 @@ extern "C" { #define HOSTNAME "ESP8266-" ///< Hostname. The setup function adds the Chip ID at the end. -#define RECV_PIN D4 -IRrecv irReceiver(RECV_PIN); +//#define RECV_PIN D4 +//IRrecv irReceiver(RECV_PIN); -#include "Commands.h" +//#include "Commands.h" const bool apMode = false; @@ -59,10 +62,10 @@ ESP8266HTTPUpdateServer httpUpdateServer; #include "FSBrowser.h" -#define DATA_PIN D8 +#define DATA_PIN D5 #define LED_TYPE WS2811 -#define COLOR_ORDER GRB -#define NUM_LEDS 24 +#define COLOR_ORDER RGB +#define NUM_LEDS 32 #define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) #define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower. @@ -228,7 +231,7 @@ void setup() { FastLED.setBrightness(brightness); - irReceiver.enableIRIn(); // Start the receiver +// irReceiver.enableIRIn(); // Start the receiver Serial.println(); Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); @@ -263,10 +266,10 @@ void setup() { for (uint8_t i = 0; i < hostname.length(); i++) hostnameChar[i] = hostname.charAt(i); - MDNS.begin(hostnameChar); - - // Add service to MDNS-SD - MDNS.addService("http", "tcp", 80); +// MDNS.begin(hostnameChar); +// +// // Add service to MDNS-SD +// MDNS.addService("http", "tcp", 80); // Print hostname. Serial.println("Hostname: " + hostname); @@ -476,7 +479,7 @@ void loop() { webSocketsServer.loop(); webServer.handleClient(); - handleIrInput(); +// handleIrInput(); if (power == 0) { fill_solid(leds, NUM_LEDS, CRGB::Black); @@ -551,213 +554,213 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length break; } } - -void handleIrInput() -{ - InputCommand command = readCommand(); - - 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: { - setPower(power == 0 ? 1 : 0); - break; - } - case InputCommand::BrightnessUp: { - adjustBrightness(true); - break; - } - case InputCommand::BrightnessDown: { - adjustBrightness(false); - break; - } - case InputCommand::PlayMode: { // toggle pause/play - setAutoplay(!autoplay); - 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 handleIrInput() +//{ +// InputCommand command = readCommand(); +// +// 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: { +// setPower(power == 0 ? 1 : 0); +// break; +// } +// case InputCommand::BrightnessUp: { +// adjustBrightness(true); +// break; +// } +// case InputCommand::BrightnessDown: { +// adjustBrightness(false); +// break; +// } +// case InputCommand::PlayMode: { // toggle pause/play +// setAutoplay(!autoplay); +// 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() { @@ -1001,7 +1004,7 @@ void sinelon() { // a colored dot sweeping back and forth, with fading trails fadeToBlackBy( leds, NUM_LEDS, 20); - int pos = beatsin16(speed, 0, NUM_LEDS); + int pos = beatsin16(speed, 0, NUM_LEDS - 1); static int prevpos = 0; CRGB color = ColorFromPalette(palettes[currentPaletteIndex], gHue, 255); if( pos < prevpos ) {