This commit is contained in:
Alex
2021-02-05 02:35:39 +03:00
parent 89a0dfa464
commit 74616748ec
23 changed files with 15 additions and 20 deletions

Binary file not shown.

View File

@@ -31,8 +31,8 @@ const char WiFiPassword[] = "12345678";
// ------------ Прочее -------------
#define MIC_VCC D6 // питание микрофона
#define PHOT_VCC D5 // питание фоторезистора
#define EE_TOUT 303000 // таймаут сохранения епром после изменения, мс
#define DEBUG_SERIAL // закомментируй чтобы выключить отладку (скорость 115200)
#define EE_TOUT 30000 // таймаут сохранения епром после изменения, мс
//#define DEBUG_SERIAL // закомментируй чтобы выключить отладку (скорость 115200)
#define EE_KEY 40 // ключ сброса WiFi (измени для сброса всех настроек)
#define NTP_UPD_PRD 5 // период обновления времени с NTP сервера, минут
@@ -89,6 +89,7 @@ void setup() {
startWiFi(); // старт вайфай
setupTime(); // выставляем время
setupADC(); // настраиваем анализ
presetRotation(true); // форсировать смену режима
}
void loop() {
@@ -97,7 +98,7 @@ void loop() {
parsing(); // ловим данные
yield();
checkEEupdate(); // сохраняем епром
presetRotation(); // смена режимов
presetRotation(0); // смена режимов по расписанию
effectsRoutine(); // мигаем
yield();
button(); // проверяем кнопку

View File

@@ -17,7 +17,7 @@ void EE_startup() {
EEPROM.get(sizeof(cfg) + sizeof(dawn), preset);
// запускаем всё
trnd.setChannel(cfg.group);
//trnd.setChannel(cfg.group);
FastLED.setMaxPowerInVoltsAndMilliamps(STRIP_VOLT, cfg.maxCur * 100);
}

View File

@@ -1,15 +1,14 @@
void effectsRoutine() {
static timerMillis effTmr(30, true);
if (cfg.state && effTmr.isReady()) {
FastLED.setBrightness(getBright());
int thisLength = getLength();
byte thisScale = getScale();
int thisWidth = (cfg.deviceType > 1) ? cfg.width : 1;
FastLED.setBrightness(getBright());
switch (CUR_PRES.effect) {
case 1: // =================================== ПЕРЛИН ===================================
FastLED.clear();
if (cfg.deviceType > 1) {
FOR_j(0, cfg.length) {
FOR_i(0, cfg.width) {
@@ -32,7 +31,6 @@ void effectsRoutine() {
}
break;
case 2: // ==================================== ЦВЕТ ====================================
FastLED.clear();
{
fill_solid(leds, cfg.length * thisWidth, CHSV(CUR_PRES.color, thisScale, CUR_PRES.min));
CRGB thisColor = CHSV(CUR_PRES.color, thisScale, CUR_PRES.max);
@@ -45,7 +43,6 @@ void effectsRoutine() {
}
break;
case 3: // ================================= СМЕНА ЦВЕТА =================================
FastLED.clear();
{
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);
@@ -59,7 +56,6 @@ void effectsRoutine() {
}
break;
case 4: // ================================== ГРАДИЕНТ ==================================
FastLED.clear();
if (CUR_PRES.fromCenter) {
FOR_i(cfg.length / 2, cfg.length) {
byte bright = 255;
@@ -88,15 +84,14 @@ void effectsRoutine() {
}
break;
case 5: // =================================== ЧАСТИЦЫ ===================================
//FastLED.clear();
FOR_i(0, cfg.length * cfg.width) leds[i].fadeToBlackBy(70);
if (cfg.deviceType > 1) {
uint16_t rndVal = 0;
FOR_i(0, thisScale / 8) {
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);
thisX = map(thisX, 20000, 45000, 0, cfg.width);
thisX = map(thisX, 10000, 55000, 0, cfg.width);
rndVal = rndVal * 2053 + 13849; // random2053 алгоритм
if (thisY >= 0 && thisY < cfg.length && thisX >= 0 && thisX < cfg.width)
@@ -106,14 +101,13 @@ void effectsRoutine() {
uint16_t rndVal = 0;
FOR_i(0, thisScale / 8) {
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 алгоритм
if (thisPos >= 0 && thisPos < cfg.length) leds[thisPos] = CHSV(CUR_PRES.rnd ? rndVal : CUR_PRES.color, 255, 255);
}
}
break;
case 6: // ==================================== ОГОНЬ ====================================
FastLED.clear();
{
if (cfg.deviceType > 1) { // 2D огонь
fireRoutine();

View File

@@ -91,6 +91,7 @@ void parsing() {
}
}
EE_updatePreset();
presetRotation(true); // форсировать смену режима
break;
case 3: DEBUGLN("Dawn");
@@ -111,6 +112,7 @@ void parsing() {
}
break;
}
FastLED.clear(); // на всякий случай
}
}
}

View File

@@ -1,5 +1,5 @@
void presetRotation() {
if (cfg.rotation && now.newMin()) { // если автосмена и новая минута
void presetRotation(bool force) {
if (cfg.rotation && (now.newMin() || force)) { // если автосмена и новая минута
if (cfg.rotRnd) { // случайная
cfg.curPreset = trnd.fromMin(cfg.rotPeriod, cfg.presetAmount);
DEBUG("Rnd changed to ");

View File

@@ -58,9 +58,7 @@ void checkGroup() {
}
if (flag) {
EEPROM.put(0, cfg);
EEPROM.commit();
delay(100);
ESP.reset();
EEPROM.commit();
}
DEBUG("group: ");
DEBUGLN(cfg.group);