Update uClock to latest version v2.2.1
This commit is contained in:
12
README.md
12
README.md
@ -19,6 +19,17 @@ Common directory locations:
|
|||||||
* [Adafruit_GFX](https://github.com/adafruit/Adafruit-GFX-Library) [BSD] - Graphics helper library.
|
* [Adafruit_GFX](https://github.com/adafruit/Adafruit-GFX-Library) [BSD] - Graphics helper library.
|
||||||
* [Adafruit_SSD1306](https://github.com/adafruit/Adafruit_SSD1306) [BSD] - Library for interacting with the SSD1306 OLED display.
|
* [Adafruit_SSD1306](https://github.com/adafruit/Adafruit_SSD1306) [BSD] - Library for interacting with the SSD1306 OLED display.
|
||||||
|
|
||||||
|
> **NOTE:**
|
||||||
|
> The uClock library needs an additional build parameter passed in order to reduce the amount of dynamic memory it allocates. This can be done by modifying your `arduino.json` file and adding the following:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"buildPreferences": [
|
||||||
|
["build.extra_flags" "-DEXT_INTERVAL_BUFFER_SIZE=1"]
|
||||||
|
]
|
||||||
|
```
|
||||||
|
For additional details, see: https://github.com/midilab/uClock/issues/53
|
||||||
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
Here's a trivial example showing some of the ways to interact with the library. This script rotates the active clock channel according to the set tempo. The encoder can change the temo or rotation direction. The play/pause button will toggle the clock activity on or off. The shift button will freeze the clock from advancing the channel rotation.
|
Here's a trivial example showing some of the ways to interact with the library. This script rotates the active clock channel according to the set tempo. The encoder can change the temo or rotation direction. The play/pause button will toggle the clock activity on or off. The shift button will freeze the clock from advancing the channel rotation.
|
||||||
@ -111,3 +122,4 @@ void UpdateDisplay() {
|
|||||||
gravity.display.display();
|
gravity.display.display();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
18
clock.h
18
clock.h
@ -29,8 +29,8 @@ class Clock {
|
|||||||
void Init() {
|
void Init() {
|
||||||
// Initialize the clock library
|
// Initialize the clock library
|
||||||
uClock.init();
|
uClock.init();
|
||||||
uClock.setMode(uClock.INTERNAL_CLOCK);
|
uClock.setClockMode(uClock.INTERNAL_CLOCK);
|
||||||
uClock.setPPQN(uClock.PPQN_96);
|
uClock.setOutputPPQN(uClock.PPQN_96);
|
||||||
uClock.setTempo(DEFAULT_TEMPO);
|
uClock.setTempo(DEFAULT_TEMPO);
|
||||||
uClock.start();
|
uClock.start();
|
||||||
}
|
}
|
||||||
@ -42,30 +42,30 @@ class Clock {
|
|||||||
|
|
||||||
// Internal PPQN96 callback for all clock timer operations.
|
// Internal PPQN96 callback for all clock timer operations.
|
||||||
void AttachIntHandler(void (*callback)(uint32_t)) {
|
void AttachIntHandler(void (*callback)(uint32_t)) {
|
||||||
uClock.setOnPPQN(callback);
|
uClock.setOnOutputPPQN(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the source of the clock mode.
|
// Set the source of the clock mode.
|
||||||
void SetSource(Source source) {
|
void SetSource(Source source) {
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case SOURCE_INTERNAL:
|
case SOURCE_INTERNAL:
|
||||||
uClock.setMode(uClock.INTERNAL_CLOCK);
|
uClock.setClockMode(uClock.INTERNAL_CLOCK);
|
||||||
break;
|
break;
|
||||||
case SOURCE_EXTERNAL_PPQN_24:
|
case SOURCE_EXTERNAL_PPQN_24:
|
||||||
uClock.setMode(uClock.EXTERNAL_CLOCK);
|
uClock.setClockMode(uClock.EXTERNAL_CLOCK);
|
||||||
case SOURCE_EXTERNAL_PPQN_4:
|
case SOURCE_EXTERNAL_PPQN_4:
|
||||||
uClock.setMode(uClock.EXTERNAL_CLOCK);
|
uClock.setClockMode(uClock.EXTERNAL_CLOCK);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExternalSource() {
|
bool ExternalSource() {
|
||||||
return uClock.getMode() == uClock.EXTERNAL_CLOCK;
|
return uClock.getClockMode() == uClock.EXTERNAL_CLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InternalSource() {
|
bool InternalSource() {
|
||||||
return uClock.getMode() == uClock.INTERNAL_CLOCK;
|
return uClock.getClockMode() == uClock.INTERNAL_CLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Tempo() {
|
int Tempo() {
|
||||||
@ -85,7 +85,7 @@ class Clock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsPaused() {
|
bool IsPaused() {
|
||||||
return uClock.state == uClock.PAUSED;
|
return uClock.clock_state == uClock.PAUSED;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user