Main Page
Namespaces
Classes
Files
File List
File Members
client
pigpio
EXAMPLES
CPP
ROTARY_ENCODER
test_rotary_encoder.cpp
Go to the documentation of this file.
1
#include <iostream>
2
3
#include <
pigpio.h
>
4
5
#include "
rotary_encoder.hpp
"
6
7
/*
8
9
REQUIRES
10
11
A rotary encoder contacts A and B connected to separate gpios and
12
the common contact connected to Pi ground.
13
14
TO BUILD
15
16
g++ -o rot_enc_cpp test_rotary_encoder.cpp rotary_encoder.cpp -lpigpio -lrt
17
18
TO RUN
19
20
sudo ./rot_enc_cpp
21
22
*/
23
24
void
callback
(
int
way)
25
{
26
static
int
pos
= 0;
27
28
pos += way;
29
30
std::cout <<
"pos="
<< pos << std::endl;
31
}
32
33
int
main
(
int
argc,
char
*argv[])
34
{
35
if
(
gpioInitialise
() < 0)
return
1;
36
37
re_decoder
dec(7, 8,
callback
);
38
39
sleep(3000);
40
41
dec.
re_cancel
();
42
43
gpioTerminate
();
44
}
45
gpioInitialise
int gpioInitialise(void)
Definition:
pigpio.c:8459
callback
void callback(int way)
Definition:
test_rotary_encoder.cpp:24
rotary_encoder.pos
int pos
Definition:
rotary_encoder.py:116
re_decoder
Definition:
rotary_encoder.hpp:8
pigpio.h
rotary_encoder.hpp
re_decoder::re_cancel
void re_cancel(void)
Definition:
rotary_encoder.cpp:79
gpioTerminate
void gpioTerminate(void)
Definition:
pigpio.c:8495
main
int main(int argc, char *argv[])
Definition:
test_rotary_encoder.cpp:33
cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Tue Oct 20 2020 03:35:57