You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
OpenTheremin_V3_with_MIDI/Open_Theremin_V3/timer.h

43 lines
808 B

#ifndef _TIMER_H
#define _TIMER_H
extern volatile uint16_t timer;
extern volatile uint16_t midi_timer;
inline uint16_t millisToTicks(uint16_t milliseconds) {
return milliseconds * (1000.0f/32);
}
inline void resetTimer() {
timer = 0;
}
inline void incrementTimer() {
timer++;
}
inline void incrementMidiTimer() {
midi_timer++;
}
inline bool timerExpired(uint16_t ticks) {
return timer >= ticks;
}
inline bool timerUnexpired(uint16_t ticks) {
return timer < ticks;
}
inline bool timerExpiredMillis(uint16_t milliseconds) {
return timerExpired(millisToTicks(milliseconds));
}
inline bool timerUnexpiredMillis(uint16_t milliseconds) {
return timerUnexpired(millisToTicks(milliseconds));
}
void ticktimer (uint16_t ticks);
void millitimer (uint16_t milliseconds);
#endif // _TIMER_H