User Tools

Site Tools


raspberrypi:pigpio_rencoder.c

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

raspberrypi:pigpio_rencoder.c [2017/05/07 15:42] – created aistisraspberrypi:pigpio_rencoder.c [2017/05/07 15:46] (current) – aistis
Line 9: Line 9:
 <code c> <code c>
 #include <stdio.h> #include <stdio.h>
-#include <stdlib.h> 
-#include <signal.h> 
- 
-#include <termios.h>  
 #include <unistd.h>   #include <unistd.h>  
- 
 #include <pigpio.h> #include <pigpio.h>
- +/* 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 ./pigpio_rencoder sudo ./pigpio_rencoder
 */ */
- 
 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[])
 { {
-    /*static struct termios oldt, newt; +    if (gpioInitialise() < 0) return -1;
-    tcgetattr( STDIN_FILENO, &oldt); +
-    newt = oldt; +
-    newt.c_lflag &= ~(ICANON | ECHO);           +
-    tcsetattr( STDIN_FILENO, TCSANOW, &newt);*/ +
- +
-   if (gpioInitialise() < 0) return -1;+
  
-   //int p = 0; +    gpioSetAlertFunc(pin1, aFunction); 
-   gpioSetAlertFunc(pin1, aFunction); +    gpioSetAlertFunc(pin2, aFunction); 
-   gpioSetAlertFunc(pin2, aFunction); +    gpioSetAlertFunc(pin3, aFunction);
-   gpioSetAlertFunc(pin3, aFunction);+
  
-    printf("Press e to exit program\n"); +    printf("Press e and enter to exit program\n");
-    //printf("press q and w to increase and decrease software pwm\n");+
     int c;       int c;  
-    while((c=getchar())!= 'e') +    while((c=getchar())!= 'e')       
-    {       +
-        //if (c == 'q') p +=5; +
-        //if (c == 'w') p -=5; +
-        //printf("%3d   \r",p); +
-        //gpioServo(18, p);+
         sleep(10);         sleep(10);
-    }  +    
-    +
-   //tcsetattr( STDIN_FILENO, TCSANOW, &oldt);+
    return 0;       return 0;   
 } }
 </code> </code>
raspberrypi/pigpio_rencoder.c.1494160953.txt.gz · Last modified: by aistis