From d43141350ca5255eb5af00e57a6afb75d41521b0 Mon Sep 17 00:00:00 2001 From: dakkar Date: Sat, 22 Aug 2020 14:47:20 +0100 Subject: generalise the code a bit --- esp32/lego-piano.ino | 62 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/esp32/lego-piano.ino b/esp32/lego-piano.ino index 4a88556..29368e6 100644 --- a/esp32/lego-piano.ino +++ b/esp32/lego-piano.ino @@ -19,13 +19,19 @@ #include int currentLed = 0; -int lastSeen = 100; +int lastSeen = -1; -const int rows[] = { 5, 23, 19, 18, 26 }; -const int cols[] = { 7, 33, 8, 21, 22 }; -const int adc[] = { 2, 4, 12, 27, 14 }; +#define DEBUG 0 + +const size_t row_count = 5; +const size_t col_count = 5; + +const int rows[row_count] = { 5, 23, 19, 18, 26 }; +const int cols[col_count] = { 7, 33, 8, 21, 22 }; +const int adc[row_count] = { 2, 4, 12, 27, 14 }; const int ampEnable = 32; +const int octave_shift = 4; void setup() { Serial.begin(115200); @@ -36,15 +42,16 @@ void setup() { dac_i2s_disable(); dac_output_enable(DAC_CHANNEL_1); - for (int i=0;i<5;++i) { + for (int i=0;i