diff --git a/firmware/src/main.cpp b/firmware/src/main.cpp index 45576a5..088c307 100644 --- a/firmware/src/main.cpp +++ b/firmware/src/main.cpp @@ -3,6 +3,22 @@ #include #include "macros.h" +// ======================================== +// Configuration +// ======================================== + +// 4 Multiplexers: GPIO pins for each analog multiplexer that handles 16 sensors +// Notes are connected in order: Mux #1 (0-15), Mux #2 (16-31), Mux #3 (32-47), Mux #4 (48-61) +const int NUM_MUX = 5; +const int PINS_PER_MUX = 12; +const int mux_in[] = {34, 34, 35, 34, 34}; // Analog signal input +// Select pins for every multiplexer, each multiplexer has 4 select pins, all sel0 are connected to 14, etc. +const int NUM_MUX_SEL = 4; +const int mux_sel[4] = {14, 27, 16, 17}; + +// ======================================== +// Code +// ======================================== u64 start_time = 0; @@ -11,7 +27,6 @@ typedef struct note { u16 midi; } Note; - // 61 Notes from C2 to C7 const int NUM_NOTES = 61; const Note notes[] = { @@ -23,21 +38,12 @@ const Note notes[] = { {"C7", 96} }; -// 4 Multiplexers: GPIO pins for each analog multiplexer that handles 16 sensors -// Notes are connected in order: Mux #1 (0-15), Mux #2 (16-31), Mux #3 (32-47), Mux #4 (48-61) -const int NUM_MUX = 5; -const int PINS_PER_MUX = 12; -const int mux_in[] = {34, 34, 35, 34, 34}; // Analog signal input -// Select pins for every multiplexer, each multiplexer has 4 select pins, all sel0 are connected to 14, etc. -const int NUM_MUX_SEL = 4; -const int mux_sel[4] = {14, 27, 16, 17}; - int lasts[NUM_NOTES]; // variable to store the value coming from the sensor u64 last_hit_times[NUM_NOTES]; -int max_sensor = 4096; -int max_threshold = 2000; -int active_threshold = 100; // Minimum value to be considered as a hit +val max_sensor = 4096; +val max_threshold = 2000; +val active_threshold = 100; // Minimum value to be considered as a hit void setup() { @@ -47,10 +53,6 @@ void setup() Serial.begin(9600); Serial.printf("Initialized\r\n"); - // Testing pin - pinMode(2, OUTPUT); - analogWrite(2, 255); - start_time = timeMillis(); }