Jump to content

Recommended Posts

Posted

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  :(

Posted

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 :)

Posted

have you added the Encoder to the table in mios_tables.inc ?

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

on ENC_NotifyChange():

MIOS_LCD_Cursor_Set(0x0);

MIOS_LCD_PrintCString("Encoder down");

Cheers,

Michael

Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...