#define STRIP_PIN 5 // пин ленты
#define NUMLEDS 21 // кол-во светодиодов
#define COLOR_DEBTH 3
#include <microLED.h>
microLED<NUMLEDS, STRIP_PIN, MLED_NO_CLOCK, LED_WS2818, ORDER_GRB, CLI_AVER> strip;
#include <Arduino.h>
byte StartClick = 0;
byte OneClick = 1;
byte HoldClick = 0;
byte CLICK = 0;
byte HOLD = 0;
byte LEFT = 0;
byte RIGHT = 0;
#include <EncButton.h>
EncButton eb(2, 3, 4);
void setup() {
Serial.begin(115200);
strip.setBrightness(255);
strip.clear();
strip.show();
delay(1);
pinMode(14, OUTPUT);
pinMode(15, OUTPUT);
digitalWrite(14, LOW);
digitalWrite(15, LOW);
eb.setBtnLevel(LOW);
eb.setClickTimeout(500);
eb.setDebTimeout(50);
eb.setHoldTimeout(600);
eb.setStepTimeout(200);
eb.setEncReverse(0);
eb.setEncType(EB_STEP4_LOW);
eb.setFastTimeout(30);
eb.counter = 0;
if (OneClick == 1) {strip.leds[0] = mHSV(0, 255, 255); strip.show();}
if (OneClick == 2) {strip.leds[1] = mHSV(0, 255, 255); strip.show();}
if (OneClick == 3) {strip.leds[2] = mHSV(0, 255, 255); strip.show();}
}
void loop() {
eb.tick();
if (eb.left()) {switch (LEFT){
case 0: strip.leds[13] = mHSV(0, 255, 255); strip.show(); digitalWrite(14, HIGH); delay(50); strip.leds[13] = mHSV(0, 0, 0); strip.show(); digitalWrite(14, LOW); break;
case 1: break;
case 2: break;
case 3: break;
case 4: break;
case 5: break;
}
}
if (eb.right()) {switch (RIGHT) {
case 0: strip.leds[4] = mHSV(0, 255, 255); strip.show(); digitalWrite(15, HIGH); delay(50); strip.leds[4] = mHSV(0, 0, 0); strip.show(); digitalWrite(15, LOW); break;
case 1: break;
case 2: break;
case 3: break;
case 4: break;
case 5: break;
}
}
if (eb.click()) { }
if (eb.hold()) {switch (HoldClick){
case 0: StartClick = 1; strip.leds[5] = mHSV(0, 255, 255); strip.show(); break;
case 1: break;
case 2: break;
case 3: break;
}
}
if (eb.hasClicks(2)) {switch (StartClick) {
case 0: switch (OneClick){
case 1: strip.leds[0] = mHSV(0, 0, 0); strip.leds[1] = mHSV(0, 255, 255); strip.leds[2] = mHSV(0, 0, 0); strip.show(); OneClick = 2; break;
case 2: strip.leds[0] = mHSV(0, 0, 0); strip.leds[1] = mHSV(0, 0, 0); strip.leds[2] = mHSV(0, 255, 255); strip.show(); OneClick = 3; break;
case 3: strip.leds[0] = mHSV(0, 255, 255); strip.leds[1] = mHSV(0, 0, 0); strip.leds[2] = mHSV(0, 0, 0); strip.show(); OneClick = 1; break;}
break;
case 1: break;
}
}
// таймаут
if (eb.timeout(1000)) Serial.println("timeout!");
// проверка на количество кликов
if (eb.hasClicks(3)) Serial.println("has 3 clicks");
}