mirror of
https://github.com/AlexGyver/GyverLamp2.git
synced 2025-08-07 16:50:35 +03:00
v0.9b
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
// FastLED 3.4.0+ https://github.com/FastLED/FastLED/releases
|
||||
|
||||
// ---------- Настройки -----------
|
||||
#define MAX_PRESETS 20 // макс количество режимов (не более 30)
|
||||
#define GL_KEY "GL" // ключ сети
|
||||
|
||||
// ------------ Кнопка -------------
|
||||
@@ -33,7 +32,7 @@ const char WiFiPassword[] = "12345678";
|
||||
#define PHOT_VCC D5 // питание фоторезистора
|
||||
#define EE_TOUT 30000 // таймаут сохранения епром после изменения, мс
|
||||
//#define DEBUG_SERIAL // закомментируй чтобы выключить отладку (скорость 115200)
|
||||
#define EE_KEY 40 // ключ сброса WiFi (измени для сброса всех настроек)
|
||||
#define EE_KEY 42 // ключ сброса WiFi (измени для сброса всех настроек)
|
||||
#define NTP_UPD_PRD 5 // период обновления времени с NTP сервера, минут
|
||||
|
||||
// ---------- БИБЛИОТЕКИ -----------
|
@@ -15,6 +15,7 @@
|
||||
#define GL_REACT_LEN 3
|
||||
#define GL_SLAVE 0
|
||||
#define GL_MASTER 1
|
||||
#define MAX_PRESETS 25 // макс количество режимов
|
||||
|
||||
// ------------------- МАКРО --------------------
|
||||
#ifdef DEBUG_SERIAL
|
||||
@@ -62,8 +63,8 @@ struct Config {
|
||||
byte workFrom = 0; // часы работы (0,1.. 23)
|
||||
byte workTo = 0; // часы работы (0,1.. 23)
|
||||
|
||||
int length = 100; // длина ленты
|
||||
int width = 1; // ширина матрицы
|
||||
int16_t length = 100; // длина ленты
|
||||
int16_t width = 1; // ширина матрицы
|
||||
|
||||
byte state = 1; // состояние 0 выкл, 1 вкл
|
||||
byte group = 1; // группа девайса (1-10)
|
||||
@@ -72,10 +73,10 @@ struct Config {
|
||||
byte presetAmount = 1; // количество режимов
|
||||
byte manualOff = 0; // выключали вручную?
|
||||
int8_t curPreset = 0; // текущий режим
|
||||
int minLight = 0; // мин освещённость
|
||||
int maxLight = 1023; // макс освещённость
|
||||
char ssid[16]; // логин wifi
|
||||
char pass[16]; // пароль wifi
|
||||
int16_t minLight = 0; // мин освещённость
|
||||
int16_t maxLight = 1023; // макс освещённость
|
||||
char ssid[32]; // логин wifi
|
||||
char pass[32]; // пароль wifi
|
||||
};
|
||||
|
||||
#define PRES_SIZE 13
|
@@ -1,11 +1,16 @@
|
||||
void effectsRoutine() {
|
||||
static timerMillis effTmr(30, true);
|
||||
static byte prevEff = 255;
|
||||
if (cfg.state && effTmr.isReady()) {
|
||||
int thisLength = getLength();
|
||||
byte thisScale = getScale();
|
||||
int thisWidth = (cfg.deviceType > 1) ? cfg.width : 1;
|
||||
|
||||
FastLED.setBrightness(getBright());
|
||||
if (prevEff != CUR_PRES.effect) {
|
||||
FastLED.clear();
|
||||
prevEff = CUR_PRES.effect;
|
||||
}
|
||||
|
||||
switch (CUR_PRES.effect) {
|
||||
case 1: // =================================== ПЕРЛИН ===================================
|
||||
@@ -134,7 +139,7 @@ void effectsRoutine() {
|
||||
}
|
||||
break;
|
||||
case 7: // ================================== КОНФЕТТИ ==================================
|
||||
FOR_i(0, thisScale >> 3) {
|
||||
FOR_i(0, (thisScale >> 3) + 1) {
|
||||
byte x = random(0, cfg.length * cfg.width);
|
||||
if (leds[x] == CRGB(0, 0, 0)) leds[x] = CHSV(CUR_PRES.rnd ? random(0, 255) : CUR_PRES.color, 255, 255);
|
||||
}
|
@@ -73,7 +73,9 @@ void parsing() {
|
||||
}
|
||||
cfg.length = data[17] | (data[16] << 8); // склеиваем
|
||||
cfg.width = data[20] | (data[19] << 8); // склеиваем
|
||||
if (cfg.length > MAX_LEDS) cfg.length = MAX_LEDS;
|
||||
if (cfg.deviceType == GL_TYPE_STRIP) cfg.width = 1;
|
||||
if (cfg.length * cfg.width > MAX_LEDS) cfg.width = MAX_LEDS / cfg.length;
|
||||
ntp.setTimeOffset((cfg.GMT - 13) * 3600);
|
||||
ntp.setPoolServerName(NTPservers[cfg.NTP - 1]);
|
||||
FastLED.setMaxPowerInVoltsAndMilliamps(STRIP_VOLT, cfg.maxCur * 100);
|
Reference in New Issue
Block a user