REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
base.h
Go to the documentation of this file.
1// Copyright (c) 2024 anabrid GmbH
2// Contact: https://www.anabrid.com/licensing/
3// SPDX-License-Identifier: MIT OR GPL-2.0-or-later
4
5#pragma once
6
7#include <array>
8#include <cstdint>
9
10#include <ArduinoJson.h>
11
12namespace daq {
13
15constexpr uint8_t NUM_CHANNELS = 8;
16
18constexpr unsigned int DEFAULT_SAMPLE_RATE = 400'000;
19
21typedef std::array<float, NUM_CHANNELS> data_vec_t;
22
29class DAQConfig {
31 uint8_t num_channels = NUM_CHANNELS;
33 unsigned int sample_rate = DEFAULT_SAMPLE_RATE;
35 bool sample_op = true;
37 bool sample_op_end = true;
38
39public:
41 DAQConfig() = default;
43 DAQConfig(uint8_t num_channels, unsigned int sample_rate);
44
46 uint8_t get_num_channels() const;
48 unsigned int get_sample_rate() const;
50 bool should_sample_op() const;
52 bool should_sample_op_end() const;
53
56 bool is_valid() const;
57
59 float index_to_time(size_t index) const;
60
63 explicit operator bool() const { return num_channels and (sample_op or sample_op_end); };
64
66 static DAQConfig from_json(JsonObjectConst &&json);
67};
68
69} // namespace daq
Data acquisition configuration.
Definition base.h:29
bool should_sample_op_end() const
Get whether to sample at the end of OP.
Definition base.cpp:39
bool should_sample_op() const
Get whether to sample during OP.
Definition base.cpp:37
static DAQConfig from_json(JsonObjectConst &&json)
Construct a configuration from a JsonObject.
Definition base.cpp:12
uint8_t get_num_channels() const
Get the configured number of channels.
Definition base.cpp:33
DAQConfig()=default
Construct a configuration using default values.
float index_to_time(size_t index) const
Convert a sample index to a time in seconds.
Definition base.cpp:51
bool is_valid() const
Check whether the configuration is valid.
Definition base.cpp:41
unsigned int get_sample_rate() const
Get the configured sample rate.
Definition base.cpp:35
Routines for data acquisition (DAQ) using the internal analog-to-digital converters (ADC).
Definition base.h:12
constexpr unsigned int DEFAULT_SAMPLE_RATE
Default sample rate.
Definition base.h:18
constexpr uint8_t NUM_CHANNELS
Number of channels available in the daq system.
Definition base.h:15
std::array< float, NUM_CHANNELS > data_vec_t
Type definition for a float data vector.
Definition base.h:21
FLASHMEM void index(awot::Request &req, awot::Response &res)
Definition server.cpp:120