2014-11-25 15:27:33 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <pigpio.h>
|
|
|
|
|
|
|
|
#include "ir_hasher.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
REQUIRES
|
|
|
|
|
|
|
|
An IR receiver output pin connected to a Pi gpio.
|
|
|
|
|
|
|
|
TO BUILD
|
|
|
|
|
2015-02-25 21:34:52 +01:00
|
|
|
gcc -o ir_hash_c test_ir_hasher.c ir_hasher.c -lpigpio -lrt -lpthread
|
2014-11-25 15:27:33 +01:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|