DIY Auto-Correlator 1.0
Auto-Correlator Card implementation using Teensy 4.x microcontrollers.
histogram.hpp
Go to the documentation of this file.
1#pragma once
2#include<type_traits>
3
4#include "./../types.hpp"
5#ifdef CORR_SIMULATOR
6 #include "pseudoSerial.hpp" //→ Add for testing
7#else
8 #include <Arduino.h>
9#endif
10
21template <typename BinType, unsigned int Bins>
23{
24 unsigned int Index;
25public:
26 BinType Histogram[Bins+1] = {0};
27
29 constexpr unsigned int size() __attribute__((always_inline))
30 {
31 return(Bins + 1);
32 }
33
35 template <typename DataType>
36 void inline push_back(DataType datum)
37 {
38 constexpr unsigned int MaxIndex = Bins-1;
39 Index = (datum > MaxIndex) * (Bins) +
40 !(datum > MaxIndex) * (datum);
41
43 }
44
46 void output() __attribute__((always_inline))
47 {
48 Serial.write((char8cast_t*)(Histogram), sizeof(BinType)*(Bins+1));
49 }
50};
Photon Counting Histogram module for Real time calculation on Teensy 4.1 microcontrollers.
Definition: histogram.hpp:23
void push_back(DataType datum)
Receives a single datum and processes it to into the Histogram.
Definition: histogram.hpp:36
BinType Histogram[Bins+1]
Histogram function array.
Definition: histogram.hpp:26
unsigned int Index
Index used by the pushback function.
Definition: histogram.hpp:24
constexpr unsigned int size() __attribute__((always_inline))
Returns the total number of buns, including the overflow bin.
Definition: histogram.hpp:29
void output() __attribute__((always_inline))
Sends the complete Histogram to the Serial output.
Definition: histogram.hpp:46