Wise Posted November 22, 2003 Report Share Posted November 22, 2003 Hi!I'm trying to figure out how to get "shift" keys into MIOS, like a regular keyboard. Need up to 5 shift layers. E.g I want to have one "seek-button", and if one of the shift buttons are pressed simultaneous it will be in slow/medium/fast/skip mode and send different midi events for the selected layer.I got this to work half-way, but there's some bugs I don't know how to work around. Here's the modifcation of the small_skeleton:USER_DIN_NotifyToggle movff MIOS_PARAMETER1, TMP1 ;;Save button number movff MIOS_PARAMETER2, TMP2 ;;Save button value ;;Get status of shift buttons connected to SR0 movlw 0x00 call MIOS_DIN_SRGet ;;Set default table movlw 0x30 movwf TBLPTRH ;;Store high byte movlw 0x80 movwf TBLPTRL ;;Store low byte IFCLR MIOS_PARAMETER1,0, call USER_SET_Shift1_Table ;;Set base adress to shift1_table (0x3300) IFCLR MIOS_PARAMETER1,1, call USER_SET_Shift2_Table ;;Set base adress to shift2_table (0x3400) IFCLR MIOS_PARAMETER1,2, call USER_SET_Shift3_Table ;;Set base adress to shift3_table (0x3500) ;;Restore MIOS_PARAMETER's movff TMP1, MIOS_PARAMETER1 movff TMP2, MIOS_PARAMETER2 ;; calc address to MIDI event clrf TMP2 ; clear help register clrc ; clear carry bit rlf MIOS_PARAMETER1, W ; shift button number to the left (== number * 2) movwf TMP1 ; save result in TMP1 rlf TMP2, F ; shift TMP2 to the left (it's zero, but just for info) movf TMP1, W ; add button offset (number *2) to TABLPTR addwf TBLPTRL, F ; low-byte movf TMP2, W addwfc TBLPTRH, F ; high-byte (+carry bit on overrun) ;; read first MIDI byte tblrd*+ ;; exit routine if no event has been defined for this button (entry = 0xff) incf TABLAT, W skpnz return ;; for MIDIbox Link: notify begin of stream call MIOS_MIDI_BeginStream ;; send first MIDI byte movf TABLAT, W call MIOS_MIDI_TxBufferPut ;; read second MIDI byte and send it tblrd*+ movf TABLAT, W call MIOS_MIDI_TxBufferPut ;; send third MIDI byte: 0x7f if button pressed, else 0x00 movlw 0x7f IFSET MIOS_PARAMETER2, 0, movlw 0x00 call MIOS_MIDI_TxBufferPut ;; for MIDIbox Link: notify end of stream call MIOS_MIDI_EndStream return and the USER_Set_ShiftX_table functions: USER_SET_Shift1_Table ;Sets the table pointer to Shift1_table TABLE_ADDR SHIFT1_TABLE return USER_SET_Shift2_Table ;Sets the table pointer to Shift2_table TABLE_ADDR SHIFT2_TABLE return USER_SET_Shift3_Table ;Sets the table pointer to Shift3_table TABLE_ADDR SHIFT3_TABLE return the tables are defined like the normal MIOS_MPROC_EVENT_TABLE : org 0x3300 ;; MIDI Trigger entry structure S1_ENTRY MACRO event_0, event_1 dw (event_1 << 8) | event_0 ENDM S1_EOT MACRO dw 0xffff ENDM SHIFT1_TABLE ;; entry 0x00-0x0f S1_ENTRY 0xb1, 0x00 S1_ENTRY 0xb1, 0x01 S1_ENTRY 0xb1, 0x02 S1_ENTRY 0xb1, 0x03 S1_ENTRY 0xb1, 0x04 S1_ENTRY 0xb1, 0x05 ;;etc.... Same structure in SHIFT[23]_TABLE. The table lookups work perfect, the mb sends different midi events based upon the shift key that is pressed. But..... The problems starts when I'm start releasing (depressing) the buttons. Eg. if I press JUST "Shif1-button", it sends B1 00 7F 2 --- CC: Bank MSB fine! And when i release Shift1: B0 00 00 1 --- CC: Bank MSB when i wanted it to send: B1 00 00 1 --- CC: Bank MSB instead... Well, this is understandable if you look at the IFCLR MIOS_PARAMETER1,0, call USER_SET_Shift1_Table ;;Set base adress to shift1_table (0x3300) IFCLR MIOS_PARAMETER1,1, call USER_SET_Shift2_Table ;;Set base adress to shift2_table (0x3400) IFCLR MIOS_PARAMETER1,2, call USER_SET_Shift3_Table ;;Set base adress to shift3_table (0x3500)It will not set the TBLPTS[HL] to the rigth "layer" :( Though this is not the biggest problem as I don't plan to use the shift-buttons to send relevant MIDI events.The real problem is that buttons get stuck in pressed state if I release the shift button before the function button.E.g:1: Pressing shift1 and hold it down =>B1 00 7F 2 --- CC: Bank MSB (all ok)2: Pressing button 7 connected to SR0: =>B1 07 7F 2 --- CC: Volume (as expected and wanted)3: Releasing shift1 button =>B0 00 00 1 --- CC: Bank MSB (As expected, not wanted but not a problem)4: Releasing button 7: =>B0 07 00 1 --- CC: Volume (As expected, but NOT wanted)How I want it to work:If I first release the shift button I want mb to send CC00 from all buttons that are pressed at that time and then send unshifted events for the same buttons.So, how i want it to work....:1: As above2: As above3: B1 00 00 2 --- CC: Bank MSB (Shift1 of) B1 07 00 2 --- CC: Volume (Shift state of button 7 off) B0 07 7F 1 --- CC: Volume (Unshifted event for button 7 on)4: B0 07 00 1 --- CC: Volume (Unshifted event for button 7 offSo, how to modify my code to get rid of the bugs, or another solution? Can't use MB64 firmware because i will have more than 64 physical buttons in my NI Traktor controller (going to be huge ;D ;D ;D)Anyone ? TK ?/Wise Quote Link to comment Share on other sites More sharing options...
TK. Posted November 26, 2003 Report Share Posted November 26, 2003 Hi Wise,my suggestion: branch to another routine which handles the shift buttons seperately. Do nothing if the shift button is pressed. Loop through all "general purpose" buttons when the shift button is released and check the button status - MIOS_DIN_PinGet will return 0 when a button is hold down - in this case send the "off" status of the "old" layer and the "on" status of the "new" layer.Don't forget to have fun! ;-)Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Wise Posted November 27, 2003 Author Report Share Posted November 27, 2003 Thx !I'll try this. And I think I know how to do it :) So this will make my life as a MIOS programmer little less complex and cut a few weeks of the project time ;D ;D ;DTK, you must be the electronics God no. 1 ;)Again, thanks for a kickass cool project !!! And of course I have fun when I'm doing this ! , it's what I live for (apart from my GF ;) ) rigth now ;D/Wise Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.