/**********************************************************

*    文件: hal_encoder.ino      by 零知实验室(www.lingzhilab.com)

*    -^^- 零知开源，让电子制作变得更简单！ -^^-

*    时间: 2019/10/10 11:55

*    说明: 

************************************************************/
#include "STM32Encoder.h"


//TIM1 PA_8,PA_9  -34,1
//TIM3 PA_6,PA_7  -A6,A7

//TIM4 PB_6,PB_7  -21,20

//TIM8 PC_6,PC_7  -30,31


//argument:

//Timer,

//Timer prescaler,

//pulses per Revolution on the encoder
STM32Encoder rudder(TIM4,PB_6,PB_7, 1, 1024);

void setup() {
	// put your setup code here, to run once:
	Serial.begin(9600);
	
	rudder.begin();
	
}

uint32_t tprint;

void loop() {
	//Report what you are doing...
	if (millis() - tprint > 1000) {
		tprint= millis();
		Serial.print("Counts: ");
		Serial.println(rudder.value());
		Serial.print("direction: ");
		Serial.println(rudder.getDirection());

	}
	
}
