Phatline Posted January 9, 2015 Report Posted January 9, 2015 (edited) SOLUTION: was only a disply Format thing: i used %u (unsigned int) instead of %d (which is signed int) see the code below: MIOS32_LCD_PrintFormattedString("%u %d %u", encoder, incrementer, enc_value[0]);} PROBLEM WAS: when i turn a ENCODER left: incrementer= 4294967295 (should be -1 ?) (this value i see on my LCD) right: incrementer= 1 (no matter how fast i turn the encoder > that should encrease by faster turns? shouldńt it? internet says: 4294967295 says that it may be a negative value "-1" when i false declared the variable as unsigned (signed meens -1 is possible) in the code below "s32 incrementer" s stand for "signed" i think... & when i change to "u32 incrementer" (and in app.h also where it is definied), i still get the same "4294967295" this is my stripped down CODE: #include <mios32.h> #include "app.h" #include <FreeRTOS.h> #include <task.h> #include <queue.h> ///////////////////////////////////////////////////////////////////////////// // Local definitions // used MIDI port and channel (DEFAULT, USB0, UART0 or UART1) #define KEYBOARD_MIDI_PORT DEFAULT #define KEYBOARD_MIDI_CHN Chn1 #define MIDI_STARTNOTE 36 //Set Encoder NR and Hardware-PIN-out #define NUM_ENCODERS 5 const mios32_enc_config_t encoders[NUM_ENCODERS] = {//(SR begin with 1, ENC with 0) { .cfg.type=DETENTED2, .cfg.speed=FAST, .cfg.speed_par=2, .cfg.sr=1, .cfg.pos=0 }, { .cfg.type=DETENTED2, .cfg.speed=FAST, .cfg.speed_par=2, .cfg.sr=1, .cfg.pos=2 }, { .cfg.type=DETENTED2, .cfg.speed=FAST, .cfg.speed_par=2, .cfg.sr=5, .cfg.pos=0 }, { .cfg.type=DETENTED2, .cfg.speed=FAST, .cfg.speed_par=2, .cfg.sr=5, .cfg.pos=2 }, { .cfg.type=DETENTED2, .cfg.speed=SLOW, .cfg.speed_par=4, .cfg.sr=4, .cfg.pos=0 },};//Menue Encoder s32 enc_value[5]= {0}; ///////////////////////////////////////////////////////////////////////////////////////// // Startup INIT void APP_Init(void){ //initialize encoders s32 i; for(i=0; i<NUM_ENCODERS; ++i) MIOS32_ENC_ConfigSet(i, encoders[i]); ..... //////////////////////////////////////////////////////////////////////////////////////// //Encoder Moved? void APP_ENC_NotifyChange(u32 encoder, s32 incrementer){ // increment to virtual position and ensure that the value is in range 0..127 s32 value = enc_value[encoder] + incrementer; if(value < 0){value = 0;} if(value > 127){value = 127;} enc_value[encoder] = value; MIOS32_LCD_Clear(); // clear screen MIOS32_LCD_CursorSet(0, 0); // X,Y MIOS32_LCD_PrintFormattedString("%u %u %u", encoder, incrementer, enc_value[0]);} I have worked thru the tutorials, >>> i only need 5 Encoders, on different PINs, so i have to declare they by hand and not with a FOR Loop over all Shiftregisters.... this is because i dont use the Tutorial code. Edited January 9, 2015 by Phatline
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now