10 #ifndef SCARAB_DIGITAL_HH_ 11 #define SCARAB_DIGITAL_HH_ 16 #include <type_traits> 68 template<
typename type >
71 template<
typename type >
75 template<
typename dig_type,
typename an_type >
82 template<
typename an_type,
typename dig_type,
87 if( analog > (an_type)(params->
levels - 1) ) analog = params->
levels - 1;
88 else if( analog < 0. ) analog = 0.;
93 template<
typename an_type,
typename dig_type,
97 double half_levels = params->
levels * 0.5;
99 if( analog > (an_type)(half_levels - 1) ) analog = half_levels - 1;
100 else if( analog < -half_levels ) analog = -half_levels;
106 #endif // SCARAB_DIGITAL_HH_
typename std::enable_if< std::is_signed< type >::value >::type * enable_if_signed
void get_calib_params2(unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, double dac_gain, bool bits_r_aligned, dig_calib_params *params)
Calculate the digitizer calibration parameters when given the DAC gain (e.g. from a digitizer's own c...
std::string type(const x_type &a_param)
an_type d2a(dig_type dig, const struct dig_calib_params *params)
Convert a signed or unsigned digital value to an analog value.
Collection of parameters used for converting between analog and digital data.
dig_type a2d(an_type analog, const struct dig_calib_params *params)
Convert an analog value to an unsigned digital value.
typename std::enable_if< std::is_unsigned< type >::value >::type * enable_if_unsigned
void get_calib_params(unsigned n_bits, unsigned data_type_size, double v_offset, double v_range, bool bits_r_aligned, dig_calib_params *params)
Calculate the digitizer calibration parameters with basic parameters: number of bits, Voffset, and Vrange.
To round(const std::chrono::duration< Rep, Period > &d)