void Encoder_Exe(void)
{
static char biphase;
register char tmp1 = 0;
if(Pin_ENC_F1) tmp1 = 0x40;
if(Pin_ENC_F2) tmp1 |= 0x80;
if((tmp1 & 0xC0) != (biphase & 0xC0)) return;
biphase >>= 2;
tmp1 |= biphase;
tmp1 &= 0xF0;
if(biphase & (1 << 1))
tmp1 |= (1 << 3);
biphase = tmp1;
if(tmp1 >= 0x90) return;
tmp1 = __swap_nibbles(tmp1);
if(tmp1 & (1 << 7))
tmp1 += 0x89;
switch(tmp1)
{
case 2:
case 4: biphase |= 8; break;
case 10:
case 17: biphase &= ~8; break;
case 8: Keyboard_SetCode(ENC_UP); break;
case 11: Keyboard_SetCode(ENC_DN); break;
}
}