james hatch
/
Encoder
df
Diff: Encoder.h
- Revision:
- 0:0a457148bccf
- Child:
- 2:6f9c364ebe40
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Encoder.h Tue Jun 30 23:41:08 2015 +0000 @@ -0,0 +1,39 @@ +#ifndef ENCODER_H +#define ENCODER_H + +#include "mbed.h" + +// Define BaseClass Encoder + +class Encoder +{ +public: + // Constructor + Encoder(PinName mosi, PinName miso, PinName sck, PinName ncs); + float angle(); + bool parityFlag(); + bool encFlag(); + void init(float zero_ang); + void flip(); + short int readRaw(); + // Functions +private: + SPI _spi; + DigitalOut _cs; + bool parity_calc(int x); + int sign; + int read(); + bool parity; + bool enc_flag; + //zero_ang for standing position + float zero_ang; + short int raw; + + + // Variables + const float enc2deg; + +}; + +#endif +