@ -17,6 +17,26 @@ The uClock library API operates through attached callback functions mechanism:
4. **setOnClockStart(onClockStartCallback) > onClockStartCallback()** on uClock Start event
4. **setOnClockStart(onClockStartCallback) > onClockStartCallback()** on uClock Start event
5. **setOnClockStop(onClockStopCallback) > onClockStopCallback()** on uClock Stop event
5. **setOnClockStop(onClockStopCallback) > onClockStopCallback()** on uClock Stop event
### Software Timer mode - for unsupported boards (or avoiding usage of interrupts)
If a supported board isn't detected during compilation then a generic fallback approach will be used. This does not utilise any interrupts and so does not ensure accurate timekeeping. This can be useful to port your projects to boards that do not have support in uClock yet, or to test if suspected bugs in your code are related to interactions with interrupts or task handling.
You can force this non-interrupt "software timer mode" even on supported boards by defining the build flag `USE_UCLOCK_SOFTWARE_TIMER`.
In order for software timer mode to work, you need to add a call to your `loop()` function to process ticks. For example,
```c++
void loop() {
uClock.run();
// do anything else you need to do inside loop()...
// you can intercalate your main processing with other uClock.run() calls to avoid timming accuracy loss.
//uClock.run();
// do anything other inside loop()...
//uClock.run();
// the faster you can call uClock.run() without blocking the better and accurate timming you can achieve.
}
```
## Set your own resolution for your clock needs
## Set your own resolution for your clock needs
1. **PPQN_24** 24 Pulses Per Quarter Note
1. **PPQN_24** 24 Pulses Per Quarter Note
@ -34,7 +54,7 @@ Furthermore, it is possible to utilize all three resolutions simultaneously, all
## uClock v2.0 Breaking Changes
## uClock v2.0 Breaking Changes
If you are coming from uClock version <2.0versionspayattentiontothebreakingchangessoyoucanupdateyourcodetoreflectthenewAPIinterface:
If you are coming from uClock version <2.0versions,payattentiontothebreakingchangessoyoucanupdateyourcodetoreflectthenewAPIinterface:
"description":"A Library to implement BPM clock tick calls using hardware interruption. Supported and tested on AVR boards(ATmega168/328, ATmega16u4/32u4 and ATmega2560) and ARM boards(Teensy, STM32XX, ESP32, Raspberry Pico, Seedstudio XIAO M0 and RP2040)",
"description":"A Library to implement BPM clock tick calls using hardware interruption. Supported and tested on AVR boards(ATmega168/328, ATmega16u4/32u4 and ATmega2560) and ARM boards(Teensy, STM32XX, ESP32, Raspberry Pico, Seedstudio XIAO M0 and RP2040)",
// no hardware timer clock? use USE_UCLOCK_SOFTWARE_TIMER
#if !defined(USE_UCLOCK_SOFTWARE_TIMER)
//
//
// General Arduino AVRs port
// General Arduino AVRs port
//
//
#if defined(ARDUINO_ARCH_AVR)
#if defined(ARDUINO_ARCH_AVR)
#include"platforms/avr.h"
#include"platforms/avr.h"
#define UCLOCK_PLATFORM_FOUND
#endif
#endif
//
//
// Teensyduino ARMs port
// Teensyduino ARMs port
//
//
#if defined(TEENSYDUINO)
#if defined(TEENSYDUINO)
#include"platforms/teensy.h"
#include"platforms/teensy.h"
#define UCLOCK_PLATFORM_FOUND
#endif
#endif
//
//
// Seedstudio XIAO M0 port
// Seedstudio XIAO M0 port
//
//
#if defined(SEEED_XIAO_M0)
#if defined(SEEED_XIAO_M0)
#include"platforms/samd.h"
#include"platforms/samd.h"
#define UCLOCK_PLATFORM_FOUND
#endif
#endif
//
//
// ESP32 family
// ESP32 family
//
//
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP32)
#include"platforms/esp32.h"
#include"platforms/esp32.h"
#define UCLOCK_PLATFORM_FOUND
#endif
#endif
//
//
// STM32XX family
// STM32XX family
//
//
#if defined(ARDUINO_ARCH_STM32)
#if defined(ARDUINO_ARCH_STM32)
#include"platforms/stm32.h"
#include"platforms/stm32.h"
#define UCLOCK_PLATFORM_FOUND
#endif
#endif
//
//
// RP2040 (Raspberry Pico) family
// RP2040 (Raspberry Pico) family
//
//
#if defined(ARDUINO_ARCH_RP2040)
#if defined(ARDUINO_ARCH_RP2040)
#include"platforms/rp2040.h"
#include"platforms/rp2040.h"
#define UCLOCK_PLATFORM_FOUND
#endif
#endif
#endif
//
// Software Timer for generic, board-agnostic, not-accurate, no-interrupt, software-only port
//
#if !defined(UCLOCK_PLATFORM_FOUND)
#pragma message ("NOTE: uClock is using the 'software timer' approach instead of specific board interrupted support, because board is not supported or because of USE_UCLOCK_SOFTWARE_TIMER build flag. Remember to call uClock.run() inside your loop().")