james hatch
/
Encoder
df
Embed:
(wiki syntax)
Show/hide line numbers
Encoder.h
00001 #ifndef ENCODER_H 00002 #define ENCODER_H 00003 00004 #include "mbed.h" 00005 00006 // Define BaseClass Encoder 00007 00008 class Encoder 00009 { 00010 public: 00011 // Constructor 00012 Encoder(PinName mosi, PinName miso, PinName sck, PinName ncs); 00013 float angle(); 00014 bool parityFlag(); 00015 bool encFlag(); 00016 void init(float zero_ang); 00017 void flip(); 00018 short int readRaw(); 00019 // Functions 00020 00021 private: 00022 SPI _spi; 00023 DigitalOut _cs; 00024 bool parity_calc(int x); 00025 int sign; 00026 int read(); 00027 bool parity; 00028 bool enc_flag; 00029 //zero_ang for standing position 00030 float zero_ang; 00031 short int raw; 00032 00033 00034 // Variables 00035 const float enc2deg; 00036 00037 }; 00038 00039 #endif 00040
Generated on Tue Jul 12 2022 21:00:54 by 1.7.2