lib Modulove
Library for building custom scripts for Modulove modules.
Loading...
Searching...
No Matches
Modulove Hardware Abstraction Library

This package provides a library for creating scripts for the Modulove A-RYTH-MATIK eurorack module.

Full Doxyen generated documentation of the library can be found here: https://awonak.github.io/libModulove/.

Installation instructions

Option 1: Arduino CLI

The recommended way to install the library is to use the Arduino CLI to download the library code directly from GitHub.

$ arduino-cli config init
$ arduino-cli config set library.enable_unsafe_install true
$ arduino-cli lib install --git-url https://github.com/awonak/libModulove.git

Option 2: Clone and symlink the repo

$ git clone https://github.com/awonak/libModulove.git
$ ln -s `pwd`/libmodulove ~/Arduino/libraries

Option 3: Include the library as a git submodule to use in your scripts.

In order to include the library source code directly in your repo as a git submodule, you must follow the Arduino Sketch specifications and place the code in the location <sketch>/src/<library>. This is documented in the src subfolder section of the Arduino Sketch Specification.

git submodule add https://github.com/awonak/libmodulove.git <sketch>/src/libmodulove

Example usage for A-RYTH-MATIK

#include "src/libmodulove/arythmatik.h"
using namespace modulove;
using namespace arythmatik;
// Declare A-RYTH-MATIK hardware variable.
// Since counter is modified in the CLK/RST handler, it should be volatile.
volatile int counter;
void setup() {
// Inside the setup, set config values prior to calling hw.Init().
#ifdef ROTATE_PANEL
hw.config.RotatePanel = true;
#endif
#ifdef ENCODER_REVERSED
hw.config.ReverseEncoder = true;
#endif
// Set up encoder parameters
hw.eb.setEncoderHandler(UpdateRotate);
hw.eb.setClickHandler(UpdatePress);
// Attach CLK & RST pin change handlers.
hw.AttachClockHandler(HandleClockPinChange);
hw.AttachResetHandler(HandleResetPinChange);
// Initialize the A-RYTH-MATIK peripherials.
hw.Init();
}
void loop() {
// Read cv inputs and process encoder state to determine state for this loop.
// Activate the current counter output.
for (int i = 0; i < OUTPUT_COUNT; i++) {
(i == counter)
? hw.outputs[i].High()
: hw.outputs[i].Low();
}
// Display the current counter step on the OLED.
hw.display.clearDisplay();
hw.display.setCursor(SCREEN_HEIGHT/2, 0);
hw.display.println("Counter: " + String(counter));
hw.display.display();
}
void HandleClockPinChange() {
// Advance the counter on CLK input
if (hw.clk.Read() == HIGH) {
counter = ++counter % OUTPUT_COUNT;
}
}
void HandleResetPinChange() {
if (hw.rst.Read() == HIGH) {
counter = 0;
}
}
void UpdateRotate(EncoderButton &eb) {
// Read the configured encoder direction (according to hw.config.ReverseEncoder setting).
// Read the number of rotation clicks since the last encoder handler event.
int rotate_count = eb.increment();
counter = (dir == DIRECTION_INCREMENT)
? min(counter + rotate_count, OUTPUT_COUNT)
: max(counter - rotate_count, 0);
}
void UpdatePress(EncoderButton &eb) {
// Reset the counter to zero.
counter = 0;
}
Hardware abstraction wrapper for A-RYTH-MATIK module.
Definition arythmatik.h:22
void AttachClockHandler(void(*callback)(void))
Pin change handlers.
Definition arythmatik.cpp:67
DigitalInput rst
RST Digital Input object.
Definition arythmatik.h:55
DigitalOutput outputs[arythmatik::OUTPUT_COUNT]
Definition arythmatik.h:52
EncoderButton eb
EncoderButton object.
Definition arythmatik.h:51
arythmatik::Direction EncoderDirection()
Parse the configured EncoderButton increment direction.
Definition arythmatik.cpp:107
void Init()
Initializes the Arduino, and A-RYTH-MATIK hardware.
Definition arythmatik.cpp:22
DigitalInput clk
CLK Digital Input object.
Definition arythmatik.h:54
void ProcessInputs()
Read the state of the CLK and RST inputs.
Definition arythmatik.cpp:94
Adafruit_SSD1306 display
OLED display object.
Definition arythmatik.h:50
bool Read()
Read live pin state as a bool.
Definition digital_input.h:80
void High()
Sets the cv output HIGH to about 5v.
Definition digital_output.h:54
void Low()
Sets the cv output LOW to 0v.
Definition digital_output.h:57
Direction
Enum constants for encoder rotation increment/decrement state.
Definition encoder_dir.h:18

Example usage for SyncLFO

#include "src/libmodulove/arythmatik.h"
using namespace modulove;
using namespace synclfo;
// Declare A-RYTH-MATIK hardware variable.
byte step = 0;
void setup() {
// Inside the setup, set config values prior to calling hw.Init().
#ifdef SYNCHRONIZER
hw.config.Synchronizer = true;
#endif
// Initialize the SyncLFO peripherials.
hw.Init();
}
void loop() {
// Read cv inputs and process button state to determine state for this loop.
// Read cv inputs to determine state for this loop.
bool advance = hw.trig.State() == DigitalInput::STATE_RISING;
if (hw.config.Synchronizer) {
advance |= hw.b1.Change() == Button::CHANGE_PRESSED;
}
// Detect if new trigger received and advance step.
if (advance) {
step = (step + 1) % synclfo::P_COUNT;
}
// Write current step CV output.
byte val = map(hw.knobs[step]->Read(), 0, MAX_INPUT, 0, MAX_OUTPUT);
hw.output.Update(val);
}
uint16_t Read()
Get the current value of the analog input.
Definition analog_input.h:49
void Update(int val)
Set the output pin to the given 8 bit value.
Definition analog_output.h:51
ButtonChange Change()
Get the state change for the button.
Definition button.h:91
InputState State()
Get the current input state of the digital input.
Definition digital_input.h:64
Hardware abstraction wrapper for SyncLFO module.
Definition synclfo.h:18
void ProcessInputs()
Read the state of the CLK and RST inputs.
Definition synclfo.cpp:49
void Init()
Initializes the Arduino, and SyncLFO hardware.
Definition synclfo.cpp:17

Third-party Arduino Libraries