tico 0.1
Mechanical Watch Terminal Timegrapher
capture_helpers.h
Go to the documentation of this file.
1#pragma once
2
3#include "config.h"
4#include "myarr.h"
5#include "resources.h"
6
7typedef struct
8{
10 size_t tickIndex;
11 unsigned int globalTickIndex;
12} LoopState;
13
23void printFinals(CapConfig* cfg, AppResources* res, size_t totalTickTock);
24
30void printPeak(CapConfig* cfg, AppResources* res);
31
37void fillReference(FILE* fpDefPeak, struct myarr* reference, size_t teeth);
38
47void shiftBufferData(size_t* ticktock,
48 struct myarr* subpos,
49 struct myarr* maxpos,
50 struct myarr* maxvals);
51
64 AppResources* res,
65 size_t totalTime,
66 size_t writeInterval);
67
82void fitAndPrint(const LoopState* state,
83 struct myarr* cumulativeTick,
84 AppResources* res,
85 CapConfig* cfg,
86 size_t currentColumns);
87
95void rotateDerivativeWindow(AppResources* res, int cumulativeShift);
96
111 struct myarr* cumulativeTick,
112 const LoopState* state,
113 CapConfig* cfg);
114
130 int peakOffset,
131 AppResources* res,
132 CapConfig* cfg);
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,...
Definition: capture_helpers.c:198
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 ...
Definition: capture_helpers.c:37
void printFinals(CapConfig *cfg, AppResources *res, size_t totalTickTock)
Helper functions for capture.c, including printing, data shifting, logging, and fitting.
Definition: capture_helpers.c:19
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 upda...
Definition: capture_helpers.c:85
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 shifti...
Definition: capture_helpers.c:180
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 necessar...
Definition: capture_helpers.c:102
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 slop...
Definition: capture_helpers.c:135
void printPeak(CapConfig *cfg, AppResources *res)
Prints the peak to the cfg->fpTotal file count, position data, and correlation data,...
Definition: capture_helpers.c:216
void rotateDerivativeWindow(AppResources *res, int cumulativeShift)
Rotates the derivative window by shifting the data in the derivative array based on the cumulative sh...
Definition: capture_helpers.c:168
Struct to hold all the resources needed for the application.
Definition: resources.h:12
brief struct to hold the configuration parameters for the capture process
Definition: config.h:8
Definition: capture_helpers.h:8
size_t tickIndex
Definition: capture_helpers.h:10
int cumulativeShift
Definition: capture_helpers.h:9
unsigned int globalTickIndex
Definition: capture_helpers.h:11
A struct to hold an array of integers or an array of doubles, along with the length of the arrays.
Definition: myarr.h:14