split cpp and h files
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
set(SOURCES
|
||||
"setup_wires.cpp"
|
||||
"step0.cpp"
|
||||
"step1.cpp"
|
||||
"step2.cpp"
|
||||
"step4.cpp"
|
||||
"step6.cpp"
|
||||
"wires_puzzle.cpp"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
#ifndef SETUP_WIRES_HPP
|
||||
#define SETUP_WIRES_HPP
|
||||
#include "setup_wires.h"
|
||||
|
||||
#include "../drivers/bottom_half.h"
|
||||
#include "../drivers/char_lcd.h"
|
||||
#include "wires_puzzle.h"
|
||||
#include <esp_log.h>
|
||||
|
||||
uint8_t wires_state = 0;
|
||||
static uint8_t wires_state = 0;
|
||||
|
||||
void print_wires(WireColor* wires, int editing_idx) {
|
||||
bool cut[NUM_WIRES];
|
||||
@@ -89,5 +83,3 @@ void setup_wires(void) {
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SETUP_WIRES_HPP */
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef SETUP_WIRES_H
|
||||
#define SETUP_WIRES_H
|
||||
|
||||
#include "../drivers/bottom_half.h"
|
||||
#include "../drivers/char_lcd.h"
|
||||
#include "../drivers/wires.h"
|
||||
#include "wires_puzzle.h"
|
||||
#include <esp_log.h>
|
||||
|
||||
void setup_wires(void);
|
||||
|
||||
#endif /* SETUP_WIRES_H */
|
||||
@@ -1,14 +1,6 @@
|
||||
#ifndef STEP_0_HPP
|
||||
#define STEP_0_HPP
|
||||
#include "step0.h"
|
||||
|
||||
#include "../drivers/bottom_half.h"
|
||||
#include "../drivers/char_lcd.h"
|
||||
#include "../drivers/wires.h"
|
||||
#include "setup_wires.hpp"
|
||||
|
||||
static const char *STEP0_TAG = "step0";
|
||||
|
||||
#define STRING_MAX_LEN 8
|
||||
static const char* TAG = "step0";
|
||||
|
||||
/// Wait for "*9819"
|
||||
void step0(void) {
|
||||
@@ -71,5 +63,3 @@ void step0(void) {
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* STEP_0_HPP */
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef STEP_0_H
|
||||
#define STEP_0_H
|
||||
|
||||
#include "../drivers/bottom_half.h"
|
||||
#include "../drivers/char_lcd.h"
|
||||
#include "../drivers/wires.h"
|
||||
#include "setup_wires.h"
|
||||
|
||||
#define STRING_MAX_LEN 8
|
||||
|
||||
/// Wait for "*9819"
|
||||
void step0(void);
|
||||
|
||||
#endif /* STEP_0_H */
|
||||
@@ -1,7 +1,4 @@
|
||||
#ifndef STEP_1_HPP
|
||||
#define STEP_1_HPP
|
||||
|
||||
#include <random>
|
||||
#include "step1.h"
|
||||
|
||||
static const char *STEP1_TAG = "step1";
|
||||
|
||||
@@ -26,15 +23,16 @@ static uint8_t NEOPIXEL_COLORS[4][3] = {
|
||||
{15, 0, 20},
|
||||
};
|
||||
|
||||
std::random_device my_rd;
|
||||
std::mt19937 my_gen(my_rd());
|
||||
std::uniform_int_distribution<> zero_to_one(0, 1);
|
||||
std::uniform_int_distribution<> zero_to_two(0, 2);
|
||||
std::uniform_int_distribution<> zero_to_three(0, 3);
|
||||
static std::random_device my_rd;
|
||||
static std::mt19937 my_gen(my_rd());
|
||||
static std::uniform_int_distribution<> zero_to_one(0, 1);
|
||||
static std::uniform_int_distribution<> zero_to_two(0, 2);
|
||||
static std::uniform_int_distribution<> zero_to_three(0, 3);
|
||||
|
||||
static lv_obj_t *scr;
|
||||
static lv_obj_t *text = NULL;
|
||||
|
||||
static lv_style_t style_screen;
|
||||
static lv_style_t green_text;
|
||||
static lv_style_t red_text;
|
||||
static lv_style_t yellow_text;
|
||||
@@ -49,7 +47,7 @@ static lv_style_t* color_styles[] = {
|
||||
&purple_text
|
||||
};
|
||||
|
||||
void init_step(void) {
|
||||
static void init_step(void) {
|
||||
scr = lv_disp_get_scr_act(NULL);
|
||||
|
||||
// Set the background color of the display to black.
|
||||
@@ -83,12 +81,12 @@ void init_step(void) {
|
||||
text = lv_label_create(scr);
|
||||
}
|
||||
|
||||
void clean_up_step(void) {
|
||||
static void clean_up_step(void) {
|
||||
lv_obj_clean(text);
|
||||
lv_obj_clean(scr);
|
||||
}
|
||||
|
||||
void generate_switch_leds(void) {
|
||||
static void generate_switch_leds(void) {
|
||||
int colors[4] = {0, 1, 2, 3};
|
||||
|
||||
int idx = zero_to_three(my_gen);
|
||||
@@ -114,7 +112,7 @@ void generate_switch_leds(void) {
|
||||
led_strip_refresh(leds);
|
||||
}
|
||||
|
||||
int generate_part_a(void) {
|
||||
static int generate_part_a(void) {
|
||||
int text_color = zero_to_three(my_gen);
|
||||
int text_idx = zero_to_three(my_gen);
|
||||
|
||||
@@ -130,7 +128,7 @@ int generate_part_a(void) {
|
||||
return text_color;
|
||||
}
|
||||
|
||||
int generate_part_b(void) {
|
||||
static int generate_part_b(void) {
|
||||
int is_color = zero_to_one(my_gen) == 0;
|
||||
if (is_color) {
|
||||
return generate_part_a();
|
||||
@@ -151,7 +149,7 @@ int generate_part_b(void) {
|
||||
return text_number;
|
||||
}
|
||||
|
||||
int generate_part_c(void) {
|
||||
static int generate_part_c(void) {
|
||||
int type = zero_to_two(my_gen);
|
||||
if (type != 0) {
|
||||
return generate_part_b();
|
||||
@@ -170,7 +168,7 @@ int generate_part_c(void) {
|
||||
return text_color + 4;
|
||||
}
|
||||
|
||||
void part_a(void) {
|
||||
static void part_a(void) {
|
||||
stop_module_timer();
|
||||
set_module_time(30);
|
||||
|
||||
@@ -209,7 +207,7 @@ void part_a(void) {
|
||||
play_raw(MOUNT_POINT "/correct.pcm");
|
||||
}
|
||||
|
||||
void part_b(void) {
|
||||
static void part_b(void) {
|
||||
stop_module_timer();
|
||||
set_module_time(25);
|
||||
|
||||
@@ -248,7 +246,7 @@ void part_b(void) {
|
||||
play_raw(MOUNT_POINT "/correct.pcm");
|
||||
}
|
||||
|
||||
void part_c(void) {
|
||||
static void part_c(void) {
|
||||
stop_module_timer();
|
||||
set_module_time(20);
|
||||
|
||||
@@ -304,7 +302,3 @@ void step1(void) {
|
||||
part_c();
|
||||
clean_up_step();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* STEP_1_HPP */
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef STEP_1_H
|
||||
#define STEP_1_H
|
||||
|
||||
#include <random>
|
||||
#include "../drivers/bottom_half.h"
|
||||
#include "../drivers/tft.h"
|
||||
#include "../drivers/leds.h"
|
||||
#include "../drivers/wires.h"
|
||||
#include "../drivers/speaker.h"
|
||||
#include "../drivers/game_timer.h"
|
||||
#include "../drivers/char_lcd.h"
|
||||
|
||||
void step1(void);
|
||||
|
||||
#endif /* STEP_1_H */
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef STEP_2_HPP
|
||||
#define STEP_2_HPP
|
||||
|
||||
static const char *STEP2_TAG = "step2";
|
||||
|
||||
void step2(void) {
|
||||
|
||||
}
|
||||
|
||||
#endif /* STEP_2_HPP */
|
||||
@@ -0,0 +1,5 @@
|
||||
static const char *TAG = "step4";
|
||||
|
||||
void step4(void) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef STEP_4_H
|
||||
#define STEP_4_H
|
||||
|
||||
void step4(void);
|
||||
|
||||
#endif /* STEP_4_H */
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef STEP_4_HPP
|
||||
#define STEP_4_HPP
|
||||
|
||||
static const char *STEP4_TAG = "step4";
|
||||
|
||||
void step4(void) {
|
||||
|
||||
}
|
||||
|
||||
#endif /* STEP_4_HPP */
|
||||
@@ -1,15 +1,9 @@
|
||||
#ifndef STEP_6_HPP
|
||||
#define STEP_6_HPP
|
||||
#include "step6.h"
|
||||
|
||||
#include "wires_puzzle.h"
|
||||
#include "drivers/wires.h"
|
||||
#include "drivers/bottom_half.h"
|
||||
|
||||
static const char *STEP6_TAG = "step6";
|
||||
static const char *TAG = "step6";
|
||||
|
||||
static uint8_t cut_wires = 0;
|
||||
|
||||
|
||||
void step6(void) {
|
||||
get_cut_wires();
|
||||
clear_all_pressed_released();
|
||||
@@ -53,5 +47,3 @@ void step6(void) {
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* STEP_6_HPP */
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef STEP_6_H
|
||||
#define STEP_6_H
|
||||
|
||||
#include "wires_puzzle.h"
|
||||
#include "drivers/wires.h"
|
||||
#include "drivers/bottom_half.h"
|
||||
#include "drivers/sd.h"
|
||||
#include "drivers/speaker.h"
|
||||
|
||||
void step6(void);
|
||||
|
||||
#endif /* STEP_6_H */
|
||||
Reference in New Issue
Block a user