GY-63_MS5611/libraries/PIR/README.md

101 lines
3.2 KiB
Markdown
Raw Normal View History

2022-12-14 13:17:10 -05:00
[![Arduino CI](https://github.com/RobTillaart/PIR/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/PIR/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/PIR/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/PIR/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/PIR/actions/workflows/jsoncheck.yml)
2023-11-15 05:53:10 -05:00
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/PIR.svg)](https://github.com/RobTillaart/PIR/issues)
2022-12-14 13:17:10 -05:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/PIR/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/PIR.svg?maxAge=3600)](https://github.com/RobTillaart/PIR/releases)
2023-11-15 05:53:10 -05:00
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/PIR.svg)](https://registry.platformio.org/libraries/robtillaart/PIR)
2022-12-14 13:17:10 -05:00
# PIR
PIR library for Arduino. Supports up to 8 PIR sensors.
## Description
2022-12-16 11:17:36 -05:00
The PIR library implements a class to monitor 1 or more PIR sensors.
2022-12-14 13:17:10 -05:00
The library supports up to 8 PIR sensors per object, which typically are added in **setup()**.
2022-12-16 11:17:36 -05:00
It is possible to add a sensor (pin) multiple times.
2022-12-14 13:17:10 -05:00
The library accepts duplicates.
2022-12-16 11:17:36 -05:00
The library has two **read()** functions, one to read a specific sensor, and one to read all of them.
2022-12-14 13:17:10 -05:00
The latter will return a mask indicating HIGH and LOW.
The first added PIR will have the LSB.
Instead of PIR sensors one can add other DigitalOut sensors or even switches.
## Interface
2023-11-15 05:53:10 -05:00
```cpp
#include "PIR.h"
```
2022-12-14 13:17:10 -05:00
#### Base
2022-12-16 11:17:36 -05:00
- **PIR()** constructor. Allocated room for 8 PIRs.
2022-12-14 13:17:10 -05:00
- **uint8_t add(uint8_t pin)** adds a PIR pin to the set of pins.
Returns the index or PIR_ARRAY_FULL (0xFE)
- **uint8_t count** returns number of PIR sensors added.
2022-12-16 11:17:36 -05:00
2022-12-14 13:17:10 -05:00
#### Read
- **uint8_t read()** read all PIR sensors in the set.
2022-12-16 11:17:36 -05:00
Returns a bit mask of HIGH / LOW values.
2022-12-14 13:17:10 -05:00
Not used slots will return 0.
- **uint8_t read(uint8_t index)** read a specific PIR sensor.
Faster than read() above.
2023-11-15 05:53:10 -05:00
Does not affect **lastValue()**
2022-12-16 11:17:36 -05:00
- **uint8_t lastValue()** returns last values read (bit mask) with read().
- **uint8_t changed()** returns bit mask of pins that changed since last read().
This can improve processing in some cases.
2022-12-14 13:17:10 -05:00
## Future
#### Must
2023-11-15 05:53:10 -05:00
2022-12-14 13:17:10 -05:00
- update documentation
#### Should
2023-11-15 05:53:10 -05:00
2022-12-14 13:17:10 -05:00
- add examples
- interrupts?
#### Could
2023-11-15 05:53:10 -05:00
2022-12-14 13:17:10 -05:00
- investigate PIR16 PIR32 class that can hold more
- think MEGA2560.
2022-12-16 11:17:36 -05:00
- or dynamic allocation? 0.2.0
- one lastRead for all?
- **uint8_t pin(uint8_t index)** to get back configuration
- **bool add(uint8_t array, length)** faster configuration. Return true if there was enough room.
- **clear()** to reset whole object?
#### Wont
2023-11-15 05:53:10 -05:00
2022-12-16 11:17:36 -05:00
- PIR class based upon a PCF8574?
- separate class
- timestamp per PIR
- lastRead, lastTriggered?
- taking "a lot of RAM" for every pin
2022-12-14 13:17:10 -05:00
- add statistics?
2023-02-03 12:56:26 -05:00
- nr of calls - high% - low%
2022-12-14 13:17:10 -05:00
- duration
2022-12-16 11:17:36 -05:00
- investigate noise (what noise)
- **remove(pin)**
- difficult, more admin, expectations...
2022-12-14 13:17:10 -05:00
2023-11-15 05:53:10 -05:00
## Support
If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.
Thank you,