I am currently experimenting with i2c communication on the patch.init module. My goal is to have a polyphonic synth which can be controlled via i2c similar to just friends being controlled by the monome crow module.
But i struggle to make the communication work.
My current test setup are two Adafruit QT Pys connected via i2c to establish valid i2c communication with typical Arduino examples. As pullups I use 10k resistors. Once I had this setup working I planed to replace the i2c receiver with the patch.init.
- I identified B7 and B8 (as labeled here datasheet) as SCL and SDA
- I soldered jumper wires to the interface PCB (front) and ensured that no shorts are present and that both button and switch are not connected to GND (default for button and down position for the switch)
- I replaced the receiving QT Py with the patch.init module
- communication did not work
- I added setSCL and setSDA as proposed here, but was unsure which pin naming convention to use
- I looked up the pin defines on github and realized that there is an “inconsistency” between the pin labeling in the datasheet and here
DaisyDuino/daisy_patch_sm.h at eb2964f5a970115ffc33ffd568a78c1743562ee7 · electro-smith/DaisyDuino · GitHub
#define PIN_PATCH_SM_I2C_SCL PB8
#define PIN_PATCH_SM_I2C_SDA PB9
the code I used on the patch.init, should shortly flash the front panel LED to indicate received i2c communication. On start up it shortly flashes to indicate that the code is working so far. The code is as follows:
#include <elapsedMillis.h>
#include "DaisyDuino.h"
DaisyHardware patch;
elapsedMillis t;
bool state;
void AudioCallback(float **in, float **out, size_t size) {
}
/** Start here */
void setup() {
/** Initialize the patch_sm hardware object */
patch = DAISY.init(DAISY_PATCH_SM);
Serial.begin(9600);
Wire.setSCL(PIN_PATCH_SM_I2C_SCL);
Wire.setSDA(PIN_PATCH_SM_I2C_SDA);
Wire.begin(4);
Wire.onReceive(receiveEvent);
/** Start Processing the audio */
//DAISY.begin(AudioCallback);
patch.WriteCvOut(PIN_PATCH_SM_CV_OUT_2, 2.5);
t = 0;
state = true;
}
/** Loop forever */
void loop() {
//patch.ProcessAllControls();
if (t>500 && state) {
state = false;
patch.WriteCvOut(PIN_PATCH_SM_CV_OUT_2, 0);
}
}
void receiveEvent (int howMany) {
Serial.println("!");
while(0 < Wire.available()) // loop through all but the last
{
char c = Wire.read(); // receive byte as a character
//Serial.print(c); // print the character
}
t = 0;
state = true;
patch.WriteCvOut(PIN_PATCH_SM_CV_OUT_2, 2.5);
}
I would highly appreciate advice on how to solve this issue and would appreciate some example code. I know that the current solution is not optimal since the button and switch are not disabled, but I would love to create my own control hardware for which the i2c pins are reserved exclusively for communication and until then this is a prototyping setup.