Hello everybody! And I will immediately apologize for my English…
Thank you Aircoookie for a great project!
I upload my usermod. It allows you to manage your LED using a graphical interface, from your mobile device (Android, iOS) via the remoteXY development environment. This app is lightweight (1.5 Mb), does not use third-party servers, and allows you to use your other controllers.
From the features I implemented:
-
change the brightness and the speed of effects by tilting the phone (G-sensor);
-
switching effects, palettes, displaying their names, color selection, enabling/disabling the preset.
/*
This file allows you to add own functionality to WLED more easily
See: Add own functionality · Aircoookie/WLED Wiki · GitHub
EEPROM bytes 2750+ are reserved for your custom use case. (if you extend #define EEPSIZE in wled01_eeprom.h)
bytes 2400+ are currently ununsed, but might be used for future wled features
*/
#define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
#include <RemoteXY.h>
#define REMOTEXY_WIFI_SSID “”
#define REMOTEXY_WIFI_PASSWORD “”
#define REMOTEXY_SERVER_PORT 6377#pragma pack(push, 1)
uint8_t RemoteXY_CONF =
{ 255, 11, 0, 103, 0, 193, 0, 8, 25, 5,
1, 1, 53, 2, 8, 7, 0, 2, 31, 88,
0, 1, 1, 33, 16, 28, 8, 0, 2, 31,
77, 111, 100, 101, 32, 43, 0, 67, 4, 2,
11, 59, 4, 0, 2, 26, 51, 5, 10, 3,
40, 51, 51, 1, 2, 46, 31, 131, 1, 15,
2, 17, 7, 1, 2, 31, 74, 111, 121, 0,
131, 0, 34, 2, 17, 7, 2, 2, 31, 67,
111, 108, 111, 114, 0, 6, 0, 3, 41, 57,
57, 2, 2, 26, 1, 1, 2, 16, 28, 8,
0, 2, 31, 77, 111, 100, 101, 32, 45, 0,
129, 0, 1, 96, 21, 3, 0, 28, 208, 148,
208, 188, 208, 184, 209, 130, 209, 128, 208, 184,
208, 185, 44, 32, 50, 48, 50, 48, 0, 67,
4, 2, 26, 59, 4, 0, 2, 26, 51, 1,
1, 33, 31, 28, 7, 0, 2, 31, 80, 97,
108, 32, 43, 0, 1, 1, 2, 31, 28, 7,
0, 2, 31, 80, 97, 108, 32, 45, 0, 65,
12, 2, 2, 11, 7, 0, 1, 1, 3, 3,
9, 5, 0, 46, 2, 65, 117, 116, 111, 0
};
struct {
// input variables
uint8_t button_on; // =1 if the button is pressed, otherwise =0
uint8_t button_next; // =1 if the button is pressed, otherwise =0
int8_t joystick_1_x; // =-100…100 x coordinate of the joystick position
int8_t joystick_1_y; // =-100…100 y coordinate of the joystick position
uint8_t rgb_1_r; // =0…255 red color value
uint8_t rgb_1_g; // =0…255 Green color value
uint8_t rgb_1_b; // =0…255 Blue color value
uint8_t button_prev; // =1 if the button is pressed, otherwise =0
uint8_t button_next_pal; // =1 if the button is pressed, otherwise =0
uint8_t button_prev_pal; // =1 if the button is pressed, otherwise =0
uint8_t button_auto; // =1 if the button is pressed, otherwise =0
char text_mode[51]; // =UTF8 string ending in zero
char text_pal[51]; // =UTF8 string ending in zero
uint8_t led_auto_r; // =0…255 brightness of the red indicator color
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)long lastUpdate = 0;
byte briCUR = bri;
byte briOLD = bri;
byte speedCUR = effectSpeed;
byte speedOLD = effectSpeed;
byte colCUR {col[0], col[1], col[2], 0};
byte colOLD {col[0], col[1], col[2], 0};
bool needUpdate = false;
uint8_t button_auto_old = 0;
uint8_t button_on_old = 0;
uint8_t button_next_old = 0;
uint8_t button_prev_old = 0;
uint8_t button_next_pal_old = 0;
uint8_t button_prev_pal_old = 0;//Use userVar0 and userVar1 (API calls &U0=,&U1=, uint16_t)
//gets called once at boot. Do all initialization that doesn’t depend on network here
void userSetup() {
RemoteXY_Init ();
RemoteXY.rgb_1_r = col[0]; RemoteXY.rgb_1_g = col[1]; RemoteXY.rgb_1_b = col[2];
}
//gets called every time WiFi is (re-)connected. Initialize own network interfaces here
void userConnected() {
}void userLoop() {
if (millis() - lastUpdate < 50) return;
lastUpdate = millis();yield();
RemoteXY_Handler ();
if (RemoteXY.connect_flag==0) return;briCUR = (RemoteXY.joystick_1_y + 104) * 1.25; //Bright 5…255
speedCUR = (RemoteXY.joystick_1_x + 104) * 1.25; //Speed 5…255
if (briCUR != briOLD) bri = briCUR; briOLD = briCUR; colorUpdated(2);
if (speedCUR != speedOLD) effectSpeed = speedCUR; speedOLD = speedCUR; colorUpdated(2);colCUR[0] = RemoteXY.rgb_1_r; colCUR[1] = RemoteXY.rgb_1_g; colCUR[2] = RemoteXY.rgb_1_b; //Color wheel
if (colCUR[0] != colOLD[0] || colCUR[1] != colOLD[1] || colCUR[2] != colOLD[2]) {
colOLD[0] = colCUR[0]; colOLD[1] = colCUR[1]; colOLD[2] = colCUR[2];
col[0] = colCUR[0]; col[1] = colCUR[1]; col[2] = colCUR[2];
effectPalette = 0; colorUpdated(2);
}
if (RemoteXY.button_on == 1 && button_on_old == 0) toggleOnOff(); //On-off
button_on_old = RemoteXY.button_on;if (RemoteXY.button_auto == 1 && button_auto_old == 0) presetCyclingEnabled = !presetCyclingEnabled; //presetCyclingEnabled On-off
button_auto_old = RemoteXY.button_auto;
RemoteXY.led_auto_r = presetCyclingEnabled * 255;
if (presetCyclingEnabled) {strcpy (RemoteXY.text_mode, “”); strcpy (RemoteXY.text_pal, “”);}needUpdate = false;
if (RemoteXY.button_next == 1 && button_next_old == 0) needUpdate = true;
if (RemoteXY.button_prev == 1 && button_prev_old == 0) needUpdate = true;
if (RemoteXY.button_next_pal == 1 && button_next_pal_old == 0) needUpdate = true;
if (RemoteXY.button_prev_pal == 1 && button_prev_pal_old == 0) needUpdate = true;
button_next_old = RemoteXY.button_next;
button_prev_old = RemoteXY.button_prev;
button_next_pal_old = RemoteXY.button_next_pal;
button_prev_pal_old = RemoteXY.button_prev_pal;if (!needUpdate) return;
presetCyclingEnabled = false;
if (RemoteXY.button_next == 1) effectCurrent++; //Next effect
if (RemoteXY.button_prev == 1) effectCurrent–; //Prev effect
if (RemoteXY.button_next_pal == 1) effectPalette++; //Next pallete
if (RemoteXY.button_prev_pal == 1) effectPalette–; //Prev pallete
if (effectCurrent == MODE_COUNT) effectCurrent = 1;
else if (effectCurrent < 1) effectCurrent = MODE_COUNT-1;
if (effectPalette == 51) effectPalette = 1;
else if (effectPalette < 1) effectPalette = 50;
colorUpdated(2);uint8_t qComma = 0;
bool insideQuotes = false;
char singleJsonSymbol;
uint8_t printedChars = 0;
char textMode[50] = “”;
char textPal[50] = “”;for (size_t i = 1; i < strlen_P(JSON_mode_names)-1; i++) { // Find the mode name in JSON
singleJsonSymbol = pgm_read_byte_near(JSON_mode_names + i);
switch (singleJsonSymbol) {
case ‘"’: insideQuotes = !insideQuotes; break;
case ‘,’: qComma++;
default:
if (!insideQuotes || (qComma != effectCurrent)) break;
textMode[printedChars] = singleJsonSymbol;
printedChars++;
}
if (qComma > effectCurrent) break;
}
strcpy (RemoteXY.text_mode, textMode);qComma = 0;
insideQuotes = false;
printedChars = 0;
for (size_t i = 1; i < strlen_P(JSON_palette_names)-1; i++) { // Find the palette name in JSON.
singleJsonSymbol = pgm_read_byte_near(JSON_palette_names + i);
switch (singleJsonSymbol) {
case ‘"’: insideQuotes = !insideQuotes; break;
case ‘,’: qComma++;
default:
if (!insideQuotes || (qComma != effectPalette)) break;
textPal[printedChars] = singleJsonSymbol;
printedChars++;
}
if (qComma > effectPalette) break;
}
strcpy (RemoteXY.text_pal, textPal);
}
Couldn’t upload the ino file (the limit for a new user)
I’m just starting to learn Arduino, so I’ll be grateful for the criticism/edits.
With respect!