#ifndef SETUP_WIRES_HPP #define SETUP_WIRES_HPP #include "../drivers/bottom_half.h" #include "../drivers/char_lcd.h" #include "wires_puzzle.h" #include uint8_t wires_state = 0; void print_wires(WireColor* wires, int editing_idx) { bool cut[NUM_WIRES]; solve_wires(wires, cut); lcd_set_cursor(&lcd, 1, 1); char string_buf[NUM_WIRES+1] = {0}; wires_to_string(wires, string_buf); lcd_print(&lcd, string_buf); lcd_set_cursor(&lcd, 1, 2); cut_to_string(cut, string_buf); lcd_print(&lcd, string_buf); lcd_set_cursor(&lcd, 1, 3); wires_state = get_wires(); for (int i = 0; i < NUM_WIRES; i++) { if (wires_state & (1<= NUM_WIRES) editing_idx = NUM_WIRES-1; } else if (button == ButtonKey::b2) { // down wires[editing_idx] = (WireColor)(((int)(wires[editing_idx]) + (NUM_COLORS-1)) % NUM_COLORS); } else if (button == ButtonKey::b3) { // up wires[editing_idx] = (WireColor)(((int)(wires[editing_idx]) + 1) % NUM_COLORS); } save_wires_to_sd_card(wires); print_wires(wires, editing_idx); } uint8_t new_wires_state = get_wires(); if (new_wires_state != wires_state) { print_wires(wires, editing_idx); } vTaskDelay(pdMS_TO_TICKS(10)); } } #endif /* SETUP_WIRES_HPP */