Serial Wombat Arduino Library

Loading...
Searching...
No Matches
SerialWombatQueuedPulseOutput.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"
30
31
34
57
58 class SerialWombatQueuedPulseOutput : public SerialWombatPin
59{
60 public:
65 SerialWombatQueuedPulseOutput(SerialWombatChip &sw):SerialWombatPin(sw){}
66
75 */
76 int16_t begin(uint8_t pin, bool initialState = 0, bool idleState = 0, bool unitsMs = 0, uint16_t QueueIndex = 0xFFFF)
77 {
78 _pin = pin;
79 _pinMode = PIN_MODE_QUEUED_PULSE_OUTPUT;
80 return (initPacketNoResponse(0,(uint8_t) initialState, idleState,unitsMs,SW_LE16(QueueIndex)));
81 }
82
88 */
89 int16_t queuePulses(uint16_t firstPulse, uint16_t secondPulse = 0)
90 {
91 uint8_t tx[] =
92 {
93 (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE1,
94 _pin,
95 _pinMode,
96 SW_LE16(firstPulse),
97 SW_LE16(secondPulse),
98 0x55
99 };
100 uint8_t rx[8];
101 int16_t result = _sw.sendPacket(tx, rx);
102 if (result < 0)
103 {
104 return (result);
105 }
106 else
107 {
108 return (rx[3]);
109 }
110 }
111
116 */
117 int16_t pause(bool paused)
118 {
119 return (initPacketNoResponse(2,(uint8_t) paused));
120 }
121};
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:41
SerialWombatCommands::CONFIGURE_PIN_MODE1
@ CONFIGURE_PIN_MODE1
(201)
Definition SerialWombat.h:229
PIN_MODE_QUEUED_PULSE_OUTPUT
@ PIN_MODE_QUEUED_PULSE_OUTPUT
(34)
Definition SerialWombat.h:282
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition SerialWombat.h:297
SerialWombatPin::_sw
SerialWombatChip & _sw
Definition SerialWombatPin.h:194
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:193
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:195
SerialWombatQueuedPulseOutput::SerialWombatQueuedPulseOutput
SerialWombatQueuedPulseOutput(SerialWombatChip &sw)
Class constructor for SerialWombatQueuedPulseOutput pin mode.
Definition SerialWombatQueuedPulseOutput.h:65
SerialWombatQueuedPulseOutput::queuePulses
int16_t queuePulses(uint16_t firstPulse, uint16_t secondPulse=0)
Add a pulse or two pulses to the queue /.
Definition SerialWombatQueuedPulseOutput.h:89
SerialWombatQueuedPulseOutput::pause
int16_t pause(bool paused)
Pause or unpause the generation of new pulses /.
Definition SerialWombatQueuedPulseOutput.h:117
SerialWombatQueuedPulseOutput::begin
int16_t begin(uint8_t pin, bool initialState=0, bool idleState=0, bool unitsMs=0, uint16_t QueueIndex=0xFFFF)
Initialize a queued pulse output mode /.
Definition SerialWombatQueuedPulseOutput.h:76