df

Dependencies:   mbed

Encoder.h

Committer:
jahatch
Date:
2015-07-01
Revision:
2:6f9c364ebe40
Parent:
0:0a457148bccf

File content as of revision 2:6f9c364ebe40:

#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