Serial Wombat Arduino Library
SerialWombatQuadEnc.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 Copyright 2020-2021 Broadwell Consulting Inc.
5 
6 "Serial Wombat" is a registered trademark of Broadwell Consulting Inc. in
7 the United States. See SerialWombat.com for usage guidance.
8 
9 Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26 */
27 
28 #include <stdint.h>
29 #include "SerialWombat.h"
30 
31 
35 typedef enum
36 {
44 
45 
46 
105 {
106 public:
107 
110  SerialWombatQuadEnc(SerialWombatChip& serialWombatChip);
111 
119  void begin(uint8_t pin, uint8_t secondPin);
120 
129  void begin(uint8_t pin, uint8_t secondPin, uint16_t debounce_mS, bool pullUpsEnabled);
130 
139  void begin(uint8_t pin, uint8_t secondPin, uint16_t debounce_mS, bool pullUpsEnabled, QE_READ_MODE_t readState);
140 
143  uint16_t read();
144 
152 
153  uint16_t read(uint16_t replacementValue);
154 
157  void write(uint16_t value);
158 private:
159 
160  uint8_t _secondPin;
161 };
162 
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition: SerialWombat.h:272
QE_ONLOW_POLL
@ QE_ONLOW_POLL
1mS Polling, process on high to low transition
Definition: SerialWombatQuadEnc.h:40
SerialWombatQuadEnc::begin
void begin(uint8_t pin, uint8_t secondPin)
Simple initialization for SerialWombatQuadEnc.
Definition: SerialWombatQuadEnc.cpp:8
SerialWombat.h
SerialWombatPin
Describes a Serial Wombat Pin. Is base class for other pin modes.
Definition: SerialWombat.h:799
QE_ONBOTH_POLL
@ QE_ONBOTH_POLL
1mS Polling, process on low to high and high to low transition
Definition: SerialWombatQuadEnc.h:42
QE_ONBOTH_INT
@ QE_ONBOTH_INT
Interrupt driven, process on low to high and high to low transition.
Definition: SerialWombatQuadEnc.h:39
QE_READ_MODE_t
QE_READ_MODE_t
Definition: SerialWombatQuadEnc.h:35
SerialWombatQuadEnc::read
uint16_t read()
Read the quadrature encoder position from the Serial Wombat chip.
Definition: SerialWombatQuadEnc.cpp:27
SerialWombatQuadEnc
A class that uses two Serial Wombat input pins to read quadrature encoder input.
Definition: SerialWombatQuadEnc.h:104
SerialWombatPin::pin
uint8_t pin()
Returns the current SW pin number. Used primarily for virtual calls by derived classes.
Definition: SerialWombat.h:861
QE_ONHIGH_INT
@ QE_ONHIGH_INT
Interrupt driven, process on low to high transition.
Definition: SerialWombatQuadEnc.h:38
QE_ONHIGH_POLL
@ QE_ONHIGH_POLL
1mS Polling, process on low to high transition
Definition: SerialWombatQuadEnc.h:41
QE_ONLOW_INT
@ QE_ONLOW_INT
Interrupt driven, process on high to low transition.
Definition: SerialWombatQuadEnc.h:37
SerialWombatQuadEnc::write
void write(uint16_t value)
This function initializes the position of the encoder.
Definition: SerialWombatQuadEnc.cpp:37
SerialWombatQuadEnc::SerialWombatQuadEnc
SerialWombatQuadEnc(SerialWombatChip &serialWombatChip)
Constructor for the SerialWombatQuadEnc class.
Definition: SerialWombatQuadEnc.cpp:3