File: test_ir_hasher.cpp

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 (44 lines) | stat: -rw-r--r-- 637 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
#include <iostream>

#include <pigpio.h>

#include "ir_hasher.hpp"

/*

REQUIRES

An IR receiver output pin connected to a Pi gpio.

TO BUILD

g++ -o ir_hash_cpp test_ir_hasher.cpp ir_hasher.cpp -lpigpio -lrt -lpthread

TO RUN

sudo ./ir_hash_cpp

*/

void callback(uint32_t hash)
{
   std::cout << "hash=" << hash << std::endl;
}

int main(int argc, char *argv[])
{
   if (gpioInitialise() >= 0)
   {
      /* Can't instantiate a Hasher before pigpio is initialised. */

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

      Hasher ir(7, callback);

      sleep(300);
   }
}