Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
BelaEncoder.h
1 #pragma once
2 #include <libraries/Encoder/Encoder.h>
3 #include <Bela.h>
4 
13 class BelaEncoder : public Encoder
14 {
15 public:
16  struct Pins {
17  unsigned int a;
18  unsigned int b;
19  };
20  struct Settings {
21  BelaContext* context;
22  float debounceMs;
23  Pins pins;
24  Polarity polarity;
25  };
26  BelaEncoder();
27  BelaEncoder(const Settings& settings);
28  int setup(const Settings& settings);
36  Rotation process(BelaContext* context);
40  Rotation process(BelaContext* context, unsigned int frame)
41  {
42  bool a = digitalRead(context, frame, pins.a);
43  bool b = digitalRead(context, frame, pins.b);
44  return Encoder::process(a, b);
45  }
46 private:
47  Pins pins;
48 };
Polarity
Definition: Encoder.h:27
Definition: BelaEncoder.h:16
Rotation process(BelaContext *context, unsigned int frame)
Definition: BelaEncoder.h:40
Rotation process(bool a, bool b)
Definition: Encoder.cpp:27
unsigned int a
Bela's digital pin connected to the encoder's A pin.
Definition: BelaEncoder.h:17
Connect a quadrature rotary encoder.
Definition: Encoder.h:15
unsigned int b
Bela's digital pin connected to the encoder's B pin.
Definition: BelaEncoder.h:18
static int digitalRead(BelaContext *context, int frame, int channel)
Read a digital input, specifying the frame number (when to read) and the pin.
Definition: Bela.h:1518
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition: Bela.h:231
Definition: BelaEncoder.h:20
Connect a quadrature rotary encoder, and handle it at audio rate from Bela.
Definition: BelaEncoder.h:13
Main Bela public API.
Rotation process(BelaContext *context)
Definition: BelaEncoder.cpp:26
Rotation
Definition: Encoder.h:18