Serial Wombat Arduino Library
SerialWombatPin.h
Go to the documentation of this file.
1 #pragma once
2 /*
3 Copyright 2023 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 
39 {
40 public:
45  SerialWombatPin(SerialWombatChip& serialWombatChip): _sw(serialWombatChip)
46  {
47  }
48 
54  SerialWombatPin(SerialWombatChip& serialWombatChip, uint8_t pin): _sw(serialWombatChip)
55  {
56  _pin = pin;
57  }
58 
65  uint16_t readPublicData()
66  {
67  return _sw.readPublicData(_pin);
68  };
69 
70 
79  void pinMode(uint8_t mode, bool pullDown = false, bool openDrain = false)
80  {
81  _sw.pinMode(_pin, mode, pullDown, openDrain);
82  }
83 
92  void digitalWrite(uint8_t val)
93  {
94  _sw.digitalWrite(_pin, val);
95  }
96 
105  {
106  return (_sw.digitalRead(_pin));
107  }
108 
109 
114  uint16_t writePublicData(uint16_t value)
115  { return _sw.writePublicData(_pin, value); }
116 
121  uint8_t pin() {return _pin;}
122 
127  uint8_t swPinModeNumber() { return _pinMode; }
128 
129 
130 
131 
132 protected:
133  uint8_t _pin = 255;
135  uint8_t _pinMode = 0;
136 
137 };
138 
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition: SerialWombat.h:286
SerialWombatChip::digitalRead
int digitalRead(uint8_t pin)
Reads the state of a Pin.
Definition: SerialWombat.h:806
SerialWombatPin::SerialWombatPin
SerialWombatPin(SerialWombatChip &serialWombatChip)
Instantiates a Serial Wombat Pin.
Definition: SerialWombatPin.h:45
SerialWombatPin::swPinModeNumber
uint8_t swPinModeNumber()
Returns the Mode number. Used primarily by derived classes to populate packet data.
Definition: SerialWombatPin.h:127
SerialWombatPin::_sw
SerialWombatChip & _sw
Definition: SerialWombatPin.h:134
SerialWombatPin::writePublicData
uint16_t writePublicData(uint16_t value)
Write a 16 bit value to this pin.
Definition: SerialWombatPin.h:114
SerialWombatChip::pinMode
void pinMode(uint8_t pin, uint8_t mode, bool pullDown=false, bool openDrain=false)
Set a pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings.
Definition: SerialWombat.h:777
SerialWombatPin::digitalRead
int digitalRead()
Reads the state of the Pin.
Definition: SerialWombatPin.h:104
SerialWombatChip::digitalWrite
void digitalWrite(uint8_t pin, uint8_t val)
Set an output pin High or Low.
Definition: SerialWombat.h:796
SerialWombatPin::SerialWombatPin
SerialWombatPin(SerialWombatChip &serialWombatChip, uint8_t pin)
Instantiates a Serial Wombat Pin.
Definition: SerialWombatPin.h:54
SerialWombatChip::readPublicData
uint16_t readPublicData(uint8_t pin)
Read the 16 Bit public data associated with a Serial Wombat Pin Mode.
Definition: SerialWombat.h:661
SerialWombatPin
Describes a Serial Wombat Pin. Is base class for other pin modes.
Definition: SerialWombatPin.h:38
SerialWombatPin::_pinMode
uint8_t _pinMode
Definition: SerialWombatPin.h:135
SerialWombatPin::readPublicData
uint16_t readPublicData()
Read the 16 Bit public data associated with this pin.
Definition: SerialWombatPin.h:65
SerialWombatChip::writePublicData
uint16_t writePublicData(uint8_t pin, uint16_t value)
Write a 16 bit value to a Serial Wombat pin Mode.
Definition: SerialWombat.h:688
SerialWombatPin::pin
uint8_t pin()
Returns the current SW pin number. Used primarily for virtual calls by derived classes.
Definition: SerialWombatPin.h:121
SerialWombatPin::_pin
uint8_t _pin
Definition: SerialWombatPin.h:133
SerialWombatPin::digitalWrite
void digitalWrite(uint8_t val)
Set output pin High or Low.
Definition: SerialWombatPin.h:92
SerialWombatPin::pinMode
void pinMode(uint8_t mode, bool pullDown=false, bool openDrain=false)
Set pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings.
Definition: SerialWombatPin.h:79