![](/media/cache/profiles/sirooni.jpg.50x50_q85.jpg)
my qei test
Diff: main.cpp
- Revision:
- 0:fb962a369fdf
- Child:
- 1:5c265e848abb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Oct 18 11:29:16 2021 +0000 @@ -0,0 +1,26 @@ +#include "QEI.h" + +Serial pc(USBTX, USBRX,115200); +//DigitalIn b(USER_BUTTON); +//Use X4 encoding. +QEI wheel[] = { + QEI(PB_7,PB_6,NC,100,QEI::X4_ENCODING), + //QEI(PA_6,PA_7,NC,100,QEI::X4_ENCODING), だめ + QEI(PA_9,PA_8,NC,100,QEI::X4_ENCODING), + QEI(PA_1,PA_0,NC,100,QEI::X4_ENCODING) +}; + +int main() { + //b.mode(PullUp); + while(1){ + /*if(b.read() == 0){ + for(int i=0; i<1; i++){ + wheel[i].reset(); + } + }*/ + for(int i=0; i<3; i++){ + pc.printf("%d=%d ", i, wheel[i].getPulses()); + } + pc.printf("\r\n"); + } +}