Main Page
Namespaces
Classes
Files
File List
File Members
client
pigpio
EXAMPLES
C
ROTARY_ENCODER
test_rotary_encoder.c
Go to the documentation of this file.
1
#include <stdio.h>
2
3
#include <
pigpio.h
>
4
5
#include "
rotary_encoder.h
"
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
gcc -o rot_enc_c test_rotary_encoder.c rotary_encoder.c -lpigpio -lrt
17
18
TO RUN
19
20
sudo ./rot_enc_c
21
22
*/
23
24
void
callback
(
int
way)
25
{
26
static
int
pos
= 0;
27
28
pos += way;
29
30
printf(
"pos=%d\n"
, pos);
31
}
32
33
int
main
(
int
argc,
char
*argv[])
34
{
35
Pi_Renc_t
* renc;
36
37
if
(
gpioInitialise
() < 0)
return
1;
38
39
renc =
Pi_Renc
(7, 8,
callback
);
40
41
sleep(300);
42
43
Pi_Renc_cancel
(renc);
44
45
gpioTerminate
();
46
}
47
gpioInitialise
int gpioInitialise(void)
Definition:
pigpio.c:8459
rotary_encoder.pos
int pos
Definition:
rotary_encoder.py:116
main
int main(int argc, char *argv[])
Definition:
test_rotary_encoder.c:33
pigpio.h
Pi_Renc_cancel
void Pi_Renc_cancel(Pi_Renc_t *renc)
Definition:
rotary_encoder.c:84
rotary_encoder.h
Pi_Renc
Pi_Renc_t * Pi_Renc(int gpioA, int gpioB, Pi_Renc_CB_t callback)
Definition:
rotary_encoder.c:57
_Pi_Renc_s
Definition:
rotary_encoder.c:8
gpioTerminate
void gpioTerminate(void)
Definition:
pigpio.c:8495
callback
void callback(int way)
Definition:
test_rotary_encoder.c:24
cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Tue Oct 20 2020 03:35:57