Merge remote-tracking branch 'origin/segment-api' into audioreactive-prototype
This commit is contained in:
commit
72770e5809
@ -26,15 +26,10 @@ private:
|
||||
bool HomeAssistantDiscovery = false; // Publish Home Assistant Device Information
|
||||
|
||||
// set the default pins based on the architecture, these get overridden by Usermod menu settings
|
||||
#ifdef ARDUINO_ARCH_ESP32 // ESP32 boards
|
||||
#define HW_PIN_SCL 22
|
||||
#define HW_PIN_SDA 21
|
||||
#else // ESP8266 boards
|
||||
#define HW_PIN_SCL 5
|
||||
#define HW_PIN_SDA 4
|
||||
#ifdef ESP8266
|
||||
//uint8_t RST_PIN = 16; // Uncoment for Heltec WiFi-Kit-8
|
||||
#endif
|
||||
int8_t ioPin[2] = {HW_PIN_SCL, HW_PIN_SDA}; // I2C pins: SCL, SDA...defaults to Arch hardware pins but overridden at setup()
|
||||
int8_t ioPin[2] = {i2c_scl, i2c_sda}; // I2C pins: SCL, SDA...defaults to Arch hardware pins but overridden at setup()
|
||||
bool initDone = false;
|
||||
|
||||
// BME280 sensor settings
|
||||
@ -177,7 +172,7 @@ private:
|
||||
public:
|
||||
void setup()
|
||||
{
|
||||
bool HW_Pins_Used = (ioPin[0]==HW_PIN_SCL && ioPin[1]==HW_PIN_SDA); // note whether architecture-based hardware SCL/SDA pins used
|
||||
bool HW_Pins_Used = (ioPin[0]==i2c_scl && ioPin[1]==i2c_sda); // note whether architecture-based hardware SCL/SDA pins used
|
||||
PinOwner po = PinOwner::UM_BME280; // defaults to being pinowner for SCL/SDA pins
|
||||
PinManagerPinType pins[2] = { { ioPin[0], true }, { ioPin[1], true } }; // allocate pins
|
||||
if (HW_Pins_Used) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
@ -444,7 +439,7 @@ public:
|
||||
for (byte i=0; i<2; i++) if (ioPin[i] != newPin[i]) { pinsChanged = true; break; } // check if any pins changed
|
||||
if (pinsChanged) { //if pins changed, deallocate old pins and allocate new ones
|
||||
PinOwner po = PinOwner::UM_BME280;
|
||||
if (ioPin[0]==HW_PIN_SCL && ioPin[1]==HW_PIN_SDA) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
if (ioPin[0]==i2c_scl && ioPin[1]==i2c_sda) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
pinManager.deallocateMultiplePins((const uint8_t *)ioPin, 2, po); // deallocate pins
|
||||
for (byte i=0; i<2; i++) ioPin[i] = newPin[i];
|
||||
setup();
|
||||
|
@ -3,14 +3,6 @@
|
||||
#include "src/dependencies/time/DS1307RTC.h"
|
||||
#include "wled.h"
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#define HW_PIN_SCL 22
|
||||
#define HW_PIN_SDA 21
|
||||
#else
|
||||
#define HW_PIN_SCL 5
|
||||
#define HW_PIN_SDA 4
|
||||
#endif
|
||||
|
||||
//Connect DS1307 to standard I2C pins (ESP32: GPIO 21 (SDA)/GPIO 22 (SCL))
|
||||
|
||||
class RTCUsermod : public Usermod {
|
||||
@ -20,7 +12,7 @@ class RTCUsermod : public Usermod {
|
||||
public:
|
||||
|
||||
void setup() {
|
||||
PinManagerPinType pins[2] = { { HW_PIN_SCL, true }, { HW_PIN_SDA, true } };
|
||||
PinManagerPinType pins[2] = { { i2c_scl, true }, { i2c_sda, true } };
|
||||
if (!pinManager.allocateMultiplePins(pins, 2, PinOwner::HW_I2C)) { disabled = true; return; }
|
||||
RTC.begin();
|
||||
time_t rtcTime = RTC.get();
|
||||
@ -45,13 +37,13 @@ class RTCUsermod : public Usermod {
|
||||
* It will be called by WLED when settings are actually saved (for example, LED settings are saved)
|
||||
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
|
||||
*/
|
||||
void addToConfig(JsonObject& root)
|
||||
{
|
||||
JsonObject top = root.createNestedObject("RTC");
|
||||
JsonArray pins = top.createNestedArray("pin");
|
||||
pins.add(HW_PIN_SCL);
|
||||
pins.add(HW_PIN_SDA);
|
||||
}
|
||||
// void addToConfig(JsonObject& root)
|
||||
// {
|
||||
// JsonObject top = root.createNestedObject("RTC");
|
||||
// JsonArray pins = top.createNestedArray("pin");
|
||||
// pins.add(i2c_scl);
|
||||
// pins.add(i2c_sda);
|
||||
// }
|
||||
|
||||
uint16_t getId()
|
||||
{
|
||||
|
@ -21,14 +21,6 @@
|
||||
#include <Wire.h>
|
||||
#include <VL53L0X.h>
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#define HW_PIN_SCL 22
|
||||
#define HW_PIN_SDA 21
|
||||
#else
|
||||
#define HW_PIN_SCL 5
|
||||
#define HW_PIN_SDA 4
|
||||
#endif
|
||||
|
||||
#ifndef VL53L0X_MAX_RANGE_MM
|
||||
#define VL53L0X_MAX_RANGE_MM 230 // max height in millimiters to react for motions
|
||||
#endif
|
||||
@ -59,7 +51,7 @@ class UsermodVL53L0XGestures : public Usermod {
|
||||
public:
|
||||
|
||||
void setup() {
|
||||
PinManagerPinType pins[2] = { { HW_PIN_SCL, true }, { HW_PIN_SDA, true } };
|
||||
PinManagerPinType pins[2] = { { i2c_scl, true }, { i2c_sda, true } };
|
||||
if (!pinManager.allocateMultiplePins(pins, 2, PinOwner::HW_I2C)) { enabled = false; return; }
|
||||
Wire.begin();
|
||||
|
||||
@ -127,13 +119,13 @@ class UsermodVL53L0XGestures : public Usermod {
|
||||
* It will be called by WLED when settings are actually saved (for example, LED settings are saved)
|
||||
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
|
||||
*/
|
||||
void addToConfig(JsonObject& root)
|
||||
{
|
||||
JsonObject top = root.createNestedObject("VL53L0x");
|
||||
JsonArray pins = top.createNestedArray("pin");
|
||||
pins.add(HW_PIN_SCL);
|
||||
pins.add(HW_PIN_SDA);
|
||||
}
|
||||
// void addToConfig(JsonObject& root)
|
||||
// {
|
||||
// JsonObject top = root.createNestedObject("VL53L0x");
|
||||
// JsonArray pins = top.createNestedArray("pin");
|
||||
// pins.add(i2c_scl);
|
||||
// pins.add(i2c_sda);
|
||||
// }
|
||||
|
||||
/*
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
|
@ -42,14 +42,6 @@
|
||||
#include "Wire.h"
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#define HW_PIN_SCL 22
|
||||
#define HW_PIN_SDA 21
|
||||
#else
|
||||
#define HW_PIN_SCL 5
|
||||
#define HW_PIN_SDA 4
|
||||
#endif
|
||||
|
||||
// ================================================================
|
||||
// === INTERRUPT DETECTION ROUTINE ===
|
||||
// ================================================================
|
||||
@ -93,7 +85,7 @@ class MPU6050Driver : public Usermod {
|
||||
* setup() is called once at boot. WiFi is not yet connected at this point.
|
||||
*/
|
||||
void setup() {
|
||||
PinManagerPinType pins[2] = { { HW_PIN_SCL, true }, { HW_PIN_SDA, true } };
|
||||
PinManagerPinType pins[2] = { { i2c_scl, true }, { i2c_sda, true } };
|
||||
if (!pinManager.allocateMultiplePins(pins, 2, PinOwner::HW_I2C)) { enabled = false; return; }
|
||||
// join I2C bus (I2Cdev library doesn't do this automatically)
|
||||
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
|
||||
@ -258,20 +250,20 @@ class MPU6050Driver : public Usermod {
|
||||
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void addToJsonState(JsonObject& root)
|
||||
{
|
||||
//void addToJsonState(JsonObject& root)
|
||||
//{
|
||||
//root["user0"] = userVar0;
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
|
||||
* Values in the state object may be modified by connected clients
|
||||
*/
|
||||
void readFromJsonState(JsonObject& root)
|
||||
{
|
||||
//void readFromJsonState(JsonObject& root)
|
||||
//{
|
||||
//if (root["bri"] == 255) DEBUG_PRINTLN(F("Don't burn down your garage!"));
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
@ -279,13 +271,13 @@ class MPU6050Driver : public Usermod {
|
||||
* It will be called by WLED when settings are actually saved (for example, LED settings are saved)
|
||||
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
|
||||
*/
|
||||
void addToConfig(JsonObject& root)
|
||||
{
|
||||
JsonObject top = root.createNestedObject("MPU6050_IMU");
|
||||
JsonArray pins = top.createNestedArray("pin");
|
||||
pins.add(HW_PIN_SCL);
|
||||
pins.add(HW_PIN_SDA);
|
||||
}
|
||||
// void addToConfig(JsonObject& root)
|
||||
// {
|
||||
// JsonObject top = root.createNestedObject("MPU6050_IMU");
|
||||
// JsonArray pins = top.createNestedArray("pin");
|
||||
// pins.add(HW_PIN_SCL);
|
||||
// pins.add(HW_PIN_SDA);
|
||||
// }
|
||||
|
||||
/*
|
||||
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
|
||||
|
@ -24,54 +24,31 @@
|
||||
//
|
||||
|
||||
//The SCL and SDA pins are defined here.
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#define HW_PIN_SCL 22
|
||||
#define HW_PIN_SDA 21
|
||||
#define HW_PIN_CLOCKSPI 18
|
||||
#define HW_PIN_DATASPI 23
|
||||
#ifndef FLD_PIN_SCL
|
||||
#define FLD_PIN_SCL 22
|
||||
#endif
|
||||
#ifndef FLD_PIN_SDA
|
||||
#define FLD_PIN_SDA 21
|
||||
#endif
|
||||
#ifndef FLD_PIN_CLOCKSPI
|
||||
#define FLD_PIN_CLOCKSPI 18
|
||||
#endif
|
||||
#ifndef FLD_PIN_SCL
|
||||
#define FLD_PIN_SCL i2c_scl
|
||||
#endif
|
||||
#ifndef FLD_PIN_SDA
|
||||
#define FLD_PIN_SDA i2c_sda
|
||||
#endif
|
||||
#ifndef FLD_PIN_CLOCKSPI
|
||||
#define FLD_PIN_CLOCKSPI spi_sclk
|
||||
#endif
|
||||
#ifndef FLD_PIN_DATASPI
|
||||
#define FLD_PIN_DATASPI 23
|
||||
#endif
|
||||
#define FLD_PIN_DATASPI spi_mosi
|
||||
#endif
|
||||
#ifndef FLD_PIN_CS
|
||||
#define FLD_PIN_CS spi_cs
|
||||
#endif
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#ifndef FLD_PIN_DC
|
||||
#define FLD_PIN_DC 19
|
||||
#endif
|
||||
#ifndef FLD_PIN_CS
|
||||
#define FLD_PIN_CS 5
|
||||
#endif
|
||||
#ifndef FLD_PIN_RESET
|
||||
#define FLD_PIN_RESET 26
|
||||
#endif
|
||||
#else
|
||||
#define HW_PIN_SCL 5
|
||||
#define HW_PIN_SDA 4
|
||||
#define HW_PIN_CLOCKSPI 14
|
||||
#define HW_PIN_DATASPI 13
|
||||
#ifndef FLD_PIN_SCL
|
||||
#define FLD_PIN_SCL 5
|
||||
#endif
|
||||
#ifndef FLD_PIN_SDA
|
||||
#define FLD_PIN_SDA 4
|
||||
#endif
|
||||
#ifndef FLD_PIN_CLOCKSPI
|
||||
#define FLD_PIN_CLOCKSPI 14
|
||||
#endif
|
||||
#ifndef FLD_PIN_DATASPI
|
||||
#define FLD_PIN_DATASPI 13
|
||||
#endif
|
||||
#ifndef FLD_PIN_DC
|
||||
#define FLD_PIN_DC 12
|
||||
#endif
|
||||
#ifndef FLD_PIN_CS
|
||||
#define FLD_PIN_CS 15
|
||||
#endif
|
||||
#ifndef FLD_PIN_RESET
|
||||
#define FLD_PIN_RESET 16
|
||||
@ -192,13 +169,14 @@ class FourLineDisplayUsermod : public Usermod {
|
||||
bool isHW;
|
||||
PinOwner po = PinOwner::UM_FourLineDisplay;
|
||||
if (type == SSD1306_SPI || type == SSD1306_SPI64) {
|
||||
isHW = (ioPin[0]==HW_PIN_CLOCKSPI && ioPin[1]==HW_PIN_DATASPI);
|
||||
isHW = (ioPin[0]==spi_sclk && ioPin[1]==spi_mosi);
|
||||
if (isHW) po = PinOwner::HW_SPI; // allow multiple allocations of HW I2C bus pins
|
||||
PinManagerPinType pins[5] = { { ioPin[0], true }, { ioPin[1], true }, { ioPin[2], true }, { ioPin[3], true }, { ioPin[4], true }};
|
||||
if (!pinManager.allocateMultiplePins(pins, 5, po)) { type=NONE; return; }
|
||||
} else {
|
||||
isHW = (ioPin[0]==HW_PIN_SCL && ioPin[1]==HW_PIN_SDA);
|
||||
isHW = (ioPin[0]==i2c_scl && ioPin[1]==i2c_sda);
|
||||
if (isHW) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
PinManagerPinType pins[2] = { { ioPin[0], true }, { ioPin[1], true } };
|
||||
if (ioPin[0]==HW_PIN_SCL && ioPin[1]==HW_PIN_SDA) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
if (!pinManager.allocateMultiplePins(pins, 2, po)) { type=NONE; return; }
|
||||
}
|
||||
|
||||
@ -718,8 +696,14 @@ class FourLineDisplayUsermod : public Usermod {
|
||||
if (pinsChanged || type!=newType) {
|
||||
if (type != NONE) delete u8x8;
|
||||
PinOwner po = PinOwner::UM_FourLineDisplay;
|
||||
if (ioPin[0]==HW_PIN_SCL && ioPin[1]==HW_PIN_SDA) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
pinManager.deallocateMultiplePins((const uint8_t *)ioPin, (type == SSD1306_SPI || type == SSD1306_SPI64) ? 5 : 2, po);
|
||||
bool isSPI = (type == SSD1306_SPI || type == SSD1306_SPI64);
|
||||
if (isSPI) {
|
||||
if (ioPin[0]==spi_sclk && ioPin[1]==spi_mosi) po = PinOwner::HW_SPI; // allow multiple allocations of HW SPI bus pins
|
||||
pinManager.deallocateMultiplePins((const uint8_t *)ioPin, 5, po);
|
||||
} else {
|
||||
if (ioPin[0]==i2c_scl && ioPin[1]==i2c_sda) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
pinManager.deallocateMultiplePins((const uint8_t *)ioPin, 2, po);
|
||||
}
|
||||
for (byte i=0; i<5; i++) ioPin[i] = newPin[i];
|
||||
if (ioPin[0]<0 || ioPin[1]<0) { // data & clock must be > -1
|
||||
type = NONE;
|
||||
|
@ -26,19 +26,19 @@
|
||||
|
||||
//The SCL and SDA pins are defined here.
|
||||
#ifndef FLD_PIN_SCL
|
||||
#define FLD_PIN_SCL HW_PIN_SCL
|
||||
#define FLD_PIN_SCL i2c_scl
|
||||
#endif
|
||||
#ifndef FLD_PIN_SDA
|
||||
#define FLD_PIN_SDA HW_PIN_SDA
|
||||
#define FLD_PIN_SDA i2c_sda
|
||||
#endif
|
||||
#ifndef FLD_PIN_CLOCKSPI
|
||||
#define FLD_PIN_CLOCKSPI HW_PIN_CLOCKSPI
|
||||
#define FLD_PIN_CLOCKSPI spi_sclk
|
||||
#endif
|
||||
#ifndef FLD_PIN_DATASPI
|
||||
#define FLD_PIN_DATASPI HW_PIN_DATASPI
|
||||
#define FLD_PIN_DATASPI spi_mosi
|
||||
#endif
|
||||
#ifndef FLD_PIN_CS
|
||||
#define FLD_PIN_CS HW_PIN_CSSPI
|
||||
#define FLD_PIN_CS spi_cs
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
@ -195,14 +195,14 @@ class FourLineDisplayUsermod : public Usermod {
|
||||
bool isHW, isSPI = (type == SSD1306_SPI || type == SSD1306_SPI64);
|
||||
PinOwner po = PinOwner::UM_FourLineDisplay;
|
||||
if (isSPI) {
|
||||
isHW = (ioPin[0]==HW_PIN_CLOCKSPI && ioPin[1]==HW_PIN_DATASPI);
|
||||
isHW = (ioPin[0]==spi_sclk && ioPin[1]==spi_mosi && ioPin[2]==spi_cs);
|
||||
if (isHW) po = PinOwner::HW_SPI; // allow multiple allocations of HW I2C bus pins
|
||||
PinManagerPinType pins[5] = { { ioPin[0], true }, { ioPin[1], true }, { ioPin[2], true }, { ioPin[3], true }, { ioPin[4], true }};
|
||||
if (ioPin[0]==HW_PIN_CLOCKSPI && ioPin[1]==HW_PIN_DATASPI && ioPin[2]==HW_PIN_CSSPI) po = PinOwner::HW_SPI; // allow multiple allocations of HW SPI bus pins
|
||||
if (!pinManager.allocateMultiplePins(pins, 5, po)) { type=NONE; return; }
|
||||
} else {
|
||||
isHW = (ioPin[0]==HW_PIN_SCL && ioPin[1]==HW_PIN_SDA);
|
||||
isHW = (ioPin[0]==i2c_scl && ioPin[1]==i2c_sda);
|
||||
if (isHW) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
PinManagerPinType pins[2] = { { ioPin[0], true }, { ioPin[1], true } };
|
||||
if (ioPin[0]==HW_PIN_SCL && ioPin[1]==HW_PIN_SDA) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
if (!pinManager.allocateMultiplePins(pins, 2, po)) { type=NONE; return; }
|
||||
}
|
||||
|
||||
@ -1107,8 +1107,8 @@ class FourLineDisplayUsermod : public Usermod {
|
||||
if (type != NONE) delete u8x8;
|
||||
PinOwner po = PinOwner::UM_FourLineDisplay;
|
||||
bool isSPI = (type == SSD1306_SPI || type == SSD1306_SPI64);
|
||||
if (!isSPI && ioPin[0]==HW_PIN_SCL && ioPin[1]==HW_PIN_SDA) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
if (isSPI && ioPin[0]==HW_PIN_CLOCKSPI && ioPin[1]==HW_PIN_DATASPI && ioPin[2]==HW_PIN_CSSPI) po = PinOwner::HW_SPI; // allow multiple allocations of HW SPI bus pins
|
||||
if (!isSPI && ioPin[0]==i2c_scl && ioPin[1]==i2c_sda) po = PinOwner::HW_I2C; // allow multiple allocations of HW I2C bus pins
|
||||
if (isSPI && ioPin[0]==spi_sclk && ioPin[1]==spi_mosi && ioPin[2]==spi_cs) po = PinOwner::HW_SPI; // allow multiple allocations of HW SPI bus pins
|
||||
pinManager.deallocateMultiplePins((const uint8_t *)ioPin, isSPI ? 5 : 2, po);
|
||||
for (byte i=0; i<5; i++) ioPin[i] = newPin[i];
|
||||
if (ioPin[0]<0 || ioPin[1]<0) { // data & clock must be > -1
|
||||
|
118
wled00/FX.cpp
118
wled00/FX.cpp
@ -1241,7 +1241,10 @@ uint16_t mode_rain()
|
||||
if (SEGENV.step > SPEED_FORMULA_L) {
|
||||
SEGENV.step = 1;
|
||||
if (strip.isMatrix) {
|
||||
uint32_t ctemp[width];
|
||||
for (int i = 0; i<width; i++) ctemp[i] = SEGMENT.getPixelColorXY(i, height-1);
|
||||
SEGMENT.move(6,1); // move all pixels down
|
||||
for (int i = 0; i<width; i++) SEGMENT.setPixelColorXY(i, 0, ctemp[i]); // wrap around
|
||||
SEGENV.aux0 = (SEGENV.aux0 % width) + (SEGENV.aux0 / width + 1) * width;
|
||||
SEGENV.aux1 = (SEGENV.aux1 % width) + (SEGENV.aux1 / width + 1) * width;
|
||||
} else {
|
||||
@ -4533,14 +4536,14 @@ uint16_t mode_wavesins(void) {
|
||||
|
||||
for (int i = 0; i < SEGLEN; i++) {
|
||||
uint8_t bri = sin8(millis()/4 + i * SEGMENT.intensity);
|
||||
uint8_t index = beatsin8(SEGMENT.speed, SEGMENT.custom1, SEGMENT.custom1+SEGMENT.custom2, 0, i * SEGMENT.custom3);
|
||||
uint8_t index = beatsin8(SEGMENT.speed, SEGMENT.custom1, SEGMENT.custom1+SEGMENT.custom2, 0, i * (SEGMENT.custom3<<3)); // custom3 is reduced resolution slider
|
||||
//SEGMENT.setPixelColor(i, ColorFromPalette(SEGPALETTE, index, bri, LINEARBLEND));
|
||||
SEGMENT.setPixelColor(i, SEGMENT.color_from_palette(index, false, PALETTE_SOLID_WRAP, 0, bri));
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
} // mode_waveins()
|
||||
static const char _data_FX_MODE_WAVESINS[] PROGMEM = "Wavesins@Speed,Brightness variation,Starting Color,Range of Colors,Color variation;!;!;1d";
|
||||
static const char _data_FX_MODE_WAVESINS[] PROGMEM = "Wavesins@!,Brightness variation,Starting color,Range of colors,Color variation;!;!;1d";
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
@ -4597,7 +4600,7 @@ uint16_t mode_2DBlackHole(void) { // By: Stepko https://editor.soulma
|
||||
// inner stars
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
x = beatsin8(SEGMENT.custom2>>3, cols/4, cols - 1 - cols/4, 0, ((i % 2) ? 128 : 0) + t * i);
|
||||
y = beatsin8(SEGMENT.custom3>>3, rows/4, rows - 1 - rows/4, 0, ((i % 2) ? 192 : 64) + t * i);
|
||||
y = beatsin8(SEGMENT.custom3 , rows/4, rows - 1 - rows/4, 0, ((i % 2) ? 192 : 64) + t * i);
|
||||
SEGMENT.addPixelColorXY(x, y, CHSV(i*32, 255, 255));
|
||||
}
|
||||
// central white dot
|
||||
@ -4983,15 +4986,15 @@ uint16_t mode_2DJulia(void) { // An animated Julia set
|
||||
|
||||
SEGMENT.custom1 = 128; // Make sure the location widgets are centered to start.
|
||||
SEGMENT.custom2 = 128;
|
||||
SEGMENT.custom3 = 128;
|
||||
SEGMENT.custom3 = 16;
|
||||
SEGMENT.intensity = 24;
|
||||
}
|
||||
|
||||
julias->xcen = julias->xcen + (float)(SEGMENT.custom1 - 128)/100000.;
|
||||
julias->ycen = julias->ycen + (float)(SEGMENT.custom2 - 128)/100000.;
|
||||
julias->xymag = julias->xymag + (float)(SEGMENT.custom3-128)/100000.;
|
||||
if (julias->xymag < 0.01) julias->xymag = 0.01;
|
||||
if (julias->xymag > 1.0) julias->xymag = 1.0;
|
||||
julias->xcen = julias->xcen + (float)(SEGMENT.custom1 - 128)/100000.f;
|
||||
julias->ycen = julias->ycen + (float)(SEGMENT.custom2 - 128)/100000.f;
|
||||
julias->xymag = julias->xymag + (float)((SEGMENT.custom3 - 16)<<3)/100000.f; // reduced resolution slider
|
||||
if (julias->xymag < 0.01f) julias->xymag = 0.01f;
|
||||
if (julias->xymag > 1.0f) julias->xymag = 1.0f;
|
||||
|
||||
float xmin = julias->xcen - julias->xymag;
|
||||
float xmax = julias->xcen + julias->xymag;
|
||||
@ -4999,10 +5002,10 @@ uint16_t mode_2DJulia(void) { // An animated Julia set
|
||||
float ymax = julias->ycen + julias->xymag;
|
||||
|
||||
// Whole set should be within -1.2,1.2 to -.8 to 1.
|
||||
xmin = constrain(xmin,-1.2,1.2);
|
||||
xmax = constrain(xmax,-1.2,1.2);
|
||||
ymin = constrain(ymin,-.8,1.0);
|
||||
ymax = constrain(ymax,-.8,1.0);
|
||||
xmin = constrain(xmin, -1.2f, 1.2f);
|
||||
xmax = constrain(xmax, -1.2f, 1.2f);
|
||||
ymin = constrain(ymin, -0.8f, 1.0f);
|
||||
ymax = constrain(ymax, -0.8f, 1.0f);
|
||||
|
||||
float dx; // Delta x is mapped to the matrix size.
|
||||
float dy; // Delta y is mapped to the matrix size.
|
||||
@ -5014,11 +5017,11 @@ uint16_t mode_2DJulia(void) { // An animated Julia set
|
||||
|
||||
|
||||
// Resize section on the fly for some animaton.
|
||||
reAl = -0.94299; // PixelBlaze example
|
||||
imAg = 0.3162;
|
||||
reAl = -0.94299f; // PixelBlaze example
|
||||
imAg = 0.3162f;
|
||||
|
||||
reAl += sin((float)millis()/305.)/20.;
|
||||
imAg += sin((float)millis()/405.)/20.;
|
||||
reAl += sin_t((float)millis()/305.f)/20.f;
|
||||
imAg += sin_t((float)millis()/405.f)/20.f;
|
||||
|
||||
dx = (xmax - xmin) / (cols); // Scale the delta x and y values to our matrix size.
|
||||
dy = (ymax - ymin) / (rows);
|
||||
@ -5064,7 +5067,7 @@ uint16_t mode_2DJulia(void) { // An animated Julia set
|
||||
|
||||
return FRAMETIME;
|
||||
} // mode_2DJulia()
|
||||
static const char _data_FX_MODE_2DJULIA[] PROGMEM = "Julia@,Max iterations per pixel,X center,Y center,Area size;;!;2d";
|
||||
static const char _data_FX_MODE_2DJULIA[] PROGMEM = "Julia@,Max iterations per pixel,X center,Y center,Area size;;!;ix=24,c1=128,c2=128,c3=16,2d";
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
@ -5113,7 +5116,7 @@ uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams.
|
||||
|
||||
CRGB spawnColor;
|
||||
CRGB trailColor;
|
||||
if (SEGMENT.custom2 > 128) {
|
||||
if (SEGMENT.check1) {
|
||||
spawnColor = SEGCOLOR(0);
|
||||
trailColor = SEGCOLOR(1);
|
||||
} else {
|
||||
@ -5154,7 +5157,7 @@ uint16_t mode_2Dmatrix(void) { // Matrix2D. By Jeremy Williams.
|
||||
|
||||
return FRAMETIME;
|
||||
} // mode_2Dmatrix()
|
||||
static const char _data_FX_MODE_2DMATRIX[] PROGMEM = "Matrix@Falling speed,Spawning rate,Trail,Custom color;Spawn,Trail;;pal=0,2d";
|
||||
static const char _data_FX_MODE_2DMATRIX[] PROGMEM = "Matrix@Falling speed,Spawning rate,Trail,,,Custom color,,;Spawn,Trail;;pal=0,2d";
|
||||
|
||||
|
||||
/////////////////////////
|
||||
@ -5415,7 +5418,7 @@ uint16_t mode_2Dsquaredswirl(void) { // By: Mark Kriegsman. https://g
|
||||
|
||||
SEGMENT.fadeToBlackBy(24);
|
||||
|
||||
uint8_t blurAmount = SEGMENT.custom3>>4;
|
||||
uint8_t blurAmount = SEGMENT.custom3>>1; // reduced resolution slider
|
||||
SEGMENT.blur(blurAmount);
|
||||
|
||||
// Use two out-of-sync sine waves
|
||||
@ -5670,7 +5673,7 @@ uint16_t mode_2Dghostrider(void) {
|
||||
const size_t maxLighters = min(cols + rows, LIGHTERS_AM);
|
||||
|
||||
if (SEGENV.call == 0) SEGMENT.setUpLeds();
|
||||
if (SEGENV.call == 0 || SEGENV.aux0 != cols || SEGENV.aux1 != rows) {
|
||||
if (SEGENV.aux0 != cols || SEGENV.aux1 != rows) {
|
||||
SEGENV.aux0 = cols;
|
||||
SEGENV.aux1 = rows;
|
||||
SEGMENT.fill(BLACK);
|
||||
@ -5755,8 +5758,8 @@ uint16_t mode_2Dfloatingblobs(void) {
|
||||
blob_t *blob = reinterpret_cast<blob_t*>(SEGENV.data);
|
||||
|
||||
if (SEGENV.call == 0) SEGMENT.setUpLeds();
|
||||
if (SEGENV.call == 0 || SEGENV.aux0 != cols || SEGENV.aux1 != rows) {
|
||||
SEGENV.aux0 = cols;
|
||||
if (SEGENV.aux0 != cols || SEGENV.aux1 != rows) {
|
||||
SEGENV.aux0 = cols; // re-initialise if virtual size changes
|
||||
SEGENV.aux1 = rows;
|
||||
SEGMENT.fill(BLACK);
|
||||
for (size_t i = 0; i < MAX_BLOBS; i++) {
|
||||
@ -5792,7 +5795,7 @@ uint16_t mode_2Dfloatingblobs(void) {
|
||||
}
|
||||
}
|
||||
uint32_t c = SEGMENT.color_from_palette(blob->color[i], false, false, 0);
|
||||
if (blob->r[i] > 1.f) SEGMENT.fill_circle(blob->y[i], blob->x[i], blob->r[i], c);
|
||||
if (blob->r[i] > 1.f) SEGMENT.fill_circle(blob->y[i], blob->x[i], roundf(blob->r[i]), c);
|
||||
else SEGMENT.setPixelColorXY(blob->y[i], blob->x[i], c);
|
||||
// move x
|
||||
if (blob->x[i] + blob->r[i] >= cols - 1) blob->x[i] += (blob->sX[i] * ((cols - 1 - blob->x[i]) / blob->r[i] + 0.005f));
|
||||
@ -5804,21 +5807,21 @@ uint16_t mode_2Dfloatingblobs(void) {
|
||||
else blob->y[i] += blob->sY[i];
|
||||
// bounce x
|
||||
if (blob->x[i] < 0.01f) {
|
||||
blob->sX[i] = (float) random8(3, cols) / (256 - SEGMENT.speed);
|
||||
blob->sX[i] = (float)random8(3, cols) / (256 - SEGMENT.speed);
|
||||
blob->x[i] = 0.01f;
|
||||
} else if (blob->x[i] > cols - 1.01f) {
|
||||
blob->sX[i] = (float) random8(3, cols) / (256 - SEGMENT.speed);
|
||||
} else if (blob->x[i] > (float)cols - 1.01f) {
|
||||
blob->sX[i] = (float)random8(3, cols) / (256 - SEGMENT.speed);
|
||||
blob->sX[i] = -blob->sX[i];
|
||||
blob->x[i] = cols - 1.01f;
|
||||
blob->x[i] = (float)cols - 1.01f;
|
||||
}
|
||||
// bounce y
|
||||
if (blob->y[i] < 0.01f) {
|
||||
blob->sY[i] = (float) random8(3, rows) / (256 - SEGMENT.speed);
|
||||
blob->sY[i] = (float)random8(3, rows) / (256 - SEGMENT.speed);
|
||||
blob->y[i] = 0.01f;
|
||||
} else if (blob->y[i] > rows - 1.01f) {
|
||||
blob->sY[i] = (float) random8(3, rows) / (256 - SEGMENT.speed);
|
||||
} else if (blob->y[i] > (float)rows - 1.01f) {
|
||||
blob->sY[i] = (float)random8(3, rows) / (256 - SEGMENT.speed);
|
||||
blob->sY[i] = -blob->sY[i];
|
||||
blob->y[i] = rows - 1.01f;
|
||||
blob->y[i] = (float)rows - 1.01f;
|
||||
}
|
||||
}
|
||||
SEGMENT.blur(SEGMENT.custom1>>2);
|
||||
@ -5828,7 +5831,7 @@ uint16_t mode_2Dfloatingblobs(void) {
|
||||
return FRAMETIME;
|
||||
}
|
||||
#undef MAX_BLOBS
|
||||
static const char _data_FX_MODE_2DBLOBS[] PROGMEM = "Blobs@!,# blobs,Blur;!,!,!;!;c1=8,2d";
|
||||
static const char _data_FX_MODE_2DBLOBS[] PROGMEM = "Blobs@!,# blobs,Blur;!,!,;!;c1=8,2d";
|
||||
|
||||
|
||||
////////////////////////////
|
||||
@ -5887,7 +5890,7 @@ uint16_t mode_2Dscrollingtext(void) {
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
static const char _data_FX_MODE_2DSCROLLTEXT[] PROGMEM = "Scrolling Text@!,Y Offset,Trail,Font size;!,!;!;ix=128,c1=0,rev=0,mi=0,rY=0,mY=0,2d";
|
||||
static const char _data_FX_MODE_2DSCROLLTEXT[] PROGMEM = "Scrolling Text@!,Y Offset,Trail,Font size;!,!;!;ix=96,c1=0,rev=0,mi=0,rY=0,mY=0,2d";
|
||||
|
||||
|
||||
////////////////////////////
|
||||
@ -5900,8 +5903,8 @@ uint16_t mode_2Ddriftrose(void) {
|
||||
const uint16_t cols = SEGMENT.virtualWidth();
|
||||
const uint16_t rows = SEGMENT.virtualHeight();
|
||||
|
||||
const float CX = cols/2.f - .5f;
|
||||
const float CY = rows/2.f - .5f;
|
||||
const float CX = (cols-cols%2)/2.f - .5f;
|
||||
const float CY = (rows-rows%2)/2.f - .5f;
|
||||
const float L = min(cols, rows) / 2.f;
|
||||
|
||||
if (SEGENV.call == 0) {
|
||||
@ -5983,12 +5986,12 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
|
||||
|
||||
if (SEGENV.call == 0) {
|
||||
SEGENV.aux0 = 255;
|
||||
SEGMENT.custom2 = *binNum;
|
||||
SEGMENT.custom3 = *maxVol * 2;
|
||||
SEGMENT.custom1 = *binNum;
|
||||
SEGMENT.custom2 = *maxVol * 2;
|
||||
}
|
||||
|
||||
*binNum = SEGMENT.custom2; // Select a bin.
|
||||
*maxVol = SEGMENT.custom3/2; // Our volume comparator.
|
||||
*binNum = SEGMENT.custom1; // Select a bin.
|
||||
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
||||
|
||||
SEGMENT.fade_out(240); // Lower frame rate means less effective fading than FastLED
|
||||
SEGMENT.fade_out(240);
|
||||
@ -6029,7 +6032,7 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
|
||||
|
||||
return FRAMETIME;
|
||||
} // mode_ripplepeak()
|
||||
static const char _data_FX_MODE_RIPPLEPEAK[] PROGMEM = "Ripple Peak@Fade rate,Max # of ripples,,Select bin,Volume (minimum);!,!;!;c3=0,mp12=0,ssim=0,1d,vo"; // Pixel, Beatsin
|
||||
static const char _data_FX_MODE_RIPPLEPEAK[] PROGMEM = "Ripple Peak@Fade rate,Max # of ripples,Select bin,Volume (minimum);!,!;!;c2=0,mp12=0,ssim=0,1d,vo"; // Pixel, Beatsin
|
||||
|
||||
|
||||
#ifndef WLED_DISABLE_2D
|
||||
@ -6532,12 +6535,12 @@ uint16_t mode_puddlepeak(void) { // Puddlepeak. By Andrew Tuline.
|
||||
float volumeSmth = *(float*) um_data->u_data[0];
|
||||
|
||||
if (SEGENV.call == 0) {
|
||||
SEGMENT.custom2 = *binNum;
|
||||
SEGMENT.custom3 = *maxVol * 2;
|
||||
SEGMENT.custom1 = *binNum;
|
||||
SEGMENT.custom2 = *maxVol * 2;
|
||||
}
|
||||
|
||||
*binNum = SEGMENT.custom2; // Select a bin.
|
||||
*maxVol = SEGMENT.custom3/4; // Our volume comparator.
|
||||
*binNum = SEGMENT.custom1; // Select a bin.
|
||||
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
||||
|
||||
SEGMENT.fade_out(fadeVal);
|
||||
|
||||
@ -6552,7 +6555,7 @@ uint16_t mode_puddlepeak(void) { // Puddlepeak. By Andrew Tuline.
|
||||
|
||||
return FRAMETIME;
|
||||
} // mode_puddlepeak()
|
||||
static const char _data_FX_MODE_PUDDLEPEAK[] PROGMEM = "Puddlepeak@Fade rate,Puddle size,,Select bin,Volume (minimum);!,!;!;c3=0,mp12=0,ssim=0,1d,vo"; // Pixels, Beatsin
|
||||
static const char _data_FX_MODE_PUDDLEPEAK[] PROGMEM = "Puddlepeak@Fade rate,Puddle size,Select bin,Volume (minimum);!,!;!;c2=0,mp12=0,ssim=0,1d,vo"; // Pixels, Beatsin
|
||||
|
||||
|
||||
//////////////////////
|
||||
@ -6746,7 +6749,7 @@ uint16_t mode_freqmatrix(void) { // Freqmatrix. By Andreas Plesch
|
||||
if(SEGENV.aux0 != secondHand) {
|
||||
SEGENV.aux0 = secondHand;
|
||||
|
||||
uint8_t sensitivity = map(SEGMENT.custom3, 0, 255, 1, 10);
|
||||
uint8_t sensitivity = map(SEGMENT.custom3, 0, 31, 1, 10); // reduced resolution slider
|
||||
int pixVal = (volumeSmth * SEGMENT.intensity * sensitivity) / 256.0f;
|
||||
if (pixVal > 255) pixVal = 255;
|
||||
|
||||
@ -6843,10 +6846,7 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun
|
||||
if(SEGENV.aux0 != secondHand) {
|
||||
SEGENV.aux0 = secondHand;
|
||||
|
||||
//uint8_t fade = SEGMENT.custom3;
|
||||
//uint8_t fadeval;
|
||||
|
||||
float sensitivity = mapf(SEGMENT.custom3, 1, 255, 1, 10);
|
||||
float sensitivity = mapf(SEGMENT.custom3, 1, 31, 1, 10); // reduced resolution slider
|
||||
float pixVal = volumeSmth * (float)SEGMENT.intensity / 256.0f * sensitivity;
|
||||
if (pixVal > 255) pixVal = 255;
|
||||
|
||||
@ -7015,12 +7015,12 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
|
||||
SEGMENT.setUpLeds();
|
||||
SEGMENT.fill(BLACK);
|
||||
SEGENV.aux0 = 255;
|
||||
SEGMENT.custom2 = *binNum;
|
||||
SEGMENT.custom3 = *maxVol * 2;
|
||||
SEGMENT.custom1 = *binNum;
|
||||
SEGMENT.custom2 = *maxVol * 2;
|
||||
}
|
||||
|
||||
*binNum = SEGMENT.custom2; // Select a bin.
|
||||
*maxVol = SEGMENT.custom3/2; // Our volume comparator.
|
||||
*binNum = SEGMENT.custom1; // Select a bin.
|
||||
*maxVol = SEGMENT.custom2 / 2; // Our volume comparator.
|
||||
|
||||
uint8_t secondHand = micros() / (256-SEGMENT.speed)/500 + 1 % 16;
|
||||
if (SEGENV.aux0 != secondHand) { // Triggered millis timing.
|
||||
@ -7038,7 +7038,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
|
||||
|
||||
return FRAMETIME;
|
||||
} // mode_waterfall()
|
||||
static const char _data_FX_MODE_WATERFALL[] PROGMEM = "Waterfall@!,Adjust color,,Select bin, Volume (minimum);!,!;!;c3=0,mp12=2,ssim=0,1d,fr"; // Circles, Beatsin
|
||||
static const char _data_FX_MODE_WATERFALL[] PROGMEM = "Waterfall@!,Adjust color,Select bin,Volume (minimum);!,!;!;c2=0,mp12=2,ssim=0,1d,fr"; // Circles, Beatsin
|
||||
|
||||
|
||||
#ifndef WLED_DISABLE_2D
|
||||
@ -7080,7 +7080,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
|
||||
|
||||
uint32_t ledColor = BLACK;
|
||||
for (int y=0; y < barHeight; y++) {
|
||||
if (SEGMENT.custom2 > 128) //color_vertical / color bars toggle
|
||||
if (SEGMENT.check1) //color_vertical / color bars toggle
|
||||
colorIndex = map(y, 0, rows-1, 0, 255);
|
||||
|
||||
ledColor = SEGMENT.color_from_palette(colorIndex, false, PALETTE_SOLID_WRAP, 0);
|
||||
@ -7094,7 +7094,7 @@ uint16_t mode_2DGEQ(void) { // By Will Tatam. Code reduction by Ewoud Wijma.
|
||||
|
||||
return FRAMETIME;
|
||||
} // mode_2DGEQ()
|
||||
static const char _data_FX_MODE_2DGEQ[] PROGMEM = "GEQ@Fade speed,Ripple decay,# of bands,Color bars;!,,Peak Color;!;c1=255,c2=64,pal=11,ssim=0,2d,fr"; // Beatsin
|
||||
static const char _data_FX_MODE_2DGEQ[] PROGMEM = "GEQ@Fade speed,Ripple decay,# of bands,,,Color bars,,;!,,Peak Color;!;c1=255,c2=64,pal=11,ssim=0,2d,fr"; // Beatsin
|
||||
|
||||
|
||||
/////////////////////////
|
||||
|
13
wled00/FX.h
13
wled00/FX.h
@ -42,7 +42,7 @@
|
||||
#define DEFAULT_COLOR (uint32_t)0xFFAA00
|
||||
#define DEFAULT_C1 (uint8_t)128
|
||||
#define DEFAULT_C2 (uint8_t)128
|
||||
#define DEFAULT_C3 (uint8_t)128
|
||||
#define DEFAULT_C3 (uint8_t)16
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
@ -376,7 +376,13 @@ typedef struct Segment {
|
||||
uint8_t opacity;
|
||||
uint32_t colors[NUM_COLORS];
|
||||
uint8_t cct; //0==1900K, 255==10091K
|
||||
uint8_t custom1, custom2, custom3; // custom FX parameters
|
||||
uint8_t custom1, custom2; // custom FX parameters/sliders
|
||||
struct {
|
||||
uint8_t custom3 : 5; // reduced range slider (0-31)
|
||||
bool check1 : 1; // checkmark 1
|
||||
bool check2 : 1; // checkmark 2
|
||||
bool check3 : 1; // checkmark 3
|
||||
};
|
||||
uint16_t startY; // start Y coodrinate 2D (top)
|
||||
uint16_t stopY; // stop Y coordinate 2D (bottom)
|
||||
char *name;
|
||||
@ -439,6 +445,9 @@ typedef struct Segment {
|
||||
custom1(DEFAULT_C1),
|
||||
custom2(DEFAULT_C2),
|
||||
custom3(DEFAULT_C3),
|
||||
check1(false),
|
||||
check2(false),
|
||||
check3(false),
|
||||
startY(0),
|
||||
stopY(1),
|
||||
name(nullptr),
|
||||
|
@ -477,10 +477,10 @@ void Segment::drawCharacter(unsigned char chr, int16_t x, int16_t y, uint8_t w,
|
||||
if (y0 >= rows) break; // drawing off-screen
|
||||
uint8_t bits = 0;
|
||||
switch (font) {
|
||||
case 40: bits = pgm_read_byte_near(&console_font_5x8[(chr * 8) + i]); break; // 5x8 font
|
||||
case 48: bits = pgm_read_byte_near(&console_font_6x8[(chr * 8) + i]); break; // 6x8 font
|
||||
case 63: bits = pgm_read_byte_near(&console_font_7x9[(chr * 8) + i]); break; // 7x9 font
|
||||
case 60: bits = pgm_read_byte_near(&console_font_5x12[(chr * 8) + i]); break; // 5x12 font
|
||||
case 40: bits = pgm_read_byte_near(&console_font_5x8[(chr * h) + i]); break; // 5x8 font
|
||||
case 48: bits = pgm_read_byte_near(&console_font_6x8[(chr * h) + i]); break; // 6x8 font
|
||||
case 63: bits = pgm_read_byte_near(&console_font_7x9[(chr * h) + i]); break; // 7x9 font
|
||||
case 60: bits = pgm_read_byte_near(&console_font_5x12[(chr * h) + i]); break; // 5x12 font
|
||||
default: return;
|
||||
}
|
||||
for (int j = 0; j<w; j++) { // character width
|
||||
|
@ -276,7 +276,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
Wire.setPins(i2c_sda, i2c_scl); // this will fail if Wire is initilised (Wire.begin() called prior)
|
||||
#endif
|
||||
Wire.begin();
|
||||
uint8_t i2c[2] = {i2c_sda, i2c_scl};
|
||||
pinManager.deallocateMultiplePins(i2c, 2, PinOwner::HW_I2C);
|
||||
} else {
|
||||
i2c_sda = -1;
|
||||
@ -293,7 +292,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
#else
|
||||
SPI.begin(spi_sclk, (int8_t)-1, spi_mosi, spi_cs);
|
||||
#endif
|
||||
uint8_t spi[3] = { spi_mosi, spi_sclk, spi_cs };
|
||||
pinManager.deallocateMultiplePins(spi, 3, PinOwner::HW_SPI);
|
||||
} else {
|
||||
spi_mosi = -1;
|
||||
|
@ -399,22 +399,25 @@ button {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.filter {
|
||||
.filter, .option {
|
||||
background-color: var(--c-4);
|
||||
/*box-shadow: 0px 0px 6px 6px var(--c-1);*/
|
||||
border-radius: 26px;
|
||||
height: 26px;
|
||||
margin: 0 auto; /* add 4-8px if you want space at the bottom */
|
||||
padding: 8px 2px;
|
||||
padding: 4px 2px;
|
||||
position: relative;
|
||||
/*width: 260px;*/
|
||||
/*transition: opacity 1s;*/
|
||||
/*opacity: 1;*/
|
||||
z-index: 1;
|
||||
opacity: 1;
|
||||
transition: opacity 0.5s linear, height 0.5s, transform 0.5s;
|
||||
transform: scaleY(1);
|
||||
}
|
||||
|
||||
.option {
|
||||
z-index: unset;
|
||||
}
|
||||
|
||||
/* Tooltip text */
|
||||
.slider .tooltiptext {
|
||||
.slider .tooltiptext, .option .tooltiptext {
|
||||
visibility: hidden;
|
||||
background-color: var(--c-5);
|
||||
/*border: 2px solid var(--c-2);*/
|
||||
@ -436,14 +439,11 @@ button {
|
||||
opacity: 0;
|
||||
transition: opacity 0.75s;
|
||||
}
|
||||
/*
|
||||
.slider.top .tooltiptext {
|
||||
top: 100%;
|
||||
bottom: unset;
|
||||
.option .tooltiptext {
|
||||
bottom: 120%;
|
||||
}
|
||||
*/
|
||||
/* Tooltip arrow */
|
||||
.slider .tooltiptext::after {
|
||||
.slider .tooltiptext::after, .option .tooltiptext::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
@ -453,16 +453,8 @@ button {
|
||||
border-style: solid;
|
||||
border-color: var(--c-5) transparent transparent transparent;
|
||||
}
|
||||
/*
|
||||
.slider.top .tooltiptext::after {
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
top: unset;
|
||||
border-color: transparent transparent var(--c-5) transparent;
|
||||
}
|
||||
*/
|
||||
/* Show the tooltip text when you mouse over the tooltip container */
|
||||
.slider:hover .tooltiptext {
|
||||
.slider:hover .tooltiptext, .option .check:hover .tooltiptext {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
}
|
||||
@ -475,8 +467,11 @@ button {
|
||||
display: none !important;
|
||||
}
|
||||
.fade {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
visibility: hidden; /* hide it */
|
||||
opacity: 0; /* make it transparent */
|
||||
transform: scaleY(0); /* shrink content */
|
||||
height: 0px; /* force other elements to move */
|
||||
padding: 0; /* remove empty space */
|
||||
}
|
||||
|
||||
.first {
|
||||
@ -1206,18 +1201,14 @@ TD .checkmark, TD .radiomark {
|
||||
top: auto !important; /* prevent sticky */
|
||||
bottom: auto !important;
|
||||
}
|
||||
/*
|
||||
.seg:last-child {
|
||||
margin: 0;
|
||||
}
|
||||
*/
|
||||
/* checkmark labels */
|
||||
.seg .schkl {
|
||||
position: absolute;
|
||||
top: 7px;
|
||||
left: 9px;
|
||||
}
|
||||
|
||||
.filter .fchkl {
|
||||
/* checkmark labels */
|
||||
.filter .fchkl, .option .ochkl {
|
||||
display: inline-block;
|
||||
min-width: 0.7em;
|
||||
padding: 1px 4px 4px 32px;
|
||||
|
@ -200,7 +200,7 @@
|
||||
<div id="fx">
|
||||
<p class="labels hd" id="modeLabel">Effect mode</p>
|
||||
<div class="staytop fnd" id="fxFind">
|
||||
<input type="text" placeholder="Search" oninput="search(this,'fxlist')" onfocus="search(this,'fxlist')" />
|
||||
<input type="text" placeholder="Search" oninput="search(this,'fxlist')" onfocus="search(this,'fxlist');gId('filters').classList.add('fade');" onblur="gId('filters').classList.remove('fade')"/>
|
||||
<i class="icons clear-icon" onclick="clean(this);"></i>
|
||||
<i class="icons search-icon" onclick="gId('filters').classList.toggle('hide');" style="cursor:pointer;"></i>
|
||||
</div>
|
||||
@ -260,7 +260,7 @@
|
||||
<div id="slider2" class="slider hide">
|
||||
<i class="icons slider-icon"></i>
|
||||
<div class="sliderwrap il">
|
||||
<input id="sliderC1" class="noslide" onchange="setCustom(1)" oninput="updateTrail(this)" max="255" min="0" type="range" value="6" />
|
||||
<input id="sliderC1" class="noslide" onchange="setCustom(1)" oninput="updateTrail(this)" max="255" min="0" type="range" value="0" />
|
||||
<div class="sliderdisplay"></div>
|
||||
</div>
|
||||
<output class="sliderbubble"></output>
|
||||
@ -269,7 +269,7 @@
|
||||
<div id="slider3" class="slider hide">
|
||||
<i class="icons slider-icon"></i>
|
||||
<div class="sliderwrap il">
|
||||
<input id="sliderC2" class="noslide" onchange="setCustom(2)" oninput="updateTrail(this)" max="255" min="0" type="range" value="6" />
|
||||
<input id="sliderC2" class="noslide" onchange="setCustom(2)" oninput="updateTrail(this)" max="255" min="0" type="range" value="0" />
|
||||
<div class="sliderdisplay"></div>
|
||||
</div>
|
||||
<output class="sliderbubble"></output>
|
||||
@ -278,12 +278,26 @@
|
||||
<div id="slider4" class="slider hide">
|
||||
<i class="icons slider-icon"></i>
|
||||
<div class="sliderwrap il">
|
||||
<input id="sliderC3" class="noslide" onchange="setCustom(3)" oninput="updateTrail(this)" max="255" min="0" type="range" value="6" />
|
||||
<input id="sliderC3" class="noslide" onchange="setCustom(3)" oninput="updateTrail(this)" max="31" min="0" type="range" value="0" />
|
||||
<div class="sliderdisplay"></div>
|
||||
</div>
|
||||
<output class="sliderbubble"></output>
|
||||
<span class="tooltiptext" id="sliderLabel4">Custom 3</span>
|
||||
</div>
|
||||
<div id="fxopt" class="option fade">
|
||||
<label id="opt0" class="check ochkl hide"><i class="icons"></i><span class="tooltiptext" id="optLabel0">Check 1</span>
|
||||
<input type="checkbox" onchange="setOption(1, this.checked)">
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<label id="opt1" class="check ochkl hide"><i class="icons"></i><span class="tooltiptext" id="optLabel1">Check 2</span>
|
||||
<input type="checkbox" onchange="setOption(2, this.checked)">
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<label id="opt2" class="check ochkl hide"><i class="icons"></i><span class="tooltiptext" id="optLabel2">Check 3</span>
|
||||
<input type="checkbox" onchange="setOption(3, this.checked)">
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -1033,7 +1033,12 @@ function updateLen(s)
|
||||
start = parseInt(gId(`seg${s}sY`).value);
|
||||
stop = parseInt(gId(`seg${s}eY`).value);
|
||||
len *= (stop-(cfg.comp.seglen?0:start));
|
||||
if (stop-start>1) gId(`seg${s}map2D`).classList.remove("hide"); else gId(`seg${s}map2D`).classList.add("hide");
|
||||
let sE = gId('fxlist').querySelector(`.lstI[data-id="${selectedFx}"]`);
|
||||
if (sE) {
|
||||
let sN = sE.querySelector(".lstIname").innerText;
|
||||
let seg = gId(`seg${s}map2D`);
|
||||
if (stop-start>1 && sN.indexOf("\u25A6")<0) seg.classList.remove("hide"); else seg.classList.add("hide");
|
||||
}
|
||||
}
|
||||
var out = "(delete)";
|
||||
if (len > 1) {
|
||||
@ -1341,18 +1346,19 @@ function setEffectParameters(idx)
|
||||
var paOnOff = (effectPars.length<3 || effectPars[2]=='')?[]:effectPars[2].split(",");
|
||||
|
||||
// set html slider items on/off
|
||||
var nSliders = Math.min(5,Math.floor(gId("sliders").children.length)); // div for each slider
|
||||
//var nSliders = Math.min(7,Math.floor(gId("sliders").children.length)); // div for each slider + filter + options
|
||||
let nSliders = 5;
|
||||
var sldCnt = 0;
|
||||
for (let i=0; i<nSliders; i++) {
|
||||
var slider = gId("slider" + i);
|
||||
var label = gId("sliderLabel" + i);
|
||||
// if (not controlDefined and for AC speed or intensity and for SR alle sliders) or slider has a value
|
||||
if ((!controlDefined && i < ((idx<128)?2:nSliders)) || (slOnOff.length>i && slOnOff[i] != "")) {
|
||||
if (slOnOff.length>i && slOnOff[i].indexOf("=")>0) {
|
||||
// embeded default values
|
||||
var dPos = slOnOff[i].indexOf("=");
|
||||
slOnOff[i] = slOnOff[i].substring(0,dPos);
|
||||
}
|
||||
//if (slOnOff.length>i && slOnOff[i].indexOf("=")>0) {
|
||||
// // embeded default values
|
||||
// var dPos = slOnOff[i].indexOf("=");
|
||||
// slOnOff[i] = slOnOff[i].substring(0,dPos);
|
||||
//}
|
||||
if (slOnOff.length>i && slOnOff[i]!="!") label.innerHTML = slOnOff[i];
|
||||
else if (i==0) label.innerHTML = "Effect speed";
|
||||
else if (i==1) label.innerHTML = "Effect intensity";
|
||||
@ -1363,13 +1369,26 @@ function setEffectParameters(idx)
|
||||
slider.classList.add("hide");
|
||||
}
|
||||
}
|
||||
if (slOnOff.length>5) {
|
||||
gId('fxopt').classList.remove('fade');
|
||||
for (let i = 0; i<3; i++) {
|
||||
if (slOnOff[5+i]!=='') {
|
||||
gId('opt'+i).classList.remove('hide');
|
||||
gId('optLabel'+i).innerHTML = slOnOff[5+i]=="!" ? 'Option' : slOnOff[5+i].substr(0,16);
|
||||
} else
|
||||
gId('opt'+i).classList.add('hide');
|
||||
}
|
||||
} else {
|
||||
gId('fxopt').classList.add('fade');
|
||||
}
|
||||
|
||||
// set the bottom position of selected effect (sticky) as the top of sliders div
|
||||
setInterval(()=>{
|
||||
let top = parseInt(getComputedStyle(gId("sliders")).height);
|
||||
//top += 5; // size of tooltip
|
||||
top += 5;
|
||||
let sel = d.querySelector('#fxlist .selected');
|
||||
if (sel) sel.style.bottom = top + "px"; // we will need to remove this when unselected (in setX())
|
||||
|
||||
},750);
|
||||
// set html color items on/off
|
||||
var cslLabel = '';
|
||||
var sep = '';
|
||||
@ -2117,6 +2136,16 @@ function setCustom(i=1)
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
function setOption(i=1, v=false)
|
||||
{
|
||||
if (i<1 || i>3) return;
|
||||
var obj = {"seg": {}};
|
||||
if (i===3) obj.seg.o3 = !(!v); //make sure it is bool
|
||||
else if (i===2) obj.seg.o2 = !(!v); //make sure it is bool
|
||||
else obj.seg.o1 = !(!v); //make sure it is bool
|
||||
requestJson(obj);
|
||||
}
|
||||
|
||||
function setLor(i)
|
||||
{
|
||||
var obj = {"lor": i};
|
||||
|
3709
wled00/html_ui.h
3709
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -222,7 +222,13 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
}
|
||||
getVal(elem[F("c1")], &seg.custom1);
|
||||
getVal(elem[F("c2")], &seg.custom2);
|
||||
getVal(elem[F("c3")], &seg.custom3);
|
||||
uint8_t cust3 = seg.custom3;
|
||||
getVal(elem[F("c3")], &cust3); // we can't pass reference to bifield
|
||||
seg.custom3 = cust3;
|
||||
|
||||
seg.check1 = elem[F("o1")] | seg.check1;
|
||||
seg.check2 = elem[F("o2")] | seg.check2;
|
||||
seg.check3 = elem[F("o3")] | seg.check3;
|
||||
|
||||
JsonArray iarr = elem[F("i")]; //set individual LEDs
|
||||
if (!iarr.isNull()) {
|
||||
@ -510,6 +516,9 @@ void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset, b
|
||||
root[F("mY")] = seg.getOption(SEG_OPTION_MIRROR_Y);
|
||||
root[F("tp")] = seg.getOption(SEG_OPTION_TRANSPOSED);
|
||||
}
|
||||
root[F("o1")] = seg.check1;
|
||||
root[F("o2")] = seg.check2;
|
||||
root[F("o3")] = seg.check3;
|
||||
root[F("ssim")] = seg.soundSim;
|
||||
root[F("mp12")] = seg.map1D2D;
|
||||
}
|
||||
@ -617,6 +626,16 @@ void serializeInfo(JsonObject root)
|
||||
root[F("noaudio")] = true;
|
||||
#endif
|
||||
|
||||
#ifdef WLED_DEBUG
|
||||
JsonArray i2c = root.createNestedArray(F("i2c"));
|
||||
i2c.add(i2c_sda);
|
||||
i2c.add(i2c_scl);
|
||||
JsonArray spi = root.createNestedArray(F("spi"));
|
||||
spi.add(spi_mosi);
|
||||
spi.add(spi_sclk);
|
||||
spi.add(spi_cs);
|
||||
#endif
|
||||
|
||||
root[F("str")] = syncToggleReceive;
|
||||
|
||||
root[F("name")] = serverDescription;
|
||||
|
@ -75,12 +75,25 @@ bool PinManagerClass::deallocateMultiplePins(const uint8_t *pinArray, byte array
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (tag==PinOwner::HW_SPI) {
|
||||
if (spiAllocCount && --spiAllocCount>0) {
|
||||
// no deallocation done until last owner releases pins
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < arrayElementCount; i++) {
|
||||
deallocatePin(pinArray[i], tag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PinManagerClass::deallocateMultiplePins(const managed_pin_type * mptArray, byte arrayElementCount, PinOwner tag)
|
||||
{
|
||||
uint8_t pins[arrayElementCount];
|
||||
for (int i=0; i<arrayElementCount; i++) pins[i] = mptArray[i].pin;
|
||||
return deallocateMultiplePins(pins, arrayElementCount, tag);
|
||||
}
|
||||
|
||||
bool PinManagerClass::allocateMultiplePins(const managed_pin_type * mptArray, byte arrayElementCount, PinOwner tag)
|
||||
{
|
||||
bool shouldFail = false;
|
||||
@ -100,8 +113,8 @@ bool PinManagerClass::allocateMultiplePins(const managed_pin_type * mptArray, by
|
||||
#endif
|
||||
shouldFail = true;
|
||||
}
|
||||
if (tag==PinOwner::HW_I2C && isPinAllocated(gpio, tag)) {
|
||||
// allow multiple "allocations" of HW I2C bus pins
|
||||
if ((tag==PinOwner::HW_I2C || tag==PinOwner::HW_SPI) && isPinAllocated(gpio, tag)) {
|
||||
// allow multiple "allocations" of HW I2C & SPI bus pins
|
||||
continue;
|
||||
} else if (isPinAllocated(gpio)) {
|
||||
#ifdef WLED_DEBUG
|
||||
@ -119,6 +132,7 @@ bool PinManagerClass::allocateMultiplePins(const managed_pin_type * mptArray, by
|
||||
}
|
||||
|
||||
if (tag==PinOwner::HW_I2C) i2cAllocCount++;
|
||||
if (tag==PinOwner::HW_SPI) spiAllocCount++;
|
||||
|
||||
// all pins are available .. track each one
|
||||
for (int i = 0; i < arrayElementCount; i++) {
|
||||
@ -145,8 +159,8 @@ bool PinManagerClass::allocateMultiplePins(const managed_pin_type * mptArray, by
|
||||
|
||||
bool PinManagerClass::allocatePin(byte gpio, bool output, PinOwner tag)
|
||||
{
|
||||
// HW I2C pins have to be allocated using allocateMultiplePins variant since there is always SCL/SDA pair
|
||||
if (!isPinOk(gpio, output) || tag==PinOwner::HW_I2C) return false;
|
||||
// HW I2C & SPI pins have to be allocated using allocateMultiplePins variant since there is always SCL/SDA pair
|
||||
if (!isPinOk(gpio, output) || tag==PinOwner::HW_I2C || tag==PinOwner::HW_SPI) return false;
|
||||
if (isPinAllocated(gpio)) {
|
||||
#ifdef WLED_DEBUG
|
||||
DEBUG_PRINT(F("PIN ALLOC: Pin "));
|
||||
|
@ -34,7 +34,7 @@ enum struct PinOwner : uint8_t {
|
||||
DebugOut = 0x89, // 'Dbg' == debug output always IO1
|
||||
DMX = 0x8A, // 'DMX' == hard-coded to IO2
|
||||
HW_I2C = 0x8B, // 'I2C' == hardware I2C pins (4&5 on ESP8266, 21&22 on ESP32)
|
||||
HW_SPI = 0x8C, // 'SPI' == hardware SPI pins (13,14&15 on ESP8266, 5,18&23 on ESP32)
|
||||
HW_SPI = 0x8C, // 'SPI' == hardware (V)SPI pins (13,14&15 on ESP8266, 5,18&23 on ESP32)
|
||||
// Use UserMod IDs from const.h here
|
||||
UM_Unspecified = USERMOD_ID_UNSPECIFIED, // 0x01
|
||||
UM_Example = USERMOD_ID_EXAMPLE, // 0x02 // Usermod "usermod_v2_example.h"
|
||||
@ -70,13 +70,18 @@ class PinManagerClass {
|
||||
uint8_t ledcAlloc[2] = {0x00, 0x00}; //16 LEDC channels
|
||||
PinOwner ownerTag[40] = { PinOwner::None };
|
||||
#endif
|
||||
uint8_t i2cAllocCount = 0; // allow multiple allocation of I2C bus pins but keep track of allocations
|
||||
struct {
|
||||
uint8_t i2cAllocCount : 4; // allow multiple allocation of I2C bus pins but keep track of allocations
|
||||
uint8_t spiAllocCount : 4; // allow multiple allocation of SPI bus pins but keep track of allocations
|
||||
};
|
||||
|
||||
public:
|
||||
PinManagerClass() : i2cAllocCount(0), spiAllocCount(0) {}
|
||||
// De-allocates a single pin
|
||||
bool deallocatePin(byte gpio, PinOwner tag);
|
||||
// De-allocates multiple pins but only if all can be deallocated (PinOwner has to be specified)
|
||||
bool deallocateMultiplePins(const uint8_t *pinArray, byte arrayElementCount, PinOwner tag);
|
||||
bool deallocateMultiplePins(const managed_pin_type *pinArray, byte arrayElementCount, PinOwner tag);
|
||||
// Allocates a single pin, with an owner tag.
|
||||
// De-allocation requires the same owner tag (or override)
|
||||
bool allocatePin(byte gpio, bool output, PinOwner tag);
|
||||
|
@ -486,8 +486,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
pinManager.deallocateMultiplePins(oldpins, 2, PinOwner::HW_I2C);
|
||||
#ifdef ESP8266
|
||||
// cannot change pins on ESP8266
|
||||
if (hw_sda_pin != HW_PIN_SDA) hw_sda_pin = -1;
|
||||
if (hw_scl_pin != HW_PIN_SCL) hw_scl_pin = -1;
|
||||
if (hw_sda_pin != HW_PIN_SDA) hw_sda_pin = HW_PIN_SDA;
|
||||
if (hw_scl_pin != HW_PIN_SCL) hw_scl_pin = HW_PIN_SCL;
|
||||
#endif
|
||||
PinManagerPinType i2c[2] = { { hw_sda_pin, true }, { hw_scl_pin, true } };
|
||||
if (pinManager.allocateMultiplePins(i2c, 2, PinOwner::HW_I2C)) {
|
||||
@ -495,7 +495,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
i2c_scl = hw_scl_pin;
|
||||
#ifdef ESP32
|
||||
Wire.setPins(i2c_sda, i2c_scl); // this will fail if Wire is initilised (Wire.begin() called)
|
||||
uint8_t i2c[2] = {i2c_sda, i2c_scl};
|
||||
pinManager.deallocateMultiplePins(i2c, 2, PinOwner::HW_I2C);
|
||||
#endif
|
||||
} else {
|
||||
@ -511,16 +510,15 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
pinManager.deallocateMultiplePins(oldpins, 3, PinOwner::HW_SPI);
|
||||
#ifdef ESP8266
|
||||
// cannot change pins on ESP8266
|
||||
if (hw_mosi_pin != HW_PIN_DATASPI) hw_mosi_pin = -1;
|
||||
if (hw_sclk_pin != HW_PIN_CLOCKSPI) hw_sclk_pin = -1;
|
||||
if (hw_cs_pin != HW_PIN_CSSPI) hw_cs_pin = -1;
|
||||
if (hw_mosi_pin != HW_PIN_DATASPI) hw_mosi_pin = HW_PIN_DATASPI;
|
||||
if (hw_sclk_pin != HW_PIN_CLOCKSPI) hw_sclk_pin = HW_PIN_CLOCKSPI;
|
||||
if (hw_cs_pin != HW_PIN_CSSPI) hw_cs_pin = HW_PIN_CSSPI;
|
||||
#endif
|
||||
PinManagerPinType spi[3] = { { hw_mosi_pin, true }, { hw_sclk_pin, true }, { hw_cs_pin, true } };
|
||||
if (pinManager.allocateMultiplePins(spi, 3, PinOwner::HW_SPI)) {
|
||||
spi_mosi = hw_mosi_pin;
|
||||
spi_sclk = hw_sclk_pin;
|
||||
spi_cs = hw_cs_pin;
|
||||
uint8_t spi[3] = { hw_mosi_pin, hw_sclk_pin, hw_cs_pin };
|
||||
pinManager.deallocateMultiplePins(spi, 3, PinOwner::HW_SPI);
|
||||
} else {
|
||||
spi_mosi = -1;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2208111
|
||||
#define VERSION 2208141
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
|
Loading…
Reference in New Issue
Block a user