mirror of
https://github.com/AlexGyver/GyverLamp2.git
synced 2025-08-09 01:20:59 +03:00
upd
This commit is contained in:
43
firmware/GyverLamp2_v0.8b/presetManager.ino
Normal file
43
firmware/GyverLamp2_v0.8b/presetManager.ino
Normal file
@@ -0,0 +1,43 @@
|
||||
void presetRotation(bool force) {
|
||||
if (cfg.rotation && (now.newMin() || force)) { // если автосмена и новая минута
|
||||
if (cfg.rotRnd) { // случайная
|
||||
cfg.curPreset = trnd.fromMin(cfg.rotPeriod, cfg.presetAmount);
|
||||
DEBUG("Rnd changed to ");
|
||||
DEBUGLN(cfg.curPreset);
|
||||
} else { // по порядку
|
||||
cfg.curPreset = ((trnd.getMin() / cfg.rotPeriod) % cfg.presetAmount);
|
||||
DEBUG("In order changed to ");
|
||||
DEBUGLN(cfg.curPreset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void changePreset(int dir) {
|
||||
if (!cfg.rotation) { // ручная смена
|
||||
cfg.curPreset += dir;
|
||||
if (cfg.curPreset >= cfg.presetAmount) cfg.curPreset = 0;
|
||||
if (cfg.curPreset < 0) cfg.curPreset = cfg.presetAmount - 1;
|
||||
DEBUG("Preset changed to ");
|
||||
DEBUGLN(cfg.curPreset);
|
||||
}
|
||||
}
|
||||
|
||||
void setPreset(byte pres) {
|
||||
if (!cfg.rotation) { // ручная смена
|
||||
cfg.curPreset = constrain(pres, 0, cfg.presetAmount - 1);
|
||||
DEBUG("Preset set to ");
|
||||
DEBUGLN(cfg.curPreset);
|
||||
}
|
||||
}
|
||||
|
||||
void setPower(bool state) {
|
||||
if (state) cfg.manualOff = 0;
|
||||
if (cfg.state && !state) cfg.manualOff = 1;
|
||||
cfg.state = state;
|
||||
if (!state) {
|
||||
delay(100); // чтобы пролететь мин. частоту обновления
|
||||
FastLED.clear();
|
||||
FastLED.show();
|
||||
}
|
||||
DEBUGLN(state ? "Power on" : "Power off");
|
||||
}
|
Reference in New Issue
Block a user