Add different puls length for reset type

This commit is contained in:
C0d3v 2026-01-19 13:11:25 +01:00
parent 54ffd02ab4
commit 3ac09781e5

View File

@ -1,7 +1,7 @@
#include <Arduino.h>
#include <Wire.h>
void resetPuzzles();
void resetPuzzles(bool easy);
/* ========================================================= */
const uint8_t ARCHIV_ADDR = 0x10;
@ -70,21 +70,23 @@ ISR(PCINT1_vect)
}
lastState = state;
}
uint8_t inputPattern = 0;
void handleEncoderMovement()
{
long diff = encoderPostion - lastClickPosition;
if (abs(diff) >= stepsPerClick)
{
resetPuzzles();
if (diff > 0)
{
selectedIndex = (selectedIndex + 1) % 8;
inputPattern = ((inputPattern << 1) | 1) & 0xFF;
}
else
{
selectedIndex = (selectedIndex + 7) % 8;
inputPattern = ((inputPattern << 1) | 0) & 0xFF;
}
resetPuzzles(inputPattern == 0b10101010);
setDrawerLight(selectedIndex);
lastClickPosition = encoderPostion;
}
@ -133,13 +135,16 @@ const int puzzleResetPins[3] = {7, 8, 9};
bool puzzlesSolved[3] = {false, false, false};
bool allSolvedSent = false;
void resetPuzzles()
void resetPuzzles(bool easy)
{
for (size_t i = 0; i < 3; i++)
{
puzzlesSolved[i] = false;
digitalWrite(puzzleResetPins[i], HIGH);
delay(30);
puzzlesSolved[i] = false;
}
delay(30 * (easy * 10)); //delay 30 or 300ms
for (size_t i = 0; i < 3; i++)
{
digitalWrite(puzzleResetPins[i], LOW);
}
allSolvedSent = false;