aboutsummaryrefslogtreecommitdiff
path: root/puzzle
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-06-26 15:44:26 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-06-26 15:44:26 +0200
commitee5d161f6153e1f9da73e477f63f38dcf52ca10c (patch)
tree926413950f64ed7b0f45f6b3551c16446ecd08d4 /puzzle
parentc77d271d9cb86bf6893098ec6c431fc87945e6c9 (diff)
`make format`
Diffstat (limited to 'puzzle')
-rw-r--r--puzzle/dummy/FreeRTOSConfig.h1
-rw-r--r--puzzle/dummy/main.cpp5
-rw-r--r--puzzle/dummy/mod.c3
-rw-r--r--puzzle/neo/FreeRTOSConfig.h1
-rw-r--r--puzzle/neo/main.cpp60
-rw-r--r--puzzle/neo/mod.c3
-rw-r--r--puzzle/smoketest/FreeRTOSConfig.h1
-rw-r--r--puzzle/smoketest/main.cpp17
-rw-r--r--puzzle/smoketest/mod.c3
-rw-r--r--puzzle/vault/FreeRTOSConfig.h1
-rw-r--r--puzzle/vault/main.cpp277
-rw-r--r--puzzle/vault/mod.c3
12 files changed, 183 insertions, 192 deletions
diff --git a/puzzle/dummy/FreeRTOSConfig.h b/puzzle/dummy/FreeRTOSConfig.h
index 072fdf7..35d9cae 100644
--- a/puzzle/dummy/FreeRTOSConfig.h
+++ b/puzzle/dummy/FreeRTOSConfig.h
@@ -49,4 +49,3 @@
#define INCLUDE_xTaskGetHandle 1
#define INCLUDE_xTaskResumeFromISR 1
#define INCLUDE_xQueueGetMutexHolder 1
-
diff --git a/puzzle/dummy/main.cpp b/puzzle/dummy/main.cpp
index d611014..5f78086 100644
--- a/puzzle/dummy/main.cpp
+++ b/puzzle/dummy/main.cpp
@@ -1,5 +1,4 @@
#include <Arduino.h>
-void setup() { }
-void loop() { }
-
+void setup() {}
+void loop() {}
diff --git a/puzzle/dummy/mod.c b/puzzle/dummy/mod.c
index 058a585..559c4d3 100644
--- a/puzzle/dummy/mod.c
+++ b/puzzle/dummy/mod.c
@@ -1,6 +1,5 @@
-#include "pb.h"
#include "pb-mod.h"
+#include "pb.h"
const char * PB_MOD_NAME = "dummy";
const i2c_addr_t PB_MOD_ADDR = PB_ADDR_MOD_DUMMY;
-
diff --git a/puzzle/neo/FreeRTOSConfig.h b/puzzle/neo/FreeRTOSConfig.h
index c0acc49..d3a5d2f 100644
--- a/puzzle/neo/FreeRTOSConfig.h
+++ b/puzzle/neo/FreeRTOSConfig.h
@@ -49,4 +49,3 @@
#define INCLUDE_xTaskGetHandle 1
#define INCLUDE_xTaskResumeFromISR 1
#define INCLUDE_xQueueGetMutexHolder 1
-
diff --git a/puzzle/neo/main.cpp b/puzzle/neo/main.cpp
index 831f97e..f636b55 100644
--- a/puzzle/neo/main.cpp
+++ b/puzzle/neo/main.cpp
@@ -1,9 +1,9 @@
-#include <Arduino.h>
-#include <Wire.h>
-#include <Adafruit_NeoTrellis.h>
-#include "pb-types.h"
#include "pb-mod.h"
+#include "pb-types.h"
#include "pb.h"
+#include <Adafruit_NeoTrellis.h>
+#include <Arduino.h>
+#include <Wire.h>
#define MATRIX_SIZE 8
#define LED_COLOR_ON 0x0000FF // Color of the LEDs in ON state
@@ -12,11 +12,14 @@
#define LED_COLOR_ORANGE 0xFFA500 // Orange color for IDLE state
Adafruit_NeoTrellis t_array[MATRIX_SIZE / 4][MATRIX_SIZE / 4] = {
- { Adafruit_NeoTrellis(PB_ADDR_ADA_NEO_1), Adafruit_NeoTrellis(PB_ADDR_ADA_NEO_2) },
- { Adafruit_NeoTrellis(PB_ADDR_ADA_NEO_3), Adafruit_NeoTrellis(PB_ADDR_ADA_NEO_4) },
+ {Adafruit_NeoTrellis(PB_ADDR_ADA_NEO_1),
+ Adafruit_NeoTrellis(PB_ADDR_ADA_NEO_2)},
+ {Adafruit_NeoTrellis(PB_ADDR_ADA_NEO_3),
+ Adafruit_NeoTrellis(PB_ADDR_ADA_NEO_4)},
};
-Adafruit_MultiTrellis trellis((Adafruit_NeoTrellis *)t_array, MATRIX_SIZE / 4, MATRIX_SIZE / 4);
+Adafruit_MultiTrellis trellis((Adafruit_NeoTrellis *) t_array, MATRIX_SIZE / 4,
+ MATRIX_SIZE / 4);
bool neoMatrix[MATRIX_SIZE][MATRIX_SIZE]; // To track state of each pixel
@@ -36,17 +39,19 @@ void toggleAdjacentLEDs(int x, int y) {
int nx = x + dx, ny = y + dy;
if (nx >= 0 && nx < MATRIX_SIZE && ny >= 0 && ny < MATRIX_SIZE) {
neoMatrix[nx][ny] = !neoMatrix[nx][ny];
- trellis.setPixelColor(nx * MATRIX_SIZE + ny, neoMatrix[nx][ny] ? LED_COLOR_ON : LED_COLOR_OFF);
+ trellis.setPixelColor(nx * MATRIX_SIZE + ny,
+ neoMatrix[nx][ny] ? LED_COLOR_ON
+ : LED_COLOR_OFF);
}
}
}
}
-
bool isNeoPuzzleSolved() {
for (int i = 0; i < MATRIX_SIZE; i++) {
for (int j = 0; j < MATRIX_SIZE; j++) {
- if (neoMatrix[i][j]) return false; // If any LED is on, puzzle is not solved
+ if (neoMatrix[i][j])
+ return false; // If any LED is on, puzzle is not solved
}
}
return true;
@@ -69,7 +74,8 @@ TrellisCallback buttonCallback(keyEvent evt) {
void setup() {
Serial.begin(115200);
- while (!Serial); // Wait for Serial to be read
+ while (!Serial)
+ ; // Wait for Serial to be read
if (!trellis.begin()) {
Serial.println("Failed to initialize NeoTrellis");
pb_hook_mod_state_write(PB_GS_NOINIT);
@@ -77,14 +83,16 @@ void setup() {
}
void set_game_field() {
- if (gamefield == false){
+ if (gamefield == false) {
// Initialize the matrix with a checkerboard pattern
bool toggle = false;
for (int i = 0; i < MATRIX_SIZE; i++) {
for (int j = 0; j < MATRIX_SIZE; j++) {
neoMatrix[i][j] = toggle;
toggle = !toggle;
- trellis.setPixelColor(i * MATRIX_SIZE + j, neoMatrix[i][j] ? LED_COLOR_ON : LED_COLOR_OFF);
+ trellis.setPixelColor(i * MATRIX_SIZE + j, neoMatrix[i][j]
+ ? LED_COLOR_ON
+ : LED_COLOR_OFF);
}
toggle = !toggle;
}
@@ -100,13 +108,9 @@ void set_game_field() {
}
}
-pb_global_state_t pb_hook_mod_state_read() {
- return puzzleState;
-}
+pb_global_state_t pb_hook_mod_state_read() { return puzzleState; }
-void pb_hook_mod_state_write(pb_global_state_t state) {
- puzzleState = state;
-}
+void pb_hook_mod_state_write(pb_global_state_t state) { puzzleState = state; }
void flashCorners(uint32_t color) {
unsigned long currentMillis = millis();
@@ -120,14 +124,19 @@ void flashCorners(uint32_t color) {
int baseIndex = (i * 4 * MATRIX_SIZE) + (j * 4);
if (ledState) {
trellis.setPixelColor(baseIndex, color); // Top-left corner
- trellis.setPixelColor(baseIndex + 3, color); // Top-right corner
- trellis.setPixelColor(baseIndex + 3 * MATRIX_SIZE, color); // Bottom-left corner
- trellis.setPixelColor(baseIndex + 3 * MATRIX_SIZE + 3, color); // Bottom-right corner
+ trellis.setPixelColor(baseIndex + 3,
+ color); // Top-right corner
+ trellis.setPixelColor(baseIndex + 3 * MATRIX_SIZE,
+ color); // Bottom-left corner
+ trellis.setPixelColor(baseIndex + 3 * MATRIX_SIZE + 3,
+ color); // Bottom-right corner
} else {
trellis.setPixelColor(baseIndex, LED_COLOR_OFF);
trellis.setPixelColor(baseIndex + 3, LED_COLOR_OFF);
- trellis.setPixelColor(baseIndex + 3 * MATRIX_SIZE, LED_COLOR_OFF);
- trellis.setPixelColor(baseIndex + 3 * MATRIX_SIZE + 3, LED_COLOR_OFF);
+ trellis.setPixelColor(baseIndex + 3 * MATRIX_SIZE,
+ LED_COLOR_OFF);
+ trellis.setPixelColor(baseIndex + 3 * MATRIX_SIZE + 3,
+ LED_COLOR_OFF);
}
}
}
@@ -136,7 +145,7 @@ void flashCorners(uint32_t color) {
}
void loop() {
- switch(puzzleState) {
+ switch (puzzleState) {
case PB_GS_PLAYING:
set_game_field();
trellis.read(); // Process button events
@@ -155,4 +164,3 @@ void loop() {
break;
}
}
-
diff --git a/puzzle/neo/mod.c b/puzzle/neo/mod.c
index 7157d22..32b348a 100644
--- a/puzzle/neo/mod.c
+++ b/puzzle/neo/mod.c
@@ -1,6 +1,5 @@
-#include "pb.h"
#include "pb-mod.h"
+#include "pb.h"
const char * PB_MOD_NAME = "neotrellis";
const i2c_addr_t PB_MOD_ADDR = PB_ADDR_MOD_NEOTRELLIS;
-
diff --git a/puzzle/smoketest/FreeRTOSConfig.h b/puzzle/smoketest/FreeRTOSConfig.h
index 81c487f..44fc902 100644
--- a/puzzle/smoketest/FreeRTOSConfig.h
+++ b/puzzle/smoketest/FreeRTOSConfig.h
@@ -49,4 +49,3 @@
#define INCLUDE_xTaskGetHandle 1
#define INCLUDE_xTaskResumeFromISR 1
#define INCLUDE_xQueueGetMutexHolder 1
-
diff --git a/puzzle/smoketest/main.cpp b/puzzle/smoketest/main.cpp
index 3169ed5..35a4ec9 100644
--- a/puzzle/smoketest/main.cpp
+++ b/puzzle/smoketest/main.cpp
@@ -1,6 +1,6 @@
-#include <Arduino.h>
-#include "lib/pbdrv/pb-types.h"
#include "lib/pbdrv/pb-mod.h"
+#include "lib/pbdrv/pb-types.h"
+#include <Arduino.h>
//! LED pin (on-board LED on Arduino Uno board) \ingroup puz_smoketest
#define EXTERNAL_LED_PIN 13
@@ -9,17 +9,13 @@
pb_global_state_t state = PB_GS_NOINIT;
-pb_global_state_t pb_hook_mod_state_read() {
- return state;
-}
+pb_global_state_t pb_hook_mod_state_read() { return state; }
-void pb_hook_mod_state_write(pb_global_state_t _state) {
- state = _state;
-}
+void pb_hook_mod_state_write(pb_global_state_t _state) { state = _state; }
void setup() {
- pinMode(EXTERNAL_LED_PIN, OUTPUT);
- pinMode(BUTTON_PIN, INPUT_PULLUP);
+ pinMode(EXTERNAL_LED_PIN, OUTPUT);
+ pinMode(BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
@@ -28,4 +24,3 @@ void loop() {
if (!digitalRead(BUTTON_PIN)) // button is inverted
state = PB_GS_SOLVED;
}
-
diff --git a/puzzle/smoketest/mod.c b/puzzle/smoketest/mod.c
index a1e2843..d9d5824 100644
--- a/puzzle/smoketest/mod.c
+++ b/puzzle/smoketest/mod.c
@@ -1,6 +1,5 @@
-#include "pb.h"
#include "pb-mod.h"
+#include "pb.h"
const char * PB_MOD_NAME = "smoketest";
const i2c_addr_t PB_MOD_ADDR = PB_ADDR_MOD_SMOKETEST;
-
diff --git a/puzzle/vault/FreeRTOSConfig.h b/puzzle/vault/FreeRTOSConfig.h
index c0acc49..d3a5d2f 100644
--- a/puzzle/vault/FreeRTOSConfig.h
+++ b/puzzle/vault/FreeRTOSConfig.h
@@ -49,4 +49,3 @@
#define INCLUDE_xTaskGetHandle 1
#define INCLUDE_xTaskResumeFromISR 1
#define INCLUDE_xQueueGetMutexHolder 1
-
diff --git a/puzzle/vault/main.cpp b/puzzle/vault/main.cpp
index 88d5b35..ba65c12 100644
--- a/puzzle/vault/main.cpp
+++ b/puzzle/vault/main.cpp
@@ -1,7 +1,7 @@
+#include "lib/pbdrv/pb-mod.h"
+#include "lib/pbdrv/pb-types.h"
#include <Arduino.h>
#include <TM1637Display.h>
-#include "lib/pbdrv/pb-types.h"
-#include "lib/pbdrv/pb-mod.h"
#define TOTAL_LEVELS 5
#define ROWS 4
@@ -9,38 +9,39 @@
#define CLK 2
#define DIO 3
#define SOLVED_PIN 53
-#define I2C_MODULE_ADDRESS 0x08 // Address of the puzzle module
-#define HANDSHAKE_RECEIVED {0x70, 0x75, 0x7a, 0x62, 0x75, 0x73} // Magic command for the handshake
-#define HANDSHAKE_SEND {0x67, 0x61, 0x6d, 0x69, 0x6e, 0x67} // Magic command for the handshake
-#define REQUEST_STATE_CMD 0x53 // 'S' to request the game state
+#define I2C_MODULE_ADDRESS 0x08 // Address of the puzzle module
+#define HANDSHAKE_RECEIVED \
+ { 0x70, 0x75, 0x7a, 0x62, 0x75, 0x73 } // Magic command for the handshake
+#define HANDSHAKE_SEND \
+ { 0x67, 0x61, 0x6d, 0x69, 0x6e, 0x67 } // Magic command for the handshake
+#define REQUEST_STATE_CMD 0x53 // 'S' to request the game state
const int ROW_PINS[ROWS] = {7, 6, 5, 4};
const int COL_PINS[COLS] = {10, 9, 8};
-const char* validButtons[TOTAL_LEVELS] = {"A2", "B1", "D3", "C2", "C3"};
+const char * validButtons[TOTAL_LEVELS] = {"A2", "B1", "D3", "C2", "C3"};
const char bombCode[] = "1234";
const uint8_t SEGMENT_MAP[] = {
- 0b00111111, // 0
- 0b00000110, // 1
- 0b01011011, // 2
- 0b01001111, // 3
- 0b01100110, // 4
- 0b01101101, // 5
- 0b01111101, // 6
- 0b00000111, // 7
- 0b01111111, // 8
- 0b01101111, // 9
- 0b01110111, // A
- 0b01111100, // B
- 0b00111001, // C
- 0b01011110, // D
- 0b01111001, // E
- 0b01110001 // F
- // Add other letters if needed
+ 0b00111111, // 0
+ 0b00000110, // 1
+ 0b01011011, // 2
+ 0b01001111, // 3
+ 0b01100110, // 4
+ 0b01101101, // 5
+ 0b01111101, // 6
+ 0b00000111, // 7
+ 0b01111111, // 8
+ 0b01101111, // 9
+ 0b01110111, // A
+ 0b01111100, // B
+ 0b00111001, // C
+ 0b01011110, // D
+ 0b01111001, // E
+ 0b01110001 // F
+ // Add other letters if needed
};
// This array of level codes matches the codes you might display per level.
-const char* levelCodes[TOTAL_LEVELS] = {"A1", "B2", "D1", "C3", "A2"};
-
+const char * levelCodes[TOTAL_LEVELS] = {"A1", "B2", "D1", "C3", "A2"};
// Puzzle state
pb_global_state_t puzzleState = PB_GS_NOINIT;
@@ -50,142 +51,138 @@ TM1637Display display(CLK, DIO);
int currentLevel = 0;
void blink_display(int num) {
- if (num == 1) {
- // Display "1111" with leading zeros shown if necessary
- display.showNumberDecEx(1111, 0b11111111, true);
- } else if (num == 0) {
- // Display "0000" with leading zeros shown if necessary
- display.showNumberDecEx(0, 0b11111111, true);
- }
- delay(500);
- display.clear();
- delay(500);
+ if (num == 1) {
+ // Display "1111" with leading zeros shown if necessary
+ display.showNumberDecEx(1111, 0b11111111, true);
+ } else if (num == 0) {
+ // Display "0000" with leading zeros shown if necessary
+ display.showNumberDecEx(0, 0b11111111, true);
+ }
+ delay(500);
+ display.clear();
+ delay(500);
}
+void display_final_code(const char * code) {
+ uint8_t segs[4] = {0, 0, 0, 0};
+ int numDigits = strlen(code);
+ numDigits = numDigits > 4 ? 4 : numDigits;
-void display_final_code(const char* code) {
- uint8_t segs[4] = {0, 0, 0, 0};
- int numDigits = strlen(code);
- numDigits = numDigits > 4 ? 4 : numDigits;
+ for (int i = 0; i < numDigits; i++) {
+ segs[i] = display.encodeDigit(code[i] - '0');
+ }
- for (int i = 0; i < numDigits; i++) {
- segs[i] = display.encodeDigit(code[i] - '0');
- }
-
- display.setSegments(segs, numDigits, 0);
+ display.setSegments(segs, numDigits, 0);
}
void check_button_press() {
- for (int col = 0; col < COLS; col++) {
- digitalWrite(COL_PINS[col], LOW);
- for (int row = 0; row < ROWS; row++) {
- if (digitalRead(ROW_PINS[row]) == LOW) {
- delay(50);
- if (digitalRead(ROW_PINS[row]) == LOW) {
- char keyPress[3] = {'A' + row, '1' + col, '\0'};
- Serial.print("Keypress detected: ");
- Serial.println(keyPress);
- if (strcmp(keyPress, validButtons[currentLevel]) == 0) {
- currentLevel++;
- if (currentLevel >= TOTAL_LEVELS) {
- pb_hook_mod_state_write(PB_GS_SOLVED);
- Serial.println("Puzzle solved!");
- display.showNumberDec(currentLevel + 1, true);
- digitalWrite(SOLVED_PIN, HIGH);
- }
- } else {
- currentLevel = 0;
- }
- while (digitalRead(ROW_PINS[row]) == LOW) {} // Ensure button release
- }
- }
- }
- digitalWrite(COL_PINS[col], HIGH);
- }
+ for (int col = 0; col < COLS; col++) {
+ digitalWrite(COL_PINS[col], LOW);
+ for (int row = 0; row < ROWS; row++) {
+ if (digitalRead(ROW_PINS[row]) == LOW) {
+ delay(50);
+ if (digitalRead(ROW_PINS[row]) == LOW) {
+ char keyPress[3] = {'A' + row, '1' + col, '\0'};
+ Serial.print("Keypress detected: ");
+ Serial.println(keyPress);
+ if (strcmp(keyPress, validButtons[currentLevel]) == 0) {
+ currentLevel++;
+ if (currentLevel >= TOTAL_LEVELS) {
+ pb_hook_mod_state_write(PB_GS_SOLVED);
+ Serial.println("Puzzle solved!");
+ display.showNumberDec(currentLevel + 1, true);
+ digitalWrite(SOLVED_PIN, HIGH);
+ }
+ } else {
+ currentLevel = 0;
+ }
+ while (digitalRead(ROW_PINS[row]) == LOW) {
+ } // Ensure button release
+ }
+ }
+ }
+ digitalWrite(COL_PINS[col], HIGH);
+ }
}
void initialize_system() {
- for (int i = 0; i < ROWS; i++) {
- pinMode(ROW_PINS[i], INPUT_PULLUP);
- }
- for (int i = 0; i < COLS; i++) {
- pinMode(COL_PINS[i], OUTPUT);
- digitalWrite(COL_PINS[i], HIGH);
- }
- Serial.println("GPIO and display initialized.");
+ for (int i = 0; i < ROWS; i++) {
+ pinMode(ROW_PINS[i], INPUT_PULLUP);
+ }
+ for (int i = 0; i < COLS; i++) {
+ pinMode(COL_PINS[i], OUTPUT);
+ digitalWrite(COL_PINS[i], HIGH);
+ }
+ Serial.println("GPIO and display initialized.");
}
void display_code_for_level(int level) {
- char code[3] = {0}; // Temp storage for level code
- strncpy(code, levelCodes[level], 2); // Copy the level-specific code
-
- uint8_t segs[4] = {0}; // Segments to send to the display
-
- // Check if the first character is a letter and map it
- if (isalpha(code[0])) {
- if (code[0] >= 'A' && code[0] <= 'F') {
- segs[0] = SEGMENT_MAP[code[0] - 'A' + 10]; // Maps A-F to their segment patterns
- } else {
- // Handle unexpected characters or extend SEGMENT_MAP for more letters
- segs[0] = 0; // Display nothing for undefined letters
- }
- } else {
- // Assume it's a number and map directly
- segs[0] = SEGMENT_MAP[code[0] - '0'];
- }
-
- // Check if the second character is a digit and map it
- if (isdigit(code[1])) {
- segs[1] = SEGMENT_MAP[code[1] - '0'];
- } else {
- // Handle unexpected characters
- segs[1] = 0; // Display nothing for undefined digits
- }
-
- // Set only the first two segments, leave others blank
- display.setSegments(segs, 2, 0); // Display on leftmost two digits
+ char code[3] = {0}; // Temp storage for level code
+ strncpy(code, levelCodes[level], 2); // Copy the level-specific code
+
+ uint8_t segs[4] = {0}; // Segments to send to the display
+
+ // Check if the first character is a letter and map it
+ if (isalpha(code[0])) {
+ if (code[0] >= 'A' && code[0] <= 'F') {
+ segs[0] = SEGMENT_MAP[code[0] - 'A'
+ + 10]; // Maps A-F to their segment patterns
+ } else {
+ // Handle unexpected characters or extend SEGMENT_MAP for more letters
+ segs[0] = 0; // Display nothing for undefined letters
+ }
+ } else {
+ // Assume it's a number and map directly
+ segs[0] = SEGMENT_MAP[code[0] - '0'];
+ }
+
+ // Check if the second character is a digit and map it
+ if (isdigit(code[1])) {
+ segs[1] = SEGMENT_MAP[code[1] - '0'];
+ } else {
+ // Handle unexpected characters
+ segs[1] = 0; // Display nothing for undefined digits
+ }
+
+ // Set only the first two segments, leave others blank
+ display.setSegments(segs, 2, 0); // Display on leftmost two digits
}
+pb_global_state_t pb_hook_mod_state_read() { return puzzleState; }
-pb_global_state_t pb_hook_mod_state_read() {
- return puzzleState;
-}
-
-void pb_hook_mod_state_write(pb_global_state_t state) {
- puzzleState = state;
-}
+void pb_hook_mod_state_write(pb_global_state_t state) { puzzleState = state; }
-void pb_hook_ev_main_state_update(pb_global_state_t state){
+void pb_hook_ev_main_state_update(pb_global_state_t state) {
Serial.println("WE IN BOISS");
}
void setup() {
- Serial.begin(115200);
- pinMode(SOLVED_PIN, OUTPUT);
- digitalWrite(SOLVED_PIN, LOW);
- display.setBrightness(0x0f);
- initialize_system();
+ Serial.begin(115200);
+ pinMode(SOLVED_PIN, OUTPUT);
+ digitalWrite(SOLVED_PIN, LOW);
+ display.setBrightness(0x0f);
+ initialize_system();
}
void loop() {
- switch(puzzleState) {
- case PB_GS_PLAYING:
- display_code_for_level(currentLevel);
- check_button_press();
- delay(100);
- break;
- case PB_GS_SOLVED:
- Serial.println("STATE = PB_GS_SOLVED");
- display_final_code(bombCode);
- digitalWrite(SOLVED_PIN, HIGH);
- break;
- case PB_GS_NOINIT:
- Serial.println("STATE = PB_GS_NOINIT");
- blink_display(0);
- break;
- case PB_GS_IDLE:
- Serial.println("STATE = PB_GS_IDLE");
- blink_display(1);
- break;
- }
+ switch (puzzleState) {
+ case PB_GS_PLAYING:
+ display_code_for_level(currentLevel);
+ check_button_press();
+ delay(100);
+ break;
+ case PB_GS_SOLVED:
+ Serial.println("STATE = PB_GS_SOLVED");
+ display_final_code(bombCode);
+ digitalWrite(SOLVED_PIN, HIGH);
+ break;
+ case PB_GS_NOINIT:
+ Serial.println("STATE = PB_GS_NOINIT");
+ blink_display(0);
+ break;
+ case PB_GS_IDLE:
+ Serial.println("STATE = PB_GS_IDLE");
+ blink_display(1);
+ break;
+ }
}
diff --git a/puzzle/vault/mod.c b/puzzle/vault/mod.c
index bae8a3d..250cb66 100644
--- a/puzzle/vault/mod.c
+++ b/puzzle/vault/mod.c
@@ -1,6 +1,5 @@
-#include "pb.h"
#include "pb-mod.h"
+#include "pb.h"
const char * PB_MOD_NAME = "vault";
const i2c_addr_t PB_MOD_ADDR = PB_ADDR_MOD_VAULT;
-