This commit is contained in:
Alex
2019-06-13 15:58:26 +03:00
parent 6597bf74d4
commit b93c4978ef
4 changed files with 11 additions and 7 deletions

View File

@@ -127,6 +127,9 @@ void setup() {
FastLED.clear();
FastLED.show();
randomSeed(analogRead(0)); // пинаем генератор случайных чисел
touch.setStepTimeout(100);
touch.setClickTimeout(500);
Serial.begin(115200);
// WI-FI
@@ -189,8 +192,7 @@ void setup() {
Udp.write(reply);
Udp.endPacket();
timeClient.begin();
touch.setStepTimeout(100);
timeClient.begin();
}
void loop() {

View File

@@ -17,17 +17,18 @@ void buttonTick() {
}
}
if (touch.isDouble()) {
if (ONflag && touch.isDouble()) {
if (++currentMode >= MODE_AMOUNT) currentMode = 0;
FastLED.setBrightness(modes[currentMode].brightness);
loadingFlag = true;
settChanged = true;
eepromTimer = millis();
}
if (touch.isHolded()) {
if (ONflag && touch.isHolded()) {
brightDirection = !brightDirection;
}
if (touch.isStep()) {
if (ONflag && touch.isStep()) {
if (brightDirection) {
if (modes[currentMode].brightness < 250) modes[currentMode].brightness += 5;
else modes[currentMode].brightness = 255;

View File

@@ -45,7 +45,7 @@ void effectsTick() {
void changePower() {
if (ONflag) {
effectsTick();
for (int i = 0; i < modes[currentMode].brightness; i += 5) {
for (int i = 0; i < modes[currentMode].brightness; i += 8) {
FastLED.setBrightness(i);
delay(1);
FastLED.show();
@@ -54,7 +54,7 @@ void changePower() {
FastLED.show();
} else {
effectsTick();
for (int i = modes[currentMode].brightness; i > 8; i -= 5) {
for (int i = modes[currentMode].brightness; i > 8; i -= 8) {
FastLED.setBrightness(i);
delay(1);
FastLED.show();

View File

@@ -14,6 +14,7 @@ void parseUDP() {
currentMode = (byte)inputBuffer.substring(3).toInt();
loadingFlag = true;
sendCurrent();
FastLED.setBrightness(modes[currentMode].brightness);
} else if (inputBuffer.startsWith("BRI")) {
modes[currentMode].brightness = inputBuffer.substring(3).toInt();
FastLED.setBrightness(modes[currentMode].brightness);