Store config
This commit is contained in:
parent
5a743d066c
commit
c797365292
1 changed files with 20 additions and 8 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <SPIFFS.h>
|
#include <SPIFFS.h>
|
||||||
#include <WiFiSettings.h>
|
#include <WiFiSettings.h>
|
||||||
#include <ezTime.h>
|
#include <ezTime.h>
|
||||||
|
#include <Preferences.h>
|
||||||
|
|
||||||
// Information about this device.
|
// Information about this device.
|
||||||
// All these keys will be added to a "device" key in the Home Assistant configuration for each entity.
|
// All these keys will be added to a "device" key in the Home Assistant configuration for each entity.
|
||||||
|
@ -48,11 +49,7 @@ ezButton encoder2Button(22);
|
||||||
|
|
||||||
MatrixPanel_I2S_DMA *dma_display = nullptr;
|
MatrixPanel_I2S_DMA *dma_display = nullptr;
|
||||||
|
|
||||||
uint16_t myBLACK = dma_display->color565(0, 0, 0);
|
Preferences prefs;
|
||||||
uint16_t myWHITE = dma_display->color565(255, 255, 255);
|
|
||||||
uint16_t myRED = dma_display->color565(255, 0, 0);
|
|
||||||
uint16_t myGREEN = dma_display->color565(0, 255, 0);
|
|
||||||
uint16_t myBLUE = dma_display->color565(0, 0, 255);
|
|
||||||
|
|
||||||
#define XMAX 64
|
#define XMAX 64
|
||||||
#define YMAX 32
|
#define YMAX 32
|
||||||
|
@ -110,6 +107,8 @@ void setup()
|
||||||
|
|
||||||
Serial.println("Moin");
|
Serial.println("Moin");
|
||||||
|
|
||||||
|
prefs.begin("transigione");
|
||||||
|
|
||||||
encoder1Button.setDebounceTime(50);
|
encoder1Button.setDebounceTime(50);
|
||||||
encoder2Button.setDebounceTime(50);
|
encoder2Button.setDebounceTime(50);
|
||||||
|
|
||||||
|
@ -119,8 +118,8 @@ void setup()
|
||||||
encoder2.attachSingleEdge(32, 33);
|
encoder2.attachSingleEdge(32, 33);
|
||||||
encoder1.setFilter(1023);
|
encoder1.setFilter(1023);
|
||||||
encoder2.setFilter(1023);
|
encoder2.setFilter(1023);
|
||||||
encoder1.setCount(BRIGHTNESS << 1);
|
encoder1.setCount(prefs.getUChar("brightness", BRIGHTNESS) << 1);
|
||||||
encoder2.setCount(program);
|
encoder2.setCount(prefs.getUChar("program", 0));
|
||||||
|
|
||||||
SPIFFS.begin(true); // On first run, will format after failing to mount
|
SPIFFS.begin(true); // On first run, will format after failing to mount
|
||||||
WiFiSettings.hostname = "transigione-";
|
WiFiSettings.hostname = "transigione-";
|
||||||
|
@ -260,6 +259,7 @@ void loop()
|
||||||
{
|
{
|
||||||
brightness = encoder1.getCount() >> 1;
|
brightness = encoder1.getCount() >> 1;
|
||||||
_ha_entity_light->publishBrightness(brightness << 1);
|
_ha_entity_light->publishBrightness(brightness << 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dma_display->setBrightness8(power ? brightness : 0);
|
dma_display->setBrightness8(power ? brightness : 0);
|
||||||
|
@ -281,6 +281,18 @@ void loop()
|
||||||
_ha_entity_light->publishEffect(*it);
|
_ha_entity_light->publishEffect(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (minuteChanged()) {
|
||||||
|
Serial.println("Der checker");
|
||||||
|
if(prefs.getUChar("brightness") != brightness) {
|
||||||
|
Serial.println("Storing brightness");
|
||||||
|
prefs.putUChar("brightness", brightness);
|
||||||
|
}
|
||||||
|
if(prefs.getUChar("program") != program) {
|
||||||
|
Serial.println("Storing program");
|
||||||
|
prefs.putUChar("program", program);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
switch (program)
|
switch (program)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -830,7 +842,7 @@ void transition4()
|
||||||
{0x0000, 0x528A, 0xAD55, 0xFFFF}};
|
{0x0000, 0x528A, 0xAD55, 0xFFFF}};
|
||||||
|
|
||||||
// Select the active palette here (index 0-7)
|
// Select the active palette here (index 0-7)
|
||||||
uint8_t currentPaletteIndex = (now_time / (1000 * 60 * 20)) % 8;
|
uint8_t currentPaletteIndex = (now_time / (1000 * 60 * 200)) % 8;
|
||||||
const uint32_t TRANSITION_DURATION = 200000UL;
|
const uint32_t TRANSITION_DURATION = 200000UL;
|
||||||
uint32_t t = now_time;
|
uint32_t t = now_time;
|
||||||
const uint16_t *currentPalette = palettes[currentPaletteIndex];
|
const uint16_t *currentPalette = palettes[currentPaletteIndex];
|
||||||
|
|
Loading…
Reference in a new issue