Jump to content

Understand MIOS32_SYS_STM_PINGET


prusaga
 Share

Recommended Posts

Hello,

I am trying to implement foot controller with some tactile switches. I am trying to capture a button press and send MIDI data. I have trying to use the tutorial polling_j5_pins. I have changed the user button (PA0) to get initialized. I am unable to use the button yet to send a MIDI signal to computer. Where am i missing something to capture button press. The program doesnt enter the if condition shown in second image.

8.PNG

9.PNG

Edited by prusaga
Link to comment
Share on other sites

hi

i used J5 for LED Indication, and one User-Button, see this: MSQ-CC-BCR

i used this code for Initialisation:

void APP_Init(void){

  // LED:  initialize J5A pin1-3 & J5B pin0-3 as outputs in Push-Pull Mode
  int pin;
  for(pin=1; pin<8; ++pin) {MIOS32_BOARD_J5_PinInit(pin, MIOS32_BOARD_PIN_MODE_OUTPUT_PP);}
     int a; for(a=1; a<8; a++) { MIOS32_BOARD_J5_PinSet(a, 0);} //Turn off all LEDs
      
  // MOMENTARY-BUTTON   initialize pin 0 of J5A,  as Digital input with internal Pull-Up
    MIOS32_BOARD_J5_PinInit(0, MIOS32_BOARD_PIN_MODE_INPUT_PU);    
}

 

as exemple - in app background, for reading the J5 States:

void APP_Background(void){    // Set Bet Structure without LCD but with PIN 1 of J5A
    
	static rythm = 0; // initalized once
    // check J5 pin 0 for changes
    static s16 count       = 0;
        
    if ( MIOS32_BOARD_J5_PinGet(0) == 0 ) { count = 500; }
    if ( count != 0  ) { count--; }
    if ( count == 1 )  {                        
        
                rythm_count++; // count thru

                switch ( rythm_count ) {
                        case 1:  rythm = 3;  break;
                        case 2:  rythm = 4;  break;
                        case 3:  rythm = 5;  break;
                        case 4:  rythm = 6;  break;
                        case 5:  rythm = 7;  break;
                        case 6:  rythm = 9;  break;
                        case 7:  rythm = 11; break;
                        default: rythm = 13; break;
                        }
      }
}

if you want to Activate a J5 with the variable rythm_count from above (switch thru the LEDs), put it also in APP_Background for example

                    for( x=1; x<8; x++) { MIOS32_BOARD_J5_PinSet(x, 0);}   // Turn off all LEDs
                    
                    switch ( rythm ) {
                        case 3:  MIOS32_BOARD_J5_PinSet(1, 1); break; // Turn on one LED - Indicate rythmset
                        case 4:  MIOS32_BOARD_J5_PinSet(2, 1); break;
                        case 5:  MIOS32_BOARD_J5_PinSet(3, 1); break;
                        case 7:  MIOS32_BOARD_J5_PinSet(4, 1); break;
                        case 9:  MIOS32_BOARD_J5_PinSet(5, 1); break;
                        case 11: MIOS32_BOARD_J5_PinSet(6, 1); break;
                        case 13: MIOS32_BOARD_J5_PinSet(7, 1); break;} break;

 

 

i am still unsure what you mean with USER-Button, if you mean one of the onboard buttons, i cant help you... stil i dont see a need to use them to initalize the J5 GPIO... i would do this in APP_Init hardcodet, or with a other DIN... however thats it from my side.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...