Skip to content

Full cubic spline implementations using the spline.h library #633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 39 commits into
base: testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
244f362
implemented new fillTable function and changed TABLE_DIVISOR to 10
benv12 Feb 18, 2025
9ec11c8
went back to old fill functions and caught up with testing
benv12 Feb 21, 2025
25eefd6
added logging for clear and reset.
benv12 Feb 21, 2025
8f4c168
took out constraints WIP
benv12 Feb 21, 2025
37418f5
changed failed neighbor constrain WIP
benv12 Feb 22, 2025
1b8d0aa
defeined PT reading range in settings.h and updated newEntry
benv12 Feb 22, 2025
ab54378
WIP
benv12 Feb 24, 2025
0bf087a
wrote polynomial interpolation/extrapolation. not tested yet
benv12 Feb 25, 2025
cae992d
wrote cubic spline interpolation. still needs testing
benv12 Feb 25, 2025
67a7ca4
cleaned up newEntry
benv12 Feb 25, 2025
2eae63b
testing out different quadratic extrapolation
benv12 Feb 26, 2025
3b94fad
added calculation for neighbor range
benv12 Feb 26, 2025
8392cef
rewrote cubic spline interpolation using spine.h library
benv12 Feb 26, 2025
b9dd308
updated spline.h library
benv12 Feb 26, 2025
f8786bb
working cubic spline interpolation
benv12 Feb 27, 2025
9a43bb2
extrap functions working
benv12 Feb 28, 2025
cc3d6b8
implemented cubic spline for lookUp, needs to be tested
benv12 Feb 28, 2025
ea90141
added extrap functions, need to debug them
benv12 Mar 3, 2025
bf1997e
implemented new fillTable() function.
benv12 Mar 3, 2025
0436647
small extrapolation changes
benv12 Mar 4, 2025
605652b
filltable() complete
benv12 Mar 5, 2025
ee09164
implemented cubic spline extrapolation.
benv12 Mar 5, 2025
7f8c716
extrap function rewrork
benv12 Mar 6, 2025
6d545c0
logging fixes
benv12 Mar 6, 2025
cfcf42e
new fillTable() function
benv12 Mar 7, 2025
7e62fa0
modified extrap functions
benv12 Mar 7, 2025
2a85005
implemented old fill functions when not enough points
benv12 Mar 8, 2025
ca3d037
fill functions rework
benv12 Mar 11, 2025
3dc01ce
fillTable() modifiication
benv12 Mar 12, 2025
e5d3c22
switched to interpolation function
benv12 Mar 13, 2025
eaeb2a1
switched to manual cubic spline interpolation
benv12 Mar 13, 2025
7adb95d
needs a lot of optimization
benv12 Mar 13, 2025
f8fda11
new fillTable() function
benv12 Mar 14, 2025
f9e302c
more spline modificiations
benv12 Mar 17, 2025
3b6cb1a
diagonal modification
benv12 Mar 17, 2025
4ec20d1
rewrite using spline library
benv12 Mar 17, 2025
ad3b6f2
small pug change
benv12 Mar 17, 2025
d31302d
Merge branch 'testing' of https://github.com/doudar/SmartSpin2k into …
benv12 Mar 17, 2025
862a74f
fixed merging issues
benv12 Mar 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/Power_Table.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "settings.h"
#include "SmartSpin_parameters.h"
#include <vector>
#include <vector>

#define POWERTABLE_LOG_TAG "PTable"
#define RETURN_ERROR INT32_MIN
Expand Down Expand Up @@ -111,6 +111,9 @@ class PowerTable {
// returns incline for wattTarget. Null if not found.
int32_t lookup(int watts, int cad);

// returns
int32_t splineLookup(int watts, int cad);

// returns watts for given cadence and target position. Returns RETURN_ERROR if not found.
int32_t lookupWatts(int cad, int32_t targetPosition);

Expand All @@ -129,12 +132,13 @@ class PowerTable {
// Display power table in log
void toLog();

// Fill table function shortened.
void fillEmptyTable(int outerValue, const std::vector<int>& emptyIndices, const std::vector<double>& x, const std::vector<double>& y, bool horizontal);
void fillEmptyTable(int outerValue, const std::vector<int>& emptyIndices, const std::vector<double>& x, const std::vector<double>& y, bool horizontal);

// Determine if we are doing horiziontal or vertical interpolation;
void findTableDirection(bool horizontal);

void extrapFillTableDirection(bool horizontal);

void extrapolateEmptyIndices(int outerIndex, const std::vector<int>& emptyIndices, const std::vector<double>& x, const std::vector<double>& y, bool horizontal);
private:
unsigned long lastSaveTime = millis();
TestResults testNeighbors(int i, int j, int value);
Expand Down
2 changes: 1 addition & 1 deletion include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const char* const DEFAULT_PASSWORD = "password";

//Max distance a failed neighbor can be horizontally from target position
#define HORIZONTAL_NEIGHBOR_RANGE 0.6

//Max distance a failed neighbr can be vertically from target position
#define VERTICAL_NEIGHBOR_RANGE 0.8

Expand Down
Loading
Loading