Serial Wombat Arduino Library
SerialWombatPulseTimer.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 Copyright 2020-2021 Broadwell Consulting Inc.
4 
5 "Serial Wombat" is a registered trademark of Broadwell Consulting Inc. in
6 the United States. See SerialWombat.com for usage guidance.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  * OTHER DEALINGS IN THE SOFTWARE.
25 */
26 
27 
28 #include <stdint.h>
29 #include "SerialWombat.h"
30 
31 class SerialWombat;
32 
35 typedef enum
36 {
40 
83 {
84 public:
88 
89 
95  void begin(uint8_t pin, SerialWombatPulseTimerUnits units = SW_PULSETIMER_uS, bool pullUpEnabled = false);
96 
100  void refresh();
101 
107 
113 
117  uint16_t readHighCounts();
118 
119 
123  uint16_t readLowCounts();
124 
131  uint16_t readPulses();
132 
136  uint16_t HighCounts = 0;
140  uint16_t LowCounts = 0;
141 
145  uint16_t Pulses = 0;
147 
148 
149 
150 
151 private:
152 
153 };
154 
159 
161 {
162 public:
164  HIGH_TIME = 0,
165  LOW_TIME = 1,
173  };
174 
178 
187 
189  uint8_t pin() { return _pin; }
191  uint8_t swPinModeNumber() { return _pinMode; }
192 };
SerialWombatPulseTimer_18AB::DUTYCYCLE_ON_LTH_TRANSITION
@ DUTYCYCLE_ON_LTH_TRANSITION
Duty cycle of the pulse as a ratio from 0 to 65535, updated on low to high transition.
Definition: SerialWombatPulseTimer.h:171
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition: SerialWombat.h:272
SerialWombatPulseTimer::readPulses
uint16_t readPulses()
Retreives the number of pulses.
Definition: SerialWombatPulseTimer.cpp:61
SerialWombatPulseTimer::HighCounts
uint16_t HighCounts
Count in selected units of last retreived high pulse.
Definition: SerialWombatPulseTimer.h:136
SerialWombatPulseTimer_18AB::HIGH_TIME
@ HIGH_TIME
The pulse high time in uS. Updated on each high to low transition.
Definition: SerialWombatPulseTimer.h:164
SerialWombatPulseTimer::MeasurementOverflowOccurred
bool MeasurementOverflowOccurred
Definition: SerialWombatPulseTimer.h:146
SerialWombatPulseTimer_18AB::FREQUENCY_ON_HTL_TRANSITION
@ FREQUENCY_ON_HTL_TRANSITION
The frequency of the pulse in Hz, based on the previous high and low times, updated on high to low tr...
Definition: SerialWombatPulseTimer.h:170
SerialWombatPulseTimer_18AB::pin
uint8_t pin()
Facilitates multi-inheritance.
Definition: SerialWombatPulseTimer.h:189
SerialWombatPulseTimer::readLowCounts
uint16_t readLowCounts()
Retreives the most recent Counts in the configured units for the most recent low pulse.
Definition: SerialWombatPulseTimer.cpp:55
SerialWombatPulseTimer::readHighCounts
uint16_t readHighCounts()
Retreives the most recent Counts in the configured units for the most recent high pulse.
Definition: SerialWombatPulseTimer.cpp:49
SerialWombatPulseTimerUnits
SerialWombatPulseTimerUnits
Definition: SerialWombatPulseTimer.h:35
SerialWombat.h
SerialWombatPin
Describes a Serial Wombat Pin. Is base class for other pin modes.
Definition: SerialWombat.h:799
SerialWombatPulseTimer_18AB
extends the SerialWombatPulseTimer class with SW18AB specific functionality
Definition: SerialWombatPulseTimer.h:160
SerialWombatPin::_pinMode
uint8_t _pinMode
Definition: SerialWombat.h:873
SerialWombatPulseTimer
A Class which uses a Serial Wombat pin to measure the length of a pulse high and low time.
Definition: SerialWombatPulseTimer.h:82
SerialWombatPulseTimer_18AB::PERIOD_ON_LTH_TRANSITION
@ PERIOD_ON_LTH_TRANSITION
The period of the pulse in uS, based on the previous high and low times, updated on low to high trans...
Definition: SerialWombatPulseTimer.h:167
SerialWombatPulseTimer_18AB::swPinModeNumber
uint8_t swPinModeNumber()
Facilitates multi-inheritance.
Definition: SerialWombatPulseTimer.h:191
SW_PULSETIMER_uS
@ SW_PULSETIMER_uS
Definition: SerialWombatPulseTimer.h:37
SerialWombatPulseTimer::LowCounts
uint16_t LowCounts
Count in selected units of last retreived low pulse.
Definition: SerialWombatPulseTimer.h:140
SerialWombatPulseTimer::refreshHighCountsPulses
void refreshHighCountsPulses()
Retreive the High counts and number of pulses Serial Wombat chip in a single transaction.
Definition: SerialWombatPulseTimer.cpp:39
SerialWombatPulseTimer::refresh
void refresh()
Retreive the latest values for HighCounts, LowCounts, Pulses, and MeasurementOverflowOccured.
Definition: SerialWombatPulseTimer.cpp:18
SerialWombatPulseTimer_18AB::SerialWombatPulseTimer_18AB
SerialWombatPulseTimer_18AB(SerialWombatChip &serialWombat)
constructor for SerialWombatPulseTimer_18AB
Definition: SerialWombatPulseTimer.cpp:74
SW_PULSETIMER_mS
@ SW_PULSETIMER_mS
Definition: SerialWombatPulseTimer.h:38
SerialWombatPin::pin
uint8_t pin()
Returns the current SW pin number. Used primarily for virtual calls by derived classes.
Definition: SerialWombat.h:861
SerialWombat
This class name is depricated. Do not use for new development. Use SerialWombatChip instead.
Definition: SerialWombat.h:782
SerialWombatAbstractProcessedInput
SerialWombatAnalogInput, SerialWombatPulseTimer, SerialWombatResistanceInput and others inherit from ...
Definition: SerialWombatAbstractProcessedInput.h:79
SerialWombatPulseTimer_18AB::LOW_TIME
@ LOW_TIME
the pulse low time in uS. Update on each low to high transition.
Definition: SerialWombatPulseTimer.h:165
SerialWombatPulseTimer_18AB::DUTYCYCLE_ON_HTL_TRANSITION
@ DUTYCYCLE_ON_HTL_TRANSITION
Duty cycle of the pulse as a ratio from 0 to 65535, updated on high to low transition.
Definition: SerialWombatPulseTimer.h:172
SerialWombatPin::_pin
uint8_t _pin
Definition: SerialWombat.h:871
SerialWombatPulseTimer::refreshHighCountsLowCounts
void refreshHighCountsLowCounts()
Retreive the High and Low counts from the Serial Wombat chip in a single transaction.
Definition: SerialWombatPulseTimer.cpp:30
SerialWombatPulseTimer_18AB::FREQUENCY_ON_LTH_TRANSITION
@ FREQUENCY_ON_LTH_TRANSITION
The frequency of the pulse in Hz, based on the previous high and low times, updated on low to high tr...
Definition: SerialWombatPulseTimer.h:169
SerialWombatPulseTimer::begin
void begin(uint8_t pin, SerialWombatPulseTimerUnits units=SW_PULSETIMER_uS, bool pullUpEnabled=false)
Initialization routine for SerialWombatPulseTimer.
Definition: SerialWombatPulseTimer.cpp:9
SerialWombatPulseTimer_18AB::PERIOD_ON_HTL_TRANSITION
@ PERIOD_ON_HTL_TRANSITION
The period of the pulse in uS, based on the previous high and low times, updated on high to low trans...
Definition: SerialWombatPulseTimer.h:168
SerialWombatPulseTimer::SerialWombatPulseTimer
SerialWombatPulseTimer(SerialWombatChip &serialWombat)
Class constructor for SerialWombatPulseTimer.
Definition: SerialWombatPulseTimer.cpp:3
SerialWombatPulseTimer_18AB::configurePublicDataOutput
int16_t configurePublicDataOutput(SerialWombatPulseTimer_18AB::publicDataOutput publicDataOutput)
configures which measurement is the Public Data Output of this pin mode
Definition: SerialWombatPulseTimer.cpp:68
SerialWombatPulseTimer_18AB::publicDataOutput
publicDataOutput
Definition: SerialWombatPulseTimer.h:163
SerialWombatPulseTimer::Pulses
uint16_t Pulses
Count of last retreived pulses.
Definition: SerialWombatPulseTimer.h:145
SerialWombatPulseTimer_18AB::PULSE_COUNT
@ PULSE_COUNT
The number of pulses that have occured since initialization. Updated on each high to low transition.
Definition: SerialWombatPulseTimer.h:166