Serial Wombat Arduino Library

Loading...
Searching...
No Matches
SerialWombatFrequencyOutput.h
Go to the documentation of this file.
1#pragma once
2/*
3 Copyright 2024 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"
32
33
59
60 class SerialWombatFrequencyOutput : public SerialWombatPin
61{
62 public:
67 SerialWombatFrequencyOutput(SerialWombatChip& serialWombat) :SerialWombatPin(serialWombat) {}
68
76 int16_t begin(uint8_t pin, uint16_t maxFrequency_Hz = 65535, bool lowFrequency = false, uint16_t dutyCycle = 0x8000)
77 {
78 _pin = pin;
79 _pinMode = (uint8_t)PIN_MODE_FREQUENCY_OUTPUT;
80 return initPacketNoResponse(0, SW_LE16(dutyCycle), SW_LE16( maxFrequency_Hz),(uint8_t)lowFrequency);
81 }
82
83
84 private:
85};
86
87
88
90 class SerialWombatFrequencyOutput_18AB: public SerialWombatFrequencyOutput, public SerialWombatAbstractScaledOutput
91{
92 public:
93 SerialWombatFrequencyOutput_18AB(SerialWombatChip& serialWombat) :SerialWombatFrequencyOutput(serialWombat), SerialWombatAbstractScaledOutput(serialWombat)
94 {}
95
96
101 uint8_t pin()
102{
103 return SerialWombatPin::_pin;
104}
105
109 uint8_t swPinModeNumber()
110 {
111 return SerialWombatPin::_pinMode;
112 }
113};
114
SerialWombat.h
SW_LE16
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
Definition SerialWombat.h:43
PIN_MODE_FREQUENCY_OUTPUT
@ PIN_MODE_FREQUENCY_OUTPUT
(36)
Definition SerialWombat.h:285
SerialWombatAbstractScaledOutput::SerialWombatAbstractScaledOutput
SerialWombatAbstractScaledOutput(SerialWombatChip &sw)
Constructor for the SerialWombatAbstractScaledOutput Class.
Definition SerialWombatAbstractScaledOutput.h:70
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition SerialWombat.h:300
SerialWombatFrequencyOutput_18AB::SerialWombatFrequencyOutput_18AB
SerialWombatFrequencyOutput_18AB(SerialWombatChip &serialWombat)
Definition SerialWombatFrequencyOutput.h:93
SerialWombatFrequencyOutput_18AB::swPinModeNumber
uint8_t swPinModeNumber()
fulfills a virtual function requirement of SerialWombatAbstractScaledOutput
Definition SerialWombatFrequencyOutput.h:109
SerialWombatFrequencyOutput_18AB::pin
uint8_t pin()
fulfills a virtual function requirement of SerialWombatAbstractScaledOutput
Definition SerialWombatFrequencyOutput.h:101
SerialWombatFrequencyOutput::begin
int16_t begin(uint8_t pin, uint16_t maxFrequency_Hz=65535, bool lowFrequency=false, uint16_t dutyCycle=0x8000)
Initialize a pin that has been declared as FrequencyOutput.
Definition SerialWombatFrequencyOutput.h:76
SerialWombatFrequencyOutput::SerialWombatFrequencyOutput
SerialWombatFrequencyOutput(SerialWombatChip &serialWombat)
Constructor for SerialWombatFrequencyOutput class.
Definition SerialWombatFrequencyOutput.h:67
SerialWombatPin::SerialWombatPin
SerialWombatPin(SerialWombatChip &serialWombatChip)
Instantiates a Serial Wombat Pin.
Definition SerialWombatPin.h:45
SerialWombatPin::initPacketNoResponse
int16_t initPacketNoResponse(uint8_t packetNumber, uint8_t param0=0x55, uint8_t param1=0x55, uint8_t param2=0x55, uint8_t param3=0x55, uint8_t param4=0x55)
Definition SerialWombatPin.h:131
SerialWombatPin::_pin
uint8_t _pin
Definition SerialWombatPin.h:205
SerialWombatPin::pin
uint8_t pin()
Returns the current SW pin number. Used primarily for virtual calls by derived classes.
Definition SerialWombatPin.h:121
SerialWombatPin::_pinMode
uint8_t _pinMode
Definition SerialWombatPin.h:207