Skip to content

Commit

Permalink
Changed example to work on Arduino
Browse files Browse the repository at this point in the history
  • Loading branch information
Rowan Easter committed Nov 21, 2019
1 parent 5a217d0 commit 41ef611
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions examples/fitCurve/fitCurve.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ void setup(){
while(!Serial);
Serial.println("Starting");

char buf[100];
int xpower = 3;
int order = 3;
Serial.printf("Fitting curve of order %i to data of power %i...\n", order, xpower);
snprintf(buf, 100, "Fitting curve of order %i to data of power %i...\n", order, xpower);
Serial.print(buf);

double x[26];
double t[26];
for (int i = 0; i < sizeof(x)/sizeof(double); i++){
t[i] = i;
x[i] = power(i, xpower);
x[i] = pow(i, xpower);
}

double coeffs[order+1];
Expand All @@ -23,11 +25,11 @@ void setup(){
uint8_t c = 'a';
Serial.println("Coefficients are");
for (int i = 0; i < sizeof(coeffs)/sizeof(double); i++){
Serial.printf("%c=%f\t ",c++, coeffs[i]);
snprintf(buf, 100, "%c=%f\t ",c++, coeffs[i]);
Serial.print(buf);
}
}
}

void loop(){
}

0 comments on commit 41ef611

Please sign in to comment.