Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

ESP8266 code

Jean-Baptiste Le Coz edited this page Sep 23, 2023 · 9 revisions

LED Strip

#define FEATURE DotStarBgrFeature // Neopixels : NeoGrbFeature / Dotstars : DotStarBgrFeature
#define METHOD DotStarSpiMethod // Neopixels :Neo800KbpsMethod / Dotstars : DotStarSpiMethod

I have test with success Dotstars (aka APA102) and Neopixels (aka WS2812B). I have selected the fastest METHOD for this two type of LED, but you can find more options at the NeoPixelBus dedicated page. If you have a problem with color try to select the right FEATURE : Brg, Grb, Rgb... are the order of the Red, Green and Blue component inside each LED which can vary.

This section of the code define the LED strip :

// LED --------------
const int NUMPIXELS = 119;
NeoPixelBus<FEATURE, METHOD> STRIP(NUMPIXELS);
// end LED -----------
  • NUMPIXELS : Choose the number of LED in your LED strip.

Push button

#define BUTTON      // Decomment this to use BUTTON

The 2 push buttons are optional. However, it's more convenient to launch your animation with a button than clicking on a touch screen.

By default, ImagePainting2 handle the 2 push buttons (BTNA and BTNB) like this :

  • BTNA : "short click" --> Play/Pause and "long click" --> Burn

  • BTNB : "short click" --> Stop and "long click" --> Light

This section of the code define the push button :

// BUTTON --------------
long DEBOUNCETIME = 50; //Debouncing Time in Milliseconds
long HOLDTIME = 500; // Hold Time in Milliseconds
const int BTNA_PIN = D3; //PIN for the button A
const int BTNB_PIN = D4; //PIN for the button B
long BTNATIMER = 0;
long BTNBTIMER = 0;
boolean ISBTNA = false;
boolean ISBTNB = false;
boolean ISBTNAHOLD = false;
boolean ISBTNBHOLD = false;
// end BUTTON-----------
  • BTNA_PIN and BTNB_PIN : I use D3 and D4 on purpose for my Wemos D1. This is internal Pull-Up Pin, so check the specification of your board before changing those PIN.

  • HOLDTIME : HOLDTIME can be tweak to have a shorter/longer "long click".

  • DEBOUNCETIME : DEBOUNCETIME can be tweak to have a good button response without false detection.

Wifi

//#define STA       // Decomment this to use STA mode instead of AP

ImagePainting2 can operate in two separate mode :

  • STA : As STAtion. In this case, the ESP8266 will connect to your router and be another client of your network. You have to look at the serial monitor of the Arduino IDE during the boot of the ESP8266 to find his IP address. This mode is mainly not interesting, except for debug.

  • AP : As Access Point. In this case, the ESP8266 will provide his own wifi network and you will connect directly on him. To keep it simple, there is no password and the ESP8266 can be reach at http://192.168.1.1. This is the preferred mode as it is very unlikely to have a wifi router everywhere.

This section of the code define the Wifi :

// WIFI --------------
#ifdef STA // STA Mode
const char* ssid = "SSID"; // your wifi ssid for STA mode
const char* password = "PASSWORD"; // your wifi password for AP mode
#else // AP Mode
const char* ssid = "imagePainting"; // wifi ssid for AP mode
IPAddress apIP(192, 168, 1, 1); // wifi IP for AP mode
#endif
// end WIFI -----------
  • SSID and PASSWORD : you have to set your router ssid and password to use STA mode.
Clone this wiki locally