mirror of
https://github.com/AlexGyver/GyverLamp2.git
synced 2025-08-08 01:00:37 +03:00
upd
This commit is contained in:
Binary file not shown.
@@ -31,8 +31,8 @@ const char WiFiPassword[] = "12345678";
|
|||||||
// ------------ Прочее -------------
|
// ------------ Прочее -------------
|
||||||
#define MIC_VCC D6 // питание микрофона
|
#define MIC_VCC D6 // питание микрофона
|
||||||
#define PHOT_VCC D5 // питание фоторезистора
|
#define PHOT_VCC D5 // питание фоторезистора
|
||||||
#define EE_TOUT 303000 // таймаут сохранения епром после изменения, мс
|
#define EE_TOUT 30000 // таймаут сохранения епром после изменения, мс
|
||||||
#define DEBUG_SERIAL // закомментируй чтобы выключить отладку (скорость 115200)
|
//#define DEBUG_SERIAL // закомментируй чтобы выключить отладку (скорость 115200)
|
||||||
#define EE_KEY 40 // ключ сброса WiFi (измени для сброса всех настроек)
|
#define EE_KEY 40 // ключ сброса WiFi (измени для сброса всех настроек)
|
||||||
#define NTP_UPD_PRD 5 // период обновления времени с NTP сервера, минут
|
#define NTP_UPD_PRD 5 // период обновления времени с NTP сервера, минут
|
||||||
|
|
||||||
@@ -89,6 +89,7 @@ void setup() {
|
|||||||
startWiFi(); // старт вайфай
|
startWiFi(); // старт вайфай
|
||||||
setupTime(); // выставляем время
|
setupTime(); // выставляем время
|
||||||
setupADC(); // настраиваем анализ
|
setupADC(); // настраиваем анализ
|
||||||
|
presetRotation(true); // форсировать смену режима
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
@@ -97,7 +98,7 @@ void loop() {
|
|||||||
parsing(); // ловим данные
|
parsing(); // ловим данные
|
||||||
yield();
|
yield();
|
||||||
checkEEupdate(); // сохраняем епром
|
checkEEupdate(); // сохраняем епром
|
||||||
presetRotation(); // смена режимов
|
presetRotation(0); // смена режимов по расписанию
|
||||||
effectsRoutine(); // мигаем
|
effectsRoutine(); // мигаем
|
||||||
yield();
|
yield();
|
||||||
button(); // проверяем кнопку
|
button(); // проверяем кнопку
|
@@ -17,7 +17,7 @@ void EE_startup() {
|
|||||||
EEPROM.get(sizeof(cfg) + sizeof(dawn), preset);
|
EEPROM.get(sizeof(cfg) + sizeof(dawn), preset);
|
||||||
|
|
||||||
// запускаем всё
|
// запускаем всё
|
||||||
trnd.setChannel(cfg.group);
|
//trnd.setChannel(cfg.group);
|
||||||
FastLED.setMaxPowerInVoltsAndMilliamps(STRIP_VOLT, cfg.maxCur * 100);
|
FastLED.setMaxPowerInVoltsAndMilliamps(STRIP_VOLT, cfg.maxCur * 100);
|
||||||
}
|
}
|
||||||
|
|
@@ -1,15 +1,14 @@
|
|||||||
void effectsRoutine() {
|
void effectsRoutine() {
|
||||||
static timerMillis effTmr(30, true);
|
static timerMillis effTmr(30, true);
|
||||||
if (cfg.state && effTmr.isReady()) {
|
if (cfg.state && effTmr.isReady()) {
|
||||||
FastLED.setBrightness(getBright());
|
|
||||||
|
|
||||||
int thisLength = getLength();
|
int thisLength = getLength();
|
||||||
byte thisScale = getScale();
|
byte thisScale = getScale();
|
||||||
int thisWidth = (cfg.deviceType > 1) ? cfg.width : 1;
|
int thisWidth = (cfg.deviceType > 1) ? cfg.width : 1;
|
||||||
|
|
||||||
|
FastLED.setBrightness(getBright());
|
||||||
|
|
||||||
switch (CUR_PRES.effect) {
|
switch (CUR_PRES.effect) {
|
||||||
case 1: // =================================== ПЕРЛИН ===================================
|
case 1: // =================================== ПЕРЛИН ===================================
|
||||||
FastLED.clear();
|
|
||||||
if (cfg.deviceType > 1) {
|
if (cfg.deviceType > 1) {
|
||||||
FOR_j(0, cfg.length) {
|
FOR_j(0, cfg.length) {
|
||||||
FOR_i(0, cfg.width) {
|
FOR_i(0, cfg.width) {
|
||||||
@@ -32,7 +31,6 @@ void effectsRoutine() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: // ==================================== ЦВЕТ ====================================
|
case 2: // ==================================== ЦВЕТ ====================================
|
||||||
FastLED.clear();
|
|
||||||
{
|
{
|
||||||
fill_solid(leds, cfg.length * thisWidth, CHSV(CUR_PRES.color, thisScale, CUR_PRES.min));
|
fill_solid(leds, cfg.length * thisWidth, CHSV(CUR_PRES.color, thisScale, CUR_PRES.min));
|
||||||
CRGB thisColor = CHSV(CUR_PRES.color, thisScale, CUR_PRES.max);
|
CRGB thisColor = CHSV(CUR_PRES.color, thisScale, CUR_PRES.max);
|
||||||
@@ -45,7 +43,6 @@ void effectsRoutine() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: // ================================= СМЕНА ЦВЕТА =================================
|
case 3: // ================================= СМЕНА ЦВЕТА =================================
|
||||||
FastLED.clear();
|
|
||||||
{
|
{
|
||||||
CRGB thisColor = ColorFromPalette(paletteArr[CUR_PRES.palette - 1], (now.weekMs >> 5) * CUR_PRES.speed / 255, CUR_PRES.min, LINEARBLEND);
|
CRGB thisColor = ColorFromPalette(paletteArr[CUR_PRES.palette - 1], (now.weekMs >> 5) * CUR_PRES.speed / 255, CUR_PRES.min, LINEARBLEND);
|
||||||
fill_solid(leds, cfg.length * thisWidth, thisColor);
|
fill_solid(leds, cfg.length * thisWidth, thisColor);
|
||||||
@@ -59,7 +56,6 @@ void effectsRoutine() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4: // ================================== ГРАДИЕНТ ==================================
|
case 4: // ================================== ГРАДИЕНТ ==================================
|
||||||
FastLED.clear();
|
|
||||||
if (CUR_PRES.fromCenter) {
|
if (CUR_PRES.fromCenter) {
|
||||||
FOR_i(cfg.length / 2, cfg.length) {
|
FOR_i(cfg.length / 2, cfg.length) {
|
||||||
byte bright = 255;
|
byte bright = 255;
|
||||||
@@ -88,15 +84,14 @@ void effectsRoutine() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5: // =================================== ЧАСТИЦЫ ===================================
|
case 5: // =================================== ЧАСТИЦЫ ===================================
|
||||||
//FastLED.clear();
|
|
||||||
FOR_i(0, cfg.length * cfg.width) leds[i].fadeToBlackBy(70);
|
FOR_i(0, cfg.length * cfg.width) leds[i].fadeToBlackBy(70);
|
||||||
if (cfg.deviceType > 1) {
|
if (cfg.deviceType > 1) {
|
||||||
uint16_t rndVal = 0;
|
uint16_t rndVal = 0;
|
||||||
FOR_i(0, thisScale / 8) {
|
FOR_i(0, thisScale / 8) {
|
||||||
int thisY = inoise16(i * 100000000ul + (now.weekMs << 6) * CUR_PRES.speed / 255);
|
int thisY = inoise16(i * 100000000ul + (now.weekMs << 6) * CUR_PRES.speed / 255);
|
||||||
thisY = map(thisY, 20000, 45000, 0, cfg.length);
|
thisY = map(thisY, 10000, 55000, 0, cfg.length);
|
||||||
int thisX = inoise16(i * 100000000ul + 2000000000ul + (now.weekMs << 6) * CUR_PRES.speed / 255);
|
int thisX = inoise16(i * 100000000ul + 2000000000ul + (now.weekMs << 6) * CUR_PRES.speed / 255);
|
||||||
thisX = map(thisX, 20000, 45000, 0, cfg.width);
|
thisX = map(thisX, 10000, 55000, 0, cfg.width);
|
||||||
rndVal = rndVal * 2053 + 13849; // random2053 алгоритм
|
rndVal = rndVal * 2053 + 13849; // random2053 алгоритм
|
||||||
|
|
||||||
if (thisY >= 0 && thisY < cfg.length && thisX >= 0 && thisX < cfg.width)
|
if (thisY >= 0 && thisY < cfg.length && thisX >= 0 && thisX < cfg.width)
|
||||||
@@ -106,14 +101,13 @@ void effectsRoutine() {
|
|||||||
uint16_t rndVal = 0;
|
uint16_t rndVal = 0;
|
||||||
FOR_i(0, thisScale / 8) {
|
FOR_i(0, thisScale / 8) {
|
||||||
int thisPos = inoise16(i * 100000000ul + (now.weekMs << 6) * CUR_PRES.speed / 255);
|
int thisPos = inoise16(i * 100000000ul + (now.weekMs << 6) * CUR_PRES.speed / 255);
|
||||||
thisPos = map(thisPos, 20000, 45000, 0, cfg.length);
|
thisPos = map(thisPos, 10000, 55000, 0, cfg.length);
|
||||||
rndVal = rndVal * 2053 + 13849; // random2053 алгоритм
|
rndVal = rndVal * 2053 + 13849; // random2053 алгоритм
|
||||||
if (thisPos >= 0 && thisPos < cfg.length) leds[thisPos] = CHSV(CUR_PRES.rnd ? rndVal : CUR_PRES.color, 255, 255);
|
if (thisPos >= 0 && thisPos < cfg.length) leds[thisPos] = CHSV(CUR_PRES.rnd ? rndVal : CUR_PRES.color, 255, 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 6: // ==================================== ОГОНЬ ====================================
|
case 6: // ==================================== ОГОНЬ ====================================
|
||||||
FastLED.clear();
|
|
||||||
{
|
{
|
||||||
if (cfg.deviceType > 1) { // 2D огонь
|
if (cfg.deviceType > 1) { // 2D огонь
|
||||||
fireRoutine();
|
fireRoutine();
|
@@ -91,6 +91,7 @@ void parsing() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EE_updatePreset();
|
EE_updatePreset();
|
||||||
|
presetRotation(true); // форсировать смену режима
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: DEBUGLN("Dawn");
|
case 3: DEBUGLN("Dawn");
|
||||||
@@ -111,6 +112,7 @@ void parsing() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
FastLED.clear(); // на всякий случай
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
void presetRotation() {
|
void presetRotation(bool force) {
|
||||||
if (cfg.rotation && now.newMin()) { // если автосмена и новая минута
|
if (cfg.rotation && (now.newMin() || force)) { // если автосмена и новая минута
|
||||||
if (cfg.rotRnd) { // случайная
|
if (cfg.rotRnd) { // случайная
|
||||||
cfg.curPreset = trnd.fromMin(cfg.rotPeriod, cfg.presetAmount);
|
cfg.curPreset = trnd.fromMin(cfg.rotPeriod, cfg.presetAmount);
|
||||||
DEBUG("Rnd changed to ");
|
DEBUG("Rnd changed to ");
|
@@ -58,9 +58,7 @@ void checkGroup() {
|
|||||||
}
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
EEPROM.put(0, cfg);
|
EEPROM.put(0, cfg);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
delay(100);
|
|
||||||
ESP.reset();
|
|
||||||
}
|
}
|
||||||
DEBUG("group: ");
|
DEBUG("group: ");
|
||||||
DEBUGLN(cfg.group);
|
DEBUGLN(cfg.group);
|
Reference in New Issue
Block a user