Jump to content

problems with rotary encoder (fixed)


mess
 Share

Recommended Posts

Hi,

I'm trying to use a rotary encoder connected to pin 6 and 7 of my second din register...

I've tried to use this encoder with this line in init():

// set encoder speed mode of datawheel
  MIOS_ENC_SpeedSet(14, DATAWHEEL_SPEED_MODE, DATAWHEEL_SPEED_DIVIDER);
  and this code in ENC_NotifyChange(...)
if (encoder == 14) {
        unsigned int value;
	if (cs_layer == CS_LAYER_SFB) {
		CS_GetSFB(cs_sfb_mode);
		value = SFB_val;
		SFB_val = (MIOS_HLP_16bitAddSaturate(incrementer, &value, SFB_max))&0xFF;
	} else {
		//if no special function is selected the encoder changes the current bpm
		value = MCLOCK_BPMGet();
		MCLOCK_BPMSet(MIOS_HLP_16bitAddSaturate(incrementer, &value, 255)&0xFF);
	}
	app_flags.DISPLAY_UPDATE_REQ = 1;
}

but the code seems to do nothing  :(

Link to comment
Share on other sites

What if you replace the if statement with something simple like sending a midi CC, does that work?

You got that encoder in the table? Does it work with normal encoder speed?

Sorry for the barrage of questions... I'm trying to pinpoint the source of the fault, and your answers will give me the hints I need :)

Link to comment
Share on other sites

;D now even more...

Thank you guys for your help  :)  :D

if you did so, try to call an easy function to determine if everthing is wired right, eg:

on ENC_NotifyChange():

I tried this already, same result

You got that encoder in the table?

-> this seems to be the solution, since I have no MIOS asm background

I was even unaware of this table (always seemed a mystery how MIOS identified encoders  ::))

so if I summarise encoder handling in MIOS C:

- connect encoder to shift register, first pin on an even pin number

- add an encoder entry in mios_tables.inc

- add a line in Init() in main.c:

 // set encoder speed mode of datawheel
  MIOS_ENC_SpeedSet(ENCODER_NR, DATAWHEEL_SPEED_MODE, DATAWHEEL_SPEED_DIVIDER); 
 

- handle encoder events in ENC_NotifyChange(...)

I will try this when I get home tonight...

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