Encoders stuff... going to Italy!

Committer:
perr1940
Date:
Mon Nov 24 03:33:29 2014 +0000
Revision:
0:1d2644a20b71
Encoders stuff!!! going to Italy;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
perr1940 0:1d2644a20b71 1 #ifndef ENCODER_H
perr1940 0:1d2644a20b71 2 #define ENCODER_H
perr1940 0:1d2644a20b71 3
perr1940 0:1d2644a20b71 4 #include "mbed.h"
perr1940 0:1d2644a20b71 5
perr1940 0:1d2644a20b71 6 // Define BaseClass Encoder
perr1940 0:1d2644a20b71 7
perr1940 0:1d2644a20b71 8 class Encoder
perr1940 0:1d2644a20b71 9 {
perr1940 0:1d2644a20b71 10 public:
perr1940 0:1d2644a20b71 11 // Constructor
perr1940 0:1d2644a20b71 12 Encoder(PinName mosi, PinName miso, PinName sck, PinName ncs);
perr1940 0:1d2644a20b71 13 float angle();
perr1940 0:1d2644a20b71 14 bool parityFlag();
perr1940 0:1d2644a20b71 15 bool encFlag();
perr1940 0:1d2644a20b71 16 void init(float zero_ang);
perr1940 0:1d2644a20b71 17 void flip();
perr1940 0:1d2644a20b71 18 short int readRaw();
perr1940 0:1d2644a20b71 19 // Functions
perr1940 0:1d2644a20b71 20 private:
perr1940 0:1d2644a20b71 21 SPI _spi;
perr1940 0:1d2644a20b71 22 DigitalOut _cs;
perr1940 0:1d2644a20b71 23 bool parity_calc(int x);
perr1940 0:1d2644a20b71 24 int sign;
perr1940 0:1d2644a20b71 25 int read();
perr1940 0:1d2644a20b71 26 bool parity;
perr1940 0:1d2644a20b71 27 bool enc_flag;
perr1940 0:1d2644a20b71 28 //zero_ang for standing position
perr1940 0:1d2644a20b71 29 float zero_ang;
perr1940 0:1d2644a20b71 30 short int raw;
perr1940 0:1d2644a20b71 31
perr1940 0:1d2644a20b71 32
perr1940 0:1d2644a20b71 33 // Variables
perr1940 0:1d2644a20b71 34 const float enc2deg;
perr1940 0:1d2644a20b71 35
perr1940 0:1d2644a20b71 36 };
perr1940 0:1d2644a20b71 37
perr1940 0:1d2644a20b71 38 #endif
perr1940 0:1d2644a20b71 39