Serial Wombat Arduino Library

Loading...
Searching...
No Matches
SerialWombatWatchdog.cpp
Go to the documentation of this file.
1#include "SerialWombatWatchdog.h"
2
3 SerialWombatWatchdog::SerialWombatWatchdog(SerialWombatChip& sw):SerialWombatPin(sw)
4{
5}
6
7 void SerialWombatWatchdog::begin(uint8_t pin, SerialWombatPinState_t normalState, SerialWombatPinState_t resetState, uint16_t timeout_mS, bool ResetWombatAfterTimeout)
8{
9 _pin = pin;
10 uint8_t tx[8] = {200,pin,7, (uint8_t)normalState,(uint8_t)resetState,SW_LE16(timeout_mS),ResetWombatAfterTimeout };
11
12 _sw.sendPacket(tx);
13
14 uint8_t tx1[8] = { 201,pin,7,0,0,0,0,0x55 };
15 if (! ResetWombatAfterTimeout)
16 {
17 tx1[5] = 0xFF; // No return to normal
18 tx1[6] = 0xFF;
19 }
20
21 _sw.sendPacket(tx1);
22}
23
24 void SerialWombatWatchdog::updateResetCountdown(uint16_t time_mS)
25{
26 _sw.writePublicData(_pin, time_mS);
27}
SW_LE16
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
Definition SerialWombat.h:41
SerialWombatPinState_t
SerialWombatPinState_t
Definition SerialWombat.h:52
SerialWombatWatchdog.h
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::_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
SerialWombatWatchdog::begin
void begin(uint8_t pin, SerialWombatPinState_t normalState, SerialWombatPinState_t resetState, uint16_t timeout_mS, bool resetWombatAfterTimeout)
Initialize a SerialWombatWatchdog.
Definition SerialWombatWatchdog.cpp:7
SerialWombatWatchdog::updateResetCountdown
void updateResetCountdown(uint16_t time_mS)
Reset the countdown timer to a specified number of mS.
Definition SerialWombatWatchdog.cpp:24
SerialWombatWatchdog::SerialWombatWatchdog
SerialWombatWatchdog(SerialWombatChip &serialWombat)
Constructor for SerialWombatWatchdog.
Definition SerialWombatWatchdog.cpp:3