Sign in to follow this  
Followers 0
gillesdeshays

Modifying DIN behaviour to get +5V on DOUT ....

7 posts in this topic

I'm trying .. with my poor "coding" knowledge to add this simple feature to my  MB64E ...

I just want to light on the LEDs included in my button ...

I want to use it for solo and mute...

but as Reason doesn't get out any MIDI message,  i just need to toggle the DOUT corresponding to "his" DIN ...

You push a button : it lights his led

You push a second time : it lights off his led ...

I try to take example on Dout_buttons & Dout_enc Test applications ... but it doesn't work ...

Any elegant coding idea ? ;)

Thanks a lot !!!!

Gilles

Share this post


Link to post
Share on other sites

Hi Gilles!

You just have to set the button's mode to "Toggle".

Toggle means: Push on - Push off

On/off means: Push on - Release off

On only means: Push on - Release nothing - Push on - Push on - and - on - and - on !

You can do it either from the midibox's learn menu (I think it's with the snapshot button) or with the vmidibox app!

Happy Reasoning!

(any news with the SB live ADC??)

Bye,

uclaros

Share this post


Link to post
Share on other sites

I tought i just had to specify  in the DOUT specifier map in the vmidibox64e_18f :

SR# 1 ( my mute leds) to DIN SR#7 ( button ID #48-55) (my mute buttons) .....

and voila !

in fact it doesn't seems to be as simple ....

I check my leds with the "dout_buttons_v1_3" test applications and the Dout SR#1 works well ... and the Din SR#7 works well also ...

Where i'm wrong this time ? ;)

thanks a lot !

Share this post


Link to post
Share on other sites

I can't really understand how to modify the code ...

I think to have to modify the MB64e_buttons.inc ... but i don't exactly know how to ...

;; --------------------------------------------------------------------------
;;  general purpose button function
;;  Input:
;;     o Button number in MIOS_PARAMETER1 (AND NOT IN WREG!)
;;     o Button value MIOS_PARAMETER2:
;;       - 1 if button has been released (=5V)
;;       - 0 if button has been pressed (=0V)
;; --------------------------------------------------------------------------
MB64E_BUTTON_GP
	;; save current button number in MB64E_CURRENT_BUTTON
	SET_BSR MB64E_BASE
	movf	MIOS_PARAMETER1, W
	movwf	MB64E_CURRENT_BUTTON, BANKED

	;; branch to SFB handler if button has been assigned to 0xff
	call	MB64E_FSR_ButtonEvnt0
	incf	INDF0, W
	bnz	MB64E_BUTTON_GP_NoSFB
MB64E_BUTTON_GP_SFB
	;; toggle LED which is assigned to the SFB
	rcall	MB64E_LED_Set	; expects MIOS_PARAMETER[12] as parameter 
	;; request display re-initialization
	bsf	CS_STAT, CS_STAT_DISPLAY_INIT_REQ
	;; save value in MIDI_EVNT_VALUE
	;; (do it here, since MIOS_PARAMETER2 will be overwritten by MB64E_BANK_Read)
	movff	MIOS_PARAMETER2, MIDI_EVNT_VALUE
	;; save SFB event number in MIDI_EVNT0
	call	MB64E_FSR_ButtonEvnt1
	movff	INDF0, MIDI_EVNT0
	;; save special function parameter value in MIDI_EVNT1
	;; calc address to button mode entry:
	call	MB64E_ADDR_ButtonEntry
	;; select the 3th byte
	movlw	3-1
	addwf	MB_ADDRL, F
	;; save it in MIDI_EVNT1
	call	MB64E_BANK_Read
	movwf	MIDI_EVNT1
	;; branch to SFB handler
	goto	MB64E_SFB_Handler
MB64E_BUTTON_GP_NoSFB

	;; save it also in MB64E_LAST_BUTTON
	movff	MB64E_CURRENT_BUTTON, MB64E_LAST_BUTTON

	;; notify that last controller move was a button
	bsf	MB_STAT, MB_STAT_LAST_WAS_BUTTON

	;; for MIDI learn function
	rcall	MB64E_BUTTON_Learn

	;; exit here if we are in learn mode (don't send button value)
	IFSET	MB_STAT, MB_STAT_LEARN_MODE, return

	;; store current button value in TMP1
	movf	MIOS_PARAMETER2, W
	movwf	TMP1

	;; calc address to button mode entry:
	call	MB64E_ADDR_ButtonEntry
	;; select the 4th byte
	movlw	4-1
	addwf	MB_ADDRL, F

	;; get fourth byte - which selects the button mode - and branch depending on value
	call	MB64E_BANK_Read
	andlw	0x03
	JUMPTABLE_2BYTES_UNSECURE
	rgoto	MB64E_BUTTON_OnOff
	rgoto	MB64E_BUTTON_OnOnly
	rgoto	MB64E_BUTTON_Toggle
	rgoto	MB64E_BUTTON_OnOff

	;; (button value stored in TMP1)
MB64E_BUTTON_OnOff
	;; save status of button
	rcall	MB64E_BUTTON_Hlp_SaveStat
	rgoto	MB64E_BUTTON_Send

	;; (button value stored in TMP1)
MB64E_BUTTON_OnOnly
	;; save status of button
	rcall	MB64E_BUTTON_Hlp_SaveStat

	;; when on: send button value defined in dump
	;; when off: send nothing
	IFSET	TMP1, 0, rgoto MB64E_BUTTON_NotifyChangeEnd
	rgoto	MB64E_BUTTON_Send

	;; (button value stored in TMP1)
MB64E_BUTTON_Toggle
	;; when on: toggle between 0x00 and the button value defined in dump
	;; when off: send nothing
	IFSET	TMP1, 0, rgoto MB64E_BUTTON_NotifyChangeEnd

	;; toggle appr. bit in BUTTON_VALUE register
	call	MB64E_FSR_ButtonValue
	SET_BSR	MB64E_BASE
	movf	MB64E_CURRENT_BUTTON, W, BANKED
	call	MIOS_HLP_GetBitORMask
	xorwf	INDF0, F

	;; 	rgoto	MB64E_BUTTON_Send


MB64E_BUTTON_Send
	call	MB64E_MIDI_SendButtonEvent

	;; request display update
	bsf	CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ
	;; reset the cursor of the CS
	call	CS_MENU_ResetCursor

MB64E_BUTTON_NotifyChangeEnd
	return

First  i cannot find the MB64E_LED_Set function

So if i understand well ..

A button is pressed ....

We check if this is an CS button

Then map the button to the button number

Then this is the SFB implementation

Then the GP implementation :

Here we save the button number in MB64E_CURRENT_BUTTON

Check if this is the button is configured to a SFB

IF not this is a GP: "MB64E_BUTTON_GP_NoSFB"

If we are not in learn mode , we store current button value in TMP1

then check the behaviour of the button ( on-off, toggle ...)

and then launch the MB64E_BUTTON_Send with some other thing before depending of the button behaviour ...

Am i right ? I must understand well how it works to modify this ...

If yes ... do i just have to add something like that :

      call MB64E_LED_Set

in the MB64E_BUTTON_Send handler ?

because, at this time,  button pin number is still in WREG, and value in MIOS_PARAMETER1.......  no ???

i try several things like that without success....

To precise ... i 'm a beginner in coding ... but i'm starting to understand how it works ...

thanx a lot for your help ! :)

gilles

Share this post


Link to post
Share on other sites

ok .. it seems to works now ...

but this is not the good button which lights to good leds ..... :-\

How can i change this with the code ? My button and leds are allready wired ...  if it's too hard i can modify the wiring ...

Another thing ... if i configue the button in Toggle mode .. the led stays lights and the button , on the LCD, is always "pressed" after the first pressing on the button .... ???

thanks

Gilles

Share this post


Link to post
Share on other sites

It's even harder for you to change the code then changing the wires ;-)

Toggle state: just save the new state with the snapshot button once all LEDs are off

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites

ok thanks TK ...

i think i understood how it works ....

I modify what i need and it works ...

Now my double MB64E is WORKING GREAT !!!!!

thanks again !

Gilles

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0