This commit is contained in:
Alex
2019-06-13 14:03:00 +03:00
parent 53b74e6db4
commit 7612db75b1
496 changed files with 202963 additions and 24 deletions

View File

@@ -1,6 +1,25 @@
/*
Скетч к проекту "Многофункциональный RGB светильник"
Страница проекта (схемы, описания): https://alexgyver.ru/GyverLamp/
Исходники на GitHub: https://github.com/AlexGyver/GyverLamp/
Нравится, как написан код? Поддержи автора! https://alexgyver.ru/support_alex/
Автор: AlexGyver, AlexGyver Technologies, 2019
https://AlexGyver.ru/
*/
// Ссылка для менеджера плат:
// http://arduino.esp8266.com/stable/package_esp8266com_index.json
// ============= НАСТРОЙКИ =============
// ---------- МАТРИЦА ---------
// -------- ВРЕМЯ -------
#define GMT 3 // смещение (москва 3)
#define NTP_ADDRESS "europe.pool.ntp.org" // сервер времени
// -------- РАССВЕТ -------
#define DAWN_BRIGHT 200 // макс. яркость рассвета
#define DAWN_TIMEOUT 1 // сколько рассвет светит после времени будильника, минут
// ---------- МАТРИЦА ---------
#define BRIGHTNESS 40 // стандартная маскимальная яркость (0-255)
#define CURRENT_LIMIT 2000 // лимит по току в миллиамперах, автоматически управляет яркостью (пожалей свой блок питания!) 0 - выключить лимит
@@ -15,28 +34,25 @@
// при неправильной настрйоке матрицы вы получите предупреждение "Wrong matrix parameters! Set to default"
// шпаргалка по настройке матрицы здесь! https://alexgyver.ru/matrix_guide/
#define LED_PIN 2 // пин ленты
#define MODE_AMOUNT 14
// -------- ВРЕМЯ -------
#define GMT 3 // смещение (москва 3)
#define NTP_ADDRESS "europe.pool.ntp.org" // сервер времени
// --------- ESP --------
#define ESP_MODE 1
// 0 - точка доступа (192.168.4.1)
// 1 - локальный (192.168.1.232)
// 0 - точка доступа (192.168.4.1 или другой)
// 1 - локальный (192.168.1.232 или другой)
// -------- Менеджер WiFi ---------
#define AC_SSID "AutoConnectAP"
#define AC_PASS "12345678"
// -------------- AP ---------------
#define AP_SSID "GyverControl"
#define AP_SSID "GyverLamp"
#define AP_PASS "12345678"
#define AP_PORT 8888
// ============= ДЛЯ РАЗРАБОТЧИКОВ =============
#define LED_PIN 2 // пин ленты
#define BTN_PIN 4
#define MODE_AMOUNT 14
#define NUM_LEDS WIDTH * HEIGHT
#define SEGMENTS 1 // диодов в одном "пикселе" (для создания матрицы из кусков ленты)
// ---------------- БИБЛИОТЕКИ -----------------
@@ -54,6 +70,7 @@
#include <WiFiUdp.h>
#include <EEPROM.h>
#include <NTPClient.h>
#include <GyverButton.h>
// ------------------- ТИПЫ --------------------
CRGB leds[NUM_LEDS];
@@ -62,6 +79,7 @@ WiFiUDP Udp;
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, NTP_ADDRESS, GMT * 3600, NTP_INTERVAL);
timerMinim timeTimer(3000);
GButton touch(BTN_PIN, LOW_PULL, NORM_OPEN);
// ----------------- ПЕРЕМЕННЫЕ ------------------
const char* autoConnectSSID = AC_SSID;
@@ -99,7 +117,16 @@ boolean settChanged = false;
// Павлин 3D, Зебра 3D, Лес 3D, Океан 3D,
void setup() {
ESP.wdtDisable();
ESP.wdtEnable(WDTO_8S);
delay(1000);
// ЛЕНТА
FastLED.addLeds<WS2812B, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)/*.setCorrection( TypicalLEDStrip )*/;
FastLED.setBrightness(BRIGHTNESS);
if (CURRENT_LIMIT > 0) FastLED.setMaxPowerInVoltsAndMilliamps(5, CURRENT_LIMIT);
FastLED.clear();
FastLED.show();
randomSeed(analogRead(0)); // пинаем генератор случайных чисел
Serial.begin(115200);
// WI-FI
@@ -154,14 +181,6 @@ void setup() {
dawnMode = EEPROM.read(100);
currentMode = EEPROM.read(101);
// ЛЕНТА
FastLED.addLeds<WS2812B, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)/*.setCorrection( TypicalLEDStrip )*/;
FastLED.setBrightness(BRIGHTNESS);
if (CURRENT_LIMIT > 0) FastLED.setMaxPowerInVoltsAndMilliamps(5, CURRENT_LIMIT);
FastLED.clear();
FastLED.show();
randomSeed(analogRead(0)); // пинаем генератор случайных чисел
// отправляем настройки
sendCurrent();
char reply[inputBuffer.length() + 1];
@@ -171,6 +190,7 @@ void setup() {
Udp.endPacket();
timeClient.begin();
touch.setStepTimeout(100);
}
void loop() {
@@ -178,6 +198,8 @@ void loop() {
effectsTick();
eepromTick();
timeTick();
buttonTick();
ESP.wdtFeed(); // пнуть собаку
}
void eeWriteInt(int pos, int val) {