10#ifndef SEMF_INPUT_SENSOR_ANALOGSENSOR_H_
11#define SEMF_INPUT_SENSOR_ANALOGSENSOR_H_
20template <
typename T,
size_t N_CHANNELS = 1>
49 void onDataAvailable();
56 size_t m_currentChannelIndex = 0;
58 SEMF_SLOT(m_onDataAvailableSlot,
AnalogSensor, *
this, onDataAvailable);
61template <
typename T,
size_t N_CHANNELS>
66 for (
size_t i = 0; i < N_CHANNELS; i++)
68 m_buffers[i].setBuffer(
buffer, bufferSize);
69 m_buffers[i].setStride(N_CHANNELS);
70 m_buffers[i].setPos(i);
74template <
typename T,
size_t N_CHANNELS>
80template <
typename T,
size_t N_CHANNELS>
83 return m_buffers[index];
86template <
typename T,
size_t N_CHANNELS>
89 m_buffers[m_currentChannelIndex].put(
static_cast<T
>(m_analogIn.value()));
91 m_currentChannelIndex++;
92 m_currentChannelIndex %= N_CHANNELS;
Interface for using ADC (Analog to Digital Conversion) hardware in interrupt mode.
Provides data from an AnalogIn to one to more Sensor objects.
LastInBuffer< T > & buffer(size_t index) override
Returns the buffer, where the measurement data is stored in.
virtual ~AnalogSensor()=default
AnalogSensor(const AnalogSensor &other)=delete
AnalogSensor(AnalogIn &analogIn, T buffer[], size_t bufferSize)
Constructor.
Base class for sensor hardware like analog sensor. By calling update(), a measurement cycle gets trig...
Signal< size_t > dataAvailable
The LastInBuffer class implements a kind of circular buffer.
The LastInDmaBuffer class implements a kind of circular buffer.
void connect(SlotBase< Arguments... > &slot)
Connect a method to the signal.