PIR Library  2
 All Classes Files Functions Variables Typedefs Macros Pages
pirlib2.h
Go to the documentation of this file.
1 /*
2 
3 PIR-1/PIR-4 Driver v2
4 
5 Copyright (c) 2014, Promixis, LLC
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or
9 without modification, are permitted provided that the
10 following conditions are met:
11 
12 1. Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the following
14 disclaimer.
15 
16 2. Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials
19 provided with the distribution.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 
36 */
37 
233 #ifndef PIRLIB2_H
234 #define PIRLIB2_H
235 
236 #include "pirlib2_global.h"
237 
238 #ifdef __cplusplus
239 extern "C" {
240 #endif
241 
249 #define PIR_ARRIVED_STATUS 1
250 #define PIR_REMOVED_STATUS 2
251 
252 
267 typedef void (*fStatusCB) ( const char * serial, unsigned char status, void * userData);
268 
279 typedef void (*fIrReceivedCB) ( const char * serial, const unsigned int * pulses, unsigned int pulseCount, void * userData);
280 
287 typedef void (*fIrSentCB) ( const char * serial, unsigned char status, void * userData );
288 
289 
298 typedef void (*fIrRawLearnCB) ( const char * serial, unsigned int modulation, const unsigned int * pulses, unsigned int pulseCount, void * userData );
299 
300 
313 #define PIR_BUTTON_IDLE 0
314 #define PIR_BUTTON_DOWN 1
315 #define PIR_BUTTON_REPEAT 2
316 #define PIR_BUTTON_UP 3
317 
329 typedef void (*fButtonCB) ( const char * serial, int button1, int button2, int button3, int button4, void * userData );
330 
334 typedef struct {
336  int size;
347  void * unused;
349  void * userData;
350 } PIR_Settings;
351 
372 PIRLIB2SHARED_EXPORT int pir_open( PIR_Settings * settings );
373 
378 PIRLIB2SHARED_EXPORT int pir_close();
379 
380 
398 PIRLIB2SHARED_EXPORT int pir_sendCCF ( const char * serial, const char * ccf, int bitmask, unsigned char repeats ) ;
399 
408 PIRLIB2SHARED_EXPORT unsigned int pir_list1 ( char * buffer, unsigned int size );
409 
410 
419 PIRLIB2SHARED_EXPORT unsigned int pir_list4 ( char * buffer, unsigned int size );
420 
427 PIRLIB2SHARED_EXPORT int pir_version ( const char * serial );
428 
429 
437 PIRLIB2SHARED_EXPORT int pir_blink( const char * serial, unsigned char count );
438 
445 #define PIR_PIR_1 1
446 #define PIR_PIR_4 4
447 
448 
449 
456 PIRLIB2SHARED_EXPORT int pir_type( const char * serial );
457 
458 
467 PIRLIB2SHARED_EXPORT int pir_detect( );
468 
469 
477 PIRLIB2SHARED_EXPORT int pir_learn( const char * serial );
478 
486 PIRLIB2SHARED_EXPORT int pir_cancelLearn( const char * serial );
487 
488 #ifdef __cplusplus
489 }
490 #endif
491 
492 
493 #endif // PIRLIB2_H
PIRLIB2SHARED_EXPORT int pir_cancelLearn(const char *serial)
starts learn mode
Definition: pirlib2.cpp:174
fStatusCB statusCallback
called when an PIR arrives or is removed.
Definition: pirlib2.h:340
PIRLIB2SHARED_EXPORT int pir_blink(const char *serial, unsigned char count)
Blinks the LED on the attached PIR-1.
Definition: pirlib2.cpp:116
fIrReceivedCB receiveCallback
called when an IR signal is recevied in normal mode.
Definition: pirlib2.h:342
PIRLIB2SHARED_EXPORT int pir_close()
Close the library.
Definition: pirlib2.cpp:25
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 ...
Definition: pirlib2.cpp:150
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.
Definition: pirlib2.h:298
int size
fill with sizeof(PIR_Settings)
Definition: pirlib2.h:336
fIrSentCB sendCallback
called when IR signal is done sending.
Definition: pirlib2.h:338
PIRLIB2SHARED_EXPORT unsigned int pir_list1(char *buffer, unsigned int size)
Get a comma separated list of PIR-1 serial numbers.
Definition: pirlib2.cpp:49
void(* fButtonCB)(const char *serial, int button1, int button2, int button3, int button4, void *userData)
fButtonCB is called on a button event.
Definition: pirlib2.h:329
void(* fStatusCB)(const char *serial, unsigned char status, void *userData)
Callback called when the status of the PIR-1 driver is affected.
Definition: pirlib2.h:267
PIRLIB2SHARED_EXPORT unsigned int pir_list4(char *buffer, unsigned int size)
Get a comma separated list of PIR-4 serial numbers.
Definition: pirlib2.cpp:74
void * userData
data needed by caller of pir library, passed by into all callbacks.
Definition: pirlib2.h:349
PIRLIB2SHARED_EXPORT int pir_version(const char *serial)
Returns the firmware version of the attached PIR.
Definition: pirlib2.cpp:99
PIRLIB2SHARED_EXPORT int pir_open(PIR_Settings *settings)
Opens the PIR Library. This must be called only once.
Definition: pirlib2.cpp:10
fButtonCB buttonCallback
called when a button is pressed on a PIR-1.
Definition: pirlib2.h:344
the Settings structure.
Definition: pirlib2.h:334
void(* fIrSentCB)(const char *serial, unsigned char status, void *userData)
fIrSentCB is called when an IR code was sent.
Definition: pirlib2.h:287
fIrRawLearnCB rawLearnCallback
called when an IR signal is received in learn mode.
Definition: pirlib2.h:346
PIRLIB2SHARED_EXPORT int pir_sendCCF(const char *serial, const char *ccf, int bitmask, unsigned char repeats)
Transmit a CCF code.
Definition: pirlib2.cpp:38
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.
Definition: pirlib2.h:279
PIRLIB2SHARED_EXPORT int pir_learn(const char *serial)
starts learn mode
Definition: pirlib2.cpp:162
PIRLIB2SHARED_EXPORT int pir_type(const char *serial)
Returns the type.
Definition: pirlib2.cpp:133