Jump to content

[Newbie] Rotary encoder confusion


Keeze
 Share

Recommended Posts

Hello,

Just started with Midibox. First, I want to build a controller for controlling various CC parameters in my VST's. Got the first kits from Smashtv an soldered everything together.

Burned the bootloader to the CORE_STM32F4 Module and loaded the Midibox NG app.

Connected a DIN and a small LED display to the CORE_STM32F4 Module.

 

First test: print "Hello World" to LCD ...works...
Second test: Connect a button ...works...
Now it is time to connect a Rotary encoder...
All seems to work.

With the following small program:

RESET_HW
LCD "%CEncoder Values"
# Hardware configuration
ENC n=1 sr= 1 pins=0:1 type=detented1
# Events
EVENT_ENC id=1 fwd_to_lcd=1 type=CC chn= 1 cc= 16 range=0:127 lcd_pos=1:1:1 label="^std_enc"

I get the folowing output in the debug-screen:

[1934162.881] MBNG_ENC_NotifyChange(1, 1)
[1934162.882] [EVENT] id=ENC:1 hw_id=ENC:1 bank=0 fwd_id=DISABLED:0 type=CC value=1 label=^std_enc
[1934163.305] MBNG_ENC_NotifyChange(1, -1)
[1934163.305] [EVENT] id=ENC:1 hw_id=ENC:1 bank=0 fwd_id=DISABLED:0 type=CC value=1 label=^std_enc
[1934163.466] MBNG_ENC_NotifyChange(1, -1)
[1934163.466] [EVENT] id=ENC:1 hw_id=ENC:1 bank=0 fwd_id=DISABLED:0 type=CC value=0 label=^std_enc
[1934163.650] MBNG_ENC_NotifyChange(1, -1)
[1934163.651] [EVENT] id=ENC:1 hw_id=ENC:1 bank=0 fwd_id=DISABLED:0 type=CC value=0 label=^std_enc

The LCD outputs only a 0 or a 1. What am I doing wrong that the value does not increment or decrement? When I slide the CC16 slider in the virtual keyboard, the LCD takes over the correct value. And as soon as i touch the encoder the values flip back to 1 or 0.

When I set the range to a map the values on the LCD show the values from the map correct and increment en decrement correctly.

I hope that someone can shed some light on this subject... ;)

Cheers,
Kees

Edited by Keeze
Link to comment
Share on other sites

Hi Keeze

I don't see a fwd_id in your config and the output seams to Disable it somehow. I don't know if that is the problem, but maybe you can add a fwd_id to test.

RESET_HW
LCD "%CEncoder Values"
# Hardware configuration
ENC n=1 sr= 1 pins=0:1 type=detented1
# Events
EVENT_ENC id=1 fwd_id=881 fwd_to_lcd=1 type=CC chn= 1 cc= 16 range=0:127 lcd_pos=1:1:1 label="^std_enc"

fwd_id can be anything you don't already use... this sample = 881

Regards, Novski

Link to comment
Share on other sites

Hello Novski,

Tnx for your reply!
I added the suggested fwd_id, but than the program stucks saying:

[11261.264] AUTOLOAD 'ENC'
[11261.264] [MBNG_FILE_C:6] ERROR: invalid fwd_id controller name in EVENT_ENC ... fwd_id=123
[11261.264] [MBNG_FILE_C] Event Pool Number of Items: 0
[11261.264] [MBNG_FILE_C] Event Pool Allocation: 12 of 65536 bytes (0%)
[11261.275] Patch 'ENC' loaded from SD Card!
[11261.278] [MBNG_FILE_R] /ENC.NGR (optional run script) not found

Cheers,
Kees

Link to comment
Share on other sites

I could be completely wrong (I am not a C-coder), but in lines 233 - 247 of mbng_enc.c I find:

     s32 value = item.value;
     if( item.min <= item.max ) {
       value = event_incrementer;
       if( value < item.min )
         value = item.min;
       else if( value > item.max )
         value = item.max;
     } else {
       // reversed range
       value = event_incrementer;
       if( value < item.max )
         value = item.max;
       else if( value > item.min )
         value = item.min;
     }

so value is replaced by event_incrementer and not added? Or am I completely wrong...

value = event_incrementer; vs value += event_incrementer;

...

Digging further..

Kees

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...