raspberrypi:pigpio_rencoder.c
Differences
This shows you the differences between two versions of the page.
| raspberrypi:pigpio_rencoder.c [2017/05/07 15:42] – created aistis | raspberrypi:pigpio_rencoder.c [2017/05/07 15:46] (current) – aistis | ||
|---|---|---|---|
| Line 9: | Line 9: | ||
| <code c> | <code c> | ||
| #include < | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | |||
| - | #include < | ||
| #include < | #include < | ||
| - | |||
| #include < | #include < | ||
| - | + | /* to compile and run | |
| - | /* | + | |
| gcc -Wall -pthread -o pigpio_rencoder pigpio_rencoder.c -lpigpio -O3 | gcc -Wall -pthread -o pigpio_rencoder pigpio_rencoder.c -lpigpio -O3 | ||
| sudo ./ | sudo ./ | ||
| */ | */ | ||
| - | |||
| int pin1 = 16; | int pin1 = 16; | ||
| int pin2 = 12; | int pin2 = 12; | ||
| Line 41: | Line 34: | ||
| int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||
| { | { | ||
| - | | + | if (gpioInitialise() < 0) return -1; |
| - | tcgetattr( STDIN_FILENO, | + | |
| - | newt = oldt; | + | |
| - | newt.c_lflag &= ~(ICANON | ECHO); | + | |
| - | tcsetattr( STDIN_FILENO, | + | |
| - | + | ||
| - | if (gpioInitialise() < 0) return -1; | + | |
| - | //int p = 0; | + | |
| - | gpioSetAlertFunc(pin1, | + | gpioSetAlertFunc(pin2, |
| - | | + | gpioSetAlertFunc(pin3, |
| - | | + | |
| - | printf(" | + | printf(" |
| - | // | + | |
| int c; | int c; | ||
| - | while((c=getchar())!= ' | + | while((c=getchar())!= ' |
| - | { | + | |
| - | //if (c == ' | + | |
| - | //if (c == ' | + | |
| - | // | + | |
| - | // | + | |
| sleep(10); | sleep(10); | ||
| - | | + | |
| - | + | ||
| - | // | + | |
| | | ||
| } | } | ||
| </ | </ | ||
raspberrypi/pigpio_rencoder.c.1494160953.txt.gz · Last modified: by aistis
