File: test_ir_hasher.c

package info (click to toggle)
pigpio 1.78-1.1
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 7,088 kB
  • sloc: ansic: 17,891; python: 4,232; sh: 741; cpp: 281; makefile: 135
file content (47 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>

#include <pigpio.h>

#include "ir_hasher.h"

/*

REQUIRES

An IR receiver output pin connected to a Pi gpio.

TO BUILD

gcc -o ir_hash_c test_ir_hasher.c  ir_hasher.c -lpigpio -lrt -lpthread

TO RUN

sudo ./ir_hash_c

*/

void callback(uint32_t hash)
{
   printf("hash=%u\n", hash);
}

int main(int argc, char *argv[])
{
   Pi_Hasher_t *hasher;

   if (gpioInitialise() < 0) return 1;

   /* 
      This assumes the output pin of an IR receiver is
      connected to gpio 7.
   */

   hasher = Pi_Hasher(7, callback, 5);

   sleep(300);

   Pi_Hasher_cancel(hasher);

   gpioTerminate();
}