File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111#define TIMER_PERIOD 300 // 20kHz sampling rate
1212#define TRIGGER_THRESHOLD 16 // 1250Hz at 20kHz sampling rate
1313#define TAP_THRESHOLD 256 // 78Hz at 20kHz sampling rate, or 16th notes at 293BPM
14- #define TRIGGER_LIMIT INT32_MAX
14+ #define TRIGGER_LIMIT UINT32_MAX
1515/* At 20kHz sampling frequency (TIMER_PERIOD 300), a 32-bit counter will
1616 * overflow every 59.65 hours. With 63 bits it overflows every 14623560 years.
1717 */
@@ -54,8 +54,8 @@ enum SynchroniserMode {
5454
5555class Synchroniser {
5656private:
57- int32_t trig;
58- int32_t period;
57+ volatile uint32_t trig;
58+ uint32_t period;
5959 bool isHigh;
6060 SynchroniserMode mode;
6161public:
@@ -107,10 +107,10 @@ class Synchroniser {
107107
108108class TapTempo {
109109private:
110- int32_t counter;
111- int32_t goLow;
112- int32_t goHigh;
113- int32_t trig;
110+ volatile uint32_t counter;
111+ uint32_t goLow;
112+ uint32_t goHigh;
113+ uint32_t trig;
114114 bool isHigh;
115115 bool on;
116116public:
@@ -155,17 +155,17 @@ class TapTempo {
155155 void clock (){
156156 if (trig < TRIGGER_LIMIT)
157157 trig++;
158- if (++counter >= goHigh)
159- counter = 0 ;
160158 if (on){
161- if (counter == 0 )
159+ if (++ counter >= goHigh){
162160 setHigh ();
163- else if (counter >= goLow && isHigh)
161+ counter = 0 ;
162+ }else if (counter >= goLow && isHigh){
164163 setLow ();
165- else if (isSineMode ())
166- setLed (LED_FULL*(goHigh-counter)/goHigh);
164+ }
165+ if (isSineMode ())
166+ setLed (LED_FULL*(goHigh-counter)/(goHigh+1 ));
167167 else
168- setLed (LED_FULL*counter/goHigh);
168+ setLed (LED_FULL*counter/( goHigh+ 1 ) );
169169 }
170170 }
171171 void setLow (){
Original file line number Diff line number Diff line change 11#include <inttypes.h>
22
3- #define FIRMWARE_VERSION "001 "
3+ #define FIRMWARE_VERSION "003 "
44#define HARDWARE_VERSION "TapTempo Rev03"
55
66/*
You can’t perform that action at this time.
0 commit comments