Update sanro.ino

Minor changes.
-------------------------
怕不是摸爆了,周末春假开始继续吧。
This commit is contained in:
ShikyC 2017-03-09 18:53:30 -05:00 committed by GitHub
parent 2fdde3f4a4
commit 49c3ee02aa

View File

@ -8,17 +8,24 @@
* * * *
***************************************************************/ ***************************************************************/
// Compatibility with Taiko Jiro
#define MODE_JIRO 1 #define MODE_JIRO 1
#define MODE_DEBUG 0 #define MODE_DEBUG 0
#define CHANNELS 4 #define CHANNELS 4
// Caches for the soundwave and power
#define SAMPLE_CACHE_LENGTH 12 #define SAMPLE_CACHE_LENGTH 12
#define POWER_CACHE_LENGTH 3 #define POWER_CACHE_LENGTH 3
// Light and heacy hit thresholds
#define LIGHT_THRES 5000 #define LIGHT_THRES 5000
#define HEAVY_THRES 20000 #define HEAVY_THRES 20000
// Forced sampling frequency
#define FORCED_FREQ 1000
#include <limits.h> #include <limits.h>
#include <Keyboard.h> #include <Keyboard.h>
#include "cache.h" #include "cache.h"
@ -110,7 +117,10 @@ void loop() {
// Force the sample frequency to be less than 1000Hz // Force the sample frequency to be less than 1000Hz
unsigned int frameTime = micros () - lastTime; unsigned int frameTime = micros () - lastTime;
lastTime = micros (); lastTime = micros ();
if (frameTime < 1000) { if (frameTime < FORCED_FREQ) {
delayMicroseconds (1000 - frameTime); delayMicroseconds (FORCED_FREQ - frameTime);
} else {
// Performance bottleneck;
Serial.print ("Exception: forced frequency is too high for the microprocessor to catch up.");
} }
} }