You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
185 lines
6.6 KiB
185 lines
6.6 KiB
#define SERIAL_SPEED 115200
|
|
|
|
// OTA
|
|
#define OTA_PASSWORD "n87z21Tx5%P%EX&*"
|
|
|
|
// DebugRemote
|
|
RemoteDebug Debug;
|
|
|
|
// LED
|
|
#define LED_NUM 300
|
|
#define LED_PIN 5 // = D1
|
|
#define LED_CHIPSET WS2812B
|
|
#define LED_COLOR_ORDER GRB
|
|
#define LED_BRIGHTNESS_DEFAULT 96
|
|
#define LED_SPEED_DEFAULT 120
|
|
#define LED_COLOR_DEFAULT CRGB::Red
|
|
|
|
#define LED_EFFECT_CYLON "cylon"
|
|
#define LED_EFFECT_COLORPATTERN "colorp"
|
|
#define LED_EFFECT_COLORTEMP "colort"
|
|
#define LED_EFFECT_FIRE "fire"
|
|
#define LED_EFFECT_FULLRED "full"
|
|
#define LED_EFFECT_ERROR "error"
|
|
|
|
// WIFI
|
|
#define WIFI_SSID "XXX"
|
|
#define WIFI_PASSWORD "XXX"
|
|
|
|
// MQTT
|
|
#define MQTT_SERVER "XXX"
|
|
#define MQTT_PORT 1883
|
|
#define MQTT_USER "XXX"
|
|
#define MQTT_PASS "XXX"
|
|
|
|
#define MQTT_LED_COMMAND "strip1/switch"
|
|
#define MQTT_LED_STATE "strip1/status"
|
|
#define MQTT_LED_EFFECT_COMMAND "strip1/effect/switch"
|
|
#define MQTT_LED_EFFECT_STATE "strip1/effect/status"
|
|
#define MQTT_LED_BRIGHTNESS_COMMAND "strip1/brightness/switch"
|
|
#define MQTT_LED_BRIGHTNESS_STATE "strip1/brightness/status"
|
|
#define MQTT_LED_SPEED_COMMAND "strip1/speed/switch"
|
|
#define MQTT_LED_SPEED_STATE "strip1/speed/status"
|
|
#define MQTT_LED_COLOR_COMMAND "strip1/color/switch"
|
|
#define MQTT_LED_COLOR_STATE "strip1/color/status"
|
|
|
|
|
|
void setupOTA();
|
|
void setupWifi();
|
|
void testConnectMQTT();
|
|
void callbackMQTT(char* topic, byte* payload, unsigned int length);
|
|
void mqttSendState();
|
|
void mqttSendEffectState();
|
|
void mqttSendBrightnessState();
|
|
void mqttSendSpeedState();
|
|
void mqttSendColorState();
|
|
void ledBlackAll();
|
|
void ledCylon();
|
|
void ledError();
|
|
void ledFullColor();
|
|
///////////////////////////////// ColorPalette
|
|
// This example shows several ways to set up and use 'palettes' of colors
|
|
// with FastLED.
|
|
//
|
|
// These compact palettes provide an easy way to re-colorize your
|
|
// animation on the fly, quickly, easily, and with low overhead.
|
|
//
|
|
// USING palettes is MUCH simpler in practice than in theory, so first just
|
|
// run this sketch, and watch the pretty lights as you then read through
|
|
// the code. Although this sketch has eight (or more) different color schemes,
|
|
// the entire sketch compiles down to about 6.5K on AVR.
|
|
//
|
|
// FastLED provides a few pre-configured color palettes, and makes it
|
|
// extremely easy to make up your own color schemes with palettes.
|
|
//
|
|
// Some notes on the more abstract 'theory and practice' of
|
|
// FastLED compact palettes are at the bottom of this file.
|
|
CRGBPalette16 currentPalette;
|
|
TBlendType currentBlending;
|
|
|
|
extern CRGBPalette16 myRedWhiteBluePalette;
|
|
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
|
|
|
|
// This example shows how to set up a static color palette
|
|
// which is stored in PROGMEM (flash), which is almost always more
|
|
// plentiful than RAM. A static PROGMEM palette like this
|
|
// takes up 64 bytes of flash.
|
|
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
|
|
{
|
|
CRGB::Red,
|
|
CRGB::Gray, // 'white' is too bright compared to red and blue
|
|
CRGB::Blue,
|
|
CRGB::Black,
|
|
|
|
CRGB::Red,
|
|
CRGB::Gray,
|
|
CRGB::Blue,
|
|
CRGB::Black,
|
|
|
|
CRGB::Red,
|
|
CRGB::Red,
|
|
CRGB::Gray,
|
|
CRGB::Gray,
|
|
CRGB::Blue,
|
|
CRGB::Blue,
|
|
CRGB::Black,
|
|
CRGB::Black
|
|
};
|
|
|
|
void ledColorPattern();
|
|
void FillLEDsFromPaletteColors(uint8_t colorIndex);
|
|
void ChangePalettePeriodically();
|
|
void SetupTotallyRandomPalette();
|
|
void SetupBlackAndWhiteStripedPalette();
|
|
void SetupPurpleAndGreenPalette();
|
|
//////////////////////////////////////////////// ColorTemperature
|
|
// THIS EXAMPLE demonstrates the second, "color temperature" control.
|
|
// It shows a simple rainbow animation first with one temperature profile,
|
|
// and a few seconds later, with a different temperature profile.
|
|
//
|
|
// The first pixel of the strip will show the color temperature.
|
|
//
|
|
// HELPFUL HINTS for "seeing" the effect in this demo:
|
|
// * Don't look directly at the LED pixels. Shine the LEDs aganst
|
|
// a white wall, table, or piece of paper, and look at the reflected light.
|
|
//
|
|
// * If you watch it for a bit, and then walk away, and then come back
|
|
// to it, you'll probably be able to "see" whether it's currently using
|
|
// the 'redder' or the 'bluer' temperature profile, even not counting
|
|
// the lowest 'indicator' pixel.
|
|
//
|
|
//
|
|
// FastLED provides these pre-conigured incandescent color profiles:
|
|
// Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc,
|
|
// HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky,
|
|
// FastLED provides these pre-configured gaseous-light color profiles:
|
|
// WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent,
|
|
// FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent,
|
|
// MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium,
|
|
// FastLED also provides an "Uncorrected temperature" profile
|
|
// UncorrectedTemperature;
|
|
|
|
#define TEMPERATURE_1 Tungsten100W
|
|
#define TEMPERATURE_2 OvercastSky
|
|
// How many seconds to show each temperature before switching
|
|
#define DISPLAYTIME 20
|
|
// How many seconds to show black between switches
|
|
#define BLACKTIME 3
|
|
void colorTemp();
|
|
///////////////////////////////////////////////Fire202
|
|
bool gReverseDirection = false;
|
|
// This basic one-dimensional 'fire' simulation works roughly as follows:
|
|
// There's a underlying array of 'heat' cells, that model the temperature
|
|
// at each point along the line. Every cycle through the simulation,
|
|
// four steps are performed:
|
|
// 1) All cells cool down a little bit, losing heat to the air
|
|
// 2) The heat from each cell drifts 'up' and diffuses a little
|
|
// 3) Sometimes randomly new 'sparks' of heat are added at the bottom
|
|
// 4) The heat from each cell is rendered as a color into the leds array
|
|
// The heat-to-color mapping uses a black-body radiation approximation.
|
|
//
|
|
// Temperature is in arbitrary units from 0 (cold black) to 255 (white hot).
|
|
//
|
|
// This simulation scales it self a bit depending on NUM_LEDS; it should look
|
|
// "OK" on anywhere from 20 to 100 LEDs without too much tweaking.
|
|
//
|
|
// I recommend running this simulation at anywhere from 30-100 frames per second,
|
|
// meaning an interframe delay of about 10-35 milliseconds.
|
|
//
|
|
// Looks best on a high-density LED setup (60+ pixels/meter).
|
|
//
|
|
//
|
|
// There are two main parameters you can play with to control the look and
|
|
// feel of your fire: COOLING (used in step 1 above), and SPARKING (used
|
|
// in step 3 above).
|
|
//
|
|
// COOLING: How much does the air cool as it rises?
|
|
// Less cooling = taller flames. More cooling = shorter flames.
|
|
// Default 50, suggested range 20-100
|
|
#define COOLING 55
|
|
|
|
// SPARKING: What chance (out of 255) is there that a new spark will be lit?
|
|
// Higher chance = more roaring fire. Lower chance = more flickery fire.
|
|
// Default 120, suggested range 50-200.
|
|
#define SPARKING 120
|
|
void fire();
|