mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.7 PulsePattern
This commit is contained in:
parent
23770b49b4
commit
200362dcf3
@ -6,11 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.7] - 2023-11-16
|
||||
- update readme.md
|
||||
|
||||
|
||||
## [0.1.6] - 2022-11-22
|
||||
- add changelog.md
|
||||
- add RP2040 to build-CI (commented as non AVR is not supported yet)
|
||||
|
||||
|
||||
## [0.1.5] - 2022-03-10
|
||||
- add times to start(), 0 = continuous mode
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
//
|
||||
// FILE: PulsePattern.cpp
|
||||
// AUTHOR: Rob dot Tillaart at gmail dot com
|
||||
// VERSION: 0.1.6
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.7
|
||||
// DATE: 2012-11-23
|
||||
// PURPOSE: Arduino Library to generate repeating pulse patterns
|
||||
//
|
||||
|
||||
|
||||
#include "PulsePattern.h"
|
||||
@ -48,8 +47,8 @@ const uint8_t level, const uint8_t prescaler)
|
||||
digitalWrite(_pin, _level);
|
||||
_state = STOPPED;
|
||||
|
||||
// fast low level AVR ports
|
||||
uint8_t _pinport = digitalPinToPort(_pin);
|
||||
// fast low level AVR ports
|
||||
uint8_t _pinport = digitalPinToPort(_pin);
|
||||
_pinout = portOutputRegister(_pinport);
|
||||
_pinbit = digitalPinToBitMask(_pin);
|
||||
}
|
||||
@ -124,7 +123,7 @@ void PulsePattern::worker()
|
||||
// TIMER code based upon - http://www.gammon.com.au/forum/?id=11504
|
||||
void PulsePattern::stopTimer()
|
||||
{
|
||||
TCCR1A = 0; // reset timer 1
|
||||
TCCR1A = 0; // reset timer 1
|
||||
TCCR1B = 0;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
//
|
||||
// FILE: PulsePattern.h
|
||||
// AUTHOR: Rob dot Tillaart at gmail dot com
|
||||
// VERSION: 0.1.6
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.7
|
||||
// DATE: 2012-11-23
|
||||
// PURPOSE: Arduino Library to generate repeating pulse patterns
|
||||
// sends a pulse pattern to a digital pin (continuously)
|
||||
@ -17,7 +17,7 @@
|
||||
#include "Arduino.h"
|
||||
|
||||
|
||||
#define PULSEPATTERN_LIB_VERSION (F("0.1.6"))
|
||||
#define PULSEPATTERN_LIB_VERSION (F("0.1.7"))
|
||||
|
||||
// RUNNING STATES
|
||||
#define NOTINIT -1
|
||||
|
@ -2,8 +2,11 @@
|
||||
[![Arduino CI](https://github.com/RobTillaart/PulsePattern/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![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)
|
||||
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/PulsePattern.svg)](https://github.com/RobTillaart/PulsePattern/issues)
|
||||
|
||||
[![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)
|
||||
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/PulsePattern.svg)](https://registry.platformio.org/libraries/robtillaart/PulsePattern)
|
||||
|
||||
|
||||
# PulsePattern
|
||||
@ -28,24 +31,29 @@ https://gammon.com.au/forum/bbshowpost.php?bbtopic_id=123
|
||||
|
||||
Use with care.
|
||||
|
||||
(there is no active development)
|
||||
Note: there is no active development.
|
||||
|
||||
|
||||
## Interface
|
||||
|
||||
```cpp
|
||||
#include "PulsePattern.h"
|
||||
```
|
||||
|
||||
- **PulsePattern()** constructor
|
||||
- **void init(uint8_t pin, uint16_t\*ar, uint8_t size, luint8_t evel, uint8_t prescaler)** initializer of the Timer1
|
||||
- pin that outputs the pattern
|
||||
- array of durations
|
||||
- size (or part) of the array to be used
|
||||
- starting level HIGH/LOW
|
||||
- prescaler, one of the 5 defines from .h file (table below)
|
||||
- pre-scaler, one of the 5 defines from .h file (table below)
|
||||
- **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
|
||||
- **void start(uint32_t times = PP_CONTINUOUS)** start the pattern generator.
|
||||
Default in the continuous mode to be backwards compatible.
|
||||
**PP_CONTINUOUS** == 0xFFFFFFFF, so times should be less than 4294967295. For convenience there is a **PP_ONCE** == 1 defined.
|
||||
**PP_CONTINUOUS** == 0xFFFFFFFF, so times should be less than 4294967295.
|
||||
For convenience there is a **PP_ONCE** == 1 defined.
|
||||
- **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.
|
||||
@ -53,18 +61,18 @@ Default in the continuous mode to be backwards compatible.
|
||||
There is some bad understood __vector_11() error when worker() is private.
|
||||
|
||||
|
||||
## Prescaler constants
|
||||
## Pre-scaler constants
|
||||
|
||||
| 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
|
||||
| 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
|
||||
|
||||
|
||||
# Operation
|
||||
@ -74,8 +82,26 @@ See examples.
|
||||
|
||||
## Future
|
||||
|
||||
#### Must
|
||||
|
||||
#### Should
|
||||
|
||||
#### Could
|
||||
|
||||
- ESP32 variant of this class (base class -> AVR -> ESP class)
|
||||
- pulse recorder class to record / generate patterns
|
||||
- add interval between patterns?
|
||||
- or is this just LOW/HIGH for a certain time.
|
||||
if time permits ...
|
||||
|
||||
#### 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,
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/PulsePattern.git"
|
||||
},
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "avr",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=PulsePattern
|
||||
version=0.1.6
|
||||
version=0.1.7
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Library to generate repeating pulse patterns. (AVR only)
|
||||
|
Loading…
Reference in New Issue
Block a user