\hypertarget{capture__helpers_8c}{}\doxysection{src/capture\+\_\+helpers.c File Reference}
\label{capture__helpers_8c}\index{src/capture\_helpers.c@{src/capture\_helpers.c}}
{\ttfamily \#include \char`\"{}capture\+\_\+helpers.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}analysis.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}modsigned.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}mydefs.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}myfft.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}mymath.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}mysync.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}parseargs.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}printing.\+h\char`\"{}}\newline
{\ttfamily \#include $<$math.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdarg.\+h$>$}\newline
Include dependency graph for capture\+\_\+helpers.\+c\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{capture__helpers_8c__incl}
\end{center}
\end{figure}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{capture__helpers_8c_a7bb6c91e392478b87529b6a7c4e0df94}{print\+Finals}} (\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$cfg, \mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$res, size\+\_\+t total\+Tick\+Tock)
\begin{DoxyCompactList}\small\item\em Helper functions for \mbox{\hyperlink{capture_8c}{capture.\+c}}, including printing, data shifting, logging, and fitting. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{capture__helpers_8c_a50e20c3eea97677665a99de3130edc5a}{fill\+Reference}} (FILE $\ast$fp\+Def\+Peak, struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$reference, size\+\_\+t teeth)
\begin{DoxyCompactList}\small\item\em Fills the reference array with data from the provided file pointer, based on the specified number of teeth. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{capture__helpers_8c_a8e13ee36857caa5124fcf483906e7892}{shift\+Buffer\+Data}} (size\+\_\+t $\ast$ticktock, struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$subpos, struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$maxpos, struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$maxvals)
\begin{DoxyCompactList}\small\item\em Shifts the buffer data for subpos, maxpos, and maxvals arrays by moving the data to the left and updating the ticktock value accordingly. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{capture__helpers_8c_aaf7cec3508044906e4daa5b37dc3323a}{process\+Logging}} (\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$cfg, \mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$res, size\+\_\+t total\+Time, size\+\_\+t write\+Interval)
\begin{DoxyCompactList}\small\item\em Processes the logging of capture data, including printing the final results and handling any necessary logging based on the provided configuration and resources. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{capture__helpers_8c_ac32de3131551418091d61d370bf8bd93}{fit\+And\+Print}} (const \mbox{\hyperlink{structLoopState}{Loop\+State}} $\ast$state, struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$cumulative\+Tick, \mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$res, \mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$cfg, size\+\_\+t current\+Columns)
\begin{DoxyCompactList}\small\item\em Fits a model to the capture data and prints the results, including calculating the intercept and slope, printing the header information, and visualizing the position of the maximum correlation based on the provided parameters. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{capture__helpers_8c_aea9fc01cce6cd5bb54702bae5a482db0}{rotate\+Derivative\+Window}} (\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$res, int cumulative\+Shift)
\begin{DoxyCompactList}\small\item\em Rotates the derivative window by shifting the data in the derivative array based on the cumulative shift and array length, effectively updating the window for the next iteration of processing. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{capture__helpers_8c_aa632bcaf1299fe0f1b4b90828d462739}{find\+Max\+Position}} (\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$res, struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$cumulative\+Tick, const \mbox{\hyperlink{structLoopState}{Loop\+State}} $\ast$state, \mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$cfg)
\begin{DoxyCompactList}\small\item\em Finds the maximum position of the correlation in the capture data by performing an FFT fit and shifting the result based on the array length, using the provided resources and configuration settings. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{capture__helpers_8c_a351d765405d74ea6875ac7e520da0d4c}{update\+Total\+Shift\+If\+Needed}} (\mbox{\hyperlink{structLoopState}{Loop\+State}} $\ast$state, int peak\+Offset, \mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$res, \mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$cfg)
\begin{DoxyCompactList}\small\item\em Updates the total shift if needed based on the cumulative shift, peak offset, and other parameters, using the provided resources and configuration settings. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{capture__helpers_8c_ac6f5d784e10f01f224b9bba1424f9cbf}{print\+Peak}} (\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$cfg, \mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$res)
\begin{DoxyCompactList}\small\item\em Prints the peak to the cfg-\/\texorpdfstring{$>$}{>}fp\+Total file count, position data, and correlation data, based on the provided parameters. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{capture__helpers_8c_a50e20c3eea97677665a99de3130edc5a}\label{capture__helpers_8c_a50e20c3eea97677665a99de3130edc5a}} 
\index{capture\_helpers.c@{capture\_helpers.c}!fillReference@{fillReference}}
\index{fillReference@{fillReference}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{fillReference()}{fillReference()}}
{\footnotesize\ttfamily void fill\+Reference (\begin{DoxyParamCaption}\item[{FILE $\ast$}]{fp\+Def\+Peak,  }\item[{struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{reference,  }\item[{size\+\_\+t}]{teeth }\end{DoxyParamCaption})}



Fills the reference array with data from the provided file pointer, based on the specified number of teeth. 


\begin{DoxyParams}{Parameters}
{\em fp\+Def\+Peak} & The file pointer to read the reference data from. \\
\hline
{\em reference} & The myarr structure to store the reference data. \\
\hline
{\em teeth} & The number of teeth to determine how much data to read. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{capture__helpers_8c_aa632bcaf1299fe0f1b4b90828d462739}\label{capture__helpers_8c_aa632bcaf1299fe0f1b4b90828d462739}} 
\index{capture\_helpers.c@{capture\_helpers.c}!findMaxPosition@{findMaxPosition}}
\index{findMaxPosition@{findMaxPosition}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{findMaxPosition()}{findMaxPosition()}}
{\footnotesize\ttfamily int find\+Max\+Position (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$}]{res,  }\item[{struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{cumulative\+Tick,  }\item[{const \mbox{\hyperlink{structLoopState}{Loop\+State}} $\ast$}]{state,  }\item[{\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$}]{cfg }\end{DoxyParamCaption})}



Finds the maximum position of the correlation in the capture data by performing an FFT fit and shifting the result based on the array length, using the provided resources and configuration settings. 


\begin{DoxyParams}{Parameters}
{\em res} & The resources used during the capture process, which may include data arrays and other relevant information for finding the maximum position. \\
\hline
{\em cumulative\+Tick} & The myarr structure containing cumulative tick data for beat error calculation, which may be used in the process of finding the maximum position. \\
\hline
{\em state} & The loop state structure for tracking cumulative shifts and tick indices \\
\hline
{\em cfg} & The configuration settings for the capture process, which may include parameters for fitting and finding the maximum position, such as the number of peaks to fit and the standard deviation threshold. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{capture__helpers_8c_ac32de3131551418091d61d370bf8bd93}\label{capture__helpers_8c_ac32de3131551418091d61d370bf8bd93}} 
\index{capture\_helpers.c@{capture\_helpers.c}!fitAndPrint@{fitAndPrint}}
\index{fitAndPrint@{fitAndPrint}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{fitAndPrint()}{fitAndPrint()}}
{\footnotesize\ttfamily void fit\+And\+Print (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{structLoopState}{Loop\+State}} $\ast$}]{state,  }\item[{struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{cumulative\+Tick,  }\item[{\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$}]{res,  }\item[{\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$}]{cfg,  }\item[{size\+\_\+t}]{current\+Columns }\end{DoxyParamCaption})}



Fits a model to the capture data and prints the results, including calculating the intercept and slope, printing the header information, and visualizing the position of the maximum correlation based on the provided parameters. 


\begin{DoxyParams}{Parameters}
{\em state} & The loop state structure for tracking cumulative shifts and tick indices \\
\hline
{\em cumulative\+Tick} & The myarr structure containing cumulative tick data for beat error calculation. \\
\hline
{\em res} & The resources used during the capture process, which may include data arrays and other relevant information for fitting and printing. \\
\hline
{\em cfg} & The configuration settings for the capture process, which may include parameters for fitting and printing. \\
\hline
{\em current\+Columns} & The current number of columns available for printing, which may be used to determine how to visualize the output. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{capture__helpers_8c_a7bb6c91e392478b87529b6a7c4e0df94}\label{capture__helpers_8c_a7bb6c91e392478b87529b6a7c4e0df94}} 
\index{capture\_helpers.c@{capture\_helpers.c}!printFinals@{printFinals}}
\index{printFinals@{printFinals}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{printFinals()}{printFinals()}}
{\footnotesize\ttfamily void print\+Finals (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$}]{cfg,  }\item[{\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$}]{res,  }\item[{size\+\_\+t}]{total\+Tick\+Tock }\end{DoxyParamCaption})}



Helper functions for \mbox{\hyperlink{capture_8c}{capture.\+c}}, including printing, data shifting, logging, and fitting. 

Prints the final results of the capture process, including total tick count, position data, and correlation data, based on the provided parameters. 
\begin{DoxyParams}{Parameters}
{\em cfg} & The configuration settings for the capture process. \\
\hline
{\em res} & The resources used during the capture process. \\
\hline
{\em total\+Tick\+Tock} & The total tick count accumulated during the capture process. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{capture__helpers_8c_ac6f5d784e10f01f224b9bba1424f9cbf}\label{capture__helpers_8c_ac6f5d784e10f01f224b9bba1424f9cbf}} 
\index{capture\_helpers.c@{capture\_helpers.c}!printPeak@{printPeak}}
\index{printPeak@{printPeak}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{printPeak()}{printPeak()}}
{\footnotesize\ttfamily void print\+Peak (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$}]{cfg,  }\item[{\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$}]{res }\end{DoxyParamCaption})}



Prints the peak to the cfg-\/\texorpdfstring{$>$}{>}fp\+Total file count, position data, and correlation data, based on the provided parameters. 


\begin{DoxyParams}{Parameters}
{\em cfg} & The configuration settings for the capture process. \\
\hline
{\em res} & The resources used during the capture process. process. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{capture__helpers_8c_aaf7cec3508044906e4daa5b37dc3323a}\label{capture__helpers_8c_aaf7cec3508044906e4daa5b37dc3323a}} 
\index{capture\_helpers.c@{capture\_helpers.c}!processLogging@{processLogging}}
\index{processLogging@{processLogging}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{processLogging()}{processLogging()}}
{\footnotesize\ttfamily void process\+Logging (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$}]{cfg,  }\item[{\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$}]{res,  }\item[{size\+\_\+t}]{total\+Time,  }\item[{size\+\_\+t}]{write\+Interval }\end{DoxyParamCaption})}



Processes the logging of capture data, including printing the final results and handling any necessary logging based on the provided configuration and resources. 


\begin{DoxyParams}{Parameters}
{\em cfg} & The configuration settings for the capture process, which may include file pointers for logging and other settings. \\
\hline
{\em res} & The resources used during the capture process, which may include data arrays and other relevant information. \\
\hline
{\em total\+Time} & The total time elapsed during the capture process, which may be used for logging or final output. \\
\hline
{\em write\+Interval} & The interval at which to write log data, which may be used to determine when to log certain information based on the total time. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{capture__helpers_8c_aea9fc01cce6cd5bb54702bae5a482db0}\label{capture__helpers_8c_aea9fc01cce6cd5bb54702bae5a482db0}} 
\index{capture\_helpers.c@{capture\_helpers.c}!rotateDerivativeWindow@{rotateDerivativeWindow}}
\index{rotateDerivativeWindow@{rotateDerivativeWindow}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{rotateDerivativeWindow()}{rotateDerivativeWindow()}}
{\footnotesize\ttfamily void rotate\+Derivative\+Window (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$}]{res,  }\item[{int}]{cumulative\+Shift }\end{DoxyParamCaption})}



Rotates the derivative window by shifting the data in the derivative array based on the cumulative shift and array length, effectively updating the window for the next iteration of processing. 


\begin{DoxyParams}{Parameters}
{\em res} & The resources used during the capture process, which may include data arrays and other relevant information for rotating the derivative window. \\
\hline
{\em cumulative\+Shift} & The total shift that has been accumulated, which will be used to determine how much to rotate the derivative window. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{capture__helpers_8c_a8e13ee36857caa5124fcf483906e7892}\label{capture__helpers_8c_a8e13ee36857caa5124fcf483906e7892}} 
\index{capture\_helpers.c@{capture\_helpers.c}!shiftBufferData@{shiftBufferData}}
\index{shiftBufferData@{shiftBufferData}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{shiftBufferData()}{shiftBufferData()}}
{\footnotesize\ttfamily void shift\+Buffer\+Data (\begin{DoxyParamCaption}\item[{size\+\_\+t $\ast$}]{ticktock,  }\item[{struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{subpos,  }\item[{struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{maxpos,  }\item[{struct \mbox{\hyperlink{structmyarr}{myarr}} $\ast$}]{maxvals }\end{DoxyParamCaption})}



Shifts the buffer data for subpos, maxpos, and maxvals arrays by moving the data to the left and updating the ticktock value accordingly. 


\begin{DoxyParams}{Parameters}
{\em ticktock} & A pointer to the current tick count that will be updated after shifting the data. \\
\hline
{\em subpos} & The myarr structure containing the subpos data to be shifted. \\
\hline
{\em maxpos} & The myarr structure containing the maxpos data to be shifted. \\
\hline
{\em maxvals} & The myarr structure containing the maxvals data to be shifted. \\
\hline
\end{DoxyParams}
\mbox{\Hypertarget{capture__helpers_8c_a351d765405d74ea6875ac7e520da0d4c}\label{capture__helpers_8c_a351d765405d74ea6875ac7e520da0d4c}} 
\index{capture\_helpers.c@{capture\_helpers.c}!updateTotalShiftIfNeeded@{updateTotalShiftIfNeeded}}
\index{updateTotalShiftIfNeeded@{updateTotalShiftIfNeeded}!capture\_helpers.c@{capture\_helpers.c}}
\doxysubsubsection{\texorpdfstring{updateTotalShiftIfNeeded()}{updateTotalShiftIfNeeded()}}
{\footnotesize\ttfamily void update\+Total\+Shift\+If\+Needed (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structLoopState}{Loop\+State}} $\ast$}]{state,  }\item[{int}]{peak\+Offset,  }\item[{\mbox{\hyperlink{structAppResources}{App\+Resources}} $\ast$}]{res,  }\item[{\mbox{\hyperlink{structCapConfig}{Cap\+Config}} $\ast$}]{cfg }\end{DoxyParamCaption})}



Updates the total shift if needed based on the cumulative shift, peak offset, and other parameters, using the provided resources and configuration settings. 


\begin{DoxyParams}{Parameters}
{\em state} & The loop state structure for tracking cumulative shifts and tick indices on the peak \\
\hline
{\em peak\+Offset} & The offset of the peak position, which may be used to determine if an update to the total shift is needed based on the cumulative shift and other parameters. \\
\hline
{\em res} & The resources used during the capture process, which may include data arrays and other relevant information for updating the total shift if needed. \\
\hline
{\em cfg} & The configuration settings for the capture process, which may include parameters for fitting and updating the total shift, such as thresholds and other relevant settings. \\
\hline
\end{DoxyParams}
