Getting Melvanimate to fly :-)
Melvanimate is a library for ESP8266 that lets you control your Neopixels over WLAN easily. It supports everything imaginable besides toasting your toast, e.g.,:
(Insert cool photos/videos here!)
The NodeMCU 1.0 board has an integrated power regulator so I can hook up the light strip and the ESP directly to 5V and it works with 0 external components. The data line of the neopixels strip is connected to the RX of the NodeMCU 1.0 board.
These are very concise instructions on how to build and run using Ubuntu 16.04 (other versions should also work).
First, install known working versions of the dependency libraries.
which git || sudo apt-get install -y git
# rm -rf $HOME/Arduino/ # Uncomment this only if you are sure what you are doing
mkdir -p $HOME/Arduino/libraries/
cd $HOME/Arduino/libraries/
git clone -o dc40877 https://github.com/adafruit/Adafruit-GFX-Library.git
git clone -o 6cfe2a5 https://github.com/bblanchon/ArduinoJson.git
git clone -o b4e453c https://github.com/sticilface/ESPmanager.git
git clone -o f1b4576 https://github.com/marvinroger/async-mqtt-client.git
git clone -o 2cc9846 https://github.com/me-no-dev/ESPAsyncTCP.git
git clone -o 5159d8b https://github.com/me-no-dev/ESPAsyncWebServer.git
git clone -o 94f5ad3 https://github.com/Makuna/NeoPixelBus.git
git clone -o 58138fe https://github.com/sticilface/Melvanimate.git
cd -
By the way, this list was made with
DIRS=$(find ~/Arduino/libraries -mindepth 1 -maxdepth 1 -type d )
echo "cd ~/Arduino/libraries"
for DIR in $DIRS ; do
cd $DIR
unset URL
unset REV
URL=$(git config --get remote.origin.url 2>/dev/null)
REV=$(git log --pretty=format:'%h' -n 1 2>/dev/null)
if [ ! -z $REV ] ; then echo git clone -o $REV $URL ; fi
cd - >/dev/null
done
echo "cd -"
Download and run Arduino AppImage that contains the IDE, the esp8266 core, and the SPIFFS upload tool.
If you are not running Linux or do not want to use the AppImage, you have to download and install those parts manually.
AI="Arduino-1.6.11.esp2.3.0-x86_64.AppImage"
wget -c "https://bintray.com/probono/AppImages/download_file?file_path=$AI" -O "$AI"
chmod a+x "$AI"
./"$AI" &
Now that we have everything in place, configure, compile, and upload.
Melvanimate has a super cool web interface that can do real magic, including over-the-air updates.
If you have multiple installations of Melvanimate in the same network, they will automatically discover each other and talk to each other. From the web interface, you can select the different devices in the upper right-hand corner.
Let's say I want my LEDs to come up as blue, whenever I attach them to a power plug, whether there is WLAN or not. To do this, we create a preset in the GUI called "Default" and change the following section like so:
SPIFFS.begin();
lights.Load("Default"); // Add this line
manager.begin();
// Add effects to the manager.
lights.Add("Off", new SwitchEffect( offFn)); // Remove "true" here
lights.Add("SimpleColor", new SimpleEffect(SimpleColorFn), true); // Add "true" here
Done! Now, whenever I power on, the lights go blue.
Who is going to implement them?
Additional notes
===
Erase chip completely (might not be necessary but I wanted to be extra cautious)
#include <FS.h>
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(115200);
Serial.println("ERASING: ");
ESP.eraseConfig();
SPIFFS.format();
Serial.print("done");
}
void loop() {
}
Upload and wait for "done"
===
Install SPIFFS uploader tool manually
mkdir $HOME/Arduino/tools
cd $HOME/Arduino/tools
wget -c "https://github.com/esp8266/arduino-esp8266fs-plugin/releases/download/0.2.0/ESP8266FS-0.2.0.zip"
unzip ESP8266FS-0.2.0.zip
rm ESP*.zip
cd -
===
For documenting the precise versions used, see
https://github.com/sticilface/Melvanimate/issues/20#issuecomment-241207754
===
For verbosity, uncomment
#define Debug_ESPManager
in espmanager.h
to get debug output you also need to select the debug port in the arudino IDE
Just use generic module, and set reset method to nodemcu, make sure CPU speed is 160, SPIFFS is 4m
// https://github.com/kayno/arduinolifx
#include <math.h>
struct rgb {
double r; // percent
double g; // percent
double b; // percent
};
rgb kelvinToRGB(long kelvin) {
rgb kelvin_rgb;
long temperature = kelvin / 100;
if(temperature <= 66) {
kelvin_rgb.r = 255;
}
else {
kelvin_rgb.r = temperature - 60;
kelvin_rgb.r = 329.698727446 * pow(kelvin_rgb.r, -0.1332047592);
if(kelvin_rgb.r < 0) kelvin_rgb.r = 0;
if(kelvin_rgb.r > 255) kelvin_rgb.r = 255;
}
if(temperature <= 66) {
kelvin_rgb.g = temperature;
kelvin_rgb.g = 99.4708025861 * log(kelvin_rgb.g) - 161.1195681661;
if(kelvin_rgb.g < 0) kelvin_rgb.g = 0;
if(kelvin_rgb.g > 255) kelvin_rgb.g = 255;
}
else {
kelvin_rgb.g = temperature - 60;
kelvin_rgb.g = 288.1221695283 * pow(kelvin_rgb.g, -0.0755148492);
if(kelvin_rgb.g < 0) kelvin_rgb.g = 0;
if(kelvin_rgb.g > 255) kelvin_rgb.g = 255;
}
if(temperature >= 66) {
kelvin_rgb.b = 255;
}
else {
if(temperature <= 19) {
kelvin_rgb.b = 0;
}
else {
kelvin_rgb.b = temperature - 10;
kelvin_rgb.b = 138.5177312231 * log(kelvin_rgb.b) - 305.0447927307;
if(kelvin_rgb.b < 0) kelvin_rgb.b = 0;
if(kelvin_rgb.b > 255) kelvin_rgb.b = 255;
}
}
return kelvin_rgb;
}