From 7fcbee4eb9d59ca395b06a82bd6a357a30adfb8c Mon Sep 17 00:00:00 2001 From: xyqyear Date: Mon, 17 Jul 2023 08:23:28 +0800 Subject: [PATCH] not sure if gcc can optimize out that one mutiplication --- maimaiTouchControl.ino | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/maimaiTouchControl.ino b/maimaiTouchControl.ino index 7e73181..84643c5 100644 --- a/maimaiTouchControl.ino +++ b/maimaiTouchControl.ino @@ -20,8 +20,7 @@ enum commandSens = 0x6B, // k }; -uint8_t SECOND_FILTER_ITERATION_SAMPLES; -uint8_t ELECTRODE_SAMPLE_INTERVAL_MS; +uint8_t DATA_READ_INTERVAL; void setup() { @@ -35,6 +34,9 @@ void setup() // config conversion + uint8_t SECOND_FILTER_ITERATION_SAMPLES; + uint8_t ELECTRODE_SAMPLE_INTERVAL_MS; + switch (SECOND_FILTER_ITERATIONS) { case 0: @@ -52,6 +54,7 @@ void setup() } ELECTRODE_SAMPLE_INTERVAL_MS = 1 << ELECTRODE_SAMPLE_INTERVAL; + DATA_READ_INTERVAL = SECOND_FILTER_ITERATION_SAMPLES * ELECTRODE_SAMPLE_INTERVAL_MS; } void loop() @@ -59,7 +62,7 @@ void loop() // there will only be a new data point every this many milliseconds // so we don't need to check every loop uint16_t currentMillis = millis(); - if (currentMillis - lastMillis > ELECTRODE_SAMPLE_INTERVAL_MS * SECOND_FILTER_ITERATION_SAMPLES) + if (currentMillis - lastMillis > DATA_READ_INTERVAL) { lastMillis = currentMillis; Recv();