Device driver interface for the PIR motion sensor.  
More...
Device driver interface for the PIR motion sensor. 
|  | 
| file | pir.h | 
|  | Device driver interface for the PIR motion sensor. 
 | 
|  | 
| file | pir_params.h | 
|  | Default configuration for PIR devices. 
 | 
|  | 
◆ anonymous enum
PIR specific return values. 
| Enumerator | 
|---|
| PIR_OK | everything went as expected  | 
| PIR_NOGPIO | errors while initializing the GPIO  | 
| PIR_NOTHREAD | errors while registering the thread  | 
| PIR_TIMEERR | errors while getting the time information  | 
Definition at line 35 of file pir.h.
 
 
◆ pir_event_t
event type for a PIR sensor 
| Enumerator | 
|---|
| PIR_STATUS_ACTIVE | motion was detected  | 
| PIR_STATUS_INACTIVE | no motion is detected  | 
Definition at line 78 of file pir.h.
 
 
◆ pir_get_occupancy()
      
        
          | int pir_get_occupancy | ( | pir_t * | dev, | 
        
          |  |  | int16_t * | occup ) | 
      
 
Read OCCUPANCY value. 
- Parameters
- 
  
    | [in] | dev | device descriptor of the PIR motion sensor to read from |  | [out] | occup | occupancy ratio [in 100 * percentage] The value is renewed when it is read. So it is percentage of occupancy since the last read. |  
 
- Returns
- 0 on success, 
- 
-1 on errors, 
 
 
◆ pir_get_status()
Read the current status of the motion sensor. 
- Parameters
- 
  
    | [in] | dev | device descriptor of the PIR motion sensor to read from |  
 
- Returns
- 1 if motion is detected, 0 otherwise 
 
 
◆ pir_init()
Initialize a PIR motion sensor. 
The PIR motion sensor is interfaced by a single GPIO pin, specified by gpio.
- Note
- The sensor needs up to a minute to settle down before meaningful measurements can be made.
- Parameters
- 
  
    | [out] | dev | device descriptor of an PIR sensor |  | [in] | params | parameters of the PIR sensor |  
 
- Returns
- 0 on success 
- 
-1 on error 
 
 
◆ pir_register_thread()
      
        
          | int pir_register_thread | ( | pir_t * | dev | ) |  | 
      
 
Register a thread for notification when state changes on the motion sensor. 
- Note
- This configures the gpio device for interrupt driven operation.
- Parameters
- 
  
    | [in] | dev | device descriptor of the PIR motion sensor to register for |  
 
- Returns
- 0 on succuess, 
- 
-1 on internal errors, 
- 
-2 if another thread is registered already