Serial Wombat Arduino Library

Loading...
Searching...
No Matches
SerialWombat18ABDataLogger.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#include <stdint.h>
28#include "SerialWombat.h"
29
30
31 enum class DataLoggerPeriod {
32 PERIOD_1024mS = 10,
33 PERIOD_512mS = 9,
34 PERIOD_256mS = 8,
35 PERIOD_128mS = 7,
36 PERIOD_64mS = 6,
37 PERIOD_32mS = 5,
38 PERIOD_16mS = 4,
39 PERIOD_8mS = 3,
40 PERIOD_4mS = 2,
41 PERIOD_2mS = 1,
42 PERIOD_1mS = 0
43};
44
48
49
50 class SerialWombat18ABDataLogger
51{
52 public:
56 */
57 SerialWombat18ABDataLogger(SerialWombatChip& serialWombat):_sw(serialWombat)
58 {
59 _sw = serialWombat;
60 }
61
71 */
72 int16_t begin(uint16_t queueAddress, uint16_t queueSizeBytes, bool queueFrameIndex, bool queueOnChange = false, DataLoggerPeriod period = DataLoggerPeriod::PERIOD_1mS)
73{
74 SerialWombatQueue swq(_sw);
75 int16_t result = swq.begin(queueAddress,queueSizeBytes);
76 if (result < 0) return (result);
77 {
78 uint8_t tx[] = {(uint8_t)SerialWombatCommands::COMMAND_BINARY_CONFIG_DATALOGGER,
79 0, //Initial Config
80 SW_LE16(queueAddress),
81 (uint8_t)(period),
82 queueFrameIndex?(uint8_t)1:(uint8_t)0,
83 queueOnChange?(uint8_t)1:(uint8_t)0,
84 };
85 return(_sw.sendPacket(tx));
86 }
87}
88
89 int16_t enable(bool enable = true)
90 {
91 uint8_t tx[] = {(uint8_t)SerialWombatCommands::COMMAND_BINARY_CONFIG_DATALOGGER,
92 1, //Logger total Enable / Disable
93 enable?(uint8_t)1:(uint8_t)0,
94 };
95 return (_sw.sendPacket(tx));
96 }
97
98 int16_t configurePin(uint8_t pin, bool queueLowByte, bool queueHighByte)
99 {
100 uint8_t tx[] = {(uint8_t)SerialWombatCommands::COMMAND_BINARY_CONFIG_DATALOGGER,
101 2, //Configure individual pins
102 pin,
103 queueLowByte?(uint8_t)1:(uint8_t)0,
104 queueHighByte?(uint8_t)1:(uint8_t)0,
105 };
106 return (_sw.sendPacket(tx));
107 }
108 private:
109 SerialWombatChip& _sw;
110
111};
DataLoggerPeriod
DataLoggerPeriod
Definition SerialWombat18ABDataLogger.h:31
DataLoggerPeriod::PERIOD_32mS
@ PERIOD_32mS
Definition SerialWombat18ABDataLogger.h:37
DataLoggerPeriod::PERIOD_1mS
@ PERIOD_1mS
Definition SerialWombat18ABDataLogger.h:42
DataLoggerPeriod::PERIOD_512mS
@ PERIOD_512mS
Definition SerialWombat18ABDataLogger.h:33
DataLoggerPeriod::PERIOD_4mS
@ PERIOD_4mS
Definition SerialWombat18ABDataLogger.h:40
DataLoggerPeriod::PERIOD_256mS
@ PERIOD_256mS
Definition SerialWombat18ABDataLogger.h:34
DataLoggerPeriod::PERIOD_8mS
@ PERIOD_8mS
Definition SerialWombat18ABDataLogger.h:39
DataLoggerPeriod::PERIOD_1024mS
@ PERIOD_1024mS
Definition SerialWombat18ABDataLogger.h:32
DataLoggerPeriod::PERIOD_128mS
@ PERIOD_128mS
Definition SerialWombat18ABDataLogger.h:35
DataLoggerPeriod::PERIOD_64mS
@ PERIOD_64mS
Definition SerialWombat18ABDataLogger.h:36
DataLoggerPeriod::PERIOD_2mS
@ PERIOD_2mS
Definition SerialWombat18ABDataLogger.h:41
DataLoggerPeriod::PERIOD_16mS
@ PERIOD_16mS
Definition SerialWombat18ABDataLogger.h:38
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
SerialWombatCommands::COMMAND_BINARY_CONFIG_DATALOGGER
@ COMMAND_BINARY_CONFIG_DATALOGGER
(0x96)
Definition SerialWombat.h:210
SerialWombat18ABDataLogger::SerialWombat18ABDataLogger
SerialWombat18ABDataLogger(SerialWombatChip &serialWombat)
Constructor for SerialWombat18ABDataLogger class /.
Definition SerialWombat18ABDataLogger.h:57
SerialWombat18ABDataLogger::begin
int16_t begin(uint16_t queueAddress, uint16_t queueSizeBytes, bool queueFrameIndex, bool queueOnChange=false, DataLoggerPeriod period=DataLoggerPeriod::PERIOD_1mS)
Initialize the Serial Wombat Data logger. It will create a queue with the given parameters / /.
Definition SerialWombat18ABDataLogger.h:72
SerialWombat18ABDataLogger::enable
int16_t enable(bool enable=true)
Definition SerialWombat18ABDataLogger.h:89
SerialWombat18ABDataLogger::configurePin
int16_t configurePin(uint8_t pin, bool queueLowByte, bool queueHighByte)
Definition SerialWombat18ABDataLogger.h:98
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition SerialWombat.h:300
SerialWombatQueue
A Class representing a Queue in the User Ram area on the Serial Wombat Chip.
Definition SerialWombatQueue.h:42
SerialWombatQueue::begin
int16_t begin(uint16_t index, uint16_t length, SerialWombatQueueType qtype=SerialWombatQueueType::QUEUE_TYPE_RAM_BYTE)
Initialize a Serial Wombat Queue (RAM Bytes) in User Memory Area on Serial Wombat Chip / /.
Definition SerialWombatQueue.h:61