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

108 lines
4.1 KiB
Markdown
Raw Normal View History

2021-01-29 06:31:58 -05:00
[![Arduino CI](https://github.com/RobTillaart/PulsePattern/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
2021-12-24 09:10:06 -05:00
[![Arduino-lint](https://github.com/RobTillaart/PulsePattern/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/PulsePattern/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/PulsePattern/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/PulsePattern/actions/workflows/jsoncheck.yml)
2023-11-16 14:04:07 -05:00
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/PulsePattern.svg)](https://github.com/RobTillaart/PulsePattern/issues)
2021-01-29 06:31:58 -05:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/PulsePattern/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/PulsePattern.svg?maxAge=3600)](https://github.com/RobTillaart/PulsePattern/releases)
2023-11-16 14:04:07 -05:00
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/PulsePattern.svg)](https://registry.platformio.org/libraries/robtillaart/PulsePattern)
2021-01-29 06:31:58 -05:00
2020-11-27 05:28:57 -05:00
# PulsePattern
2021-12-24 09:10:06 -05:00
Arduino Library to generate repeating pulse patterns **AVR ONLY**.
2020-11-27 05:28:57 -05:00
## Description
This is an **experimental** library to generate pulse patterns by means of an Arduino UNO.
As the library uses **AVR hardware timers** it is definitely **NOT** working for ESP
or other non-AVR processors.
The library uses timer1 for the timing of the pulses.
2021-12-24 09:10:06 -05:00
Therefore the class is implemented with a static instance called PPO.
Still by calling **init()** one can change all parameters of the process.
One should note that calling **init()** forces the timer to stop.
2020-11-27 05:28:57 -05:00
The timer code is based upon the website of Nick Gammon which
holds quite a lot of good solid material (Thanks Nick!).
https://gammon.com.au/forum/bbshowpost.php?bbtopic_id=123
Use with care.
2023-11-16 14:04:07 -05:00
Note: there is no active development.
2021-12-24 09:10:06 -05:00
2020-11-27 05:28:57 -05:00
## Interface
2023-11-16 14:04:07 -05:00
```cpp
#include "PulsePattern.h"
```
2020-11-27 05:28:57 -05:00
- **PulsePattern()** constructor
2021-12-24 09:10:06 -05:00
- **void init(uint8_t pin, uint16_t\*ar, uint8_t size, luint8_t evel, uint8_t prescaler)** initializer of the Timer1
2021-01-29 06:31:58 -05:00
- pin that outputs the pattern
- array of durations
- size (or part) of the array to be used
- starting level HIGH/LOW
2023-11-16 14:04:07 -05:00
- pre-scaler, one of the 5 defines from .h file (table below)
2021-12-24 09:10:06 -05:00
- **void setFactor(float perc)** percentage = factor to correct timing (relative).
- **float getFactor()** get the internal used factor. Due to rounding it can be slightly different.
- **void stop()** stop the pattern generator
2022-03-11 04:36:49 -05:00
- **void start(uint32_t times = PP_CONTINUOUS)** start the pattern generator.
Default in the continuous mode to be backwards compatible.
2023-11-16 14:04:07 -05:00
**PP_CONTINUOUS** == 0xFFFFFFFF, so times should be less than 4294967295.
For convenience there is a **PP_ONCE** == 1 defined.
2021-12-24 09:10:06 -05:00
- **void cont()** continue the pattern generator from the last stopped place (approx).
- **bool isRunning()** status indicator
- **void worker()** must be public otherwise the ISR cannot call it.
2021-01-29 06:31:58 -05:00
2020-11-27 05:28:57 -05:00
There is some bad understood __vector_11() error when worker() is private.
2021-12-24 09:10:06 -05:00
2023-11-16 14:04:07 -05:00
## Pre-scaler constants
2020-11-27 05:28:57 -05:00
2023-11-16 14:04:07 -05:00
| Value | Prescaler | Timer1 | Notes |
|:-------:|:----- -----------|:-------------|:------------:|
| 0 | NO_CLOCK | timer off |
| 1 | PRESCALE_1 | clk / 1 |
| 2 | PRESCALE_8 | clk / 8 |
| 3 | PRESCALE_64 | clk / 64 |
| 4 | PRESCALE_256 | clk / 250 |
| 5 | PRESCALE_1024 | clk / 1024 | about 1 ms / pulse
| 6 | EXT_T1_FALLING | T1 = pin 5 | not tested
| 7 | EXT_T2_RISING | | not tested
2021-12-24 09:10:06 -05:00
# Operation
See examples.
2020-11-27 05:28:57 -05:00
2021-01-29 06:31:58 -05:00
## Future
2023-11-16 14:04:07 -05:00
#### Must
#### Should
#### Could
2021-12-24 09:10:06 -05:00
- ESP32 variant of this class (base class -> AVR -> ESP class)
2021-01-29 06:31:58 -05:00
- pulse recorder class to record / generate patterns
2022-03-11 04:36:49 -05:00
- add interval between patterns?
- or is this just LOW/HIGH for a certain time.
2021-01-29 06:31:58 -05:00
if time permits ...
2023-11-16 14:04:07 -05:00
#### Wont
## 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,