Starting a new thread since my 2 previous where a bit confusing, Let me 
instead describe my problem and maybe someone can point me to a possible 
solution.
please excuse me if this all looks simple but I'm some what new to java and 
still learning the ropes.

I'm using an IDrive from a BMW. Its a kind of rotary and uses photo 
resistors to determines what way and how many steps you rotate it. I use 
this rotary to animate GUI in my app.

The way it works is that the 2 photo resistors are placed slightly offset 
and are either lit or dark. when rotating the rotary it cut or lit one 
photo resistors a fragment before the other. this is how I determines what 
way I rotate. when the rotary is inactive both photo resistors are lit or 
dark.

Right now I'm just reading the photo resistors periodically with 
digitalinput.read() and I tend to miss the offset cut from time to time, 
especially over bluetooth, witch makes things a bit erratic.

Does anyone have a suggestion how i should do this to catch all "pulses"?


//This is called every time in the ioio loop

public void setRotation(boolean DigitalInput1, boolean DigitalInput2){
 oldA = A;
 oldB = B;
 oldRotation = rotation;
 A = DigitalInput1;
 B = DigitalInput2;

// CALCULATE ROTATION
// 1 = CW  
//-1= CCW
  if(A != oldA){
  if(A != B){
  rotation = 1;
  }else{
  rotation = -1;
  }
  }
  if(B != oldB){
  if(B == A){
  rotation = 1;
  }else{
  rotation = -1;
  }
  }
// CALCULATES KNOB steps  
  if(A && B && ifChange ==0){
   if(rotation == 1 && oldRotation == rotation){counter++;}
   if(rotation == -1 && oldRotation == rotation){counter--;}
   ifChange = 2;
  }else if(!A && !B && ifChange == 2){
   if(rotation == 1 && oldRotation == rotation){counter++;}
   if(rotation == -1 && oldRotation == rotation){counter--;}
   ifChange = 0;
  }
  
  
 }

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to