tico 0.1
Mechanical Watch Terminal Timegrapher
Data Structures | Functions
capture_helpers.h File Reference
#include "config.h"
#include "myarr.h"
#include "resources.h"
Include dependency graph for capture_helpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  LoopState
 

Functions

void printFinals (CapConfig *cfg, AppResources *res, size_t totalTickTock)
 Helper functions for capture.c, including printing, data shifting, logging, and fitting. More...
 
void printPeak (CapConfig *cfg, AppResources *res)
 Prints the peak to the cfg->fpTotal file count, position data, and correlation data, based on the provided parameters. More...
 
void fillReference (FILE *fpDefPeak, struct myarr *reference, size_t teeth)
 Fills the reference array with data from the provided file pointer, based on the specified number of teeth. More...
 
void shiftBufferData (size_t *ticktock, struct myarr *subpos, struct myarr *maxpos, struct myarr *maxvals)
 Shifts the buffer data for subpos, maxpos, and maxvals arrays by moving the data to the left and updating the ticktock value accordingly. More...
 
void processLogging (CapConfig *cfg, AppResources *res, size_t totalTime, size_t writeInterval)
 Processes the logging of capture data, including printing the final results and handling any necessary logging based on the provided configuration and resources. More...
 
void fitAndPrint (const LoopState *state, struct myarr *cumulativeTick, AppResources *res, CapConfig *cfg, size_t currentColumns)
 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. More...
 
void rotateDerivativeWindow (AppResources *res, int cumulativeShift)
 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. More...
 
int findMaxPosition (AppResources *res, struct myarr *cumulativeTick, const LoopState *state, CapConfig *cfg)
 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. More...
 
void updateTotalShiftIfNeeded (LoopState *state, int peakOffset, AppResources *res, CapConfig *cfg)
 Updates the total shift if needed based on the cumulative shift, peak offset, and other parameters, using the provided resources and configuration settings. More...
 

Function Documentation

◆ fillReference()

void fillReference ( FILE *  fpDefPeak,
struct myarr reference,
size_t  teeth 
)

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

Parameters
fpDefPeakThe file pointer to read the reference data from.
referenceThe myarr structure to store the reference data.
teethThe number of teeth to determine how much data to read.

◆ findMaxPosition()

int findMaxPosition ( AppResources res,
struct myarr cumulativeTick,
const LoopState state,
CapConfig cfg 
)

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.

Parameters
resThe resources used during the capture process, which may include data arrays and other relevant information for finding the maximum position.
cumulativeTickThe myarr structure containing cumulative tick data for beat error calculation, which may be used in the process of finding the maximum position.
stateThe loop state structure for tracking cumulative shifts and tick indices
cfgThe 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.

◆ fitAndPrint()

void fitAndPrint ( const LoopState state,
struct myarr cumulativeTick,
AppResources res,
CapConfig cfg,
size_t  currentColumns 
)

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.

Parameters
stateThe loop state structure for tracking cumulative shifts and tick indices
cumulativeTickThe myarr structure containing cumulative tick data for beat error calculation.
resThe resources used during the capture process, which may include data arrays and other relevant information for fitting and printing.
cfgThe configuration settings for the capture process, which may include parameters for fitting and printing.
currentColumnsThe current number of columns available for printing, which may be used to determine how to visualize the output.

◆ printFinals()

void printFinals ( CapConfig cfg,
AppResources res,
size_t  totalTickTock 
)

Helper functions for 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.

Parameters
cfgThe configuration settings for the capture process.
resThe resources used during the capture process.
totalTickTockThe total tick count accumulated during the capture process.

◆ printPeak()

void printPeak ( CapConfig cfg,
AppResources res 
)

Prints the peak to the cfg->fpTotal file count, position data, and correlation data, based on the provided parameters.

Parameters
cfgThe configuration settings for the capture process.
resThe resources used during the capture process. process.

◆ processLogging()

void processLogging ( CapConfig cfg,
AppResources res,
size_t  totalTime,
size_t  writeInterval 
)

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

Parameters
cfgThe configuration settings for the capture process, which may include file pointers for logging and other settings.
resThe resources used during the capture process, which may include data arrays and other relevant information.
totalTimeThe total time elapsed during the capture process, which may be used for logging or final output.
writeIntervalThe interval at which to write log data, which may be used to determine when to log certain information based on the total time.

◆ rotateDerivativeWindow()

void rotateDerivativeWindow ( AppResources res,
int  cumulativeShift 
)

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.

Parameters
resThe resources used during the capture process, which may include data arrays and other relevant information for rotating the derivative window.
cumulativeShiftThe total shift that has been accumulated, which will be used to determine how much to rotate the derivative window.

◆ shiftBufferData()

void shiftBufferData ( size_t *  ticktock,
struct myarr subpos,
struct myarr maxpos,
struct myarr maxvals 
)

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

Parameters
ticktockA pointer to the current tick count that will be updated after shifting the data.
subposThe myarr structure containing the subpos data to be shifted.
maxposThe myarr structure containing the maxpos data to be shifted.
maxvalsThe myarr structure containing the maxvals data to be shifted.

◆ updateTotalShiftIfNeeded()

void updateTotalShiftIfNeeded ( LoopState state,
int  peakOffset,
AppResources res,
CapConfig cfg 
)

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

Parameters
stateThe loop state structure for tracking cumulative shifts and tick indices on the peak
peakOffsetThe 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.
resThe resources used during the capture process, which may include data arrays and other relevant information for updating the total shift if needed.
cfgThe configuration settings for the capture process, which may include parameters for fitting and updating the total shift, such as thresholds and other relevant settings.