moogah Posted November 30, 2006 Report Share Posted November 30, 2006 I've finally run into another stumbling block in getting the SEQ to feel like an 808's sequencer. What I have been successful in doing is 'mapping' the press of a function button + GP button to changing both the track and layer parameters so that users can select which instrument they are editing (we are in drum mode). Now, what I want to implement is the instrument select switch like on the original using an encoder. I've already got variables setup that remember which number instrument was last pressed so I can increment or decrement that in response to an encoder event and then I *should* be able to move the result into MIOS_PARAMETER1 and then call PROJECT8_ChangeInstrument which takes a GP number, converts it into track/layer then calls SEQ_BUTTON_Trackx_Cont & SEQ_BUTTON_Layerx to change the active layer. Now, moving the encoder does change the value of PROJECT8_INSTNUM0 and that is reflected in the GP LED display (I have coded it to display the selected track when the function key is pressed). However, there are two problems: the first is that the track/layer value doesn't get updated and the second I believe provides the best clue as to what is happening. When I move the encoder the app doesn't always respond right away, the impression I get is that the value from the encoder is only being updated at a period similar to 1/8 note causing it to sometimes adjust immediatly and sometimes take a few 10s of miliseconds to update. Now, after troubleshooting this for most of the evening I've decided to take a break and see if I can get a hint or just a fresh perspective from people here. It's occured to me that perhaps this is normal behavior for the encoders in the SEQ app as they are not normally used like this. That still would not explain why the track/layer doesn't get updated tho, most of my troubleshooting has been focused around being sure that the value of MIOS_PARAMETER1 that gets 'passed' into PROJECT8_ChangeInstrument is correct, and I am 99% sure of that now.Variable declarations;; free for your pleasure: 0x360-0x37f ;; and 0x380-0x3ff if the AIN handler is disabled P8_BASE EQU 0x380 PROJECT8_INSTNUM0 EQU 0x380 PROJECT8_INSTNUM1 EQU 0x381 PROJECT8_MODE EQU 0x382 PROJECT8_PARAM1 EQU 0x383 PROJECT8_PARAM2 EQU 0x384 PROJECT8_PARAM3 EQU 0x385 PROJECT8_INST_LED0 EQU 0x386 PROJECT8_INST_LED1 EQU 0x387 PROJECT8_TEMP_VAR EQU 0x388 Encoder pin assignments MIOS_ENC_PIN_TABLE ;; encoders 1-16 ;; SR Pin Mode #if DEFAULT_ENC_DATAWHEEL >= 0 ENC_ENTRY 2, 2, MIOS_ENC_MODE_DETENTED ; Data Wheel #endif ENC_ENTRY 1, 6, MIOS_ENC_MODE_DETENTED2 ; ins select ENC_ENTRY 6, 2, MIOS_ENC_MODE_DETENTED2 ; tempo Catching the encoder events USER_ENC_NotifyChange #if DEFAULT_ENC_DATAWHEEL >= 0 ;; branch to SEQ_ENC_Datawheel if datawheel movf MIOS_PARAMETER1, W xorlw DEFAULT_ENC_DATAWHEEL skpnz goto SEQ_ENC_Datawheel #endif movf MIOS_PARAMETER1, W xorlw 0x00 skpnz goto PROJECT8_InstChange movf MIOS_PARAMETER1, W xorlw 0x01 skpnz goto PROJECT8_TempoChange inc/dec the current selected instrument (track/layer) and move it into MIOS_PARAMETER1 PROJECT8_InstChange SET_BSR P8_BASE btfss MIOS_PARAMETER2, 7, 0 ; increment if negative bit is clear incf PROJECT8_INSTNUM0, 1 btfsc MIOS_PARAMETER2, 7, 0 ; decrement if negative bit is set decf PROJECT8_INSTNUM0, 1 movff PROJECT8_INSTNUM0, MIOS_PARAMETER1 PROJECT8_ChangeInstrument ;This function takes MIOS_PARAMETER1, converts it to a track/layer number then calls the functions to change the track/layer Some of the additional code to display the selected track on the GP LED's. PROJECT8_INSTNUM0 is used to determine which LED to light up, so I'm fairly sure it is not being overwritten SEQ_GP_LED_Update ;; clear the 16 GP LEDs SET_BSR SEQ_BASE clrf SEQ_GP_LED0, BANKED clrf SEQ_GP_LED1, BANKED ;; menu select LED overlays everything SET_BSR P8_BASE BIFSET PROJECT8_MODE, PROJECT8_MODE_MENU1, BANKED, rgoto PROJECT8_Menu1_LED SET_BSR SEQ_BASE Quote Link to comment Share on other sites More sharing options...
moogah Posted December 1, 2006 Author Report Share Posted December 1, 2006 *sigh*No love tonight either. On the way home from work I had become very hopeful that the problem was caused by some ungrounded AIN pins or some wrong settings in main.asm reguarding the AIN pins.. but no.. I got a few other features coded up and tested and then began to work through the process of comparing what is different about my method of using the encoder and what is in SEQ_ENC_Handler. Unfortunaltly my mojo must be weak tonight because as I went to make another test upload everything went wrong.. actually the upload went fine but when the PIC booted into MIOS the LCD messages were offset across half the screen and wrapped around the other side while midi messages streamed from the PIC.. doh. I checked my code real quick for some bonehead mistakes like leaving in an org 0x00000 statement. Nope, all clear there. Not wanting to loose any time I simply poped open another PIC and proceded to upload, this time it wouldn't boot into MIOS at all. Doh. So I decided I must have done something stoopid in code and loaded up the .hex (I use MIOS studio) for the 2.4c application.... still no dice, same symptoms. DOh. I figured I'd try one more PIC just for the hell of it and then call it quits, no dice there either. DOH.Thats it for me tonight :( ??? Quote Link to comment Share on other sites More sharing options...
moogah Posted December 2, 2006 Author Report Share Posted December 2, 2006 Derr. :-[In case anybody doesn't already realize what I did wrong last night, here it is: In the process of testing code I must have overwritten a section of the memory where MIOS lives, and then didn't remember to re-upload MIOS in order to fix this. In short, MIOS didn't boot because MIOS wasn't there. Derf.UPDATE:Mojo is back tonight ;D Once I had a programmed PIC to work with it only took my a cycle or two to realize that I wasn't clearing the value of MIOS_PARAMETER2, which is where the direction of the encoder movement is stored.Here is the working code with a bit added to display the selected track for a couple seconds whenever the encoder is moved:PROJECT8_InstChange SET_BSR P8_BASE bsf PROJECT8_MODE, PROJECT8_MODE_MENU1, BANKED TABLE_ADDR PROJECT8_ExitInstSelect movlw 0x08 call CS_MENU_SetDelayedCallbackHook btfss MIOS_PARAMETER2, 7, 0 ; increment if negative bit is clear incf PROJECT8_INSTNUM0, 1 btfsc MIOS_PARAMETER2, 7, 0 ; decrement if negative bit is set decf PROJECT8_INSTNUM0, 1 clrf MIOS_PARAMETER2, 0 ; AHA! I didn't clear this last time! movff PROJECT8_INSTNUM0, MIOS_PARAMETER1; Code snippedPROJECT8_ExitInstSelect SET_BSR P8_BASE bcf PROJECT8_MODE, PROJECT8_MODE_MENU1, BANKED return 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.