mirror of
https://github.com/AlexGyver/GyverLamp2.git
synced 2025-08-08 17:11:05 +03:00
v0.22b
This commit is contained in:
@@ -68,7 +68,7 @@ void drawDots(int X, int Y, CRGB color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drawClock(byte Y, byte speed, CRGB color) {
|
void drawClock(byte Y, byte speed, CRGB color) {
|
||||||
if (cfg.deviceType == 1 || cfg.width < 16) return; // лента или мелкая матрица - на выход
|
if (cfg.deviceType == 1) return; // лента - на выход
|
||||||
byte h1, h2, m1, m2;
|
byte h1, h2, m1, m2;
|
||||||
if (gotNTP || gotTime) {
|
if (gotNTP || gotTime) {
|
||||||
h1 = now.hour / 10;
|
h1 = now.hour / 10;
|
||||||
|
@@ -1,4 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
|
Версия 0.22b
|
||||||
|
Чуть переделан смерч
|
||||||
|
Исправлены глюки когда есть вайфай но нет интернета
|
||||||
|
Добавлено свечение после завершения рассвета, время настраивается
|
||||||
|
Обновлены бинарники, прошлая версия могла быть с ошибкой
|
||||||
|
|
||||||
Версия 0.21b
|
Версия 0.21b
|
||||||
Выбор палитры для частиц и конфетти
|
Выбор палитры для частиц и конфетти
|
||||||
Счётчик количества ламп онлайн в приложении
|
Счётчик количества ламп онлайн в приложении
|
||||||
@@ -115,10 +121,10 @@ const char AP_NameChar[] = "GyverLamp2";
|
|||||||
const char WiFiPassword[] = "12345678";
|
const char WiFiPassword[] = "12345678";
|
||||||
|
|
||||||
// ------------ Прочее -------------
|
// ------------ Прочее -------------
|
||||||
#define GL_VERSION 21 // код версии прошивки
|
#define GL_VERSION 22 // код версии прошивки
|
||||||
#define EE_TOUT 30000 // таймаут сохранения епром после изменения, мс
|
#define EE_TOUT 30000 // таймаут сохранения епром после изменения, мс
|
||||||
//#define DEBUG_SERIAL // закомментируй чтобы выключить отладку (скорость 115200)
|
//#define DEBUG_SERIAL // закомментируй чтобы выключить отладку (скорость 115200)
|
||||||
#define EE_KEY 55 // ключ сброса WiFi (измени для сброса всех настроек)
|
#define EE_KEY 56 // ключ сброса eeprom
|
||||||
#define NTP_UPD_PRD 5 // период обновления времени с NTP сервера, минут
|
#define NTP_UPD_PRD 5 // период обновления времени с NTP сервера, минут
|
||||||
//#define SKIP_WIFI // пропустить подключение к вафле (для отладки)
|
//#define SKIP_WIFI // пропустить подключение к вафле (для отладки)
|
||||||
|
|
||||||
@@ -178,7 +184,7 @@ CRGB leds[MAX_LEDS];
|
|||||||
Time now;
|
Time now;
|
||||||
Button btn(BTN_PIN);
|
Button btn(BTN_PIN);
|
||||||
timerMillis EEtmr(EE_TOUT), turnoffTmr, connTmr(120000ul), dawnTmr, holdPresTmr(30000ul), blinkTmr(300);
|
timerMillis EEtmr(EE_TOUT), turnoffTmr, connTmr(120000ul), dawnTmr, holdPresTmr(30000ul), blinkTmr(300);
|
||||||
timerMillis effTmr(30, true), onlineTmr(500, true);
|
timerMillis effTmr(30, true), onlineTmr(500, true), postDawn(10 * 60000ul);
|
||||||
TimeRandom trnd;
|
TimeRandom trnd;
|
||||||
VolAnalyzer vol(A0), low, high;
|
VolAnalyzer vol(A0), low, high;
|
||||||
FastFilter phot;
|
FastFilter phot;
|
||||||
|
@@ -81,7 +81,7 @@ struct Config {
|
|||||||
int16_t length = 16; // длина ленты
|
int16_t length = 16; // длина ленты
|
||||||
int16_t width = 16; // ширина матрицы
|
int16_t width = 16; // ширина матрицы
|
||||||
|
|
||||||
byte GMT = 3; // часовой пояс +13
|
byte GMT = 16; // часовой пояс +13
|
||||||
uint32_t cityID = 1; // city ID
|
uint32_t cityID = 1; // city ID
|
||||||
bool mqtt = 0; // mqtt
|
bool mqtt = 0; // mqtt
|
||||||
char mqttID[32]; //
|
char mqttID[32]; //
|
||||||
@@ -122,13 +122,14 @@ struct Preset {
|
|||||||
byte fromPal = 0; // из палитры (0/1)
|
byte fromPal = 0; // из палитры (0/1)
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DAWN_SIZE 23
|
#define DAWN_SIZE 24
|
||||||
struct Dawn {
|
struct Dawn {
|
||||||
byte state[7] = {0, 0, 0, 0, 0, 0, 0}; // (1/0)
|
byte state[7] = {0, 0, 0, 0, 0, 0, 0}; // (1/0)
|
||||||
byte hour[7] = {0, 0, 0, 0, 0, 0, 0}; // (0.. 59)
|
byte hour[7] = {0, 0, 0, 0, 0, 0, 0}; // (0.. 59)
|
||||||
byte minute[7] = {0, 0, 0, 0, 0, 0, 0}; // (0.. 59)
|
byte minute[7] = {0, 0, 0, 0, 0, 0, 0}; // (0.. 59)
|
||||||
byte bright = 100; // (0.. 255)
|
byte bright = 100; // (0.. 255)
|
||||||
byte time = 1; // (5,10,15,20..)
|
byte time = 1; // (5,10,15,20..)
|
||||||
|
byte post = 1; // (5,10,15,20..)
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -26,6 +26,11 @@ void EE_startup() {
|
|||||||
DEBUGLN(sizeof(cfg) + sizeof(dawn) + sizeof(pal) + sizeof(preset) + 1);
|
DEBUGLN(sizeof(cfg) + sizeof(dawn) + sizeof(pal) + sizeof(preset) + 1);
|
||||||
|
|
||||||
// запускаем всё
|
// запускаем всё
|
||||||
|
if (cfg.deviceType == GL_TYPE_STRIP) {
|
||||||
|
if (cfg.length > MAX_LEDS) cfg.length = MAX_LEDS;
|
||||||
|
cfg.width = 1;
|
||||||
|
}
|
||||||
|
if (cfg.length * cfg.width > MAX_LEDS) cfg.width = MAX_LEDS / cfg.length;
|
||||||
FastLED.setMaxPowerInVoltsAndMilliamps(STRIP_VOLT, cfg.maxCur * 100);
|
FastLED.setMaxPowerInVoltsAndMilliamps(STRIP_VOLT, cfg.maxCur * 100);
|
||||||
updPal();
|
updPal();
|
||||||
}
|
}
|
||||||
|
@@ -2,12 +2,19 @@ void effectsRoutine() {
|
|||||||
static byte prevEff = 255;
|
static byte prevEff = 255;
|
||||||
if (!effTmr.isReady()) return;
|
if (!effTmr.isReady()) return;
|
||||||
|
|
||||||
if (dawnTmr.running()) {
|
if (dawnTmr.running() || postDawn.running()) {
|
||||||
fill_solid(leds, MAX_LEDS, ColorFromPalette(HeatColors_p, dawnTmr.getLength8(), scaleFF(dawnTmr.getLength8(), dawn.bright), LINEARBLEND));
|
byte thisColor = dawnTmr.getLength8();
|
||||||
|
if (postDawn.running()) thisColor = 255;
|
||||||
|
fill_solid(leds, MAX_LEDS, ColorFromPalette(HeatColors_p, thisColor, scaleFF(thisColor, dawn.bright), LINEARBLEND));
|
||||||
drawClock(cfg.length / 2 - 4, 100, 0);
|
drawClock(cfg.length / 2 - 4, 100, 0);
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
if (dawnTmr.isReady()) {
|
if (dawnTmr.isReady()) {
|
||||||
dawnTmr.stop();
|
dawnTmr.stop();
|
||||||
|
postDawn.setInterval(dawn.post * 60000ul);
|
||||||
|
postDawn.restart();
|
||||||
|
}
|
||||||
|
if (postDawn.isReady()) {
|
||||||
|
postDawn.stop();
|
||||||
FastLED.clear();
|
FastLED.clear();
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
@@ -234,12 +241,11 @@ void effectsRoutine() {
|
|||||||
FOR_k(0, (thisScale >> 5) + 1) {
|
FOR_k(0, (thisScale >> 5) + 1) {
|
||||||
FOR_i(0, cfg.length) {
|
FOR_i(0, cfg.length) {
|
||||||
//byte thisPos = inoise8(i * 10 - (now.weekMs >> 1) * CUR_PRES.speed / 255, k * 10000);
|
//byte thisPos = inoise8(i * 10 - (now.weekMs >> 1) * CUR_PRES.speed / 255, k * 10000);
|
||||||
byte thisPos = inoise8(i * 10 + k * 10000, (now.weekMs >> 1) * CUR_PRES.speed / 255);
|
byte thisPos = inoise8(i * 10 + (now.weekMs >> 3) * CUR_PRES.speed / 255 + k * 10000, (now.weekMs >> 1) * CUR_PRES.speed / 255);
|
||||||
thisPos = map(thisPos, 50, 200, 0, cfg.width);
|
thisPos = map(thisPos, 50, 200, 0, cfg.width);
|
||||||
byte scale = 3;
|
byte scale = 4;
|
||||||
FOR_j(0, scale) {
|
FOR_j(0, scale) {
|
||||||
CRGB color = ColorFromPalette(paletteArr[CUR_PRES.palette - 1], scalePal(j * 255 / scale), 255, LINEARBLEND);
|
CRGB color = ColorFromPalette(paletteArr[CUR_PRES.palette - 1], scalePal(j * 255 / scale), (255 - j * 255 / (scale - 1)), LINEARBLEND);
|
||||||
color.fadeToBlackBy(j * 255 / scale);
|
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
setPixOverlap(thisPos, i, color);
|
setPixOverlap(thisPos, i, color);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
// TODO
|
#ifndef mString_h
|
||||||
// защита от переполнения
|
#define mString_h
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
char* mUtoa(uint32_t value, char *buffer, bool clear = 1);
|
char* mUtoa(uint32_t value, char *buffer, bool clear = 1);
|
||||||
char* mLtoa(int32_t value, char *buffer, bool clear = 1);
|
char* mLtoa(int32_t value, char *buffer, bool clear = 1);
|
||||||
@@ -356,5 +358,5 @@ class mString {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
#endif
|
@@ -42,8 +42,9 @@ void controlHandler(bool state) {
|
|||||||
DEBUGLN("stop off timer");
|
DEBUGLN("stop off timer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dawnTmr.running()) {
|
if (dawnTmr.running() || postDawn.running()) {
|
||||||
dawnTmr.stop();
|
dawnTmr.stop();
|
||||||
|
postDawn.stop();
|
||||||
delay(50);
|
delay(50);
|
||||||
FastLED.clear();
|
FastLED.clear();
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
void setupTime() {
|
void setupTime() {
|
||||||
ntp.setUpdateInterval(NTP_UPD_PRD * 60000ul);
|
ntp.setUpdateInterval(NTP_UPD_PRD * 60000ul / 2); // ставим меньше, так как апдейт вручную
|
||||||
ntp.setTimeOffset((cfg.GMT - 13) * 3600);
|
ntp.setTimeOffset((cfg.GMT - 13) * 3600l);
|
||||||
ntp.setPoolServerName(NTPserver);
|
ntp.setPoolServerName(NTPserver);
|
||||||
if (cfg.WiFimode && !connTmr.running()) { // если успешно подключились к WiFi
|
if (cfg.WiFimode && !connTmr.running()) { // если успешно подключились к WiFi
|
||||||
ntp.begin();
|
ntp.begin();
|
||||||
@@ -19,7 +19,7 @@ void timeTicker() {
|
|||||||
now.day = ntp.getDay(); // вс 0, сб 6
|
now.day = ntp.getDay(); // вс 0, сб 6
|
||||||
now.weekMs = now.getWeekS() * 1000ul + ntp.getMillis();
|
now.weekMs = now.getWeekS() * 1000ul + ntp.getMillis();
|
||||||
now.setMs(ntp.getMillis());
|
now.setMs(ntp.getMillis());
|
||||||
if (ntp.update()) gotNTP = true;
|
if (now.sec == 0 && now.min % NTP_UPD_PRD == 0 && ntp.update()) gotNTP = true;
|
||||||
} else { // если вайфай не подключен
|
} else { // если вайфай не подключен
|
||||||
now.tick(); // тикаем своим счётчиком
|
now.tick(); // тикаем своим счётчиком
|
||||||
}
|
}
|
||||||
@@ -75,6 +75,7 @@ void checkWorkTime() {
|
|||||||
byte curState = isWorkTime(now.hour, cfg.workFrom, cfg.workTo);
|
byte curState = isWorkTime(now.hour, cfg.workFrom, cfg.workTo);
|
||||||
if (prevState != curState) { // переключение расписания
|
if (prevState != curState) { // переключение расписания
|
||||||
prevState = curState;
|
prevState = curState;
|
||||||
|
// todo: проверить пересечение с рассветом
|
||||||
if (curState && !cfg.state && !cfg.manualOff) fade(1); // нужно включить, а лампа выключена и не выключалась вручную
|
if (curState && !cfg.state && !cfg.manualOff) fade(1); // нужно включить, а лампа выключена и не выключалась вручную
|
||||||
if (!curState && cfg.state) fade(0); // нужно выключить, а лампа включена
|
if (!curState && cfg.state) fade(0); // нужно выключить, а лампа включена
|
||||||
}
|
}
|
||||||
|
@@ -38,7 +38,7 @@ class timerMillis {
|
|||||||
return _active;
|
return _active;
|
||||||
}
|
}
|
||||||
byte getLength8() {
|
byte getLength8() {
|
||||||
return (_active) ? ((millis() - _tmr) * 255ul / _interval) : 0;
|
return (_active) ? ((min(uint32_t(millis() - _tmr), _interval)) * 255ul / _interval) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user