add encoder support (LIR-OM158A)

This commit is contained in:
Edward Emelianov
2024-03-23 17:43:38 +03:00
parent 7de5819361
commit b89b548e0a
11 changed files with 108 additions and 56 deletions

View File

@@ -83,23 +83,20 @@ int main(void){
if(ans) USB_sendstr(ans);
}
ESW_process();
static uint8_t oldswitches[2] = {0};
int send = 0;
for(int i = 0; i < 2; ++i){
uint8_t new = getESW(i);
if(oldswitches[i] != new){
send = 1;
oldswitches[i] = new;
USB_sendstr("ESW"); USB_putbyte('0' + i);
USB_sendstr(" changed @"); printu(Tms);
USB_sendstr(" to "); printuhex(new); newline();
}
static uint8_t oldswitches = 0;
uint8_t new = getESW(1);
if(oldswitches != new){
oldswitches = new;
USB_sendstr("ESW changed @"); printu(Tms);
USB_sendstr(" to "); printuhex(new); newline();
CANsendLim();
}
encoder_process();
if(FLAG(EMULATE_PEP)){
if(Tms - encT > ENCODER_PERIOD){
encT = Tms;
CANsendEnc();
} else if(send) CANsendLim();
}
}
}
}