Initial commimt

This commit is contained in:
7u83 2024-05-19 00:56:34 +02:00
parent d7cd9b8d4d
commit c73d714dae

25
rotary_encoder_stat.c Normal file
View File

@ -0,0 +1,25 @@
#include "mc8051fun.h"
static uint8_t lastb=0xff;
static uint8_t hist=0x00;
int8_t rotary_encoder_stat(uint8_t b)
{
if (b==0x00)
return 0;
if (b==lastb)
return 0;
lastb=b;
hist = (hist << 2) | b;
switch (hist){
case 0b11011011:
return 1;
case 0b11100111:
return -1;
default:
return 0;
}
}