www
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
/**
|
||||
*
|
||||
* 洞洞板氛围灯
|
||||
*
|
||||
*/
|
||||
|
||||
#define BLINKER_PRINT Serial
|
||||
#define BLINKER_MIOT_LIGHT
|
||||
#define BLINKER_WIFI
|
||||
@@ -7,7 +13,7 @@
|
||||
#define BLINKER_OTA_VERSION_CODE "1.0.1"
|
||||
|
||||
//【据自己情况修改】Blinker 的秘钥
|
||||
char auth[] = "b082a19ce985";
|
||||
char auth[] = "199e88f6969a";
|
||||
// 自己家中的 2.4G wifi名称
|
||||
char ssid[] = "bmy";
|
||||
// 自己家中的 2.4G wifi密码
|
||||
@@ -16,7 +22,7 @@ char pswd[] = "lb714500";
|
||||
//【据自己情况修改】WS2812的 GPIO 引脚编号
|
||||
#define LED_PIN 0 // 对应开发板上的 D3
|
||||
#define LED_PIN_TWO 2 // 对应开发板上的 D4
|
||||
#define LED_PIN_THREE 14 // 对应开发板上的 D5
|
||||
// #define LED_PIN_THREE 14 // 对应开发板上的 D5
|
||||
|
||||
#define LED_COUNT 60 //【据自己情况修改】灯珠个数
|
||||
#define DEFAULT_COLOR 0xFF5900 // 初始化灯的颜色
|
||||
@@ -33,7 +39,7 @@ unsigned long now = 0; // 当前的时候
|
||||
// 初始化 WS2812FX
|
||||
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
|
||||
WS2812FX ws2812two = WS2812FX(60, LED_PIN_TWO, NEO_GRB + NEO_KHZ800);
|
||||
WS2812FX ws2812three = WS2812FX(30, LED_PIN_THREE, NEO_GRB + NEO_KHZ800);
|
||||
// WS2812FX ws2812three = WS2812FX(30, LED_PIN_THREE, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
// 颜色选择器
|
||||
BlinkerRGB RGB1("RGB");
|
||||
@@ -57,38 +63,38 @@ BlinkerSlider brightnessSlider("brightness");
|
||||
void rgb1_callback(uint8_t r_value, uint8_t g_value, uint8_t b_value, uint8_t bright_value) {
|
||||
ws2812fx.setColor(ws2812fx.Color(r_value, g_value, b_value));
|
||||
ws2812two.setColor(ws2812two.Color(r_value, g_value, b_value));
|
||||
ws2812three.setColor(ws2812three.Color(r_value, g_value, b_value));
|
||||
// ws2812three.setColor(ws2812three.Color(r_value, g_value, b_value));
|
||||
|
||||
|
||||
if (bright_value != 0) {
|
||||
ws2812fx.setBrightness(bright_value);
|
||||
ws2812two.setBrightness(bright_value);
|
||||
ws2812three.setBrightness(bright_value);
|
||||
// ws2812three.setBrightness(bright_value);
|
||||
}
|
||||
}
|
||||
|
||||
// 开灯
|
||||
void openLamp() {
|
||||
if (!ws2812fx.isRunning() || !ws2812two.isRunning() || !ws2812three.isRunning()) {
|
||||
if (!ws2812fx.isRunning() || !ws2812two.isRunning()) {
|
||||
openButton.color("#F0AA41");
|
||||
openButton.text("已开启");
|
||||
openButton.print("on");
|
||||
ws2812fx.start();
|
||||
ws2812two.start();
|
||||
ws2812three.start();
|
||||
// ws2812three.start();
|
||||
}
|
||||
}
|
||||
|
||||
// 关灯
|
||||
void closeLamp() {
|
||||
if (ws2812fx.isRunning() || ws2812two.isRunning() || ws2812three.isRunning()) {
|
||||
if (ws2812fx.isRunning() || ws2812two.isRunning()) {
|
||||
closeRandom();
|
||||
openButton.color("#595959");
|
||||
openButton.text("已关闭");
|
||||
openButton.print("off");
|
||||
ws2812fx.stop();
|
||||
ws2812two.stop();
|
||||
ws2812three.stop();
|
||||
// ws2812three.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,10 +116,10 @@ int BrightTransformation(int Bright) {
|
||||
void defaultButton_Callback(const String & state) {
|
||||
closeRandom();
|
||||
|
||||
ws2812three.setBrightness(DEFAULT_BRIGHTNESS);
|
||||
ws2812three.setSpeed(DEFAULT_SPEED);
|
||||
ws2812three.setColor(DEFAULT_COLOR);
|
||||
ws2812three.setMode(DEFAULT_MODE);
|
||||
// ws2812three.setBrightness(DEFAULT_BRIGHTNESS);
|
||||
// ws2812three.setSpeed(DEFAULT_SPEED);
|
||||
// ws2812three.setColor(DEFAULT_COLOR);
|
||||
// ws2812three.setMode(DEFAULT_MODE);
|
||||
|
||||
ws2812two.setBrightness(DEFAULT_BRIGHTNESS);
|
||||
ws2812two.setSpeed(DEFAULT_SPEED);
|
||||
@@ -132,9 +138,9 @@ void defaultButton_Callback(const String & state) {
|
||||
void workButton_Callback(const String & state) {
|
||||
closeRandom();
|
||||
|
||||
ws2812three.setBrightness(127);
|
||||
ws2812three.setSpeed(1000);
|
||||
ws2812three.setMode(FX_MODE_COLOR_WIPE_RANDOM);
|
||||
// ws2812three.setBrightness(127);
|
||||
// ws2812three.setSpeed(1000);
|
||||
// ws2812three.setMode(FX_MODE_COLOR_WIPE_RANDOM);
|
||||
|
||||
ws2812two.setBrightness(127);
|
||||
ws2812two.setSpeed(1000);
|
||||
@@ -150,9 +156,9 @@ void workButton_Callback(const String & state) {
|
||||
void sleepButton_Callback(const String & state) {
|
||||
closeRandom();
|
||||
|
||||
ws2812three.setColor(255, 89, 0);
|
||||
ws2812three.setBrightness(50);
|
||||
ws2812three.setMode(FX_MODE_BREATH);
|
||||
// ws2812three.setColor(255, 89, 0);
|
||||
// ws2812three.setBrightness(50);
|
||||
// ws2812three.setMode(FX_MODE_BREATH);
|
||||
|
||||
ws2812two.setColor(255, 89, 0);
|
||||
ws2812two.setBrightness(50);
|
||||
@@ -167,7 +173,7 @@ void sleepButton_Callback(const String & state) {
|
||||
// 拖动调节亮度
|
||||
void brightnessSlider_Callback(int32_t value) {
|
||||
uint8_t set_brightness = 255 * int(value) / 100;
|
||||
ws2812three.setBrightness(set_brightness);
|
||||
// ws2812three.setBrightness(set_brightness);
|
||||
ws2812two.setBrightness(set_brightness);
|
||||
ws2812fx.setBrightness(set_brightness);
|
||||
brightnessSlider.print(value);
|
||||
@@ -217,7 +223,7 @@ void miotBright(const String & bright) {
|
||||
}
|
||||
//进行亮度值转换
|
||||
uint8_t set_brightness = 255 * colorW / 100;
|
||||
ws2812three.setBrightness(set_brightness);
|
||||
// ws2812three.setBrightness(set_brightness);
|
||||
ws2812two.setBrightness(set_brightness);
|
||||
ws2812fx.setBrightness(set_brightness);
|
||||
brightnessSlider.print(colorW);
|
||||
@@ -229,7 +235,7 @@ void miotBright(const String & bright) {
|
||||
// 灯的颜色设置
|
||||
void miotColor(int32_t color) {
|
||||
BLINKER_LOG("need set color: ", color);
|
||||
ws2812three.setColor(color);
|
||||
// ws2812three.setColor(color);
|
||||
ws2812two.setColor(color);
|
||||
ws2812fx.setColor(color);
|
||||
BlinkerMIOT.color(color);
|
||||
@@ -285,9 +291,9 @@ void miotMode(uint8_t mode) {
|
||||
|
||||
// 日光 模式
|
||||
if (mode == BLINKER_CMD_MIOT_DAY) {
|
||||
ws2812three.setColor(255, 255, 255);
|
||||
ws2812three.setBrightness(255);
|
||||
ws2812three.setMode(DEFAULT_MODE);
|
||||
// ws2812three.setColor(255, 255, 255);
|
||||
// ws2812three.setBrightness(255);
|
||||
// ws2812three.setMode(DEFAULT_MODE);
|
||||
|
||||
ws2812two.setColor(255, 255, 255);
|
||||
ws2812two.setBrightness(255);
|
||||
@@ -300,9 +306,9 @@ void miotMode(uint8_t mode) {
|
||||
}
|
||||
// 月光 模式
|
||||
else if (mode == BLINKER_CMD_MIOT_NIGHT) {
|
||||
ws2812three.setColor(255, 89, 0);
|
||||
ws2812three.setBrightness(255);
|
||||
ws2812three.setMode(FX_MODE_STATIC);
|
||||
// ws2812three.setColor(255, 89, 0);
|
||||
// ws2812three.setBrightness(255);
|
||||
// ws2812three.setMode(FX_MODE_STATIC);
|
||||
|
||||
ws2812two.setColor(255, 89, 0);
|
||||
ws2812two.setBrightness(255);
|
||||
@@ -315,9 +321,9 @@ void miotMode(uint8_t mode) {
|
||||
}
|
||||
// 彩光 模式
|
||||
else if (mode == BLINKER_CMD_MIOT_COLOR) {
|
||||
ws2812three.setBrightness(255);
|
||||
ws2812three.setSpeed(200);
|
||||
ws2812three.setMode(FX_MODE_RAINBOW_CYCLE);
|
||||
// ws2812three.setBrightness(255);
|
||||
// ws2812three.setSpeed(200);
|
||||
// ws2812three.setMode(FX_MODE_RAINBOW_CYCLE);
|
||||
|
||||
ws2812two.setBrightness(255);
|
||||
ws2812two.setSpeed(200);
|
||||
@@ -330,30 +336,30 @@ void miotMode(uint8_t mode) {
|
||||
}
|
||||
// 温馨 模式
|
||||
else if (mode == BLINKER_CMD_MIOT_WARMTH) {
|
||||
ws2812three.setMode(FX_MODE_TWINKLEFOX);
|
||||
// ws2812three.setMode(FX_MODE_TWINKLEFOX);
|
||||
ws2812two.setMode(FX_MODE_TWINKLEFOX);
|
||||
ws2812fx.setMode(FX_MODE_TWINKLEFOX);
|
||||
}
|
||||
// 电视模式
|
||||
else if (mode == BLINKER_CMD_MIOT_TV) {
|
||||
ws2812three.setBrightness(20);
|
||||
ws2812three.setSpeed(1000);
|
||||
ws2812three.setMode(FX_MODE_CHASE_RAINBOW);
|
||||
// ws2812three.setBrightness(20);
|
||||
// ws2812three.setSpeed(1000);
|
||||
// ws2812three.setMode(FX_MODE_CHASE_RAINBOW);
|
||||
|
||||
ws2812two.setBrightness(20);
|
||||
ws2812two.setBrightness(255);
|
||||
ws2812two.setSpeed(1000);
|
||||
ws2812two.setMode(FX_MODE_CHASE_RAINBOW);
|
||||
|
||||
ws2812fx.setBrightness(20);
|
||||
ws2812fx.setBrightness(255);
|
||||
ws2812fx.setSpeed(1000);
|
||||
ws2812fx.setMode(FX_MODE_CHASE_RAINBOW);
|
||||
brightnessSlider.print(BrightTransformation(20));
|
||||
}
|
||||
// 阅读 模式
|
||||
else if (mode == BLINKER_CMD_MIOT_READING) {
|
||||
ws2812three.setBrightness(255);
|
||||
ws2812three.setSpeed(200);
|
||||
ws2812three.setMode(FX_MODE_MULTI_STROBE);
|
||||
// ws2812three.setBrightness(255);
|
||||
// ws2812three.setSpeed(200);
|
||||
// ws2812three.setMode(FX_MODE_MULTI_STROBE);
|
||||
|
||||
ws2812two.setBrightness(255);
|
||||
ws2812two.setSpeed(200);
|
||||
@@ -366,8 +372,8 @@ void miotMode(uint8_t mode) {
|
||||
}
|
||||
// 电脑模式
|
||||
else if (mode == BLINKER_CMD_MIOT_COMPUTER) {
|
||||
ws2812three.setBrightness(255);
|
||||
ws2812three.setMode(FX_MODE_COLOR_SWEEP_RANDOM);
|
||||
// ws2812three.setBrightness(255);
|
||||
// ws2812three.setMode(FX_MODE_COLOR_SWEEP_RANDOM);
|
||||
|
||||
ws2812two.setBrightness(255);
|
||||
ws2812two.setMode(FX_MODE_COLOR_SWEEP_RANDOM);
|
||||
@@ -411,7 +417,7 @@ void heartbeat() {
|
||||
void changeRandomTheme() {
|
||||
if (isUseRandomTheme) {
|
||||
if (now - last_change > TIMER_MS) {
|
||||
ws2812three.setMode((ws2812three.getMode() + 1) % ws2812three.getModeCount());
|
||||
// ws2812three.setMode((ws2812three.getMode() + 1) % ws2812three.getModeCount());
|
||||
ws2812two.setMode((ws2812two.getMode() + 1) % ws2812two.getModeCount());
|
||||
ws2812fx.setMode((ws2812fx.getMode() + 1) % ws2812fx.getModeCount());
|
||||
BlinkerMIOT.brightness(100 * ws2812fx.getBrightness() / 255);
|
||||
@@ -422,12 +428,12 @@ void changeRandomTheme() {
|
||||
|
||||
void Ws2812fxInit() {
|
||||
|
||||
ws2812three.init();
|
||||
ws2812three.setBrightness(DEFAULT_BRIGHTNESS);
|
||||
ws2812three.setSpeed(DEFAULT_SPEED);
|
||||
ws2812three.setColor(DEFAULT_COLOR);
|
||||
ws2812three.setMode(DEFAULT_MODE);
|
||||
ws2812three.start();
|
||||
// ws2812three.init();
|
||||
// ws2812three.setBrightness(DEFAULT_BRIGHTNESS);
|
||||
// ws2812three.setSpeed(DEFAULT_SPEED);
|
||||
// ws2812three.setColor(DEFAULT_COLOR);
|
||||
// ws2812three.setMode(DEFAULT_MODE);
|
||||
// ws2812three.start();
|
||||
|
||||
ws2812two.init();
|
||||
ws2812two.setBrightness(DEFAULT_BRIGHTNESS);
|
||||
@@ -464,7 +470,7 @@ void BlinkerInit() {
|
||||
// 工作模式
|
||||
workButton.attach(workButton_Callback);
|
||||
// 默认模式
|
||||
defaultButton.attach(defaultButton_Callback);
|
||||
defaultButton.·(defaultButton_Callback);
|
||||
// 休眠模式
|
||||
sleepButton.attach(sleepButton_Callback);
|
||||
// 随机模式
|
||||
@@ -501,7 +507,7 @@ void loop() {
|
||||
now = millis();
|
||||
ws2812fx.service();
|
||||
ws2812two.service();
|
||||
ws2812three.service();
|
||||
// ws2812three.service();
|
||||
Blinker.run();
|
||||
changeRandomTheme();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user