teratermを見やすいようにした。prinf文内のエスケープシーケンスでカーソルを動かす機能を利用した。詳細については https://www.mm2d.net/main/prog/c/console-02.html を見てね
main.cpp
- Committer:
- NYANTA
- Date:
- 2018-08-16
- Revision:
- 0:7f7fff9d3383
File content as of revision 0:7f7fff9d3383:
#include "mbed.h" #include "QEI.h" Serial pc(USBTX,USBRX); DigitalOut GLED(PB_7); DigitalOut YLED(PC_12); DigitalOut BLED(PD_2); DigitalOut R1LED(PC_13); DigitalOut R2LED(PA_4); DigitalOut R3LED(PB_0); DigitalOut R4LED(PC_2); DigitalOut R5LED(PC_3); DigitalIn UBTN1(PA_0); DigitalIn UBTN2(PA_1); DigitalIn FOTO1(PA_15); DigitalIn FOTO2(PC_5); QEI ECR(PA_2,PA_3,NC,600,QEI::X4_ENCODING); int main(void){ GLED = 1; while(true){ /*GLED = 1; YLED = 1; BLED = 1; R1LED = 1; R2LED = 1; R3LED = 1; R4LED = 1; R5LED = 1; wait(0.5); GLED = 1; YLED = 1; BLED = 1; R1LED = 1; R2LED = 1; R3LED = 1; R4LED = 1; R5LED = 1;*/ wait(0.5); pc.printf("Pulses: %07d\n", ECR.getPulses()/4); pc.printf("Rotate: %04.3f\033[0J\033[H", (double)ECR.getPulses()/(600*4)); } }