shanteacontrols / OpenDeck

Software and hardware platform for simpler building of MIDI controllers.
https://shanteacontrols.com
Apache License 2.0
618 stars 53 forks source link

Change leds blink time for PWM #302

Open nicolasvair opened 1 month ago

nicolasvair commented 1 month ago

Hi,

I'm using a M open deck board.

I'm using the leds as vu meters using pwm in midi (sending led on & led off messages). Fast PWM rate = high brightness corresponding to high RMS value. That's dirty but I found a threshold that works ok and doesn't make me loose midi messages, but I'd like to have more leds/meter.

A better way to do it would be to modify blink speed so that I can have 4 values of intensity, thus lowering the amount of midi messages. Still not perfect but I'd reduce the amount of messages by a factor between 2 and 5.

So I found that array in src/firmware/application/io/leds/LEDs.h

  /// Array holding time indexes (multipled by 50) after which LED state is toggled for all possible blink rates.
  static constexpr uint8_t BLINK_RESET_TIMER[TOTAL_BLINK_SPEEDS] = {
      20,
      10,
      5,
      0,
  };

I would ideally need values lower than 50 ms but it's a good start. Maybe I could just change type to float ?

My questions are :

Once again, thank you shantea for this fantastic tool !

Nico

paradajz commented 1 month ago

Hi,

I'm using a M open deck board.

Which version?

My questions are :

  • do I have to build the firmware to edit those values, or is it something I can edit with sysex ?

You need to build it for the correct target (opendeck2 or opendeck21, I don't know which version you're using).

  • I so, can I upload the firmware through the UI of open deck or do I need another Arduino to flash it ?

Once you build the firmware sysex will be generated among other files which you can use through the web UI.

  • would it be too much asking for letting the user specify the delay of blink ?

It's not planned at the moment.

  • how complex / possible would it be to use a separate serial or OSC connection so I don't flood the midi ? (I'm using max4live so I can format my data easily)

At this point, very.

Once again, thank you shantea for this fantastic tool !

You're welcome.

nicolasvair commented 1 month ago

Ok thank you for your answers, I'll try to build it. But I'm on macOS.. wish me luck ! ha

nicolasvair commented 2 weeks ago

Hi,

I finally managed to build the firmware on Mac, via multipass as a virtual machine for ubuntu 24.04

It wasn't trivial but it finally worked.

Doing so, I didn't use docker-compose (I've read that it was deprecated) but docker compose (removing the dash in /.script/dev.sh), and the build worked till the end without errors.

I built using target opendeck22 as my board is a 2.2.1 revision 2022.12, could you please confirm this ?

I obtained a sysex file that I transferred by putting the board in dfu first.

Now I'm not sure what happened. It seemed to work ok because it went through the end without issue (I didn't modify the source code yet), I was able to have the communication and midi connection with my daw.

But the three dots "loading" kept appearing on the first page :

image

So I tried a "reset to factory settings" and since then each time the board receive a midi CC or note it doesn't respond anymore. So I can't use the configurator.. But if the board doesn't receive anything it's working quite ok.

Is there anyway to send the firmware again through usb-C without using midi ? Like using pico tools with the binary or hex ?

paradajz commented 2 weeks ago

Is there anyway to send the firmware again through usb-C without using midi ? Like using pico tools with the binary or hex ?

Yes, short circuit the 2-pin RPB connector and then connect the board to the PC. A new drive will show up and then you need to drag merged.uf2 file on it and wait for the few seconds before the board reboots. Make sure to remove the short circuit once the disk drive has been shown.

image

nicolasvair commented 2 weeks ago

Thank you for the quick reply.

Sadly the uf2 method didn't solved, I then connected the pins for DFU, transmitted original opendeck22 through web interface, still not working.

Always stuck here

image
nicolasvair commented 2 weeks ago

You confirm I should use opendeck22 fo board 2.2.1 revision 2022.12 ?

nicolasvair commented 2 weeks ago

Bingo, had to reset flash memory using uf2

https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html#resetting-flash-memory

I don't understand much but that memory could get corrupted in some rare cases. https://petewarden.com/2024/01/16/understanding-the-raspberry-pi-picos-memory-layout/

nicolasvair commented 2 weeks ago

Ok it’s working great now !

I’m diving into the leds.cpp

I realized just changing the blink rate doesn’t do anything about brightness cause it’s still 50% of the time.

So it’s getting a bit more difficult but I’ll find my way.

Is there any easy way to print value or send a message to open deck configurator ?

and a way to see compilation errors ?

Thank you ! 🙏

nicolasvair commented 2 weeks ago

Please any easy way to print a value through open deck configurator or another tool ?