Serial Wombat Arduino Library
Loading...
Searching...
No Matches
SerialWombatRandomBlink.h
Go to the documentation of this file.
1#pragma once
2/*
3Copyright 2026 Broadwell Consulting Inc.
4
5"Serial Wombat" is a registered trademark of Broadwell Consulting Inc. in
6the United States. See SerialWombat.com for usage guidance.
7
8Permission 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
15The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17
18THE 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#include <stdint.h>
28#include "SerialWombat.h"
31
61
63{
64public:
71
72
73
88 int16_t begin(uint8_t pin,
89 uint16_t onTimeMax,
90 uint16_t offTimeMax,
91 uint16_t onTimeMin = 0,
92 uint16_t offTimeMin = 0,
93 uint16_t onPWMMin = 0xFFFF,
94 uint16_t onPWMMax = 0xFFFF,
95 uint16_t offPWMMin = 0, uint16_t offPWMMax = 0)
96 {
97 _pin = pin;
99 int16_t result = initPacketNoResponse(0, SW_LE16(onTimeMax), SW_LE16(offTimeMax));
100 if (result < 0)
101 {
102 return result;
103 }
104
105
106 if (onPWMMin != 0xFFFF || onPWMMax != 0xFFFF)
107 {
108 result = initPacketNoResponse(1, SW_LE16(onPWMMin), SW_LE16(onPWMMax));
109 if (result < 0)
110 {
111 return result;
112 }
113 }
114 if (offPWMMin != 0 || offTimeMax != 0)
115 {
116 result = initPacketNoResponse(2, SW_LE16(offPWMMin), SW_LE16(offPWMMax));
117
118 if (result < 0)
119 {
120 return result;
121 }
122 }
123 if (onTimeMin != 0 || offTimeMin != 0)
124 {
125 result = initPacketNoResponse(3, SW_LE16(onTimeMin), SW_LE16(offTimeMin));;
126 }
127 return result;
128 }
129
130
131
132
137 uint8_t pin()
138 {
140 }
141
147 {
149 }
150};
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
@ PIN_MODE_RANDOMBLINK
(42)
SerialWombatAbstractScaledOutput(SerialWombatChip &sw)
Constructor for the SerialWombatAbstractScaledOutput Class.
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
SerialWombatPin(SerialWombatChip &serialWombatChip)
Instantiates a Serial Wombat Pin.
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)