Plugdata and Oled + Rot Encoder Menue (simple!)

This is some sort of simple and crude, but perhaps it might still be inspiring or useful for others?

What is it?
The idea is to provide a simple means of output on a Oled Display for Puredata Patches and use the Programming invironment of Plugdata. Also a simple menue interface to set parameters with a rot encoder is shown.

How is it done?
We can think of 3 components of the running software:
A The callback routine triggered by interrupt every millisecond.
A1 The Plugdata patch, compiled by heavy for sound processing is running in A.

B The main loop, which will be interrupted by A for less time critical stuff. Here we will process the display handling.

To have a very simple means for communication we use a plugdata table (tabwrite and tabread), which can be accessed as an array of floats from B-side.

Hardware connections:
Hardware connection of a 128*64 pixel monocrome display with SSD1306 controller via I2C.
VCC goes to 3V3_digital Pin 38
GND goes to GND_digital Pin 40
I2C SCL Pin 12
I2C address = 0x3C
The display is not included in the JSON file, because we only handle the it on B-side. The pins are somewhere fixed to these pins. Setting different pins did not work! The speed works with 400kHz in my setup.

The rot-encoder is connected to the pins as described in the JSON file:

   "encoder": {
      "component": "Encoder",
      "pin": {
         "a": 26,
         "b": 25,
         "click": 14

The numbers are digital port numbers here.

Software setup:
We have to tell Plugdata, that we want to include some user software. Fortunately this is quite straightforward, because plugdata uses a template file HeavyDaisy.cpp, which we can modify. It can be found in:

Here we add some lines to include the user source code file, and to install the CpuLoadMeter, to call userMainInit(); and to call userMainLoop();

Then we write a source code file which contains the 2 routines userMainInit() and userMainLoop().
The Encoder Press switch cycles through the parameters to be edited. The parameter number is at table position 48, the rot encoder can then change the selected parameter.

The example displays the CPU load and an input level (position 6/7 of the table). CPU load of the callback routine in percent.
Also as a parameter number 5 at position 60 of the table, the volume of the output can be controlled.
There is also a blinking led, using the table.

I had difficulties to get the tabread/tabwrite do what I wanted and I was not able to find in depth discriptions. It seems that tabread needs a bang to read. And tabwrite needs both an address with bang and new data with bang for every write.
For easy display, I use 0…100 pc for all parameters, shown as 0…99 with 2 digits. This way I can squeeze 6 parameters in one line.
With included debug printing, this patch can be compiled with “big” patch size.

Big thanks for Daisy and for PLUGDATA and the help I got here in the forum!!!

Have fun, Christof

Aaaaaah, this is ???: I cannot upload a ZIP file. Is there a trick? Renaming for jpg did not work… How are you supposed to provide examples???

1 Like

Do realize that if you start modifying the template you might break other usage.
Also on the next update of the toolchain it will be overwritten, so take care to make backups.

In the future we might look at a way to include such custom code more directly, but this would need quite some consideration to make sure we don’t break things for other users :slight_smile:

ps; I have no idea how to upload zip files either :person_shrugging:

There are several possibilities to share files, among them - put it on some kind of shared storage or virtual disk, such as Google Drive, MS OneDrive, DropBox, etc and put a link to it on the forum, or even better, put it on GitHub, or GitLab etc.

But it is annoying, it’s been brought up before, with some response from Electro-Smith that they’ll ‘look into it’…

I don’t really see why the restriction exists, but there are many things in this world I don’t understand.

Well I have been able to share projects at Parallax and at PJRC/Teensy forums. They seem to see, that this is kind of showcase for their products. It is kind of very strange, because Daisy Seed is a product more for people, who are more interested in Sound and Music, but everything seems to be rather complicated and more made for professional programmers. You would think, that customers should be encouraged to share even their simpler stuff???
I also wanted to share my little Preamp Project, but…

@cebersp and @dreamer, .zip can be uploaded now! No ZIP Files - #2 by Takumi_Ogata

@tunagenes, can you link me to where it was brought up so that I can provide an update to that person?
I couldn’t find a post mentioning it unfortunately. Let me know, thanks! I didn’t have any luck searching “Upload zip” (aside from what cebersp’s post), “Post zip”, nor “zip permission”. I don’t know how else that person could’ve phrased it.


That’s great that you now can upload a zip.

Here’s your post in the thread I was thinking of:

@Astrin said goodbye to the forum a while ago, I don’t know if he still reads it.

Ah I see! I was still fairly new at the time, so I wanted to double check with the team if there was a reason why the docx file wasn’t permitted. Something must have happened on the day I asked that took priority.

I think most file types used to be permitted but the forum system that we use automatically may have excluded them at one point since I saw a .zip posted on the forum around 2021 while I was searching around today.

Anyway, I added .docx, .pdf, and .txt to the “permitted file types” too :slight_smile:

1 Like

So here is the ZIP, as now it is possible: (7.2 KB)

Oh, It’s a pity that I cannot edit the first post any more. I should have mentioned, that on both SCL and SDA there is a 4k7 pullup resistor to 3V3_digital.

Have fun,

Looking at your pd patch and the modified code I really have no idea what this is supposed to do :person_shrugging:

Oh, did You also have a look into LedRot_A.cpp?

This is the Output: