 // if it's CW or CCW, reset stage to 0
 byte EncoderState[ENCODER_COUNT];
 
-const byte CWPattern1 = B00011110, CWPattern2 = B01111000, CWPattern3 = B11100001, CWPattern4 = B10000111;
-const byte CCWPattern1 = B00101101, CCWPattern2 = B10110100, CCWPattern3 = B11010010, CCWPattern4 = B01001110;
+//const byte CWPattern1 = B00011110, CWPattern2 = B01111000, CWPattern3 = B11100001, CWPattern4 = B10000111;
+//const byte CCWPattern1 = B00101101, CCWPattern2 = B10110100, CCWPattern3 = B11010010, CCWPattern4 = B01001110;
+const byte CWPattern1 = B00000001, CWPattern2 = B00000111, CWPattern3 = B00001110, CWPattern4 = B00001000;
+const byte CCWPattern1 = B00000010, CCWPattern2 = B00001011, CCWPattern3 = B00001101, CCWPattern4 = B00000100;
+//const byte CWCCWCompareMask = B11111111;
+const byte CWCCWCompareMask = B00001111;
 
 //store the rotary encoder's last pulse time, this will be used to remove the drift effect
 unsigned long prevEncoderMillis[ENCODER_COUNT];

			byte encoderId = rowid * 8 + colid / 2;
			//int encoderState = encoderTable[ prevEncoderValue[ encoderId ] << 2 | encoderValue ];

			if ( encoderValue != prevEncoderValue[encoderId]  )
			{
				//we have a "pulse" from rotary encoder
				int direction = 0;
				EncoderState[encoderId] = EncoderState[encoderId] << 2 | encoderValue;

				if (EncoderState[encoderId] == CWPattern1  || EncoderState[encoderId] == CWPattern3 )
				{
					//this is a full CW pattern,
					direction = 1;
					//EncoderState[encoderId] = 0;
				}
				else if (EncoderState[encoderId] == CCWPattern1  || EncoderState[encoderId] == CCWPattern3 )
				{
					//this is a full CCW pattern,
					direction = -1;

		//joyReport.axis[ind] = map(analogRead(54+ind), 0, 1023, -32768,32767 );
	}
	sendJoyReport(&joyReport);
//	delay(20);
}
