change time to seconds

This commit is contained in:
Philipp Kramer 2022-05-05 12:45:39 +02:00
parent 900b38e2cd
commit 669aeca055
4 changed files with 87 additions and 80007 deletions

View file

@ -1,7 +1,7 @@
Table table; Table table;
float frequency=4; //data frequency in Hz float frequency=4; //data frequency in Hz
int duration=1000*10; //in ms int duration=10; //in s
void setup() { void setup() {
table = new Table(); table = new Table();
@ -9,9 +9,9 @@ void setup() {
table.addColumn("heartrate"); table.addColumn("heartrate");
table.addColumn("random"); table.addColumn("random");
for (int i=0;i<(int)(duration/frequency);i++) { for (int i=0;i<(int)(duration*frequency);i++) {
TableRow newRow = table.addRow(); TableRow newRow = table.addRow();
newRow.setInt("time", (int)(i*(1000/frequency))); newRow.setFloat("time", (float)(i/frequency));
newRow.setFloat("heartrate", noise(i/10)*40.0+60); newRow.setFloat("heartrate", noise(i/10)*40.0+60);
newRow.setFloat("random", random(1)); newRow.setFloat("random", random(1));
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -10,8 +10,8 @@ Table data;
TableRow datarow; TableRow datarow;
int rowid=0; int rowid=0;
long time=0; float time=0;
long starttime=0; float starttime=0;
public enum Playmode { public enum Playmode {
STOP, LOOP; STOP, LOOP;
@ -42,7 +42,7 @@ void setup() {
void draw() { void draw() {
time=millis()-starttime; time=millis()/1000.0-starttime;
datarow = data.getRow(rowid); datarow = data.getRow(rowid);
background(0); background(0);
@ -97,7 +97,7 @@ void draw() {
void restart() { void restart() {
play=true; play=true;
starttime=millis(); starttime=millis()/1000.0;
rowid=0; rowid=0;
} }