Using custom 128-led strip RGB-encoders

Hello there,

As I developed my own 128-led strip RGB-encoder in the past, I would like to get some more info on how I would be able to integrate these into the Zynhian UI, as a replacement for the standard Zynthian kit encoders.

Schermafbeelding 2022-09-16 om 09.32.00

See it in action here

I have complete control over the firmware of these encoders, at the moment they work using I2C, where the level is reported (0-254) or the level is set by an I2C command.

Is it possible to use these with I2C? Do I need to use an interrupt pin to signal a turn/click, …? Where in the Zynthian code should I start looking? Or is this simply some kind of configuration? If so, what is the expected/required behavior of an i2c encoder in Zynthian? Like I said, I can always adapt the firmware on my encoder to match what Zynthian needs…

1 Like

Hi @Meirssv !

Nice device! I never saw an “encoder + led ring” with this high resolution! Congrats!

Take a look to the zyncoder library:

The interesting bits are:

  • zynpot => abstraction layer
  • zyncoder => switch & rotary step encoder implementation (using Bourns PEC11 as reference device)
  • zynrv112 => rotary analog encoder implementation (using Alpha RV112 as reference device)
  • zyncoder_i2c => it should be a i2c rotary encoder implementation, but it’s outdated and not working for sure

Zynthian encoders/pots are purely incremental. I think the best option would be to expose the encoder device so zyncoder library can load it normally. If you prefer i2c , you should implement an i2c “zynpot”. You could use zyncoder & zyncoder_i2c as starting point.

For the led-feedback part, we have nothing like this implemented, but it shouldn’t be a problem to modify the zynthian_gui_controller for including an update call when value changes.


Ok, thanks for the guidance. I know my way around programming, but I’m not very familiar with building these things in Linux.

Do I just go ahead and start by cloning the zynthian/zyncoder repository on my Zynthian-box, start programming, building it?

How do I eventually install what I built using above step to be used by the Zynthian UI on my box to test it? Or is this automatically ‘activated’? Is it possible to perform some kind of unit tests on the encoder parts?

Very nice device! One, of course, presumes the LED’s are Tri Colour…?

Probably better to fork rather than clone the repository so that you have control of your own sub project at github ( You will need an account up there ).

You then use git tools to pull down your forked copy from your github repository and smash that around to your hearts content.

I’m presuming from the way you describe the process that you haven’t met git directly.
It has a VERY close relationship with linux as, they are projects initiated by the same guy.

It has it’s characteristics, legend says it was written in a weekend, but it works and operates entirely peer to peer which seems to be the preferred model as we’ve learnt over the past twenty or so years.

Actually running and developing code on a zynthian depends largely on your focus. I have only really ever submitted one Pull Request but have read and manipulated a great deal of zynthian code over the years, and I’ve found Visual Studio Code from Microsoft to be the most effective mechanism as it’s an IDE and will handle many tasks around development in a very efficent and intelligent way.
For instance it will manage your github account, allowing you to pull and push code from your zynthian to the github repository. It will also allow you to debug remotely from another host, which all just works. If you have ever had to configure such an environment from scratch across frequently changing environments you will appreciate this.

If you know all this please forgive my presumption.

The led in the encoder is RGB, the 128 led ring is single color for the moment. Routing all these signals to these leds on a dual layer board was already a pretty PITA. Making these 128 leds rgb would be impossible with a two layer pcb I think.

I have a little bit of experience with GIT, but not a lot. For now I would just work on a local copy of the code, just to mess around a bit and see if I can get anywhere with it.

Don’t worry, it’s just me letting my imagination running away with itself…

It looks quite big. Larger than 50mm? I wonder if a smaller version might be beneficial.

I would suggest offering the option to light different patterns, e.g. an arc.

That is already ‘built-in’. But it uses a lot of current then, 128 leds… Although I use a MAX6954ATL+ driving these 128 leds, and that chip should handle this a bit ‘smart’, I get 400 mA when all leds are powered. (Full arc)

I don’t have the device at hand now, so not sure about exact dimensions. Of course, when you need to position 128 leds in a circle, you need a slightly bigger diameter :wink:

Well, I’ve got the zyncoder_test running with my i2c 128-led RGB encoder. Just reading the direction out of the encoder for now (interrupt driven)

Going smooth :smiley:

Are you using testing branch? You should because we are really close to release a new versión and there is a lot of changes. Don’t waste your time with the stable branch.


4 encoders. 32 leds each. Daisy chain the encoders to utilise one controller chip.

The LEDs should be strobed to reduce current usage, i.e. do not power all at the same time. If done correctly the effect is not visible to the human eye but reduces current significantly.

1 Like

I’ve done a bit of reading up on how to use GitHub passed weekend so I started now by forking the zyncoder:testing branch. I will work on that fork on a branch of my own. As I understood, the way to proceed is to do a Pull Request when my coding is done?

Yep, submit a pull request when you are complete. and it will be reviewed by the maintainers.

@jofemodo You mentioned zyncoder_i2c was outdated and not working for sure. Indeed, when trying to build this for zyncoder_test I saw missing functions. What should my approach be best like? Rewriting the zyncoder_i2c part or create a new one?

zyncoder_i2c is a driver for a bespoke i2c interface that I built. Details of an enhanced version are here. It was an unofficial hack that I did when I first started to use Zynthian. I made a very custom build which is now in a box somewhere and not used so I haven’t touched that code for a long time. There are others who used it as a basis for some other custom interfaces but I would suggest the code is at least obsolescent if not obsolete and we should deprecate it. There have been many changes to the Zynthian structure since that driver was last touched and I would imaging it is broken.

Note: Zynthian uses the Raspberry Pi I2C interface for many purposes. This specific driver was to interface with a particular I2C based device. Don’t be confused - it is not the main method of Zynthian interfacing with I2C devices.