Compare commits
15 Commits
b3322b169b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| d501292f32 | |||
| 1974376134 | |||
| 8c0f98b7a7 | |||
| 92a2d39e49 | |||
| 69f1cba2f8 | |||
| e2bf85c91e | |||
| d3f10ea70b | |||
| c2b5331bbd | |||
| 462485dfa6 | |||
| 64cde85752 | |||
| 26ee30d1e9 | |||
| 9df16a82c4 | |||
| 9f964f63d3 | |||
| 3ac09781e5 | |||
| 54ffd02ab4 |
@@ -43,9 +43,13 @@ unsigned long lockTimer = 0;
|
|||||||
bool unlocked = false;
|
bool unlocked = false;
|
||||||
|
|
||||||
void openLock(uint8_t indexOn) {
|
void openLock(uint8_t indexOn) {
|
||||||
|
digitalWrite(schubladen[indexOn].schlossPin, HIGH);
|
||||||
|
delay(400);
|
||||||
|
digitalWrite(schubladen[indexOn].schlossPin, LOW);
|
||||||
|
delay(400);
|
||||||
|
digitalWrite(schubladen[indexOn].schlossPin, HIGH);
|
||||||
unlocked = true;
|
unlocked = true;
|
||||||
lockTimer = millis();
|
lockTimer = millis();
|
||||||
digitalWrite(schubladen[indexOn].schlossPin, HIGH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onI2CReceive(int len) {
|
void onI2CReceive(int len) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
void resetPuzzles();
|
void resetPuzzles(bool easy);
|
||||||
|
|
||||||
/* ========================================================= */
|
/* ========================================================= */
|
||||||
const uint8_t ARCHIV_ADDR = 0x10;
|
const uint8_t ARCHIV_ADDR = 0x10;
|
||||||
@@ -70,21 +70,27 @@ ISR(PCINT1_vect)
|
|||||||
}
|
}
|
||||||
lastState = state;
|
lastState = state;
|
||||||
}
|
}
|
||||||
|
uint8_t inputPattern = 0;
|
||||||
|
uint8_t secretPattern = 0b10101010;
|
||||||
void handleEncoderMovement()
|
void handleEncoderMovement()
|
||||||
{
|
{
|
||||||
long diff = encoderPostion - lastClickPosition;
|
long diff = encoderPostion - lastClickPosition;
|
||||||
if (abs(diff) >= stepsPerClick)
|
if (abs(diff) >= stepsPerClick)
|
||||||
{
|
{
|
||||||
resetPuzzles();
|
|
||||||
if (diff > 0)
|
if (diff > 0)
|
||||||
{
|
{
|
||||||
|
// right turn
|
||||||
selectedIndex = (selectedIndex + 1) % 8;
|
selectedIndex = (selectedIndex + 1) % 8;
|
||||||
|
inputPattern = ((inputPattern << 1) | 1) & 0xFF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//left turn
|
||||||
selectedIndex = (selectedIndex + 7) % 8;
|
selectedIndex = (selectedIndex + 7) % 8;
|
||||||
|
inputPattern = ((inputPattern << 1) | 0) & 0xFF;
|
||||||
}
|
}
|
||||||
|
bool reset = inputPattern == secretPattern;
|
||||||
|
resetPuzzles(reset);
|
||||||
setDrawerLight(selectedIndex);
|
setDrawerLight(selectedIndex);
|
||||||
lastClickPosition = encoderPostion;
|
lastClickPosition = encoderPostion;
|
||||||
}
|
}
|
||||||
@@ -133,13 +139,20 @@ const int puzzleResetPins[3] = {7, 8, 9};
|
|||||||
bool puzzlesSolved[3] = {false, false, false};
|
bool puzzlesSolved[3] = {false, false, false};
|
||||||
bool allSolvedSent = false;
|
bool allSolvedSent = false;
|
||||||
|
|
||||||
void resetPuzzles()
|
void resetPuzzles(bool easy)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < 3; i++)
|
for (size_t i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
puzzlesSolved[i] = false;
|
|
||||||
digitalWrite(puzzleResetPins[i], HIGH);
|
digitalWrite(puzzleResetPins[i], HIGH);
|
||||||
delay(30);
|
puzzlesSolved[i] = false;
|
||||||
|
}
|
||||||
|
if (easy)
|
||||||
|
delay(400);
|
||||||
|
else
|
||||||
|
delay(90);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
digitalWrite(puzzleResetPins[i], LOW);
|
digitalWrite(puzzleResetPins[i], LOW);
|
||||||
}
|
}
|
||||||
allSolvedSent = false;
|
allSolvedSent = false;
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ NormalizedRGB updateLeft()
|
|||||||
uint32_t sum = inputR + inputG + inputB;
|
uint32_t sum = inputR + inputG + inputB;
|
||||||
|
|
||||||
NormalizedRGB leftRGB;
|
NormalizedRGB leftRGB;
|
||||||
|
strip.begin();
|
||||||
if (sum > 0)
|
if (sum > 0)
|
||||||
{
|
{
|
||||||
leftRGB.r = (uint32_t)inputR * MAX_SUM / sum;
|
leftRGB.r = (uint32_t)inputR * MAX_SUM / sum;
|
||||||
@@ -138,6 +139,7 @@ NormalizedRGB updateLeft()
|
|||||||
{
|
{
|
||||||
strip.setPixelColor(2, strip.Color(0, 0, 0, 0));
|
strip.setPixelColor(2, strip.Color(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
strip.show();
|
||||||
return leftRGB;
|
return leftRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,7 +151,7 @@ NormalizedRGB updateMiddle()
|
|||||||
uint32_t sum = inputR + inputG + inputB;
|
uint32_t sum = inputR + inputG + inputB;
|
||||||
|
|
||||||
NormalizedRGB middleRGB;
|
NormalizedRGB middleRGB;
|
||||||
|
strip.begin();
|
||||||
if (sum > 0)
|
if (sum > 0)
|
||||||
{
|
{
|
||||||
middleRGB.r = (uint32_t)inputR * MAX_SUM / sum;
|
middleRGB.r = (uint32_t)inputR * MAX_SUM / sum;
|
||||||
@@ -161,6 +163,7 @@ NormalizedRGB updateMiddle()
|
|||||||
{
|
{
|
||||||
strip.setPixelColor(1, strip.Color(0, 0, 0, 0));
|
strip.setPixelColor(1, strip.Color(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
strip.show();
|
||||||
return middleRGB;
|
return middleRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +175,7 @@ NormalizedRGB updateRight()
|
|||||||
uint32_t sum = inputR + inputG + inputB;
|
uint32_t sum = inputR + inputG + inputB;
|
||||||
|
|
||||||
NormalizedRGB rightRGB;
|
NormalizedRGB rightRGB;
|
||||||
|
strip.begin();
|
||||||
if (sum > 0)
|
if (sum > 0)
|
||||||
{
|
{
|
||||||
rightRGB.r = (uint32_t)inputR * MAX_SUM / sum;
|
rightRGB.r = (uint32_t)inputR * MAX_SUM / sum;
|
||||||
@@ -184,7 +187,7 @@ NormalizedRGB updateRight()
|
|||||||
{
|
{
|
||||||
strip.setPixelColor(0, strip.Color(0, 0, 0, 0));
|
strip.setPixelColor(0, strip.Color(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
strip.show();
|
||||||
return rightRGB;
|
return rightRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,29 +214,36 @@ NormalizedRGB generateRandomNormalizedRGB(const Section *section, uint8_t from,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameBoard finishedBoard;
|
GameBoard finishedBoard;
|
||||||
void generateTargetGameBoard()
|
void generateTargetGameBoard(bool easy)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < 6; i++)
|
for (size_t i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
slavePotiValues[i] = 0;
|
slavePotiValues[i] = 0;
|
||||||
}
|
}
|
||||||
digitalWrite(COMPLETED_PIN, LOW);
|
digitalWrite(COMPLETED_PIN, LOW);
|
||||||
|
GameBoard board;
|
||||||
|
if (easy)
|
||||||
|
{
|
||||||
|
board.left = generateRandomNormalizedRGB(pot3, 2, 3);
|
||||||
|
board.middle = generateRandomNormalizedRGB(pot4, 3, 4);
|
||||||
|
board.right = generateRandomNormalizedRGB(pot5, 4, 5);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
board.left = generateRandomNormalizedRGB(pot3, 0, 3);
|
||||||
|
board.middle = generateRandomNormalizedRGB(pot4, 0, 4);
|
||||||
|
board.right = generateRandomNormalizedRGB(pot5, 1, 5);
|
||||||
|
}
|
||||||
strip.begin();
|
strip.begin();
|
||||||
strip.clear();
|
strip.clear();
|
||||||
GameBoard board;
|
|
||||||
// left
|
|
||||||
board.left = generateRandomNormalizedRGB(pot3, 0, 3);
|
|
||||||
finishedLeft = false;
|
finishedLeft = false;
|
||||||
strip.setPixelColor(3, strip.Color(board.left.r, board.left.g, board.left.b, 0)); // left
|
strip.setPixelColor(3, strip.Color(board.left.r, board.left.g, board.left.b, 0)); // left
|
||||||
// middle
|
|
||||||
board.middle = generateRandomNormalizedRGB(pot4, 0, 4);
|
|
||||||
finishedMiddle = false;
|
finishedMiddle = false;
|
||||||
strip.setPixelColor(4, strip.Color(board.middle.r, board.middle.g, board.middle.b, 0)); // middle
|
strip.setPixelColor(4, strip.Color(board.middle.r, board.middle.g, board.middle.b, 0)); // middle
|
||||||
// right
|
|
||||||
board.right = generateRandomNormalizedRGB(pot5, 1, 5);
|
|
||||||
finishedRight = false;
|
finishedRight = false;
|
||||||
strip.setPixelColor(5, strip.Color(board.right.r, board.right.g, board.right.b, 0)); // left
|
strip.setPixelColor(5, strip.Color(board.right.r, board.right.g, board.right.b, 0)); // right
|
||||||
//------------------
|
|
||||||
|
|
||||||
finishedBoard = board;
|
finishedBoard = board;
|
||||||
strip.show();
|
strip.show();
|
||||||
@@ -261,7 +271,7 @@ void setup()
|
|||||||
if (powerOnState)
|
if (powerOnState)
|
||||||
{
|
{
|
||||||
strip.begin();
|
strip.begin();
|
||||||
generateTargetGameBoard();
|
generateTargetGameBoard(false);
|
||||||
strip.show();
|
strip.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,7 +308,7 @@ void loop()
|
|||||||
// Detecting turn-on
|
// Detecting turn-on
|
||||||
if (!powerOnState && digitalRead(POWER_PIN) == HIGH)
|
if (!powerOnState && digitalRead(POWER_PIN) == HIGH)
|
||||||
{
|
{
|
||||||
generateTargetGameBoard();
|
generateTargetGameBoard(false);
|
||||||
powerOnState = true;
|
powerOnState = true;
|
||||||
}
|
}
|
||||||
if (!powerOnState)
|
if (!powerOnState)
|
||||||
@@ -309,11 +319,14 @@ void loop()
|
|||||||
|
|
||||||
if (digitalRead(REGENERATE_PIN) == HIGH)
|
if (digitalRead(REGENERATE_PIN) == HIGH)
|
||||||
{
|
{
|
||||||
generateTargetGameBoard();
|
unsigned long resetTimer = millis();
|
||||||
delay(50); // Puls kurz blockieren
|
while (digitalRead(REGENERATE_PIN) == HIGH)
|
||||||
|
{
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
generateTargetGameBoard(millis() - resetTimer > 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
strip.begin();
|
|
||||||
readExternalPotiValues();
|
readExternalPotiValues();
|
||||||
|
|
||||||
if (!finishedLeft)
|
if (!finishedLeft)
|
||||||
@@ -350,5 +363,4 @@ void loop()
|
|||||||
{
|
{
|
||||||
digitalWrite(COMPLETED_PIN, HIGH);
|
digitalWrite(COMPLETED_PIN, HIGH);
|
||||||
}
|
}
|
||||||
strip.show();
|
|
||||||
}
|
}
|
||||||
|
|||||||
5
terminal/puzzle_colorFade/potiNano/.gitignore
vendored
Normal file
5
terminal/puzzle_colorFade/potiNano/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.pio
|
||||||
|
.vscode/.browse.c_cpp.db*
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/ipch
|
||||||
14
terminal/puzzle_colorFade/potiNano/platformio.ini
Normal file
14
terminal/puzzle_colorFade/potiNano/platformio.ini
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env:nanoatmega328new]
|
||||||
|
platform = atmelavr
|
||||||
|
board = nanoatmega328new
|
||||||
|
framework = arduino
|
||||||
39
terminal/puzzle_colorFade/potiNano/src/main.cpp
Normal file
39
terminal/puzzle_colorFade/potiNano/src/main.cpp
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
#define I2C_SLAVE_ADDRESS 0x08
|
||||||
|
|
||||||
|
volatile uint16_t bufferA[6];
|
||||||
|
volatile uint16_t bufferB[6];
|
||||||
|
|
||||||
|
// Pointer to the buffer currently exposed to ISR
|
||||||
|
volatile uint16_t* activeBuffer = bufferA;
|
||||||
|
|
||||||
|
void onI2CRequest() {
|
||||||
|
// Safe: ISR only reads active buffer
|
||||||
|
Wire.write((uint8_t*)activeBuffer, 6 * sizeof(uint16_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Wire.begin(I2C_SLAVE_ADDRESS);
|
||||||
|
Wire.onRequest(onI2CRequest);
|
||||||
|
analogReference(DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// Choose the inactive buffer
|
||||||
|
volatile uint16_t* writeBuffer =
|
||||||
|
(activeBuffer == bufferA) ? bufferB : bufferA;
|
||||||
|
|
||||||
|
writeBuffer[0] = analogRead(A0);
|
||||||
|
writeBuffer[1] = analogRead(A1);
|
||||||
|
writeBuffer[2] = analogRead(A2);
|
||||||
|
writeBuffer[3] = analogRead(A3);
|
||||||
|
writeBuffer[4] = analogRead(A6);
|
||||||
|
writeBuffer[5] = analogRead(A7);
|
||||||
|
|
||||||
|
// Atomic pointer swap
|
||||||
|
noInterrupts();
|
||||||
|
activeBuffer = writeBuffer;
|
||||||
|
interrupts();
|
||||||
|
}
|
||||||
@@ -97,20 +97,26 @@ bool readButton(uint8_t i) {
|
|||||||
|
|
||||||
// ------------------ Neues Spiel ------------------
|
// ------------------ Neues Spiel ------------------
|
||||||
|
|
||||||
void generateNewGame() {
|
void generateNewGame(bool easy) {
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 6; i++) solutionOrder[i] = i;
|
for (uint8_t i = 0; i < 6; i++)
|
||||||
|
solutionOrder[i] = i;
|
||||||
|
|
||||||
for (int i = 5; i > 0; i--) {
|
if (!easy)
|
||||||
|
{
|
||||||
|
for (int i = 5; i > 0; i--)
|
||||||
|
{
|
||||||
int j = random(i + 1);
|
int j = random(i + 1);
|
||||||
uint8_t t = solutionOrder[i];
|
uint8_t t = solutionOrder[i];
|
||||||
solutionOrder[i] = solutionOrder[j];
|
solutionOrder[i] = solutionOrder[j];
|
||||||
solutionOrder[j] = t;
|
solutionOrder[j] = t;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 6; i++)
|
for (uint8_t i = 0; i < 6; i++)
|
||||||
expectedOrder[i] = solutionOrder[5 - i];
|
expectedOrder[i] = solutionOrder[5 - i];
|
||||||
|
|
||||||
|
pixelsSolution.begin();
|
||||||
for (uint8_t i = 0; i < 6; i++) {
|
for (uint8_t i = 0; i < 6; i++) {
|
||||||
uint8_t c = solutionOrder[i];
|
uint8_t c = solutionOrder[i];
|
||||||
pixelsSolution.setPixelColor(
|
pixelsSolution.setPixelColor(
|
||||||
@@ -124,6 +130,7 @@ void generateNewGame() {
|
|||||||
}
|
}
|
||||||
pixelsSolution.show();
|
pixelsSolution.show();
|
||||||
|
|
||||||
|
pixelsButtons.begin();
|
||||||
for (uint8_t i = 0; i < 18; i++) {
|
for (uint8_t i = 0; i < 18; i++) {
|
||||||
buttonAssignment[i] = -1;
|
buttonAssignment[i] = -1;
|
||||||
pixelsButtons.setPixelColor(i, 0);
|
pixelsButtons.setPixelColor(i, 0);
|
||||||
@@ -135,12 +142,16 @@ void generateNewGame() {
|
|||||||
uint8_t idx[18];
|
uint8_t idx[18];
|
||||||
for (uint8_t i = 0; i < 18; i++) idx[i] = i;
|
for (uint8_t i = 0; i < 18; i++) idx[i] = i;
|
||||||
|
|
||||||
for (int i = 17; i > 0; i--) {
|
if (!easy)
|
||||||
|
{
|
||||||
|
for (int i = 17; i > 0; i--)
|
||||||
|
{
|
||||||
int j = random(i + 1);
|
int j = random(i + 1);
|
||||||
uint8_t t = idx[i];
|
uint8_t t = idx[i];
|
||||||
idx[i] = idx[j];
|
idx[i] = idx[j];
|
||||||
idx[j] = t;
|
idx[j] = t;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 6; i++)
|
for (uint8_t i = 0; i < 6; i++)
|
||||||
buttonAssignment[idx[i]] = solutionOrder[i];
|
buttonAssignment[idx[i]] = solutionOrder[i];
|
||||||
@@ -230,18 +241,20 @@ void setup() {
|
|||||||
pinMode(7, INPUT_PULLUP);
|
pinMode(7, INPUT_PULLUP);
|
||||||
pinMode(8, INPUT_PULLUP);
|
pinMode(8, INPUT_PULLUP);
|
||||||
|
|
||||||
powerOnState = digitalRead(PIN_POWER_ON) == HIGH;
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 12; i++)
|
for (uint8_t i = 0; i < 12; i++)
|
||||||
expander.write(i, HIGH);
|
expander.write(i, HIGH);
|
||||||
|
|
||||||
pixelsButtons.begin();
|
|
||||||
pixelsSolution.begin();
|
|
||||||
|
|
||||||
generateNewGame();
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 18; i++)
|
for (uint8_t i = 0; i < 18; i++)
|
||||||
lastPressed[i] = false;
|
lastPressed[i] = false;
|
||||||
|
|
||||||
|
powerOnState = digitalRead(PIN_POWER_ON) == HIGH;
|
||||||
|
|
||||||
|
if (powerOnState)
|
||||||
|
{
|
||||||
|
generateNewGame(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------ Loop ------------------
|
// ------------------ Loop ------------------
|
||||||
@@ -267,7 +280,7 @@ void loop() {
|
|||||||
// Detecting turn-on
|
// Detecting turn-on
|
||||||
if (!powerOnState && digitalRead(PIN_POWER_ON) == HIGH)
|
if (!powerOnState && digitalRead(PIN_POWER_ON) == HIGH)
|
||||||
{
|
{
|
||||||
generateNewGame();
|
generateNewGame(false);
|
||||||
powerOnState = true;
|
powerOnState = true;
|
||||||
}
|
}
|
||||||
if (!powerOnState)
|
if (!powerOnState)
|
||||||
@@ -275,14 +288,18 @@ void loop() {
|
|||||||
// We are turned-off and stop anything after here
|
// We are turned-off and stop anything after here
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unsigned long now = millis();
|
|
||||||
|
|
||||||
bool trigger = digitalRead(PIN_TRIGGER_SHUFFLE);
|
if (digitalRead(PIN_TRIGGER_SHUFFLE) == HIGH)
|
||||||
if (trigger && !lastTriggerState) {
|
{
|
||||||
generateNewGame();
|
unsigned long resetTimer = millis();
|
||||||
|
while (digitalRead(PIN_TRIGGER_SHUFFLE) == HIGH)
|
||||||
|
{
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
generateNewGame(millis() - resetTimer > 150);
|
||||||
}
|
}
|
||||||
lastTriggerState = trigger;
|
|
||||||
|
|
||||||
|
unsigned long now = millis();
|
||||||
for (uint8_t i = 0; i < 18; i++) {
|
for (uint8_t i = 0; i < 18; i++) {
|
||||||
bool pressed = readButton(i);
|
bool pressed = readButton(i);
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,16 @@ int ledIndex(int logical) {
|
|||||||
return (NUM_LEDS - 1) - logical;
|
return (NUM_LEDS - 1) - logical;
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateNewSequence() {
|
void generateNewSequence(bool easy) {
|
||||||
for (int i = 0; i < NUM_LEDS; i++) {
|
for (int i = 0; i < NUM_LEDS; i++) {
|
||||||
|
if (easy)
|
||||||
|
{
|
||||||
|
sequence[i] = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
sequence[i] = random(0, 2);
|
sequence[i] = random(0, 2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAll(uint32_t color) {
|
void setAll(uint32_t color) {
|
||||||
@@ -110,10 +116,11 @@ void setup() {
|
|||||||
strip.show();
|
strip.show();
|
||||||
|
|
||||||
randomSeed(millis());
|
randomSeed(millis());
|
||||||
generateNewSequence();
|
generateNewSequence(false);
|
||||||
resetGame();
|
resetGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
//Detecting turn-off
|
//Detecting turn-off
|
||||||
if (powerOnState && digitalRead(POWER_PIN) == LOW) {
|
if (powerOnState && digitalRead(POWER_PIN) == LOW) {
|
||||||
@@ -129,10 +136,16 @@ void loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Master-D2 HIGH → neue Sequenz
|
// Master-D2 HIGH → neue Sequenz
|
||||||
if (digitalRead(randomizer_master_pin) == HIGH) {
|
if (digitalRead(randomizer_master_pin) == HIGH)
|
||||||
generateNewSequence();
|
{
|
||||||
|
unsigned long resetTimer = millis();
|
||||||
|
while (digitalRead(randomizer_master_pin) == HIGH)
|
||||||
|
{
|
||||||
|
delay(10);
|
||||||
|
}
|
||||||
|
generateNewSequence(millis() - resetTimer > 150);
|
||||||
resetGame();
|
resetGame();
|
||||||
delay(50); // Puls kurz blockieren
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentButton1State = digitalRead(BUTTON1_PIN);
|
int currentButton1State = digitalRead(BUTTON1_PIN);
|
||||||
|
|||||||
Reference in New Issue
Block a user