From 49c3ee02aa0683a81723c28c8238129d5b547cb3 Mon Sep 17 00:00:00 2001 From: ShikyC Date: Thu, 9 Mar 2017 18:53:30 -0500 Subject: [PATCH] Update sanro.ino MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minor changes. ------------------------- 怕不是摸爆了,周末春假开始继续吧。 --- sanro/sanro.ino | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sanro/sanro.ino b/sanro/sanro.ino index ebd8922..8b0cb13 100644 --- a/sanro/sanro.ino +++ b/sanro/sanro.ino @@ -8,17 +8,24 @@ * * ***************************************************************/ +// Compatibility with Taiko Jiro #define MODE_JIRO 1 + #define MODE_DEBUG 0 #define CHANNELS 4 +// Caches for the soundwave and power #define SAMPLE_CACHE_LENGTH 12 #define POWER_CACHE_LENGTH 3 +// Light and heacy hit thresholds #define LIGHT_THRES 5000 #define HEAVY_THRES 20000 +// Forced sampling frequency +#define FORCED_FREQ 1000 + #include #include #include "cache.h" @@ -110,7 +117,10 @@ void loop() { // Force the sample frequency to be less than 1000Hz unsigned int frameTime = micros () - lastTime; lastTime = micros (); - if (frameTime < 1000) { - delayMicroseconds (1000 - frameTime); + if (frameTime < FORCED_FREQ) { + delayMicroseconds (FORCED_FREQ - frameTime); + } else { + // Performance bottleneck; + Serial.print ("Exception: forced frequency is too high for the microprocessor to catch up."); } }