hi
i’m trying to modify mios code to handle the snap mode (only this) in the midiobox64E.
i have take a look at both mb64_pots.inc and mb64e_fader.inc files, which seems to me that handle the pots value.
the routines are very similar, and i tried to “merge” the snap functions from mb64_pots.inc into the mb64e_fader.inc
so i added a call to the routine that do the snap mode in the section which sends the midi events
;; process snap mode
call MB64E_FADER_Conv
;; branch to the end if zero bit set
bz MB64E_FADER_Send_End
and removed the following two lines
;; store new value
call MB64E_FSR_FaderValue
movff MB64E_FADER_NEW_VALUE, INDF0
;; --------------------------------------------------------------------------
;;Â This function is used to send a fader value
;;Â Input:
;;Â Â Â o fader number in MB64E_CURRENT_ENTRY
;;Â Â Â o absolute position in WREG
;; --------------------------------------------------------------------------
MB64E_FADER_Send
;; store current position in TMP1
movwf TMP1
;; scale value depending on Min/Max entry
;; calc address to Min/Max entry:
call MB64E_ADDR_FaderEntry
;; select the 3rd byte
movlw 3-1
addwf MB_ADDRL, F
;; scale value:
;; copy min value to MB64E_ENTRY_MIN_VALUE
;; copy max value to MB64E_ENTRY_MAX_VALUE
;; move fader value to WREG
call MB64E_BANK_Read
movff WREG, MB64E_ENTRY_MIN_VALUE
call MB64E_BANK_Read
movff WREG, MB64E_ENTRY_MAX_VALUE
movf TMP1, W
call MB64E_FADER_ScaleValue
;; store result in MB64E_FADER_NEW_VALUE
movff WREG, MB64E_FADER_NEW_VALUE
;; get pointer to FADER_VALUE_xx register
call MB64E_FSR_FaderValue
;; store value in MB64E_FADER_VALUE
movff INDF0, MB64E_FADER_LAST_VALUE
;; copy the new value into this location for the next call
movff MB64E_FADER_NEW_VALUE, INDF0
;; if new value == old value, branch to the end
SET_BSR MB64E_BASE
movf MB64E_FADER_NEW_VALUE, W, BANKED
xorwf MB64E_FADER_LAST_VALUE, W, BANKED
bz MB64E_FADER_Send_End
;; process snap/relative mode
call MB64E_FADER_Conv
;; branch to the end if zero bit set
bz MB64E_FADER_Send_End
;; send MIDI value
call MB64E_MIDI_SendFaderEvent
;; clear request fader pos update
bcf MB_STAT3, MB_STAT3_FADER_UPDATE_REQ
; bcf MB_STAT3, MB_STAT3_FADER_SOFT_UPDATE_REQ
;; request display update
bsf CS_STAT, CS_STAT_DISPLAY_UPDATE_REQ
;; reset the cursor of the CS
call CS_MENU_ResetCursor
MB64E_FADER_Send_End
return
and then i copid the complete routine that handles the snap mode. i changed all the names of the variables from “pot” to “fader” and also the routine labels from “mb64” to “mb64E”. the code is assembled without error, but it doesnt work… it seems that the snap routine is never called… i also tried the relative routine (copied too in the inc file) but neither this seems to work. (note that i inserted a “rgoto” function which use by default one of the two routine - snap or relative). could you please help me? i think that there is something else to be considered, which is behiond my understanding of the code!!
;; --------------------------------------------------------------------------
;;Â This function processes the new FADER value
;;Â Input:
;;Â Â Â o number of current FADER in MB64E_CURRENT_FADER
;;Â Â Â o last value in MB64E_FADER_LAST_VALUE
;;Â Â Â o new value in MB64E_FADER_NEW_VALUE
;;Â Â Â o min value in MB64E_FADER_MIN_VALUE
;;Â Â Â o max value in MB64E_FADER_MAX_VALUE
;;Â Output:
;;Â Â Â o processed/converted value in INDF0
;;Â Â Â Â zero bit cleared when the value should be sent
;;
;;Â Â Â taken from MB64E_pots.inc, only the snap or relative mode here is used by default
;; --------------------------------------------------------------------------
MB64E_FADER_Conv
;; get pointer to FADER_VALUE_xx register (the active value)
;; (controlled from MB64E if snap bit is set, or via MIDI)
call MB64E_FSR_FaderValue
;; if soft takeover flag already set, jump to the end
IFSET INDF0, 7, rgoto MB64E_FADER_ConvBypass
;; jump to the end if active value == new value
movf INDF0, W
xorwf MB64E_FADER_NEW_VALUE, W, BANKED
bz MB64E_FADER_ConvBypass
rgoto MB64E_FADER_ConvRelative
;; ------------------------------------------------------------------
MB64E_FADER_ConvSnap
;; "snap" mode selected: "soft-takeover"
;; branch depending on clockwise or counter clockwise turn
;; means: last value <= new value
movf MB64E_FADER_LAST_VALUE, W, BANKED
IFLEQ MB64E_FADER_NEW_VALUE, BANKED, rgoto MB64E_FADER_ConvSnap_CClockwise
MB64E_FADER_ConvSnap_Clockwise
;; FADER has been moved clockwise
;; exit if if new value <= active value
movf INDF0, W
IFLEQ MB64E_FADER_NEW_VALUE, BANKED, rgoto MB64E_FADER_Conv_DontSend
;; exit if active value >= last value
IFGEQ MB64E_FADER_LAST_VALUE, BANKED, rgoto MB64E_FADER_Conv_DontSend
;; else continue
rgoto MB64E_FADER_ConvBypass
MB64E_FADER_ConvSnap_CClockwise
;; FADER has been counter clockwise
;; exit if if new value >= active value
movf INDF0, W
IFGEQ MB64E_FADER_NEW_VALUE, BANKED, rgoto MB64E_FADER_Conv_DontSend
;; exit if active value <= last value
IFLEQ MB64E_FADER_LAST_VALUE, BANKED, rgoto MB64E_FADER_Conv_DontSend
;; else continue
rgoto MB64E_FADER_ConvBypass
;; ------------------------------------------------------------------
MB64E_FADER_ConvRelative
;; "relative" mode selected:
;; clear snap bit (will be set independent from last status)
bcf INDF0, 7
;; calculate difference between last and new value
movf MB64E_FADER_LAST_VALUE, W, BANKED
subwf MB64E_FADER_NEW_VALUE, W, BANKED
;; add difference to active value
addwf INDF0, F
;; saturate:
IFSET WREG, 7, rgoto MB64E_FADER_ConvRelative_CCW
MB64E_FADER_ConvRelative_CW
movf 0X7F, W, BANKED
IFSET INDF0, 7, rgoto MB64E_FADER_ConvRelative_Max
IFLEQ INDF0, ACCESS, rgoto MB64E_FADER_ConvRelative_Cont
MB64E_FADER_ConvRelative_Max
movwf INDF0
rgoto MB64E_FADER_ConvRelative_Cont
MB64E_FADER_ConvRelative_CCW
movf 0X00, W, BANKED
IFSET INDF0, 7, rgoto MB64E_FADER_ConvRelative_Min
IFGEQ INDF0, ACCESS, rgoto MB64E_FADER_ConvRelative_Cont
MB64E_FADER_ConvRelative_Min
movwf INDF0
rgoto MB64E_FADER_ConvRelative_Cont
MB64E_FADER_ConvRelative_Cont
rgoto MB64E_FADER_Conv_Send
;; ------------------------------------------------------------------
;; ------------------------------------------------------------------
MB64E_FADER_ConvBypass
;; save new value in active value
movff MB64E_FADER_NEW_VALUE, INDF0
;; ------------------------------------------------------------------
MB64E_FADER_Conv_Send
;; set snap bit
bsf INDF0, 7
iorlw 0xff ; (clear zero bit)
return
;; ------------------------------------------------------------------
MB64E_FADER_Conv_DontSend
andlw 0x00 ; (set zero bit)
return
the rest of the mb64e_fader.inc is the same
thank you!