#include "pirlib2_global.h"
Go to the source code of this file.
|
| typedef void(* | fStatusCB )(const char *serial, unsigned char status, void *userData) |
| | Callback called when the status of the PIR-1 driver is affected. More...
|
| |
| typedef void(* | fIrReceivedCB )(const char *serial, const unsigned int *pulses, unsigned int pulseCount, void *userData) |
| | Called when an IR signal is received in non-learn mode. More...
|
| |
| typedef void(* | fIrSentCB )(const char *serial, unsigned char status, void *userData) |
| | fIrSentCB is called when an IR code was sent. More...
|
| |
| typedef void(* | fIrRawLearnCB )(const char *serial, unsigned int modulation, const unsigned int *pulses, unsigned int pulseCount, void *userData) |
| | fIrRawLearnCB is called when an IR code is received in LEARN mode. More...
|
| |
| typedef void(* | fButtonCB )(const char *serial, int button1, int button2, int button3, int button4, void *userData) |
| | fButtonCB is called on a button event. More...
|
| |
|
| PIRLIB2SHARED_EXPORT int | pir_open (PIR_Settings *settings) |
| | Opens the PIR Library. This must be called only once. More...
|
| |
| PIRLIB2SHARED_EXPORT int | pir_close () |
| | Close the library. More...
|
| |
| PIRLIB2SHARED_EXPORT int | pir_sendCCF (const char *serial, const char *ccf, int bitmask, unsigned char repeats) |
| | Transmit a CCF code. More...
|
| |
| PIRLIB2SHARED_EXPORT unsigned int | pir_list1 (char *buffer, unsigned int size) |
| | Get a comma separated list of PIR-1 serial numbers. More...
|
| |
| PIRLIB2SHARED_EXPORT unsigned int | pir_list4 (char *buffer, unsigned int size) |
| | Get a comma separated list of PIR-4 serial numbers. More...
|
| |
| PIRLIB2SHARED_EXPORT int | pir_version (const char *serial) |
| | Returns the firmware version of the attached PIR. More...
|
| |
| PIRLIB2SHARED_EXPORT int | pir_blink (const char *serial, unsigned char count) |
| | Blinks the LED on the attached PIR-1. More...
|
| |
| PIRLIB2SHARED_EXPORT int | pir_type (const char *serial) |
| | Returns the type. More...
|
| |
| PIRLIB2SHARED_EXPORT int | pir_detect () |
| | Looks for attached PIR-1 or PIR-4 devices. This library runs this code on startup but after that the calling code is responsible for periodically running this. More...
|
| |
| PIRLIB2SHARED_EXPORT int | pir_learn (const char *serial) |
| | starts learn mode More...
|
| |
| PIRLIB2SHARED_EXPORT int | pir_cancelLearn (const char *serial) |
| | starts learn mode More...
|
| |
Main C interface of the library.
| #define PIR_ARRIVED_STATUS 1 |
PIR-1 or PIR-4 has arrived
| #define PIR_BUTTON_DOWN 1 |
| #define PIR_BUTTON_IDLE 0 |
| #define PIR_BUTTON_REPEAT 2 |
| #define PIR_REMOVED_STATUS 2 |
PIR-1 or PIR-4 was removed
fButtonCB is called on a button event.
- Parameters
-
| serial | serial number of PIR |
| button1 | current event number, PIR_BUTTON_DOWN, PIR_BUTTON_IDLE, PIR_BUTTON_REPEAT or PIR_BUTTON_UP |
| button1 | current event number, PIR_BUTTON_DOWN, PIR_BUTTON_IDLE, PIR_BUTTON_REPEAT or PIR_BUTTON_UP |
| button2 | current event number, PIR_BUTTON_DOWN, PIR_BUTTON_IDLE, PIR_BUTTON_REPEAT or PIR_BUTTON_UP |
| button3 | current event number, PIR_BUTTON_DOWN, PIR_BUTTON_IDLE, PIR_BUTTON_REPEAT or PIR_BUTTON_UP |
| button4 | current event number, PIR_BUTTON_DOWN, PIR_BUTTON_IDLE, PIR_BUTTON_REPEAT or PIR_BUTTON_UP |
| userData | userData element from PIR_Settings |
fIrRawLearnCB is called when an IR code is received in LEARN mode.
- Parameters
-
| serial | serial number of PIR |
| modulation | is the modulation frequency of the signal. |
| pulses | is the array that holds the pulse lenghts |
| pulseCount | is the number of elements in the buffer. |
| userData | userData element from PIR_Settings |
Called when an IR signal is received in non-learn mode.
fIrReceivedCB is called when an IR code is received. Note that the received code is NOT an CCF code and must be compared 'fuzzy'.
- Parameters
-
| serial | serial number of PIR |
| pulses | pulses is a array of pulse lenghts. |
| pulseCount | pulseCount is the number of elements in the pulses array. |
| userData | userData element from PIR_Settings |
fIrSentCB is called when an IR code was sent.
- Parameters
-
| serial | serial number of PIR |
| status,0 | = OK otherwise error. |
| userData | userData element from PIR_Settings |
Callback called when the status of the PIR-1 driver is affected.
For example when a new PIR-1 arrives.
PIR_ARRIVED_STATUS if a new PIR-1 arrives. PIR_REMOVED_STATUS if a PIR-1 is removed.
- Parameters
-
| serial | serial number of PIR |
| status | PIR_ARRIVED_STATUS or PIR_REMOVED_STATUS |
| userData | userData element from PIR_Settings |
| PIRLIB2SHARED_EXPORT int pir_blink |
( |
const char * |
serial, |
|
|
unsigned char |
count |
|
) |
| |
Blinks the LED on the attached PIR-1.
- Parameters
-
| serial | serial number of the PIR-1 to query. |
| count | the number of times to blink. |
- Returns
- 0 on success
-
< 0 on error
| PIRLIB2SHARED_EXPORT int pir_cancelLearn |
( |
const char * |
serial | ) |
|
starts learn mode
- Parameters
-
| serial | number of PIR-1 to stop learning. |
- Returns
- 0 on success
-
< 0 on error
| PIRLIB2SHARED_EXPORT int pir_close |
( |
| ) |
|
Close the library.
- Returns
- 0 on success.
| PIRLIB2SHARED_EXPORT int pir_detect |
( |
| ) |
|
Looks for attached PIR-1 or PIR-4 devices. This library runs this code on startup but after that the calling code is responsible for periodically running this.
- Returns
- 0 on success
-
< 0 on error
| PIRLIB2SHARED_EXPORT int pir_learn |
( |
const char * |
serial | ) |
|
starts learn mode
- Parameters
-
| serial | serial number of PIR-1 to use for learning. |
- Returns
- 0 on success
-
< 0 on error
| PIRLIB2SHARED_EXPORT unsigned int pir_list1 |
( |
char * |
buffer, |
|
|
unsigned int |
size |
|
) |
| |
Get a comma separated list of PIR-1 serial numbers.
- Parameters
-
| buffer | allocated by caller |
| size | size of buffer |
- Returns
- the number of characters required in the buffer to hold the full string. If this number is larger then you have passed in size adjust your buffer and call again.
| PIRLIB2SHARED_EXPORT unsigned int pir_list4 |
( |
char * |
buffer, |
|
|
unsigned int |
size |
|
) |
| |
Get a comma separated list of PIR-4 serial numbers.
- Parameters
-
| buffer | allocated by caller |
| size | size of buffer |
- Returns
- the number of characters required in the buffer to hold the full string. If this number is larger then you have passed in size adjust your buffer and call again.
| PIRLIB2SHARED_EXPORT int pir_open |
( |
PIR_Settings * |
settings | ) |
|
Opens the PIR Library. This must be called only once.
- Parameters
-
- Returns
- 0 on success.
-
< 0 on error.
The PIR_Settings struct contents is copied so there is no need to keep the object around after pir_open
Example
This example opens the library without any callbacks registered.
| PIRLIB2SHARED_EXPORT int pir_sendCCF |
( |
const char * |
serial, |
|
|
const char * |
ccf, |
|
|
int |
bitmask, |
|
|
unsigned char |
repeats |
|
) |
| |
Transmit a CCF code.
CCF codes are the IR codes formatted according to the Pronto CCF format. This library only supports CCF-RAW codes.
Multiple code can be sent in quick succesion without waiting for fIrSentCB callback. Internally the library will queue the CCF codes.
- Parameters
-
| serial | the serial number of the PIR to use for sending or 0 ( or "" ) for all attached PIRs. |
| ccf | Pronto CCF string. |
| bitmask | combination of bits 1 = back of PIR, 2 = front panel for pir-1 |
| bitmask | = 1, 2, 4 or 8 respectively for ports 1,2,3 or 4 on PIR-4 |
| repeats | = number of times to repeat the ir signal. |
- Returns
- 0 = success
-
< 0 = error
| PIRLIB2SHARED_EXPORT int pir_type |
( |
const char * |
serial | ) |
|
Returns the type.
- Parameters
-
| serial | serial number of the PIR-1 to query. |
- Returns
- PIR_PIR_1 or PIR_PIR_4 on success
-
< 0 on error
| PIRLIB2SHARED_EXPORT int pir_version |
( |
const char * |
serial | ) |
|
Returns the firmware version of the attached PIR.
- Parameters
-
| serial | serial number of the PIR-1 to query. |
- Returns
- version of firmware on success (>0)
-
< 0 on error.