Go to the documentation of this file.00001 #include <stdio.h>
00002
00003 #include <pigpio.h>
00004
00005 #include "rotary_encoder.h"
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 void callback(int way)
00025 {
00026 static int pos = 0;
00027
00028 pos += way;
00029
00030 printf("pos=%d\n", pos);
00031 }
00032
00033 int main(int argc, char *argv[])
00034 {
00035 Pi_Renc_t * renc;
00036
00037 if (gpioInitialise() < 0) return 1;
00038
00039 renc = Pi_Renc(7, 8, callback);
00040
00041 sleep(300);
00042
00043 Pi_Renc_cancel(renc);
00044
00045 gpioTerminate();
00046 }
00047