Pololu3piPlus32U4 library
Pololu3piPlus32U4Encoders.h
Go to the documentation of this file.
1 // Copyright (C) Pololu Corporation. See www.pololu.com for details.
2 
4 
5 #pragma once
6 
7 #include <stdint.h>
8 
9 namespace Pololu3piPlus32U4
10 {
11 
28 class Encoders
29 {
30 
31 public:
32 
40  static void flipEncoders(bool flip);
41 
48  static void init()
49  {
50  static bool initialized = 0;
51  if (!initialized)
52  {
53  initialized = true;
54  init2();
55  }
56  }
57 
68  static int16_t getCountsLeft();
69 
74  static int16_t getCountsRight();
75 
82  static int16_t getCountsAndResetLeft();
83 
88  static int16_t getCountsAndResetRight();
89 
103  static bool checkErrorLeft();
104 
108  static bool checkErrorRight();
109 
110 private:
111 
112  static void init2();
113  static bool flip;
114 };
115 
116 }
Reads counts from the encoders on the 3pi+ 32U4.
static void flipEncoders(bool flip)
Flips the direction of the encoders.
static bool checkErrorRight()
Returns true if an error was detected on the right-side encoder.
static int16_t getCountsRight()
Returns the number of counts that have been detected from the right-side encoder.
static bool checkErrorLeft()
Returns true if an error was detected on the left-side encoder.
static int16_t getCountsAndResetRight()
Returns the number of counts that have been detected from the left-side encoder and clears the counts...
static int16_t getCountsAndResetLeft()
Returns the number of counts that have been detected from the left-side encoder and clears the counts...
static int16_t getCountsLeft()
Returns the number of counts that have been detected from the left-side encoder.
static void init()
Initializes the encoders (called automatically).
Top-level namespace for the Pololu3piPlus32U4 library.