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 SDA PIN 13
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:
ā€¦ā€¦\plugdata\Toolchain\usr\bin\Heavy_internal\hvcc\generators\c2daisy\templates

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.

Example:
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.

THANKS
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.

2 Likes

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:
LedRot_A.zip (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,
Christof

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: