Commit a81bfdca authored by Olivier Kaufmann's avatar Olivier Kaufmann
Browse files

Fix negative sleep_times

Showing with 1 addition and 1 deletion
+1 -1
...@@ -65,7 +65,7 @@ class OhmPiHardware: ...@@ -65,7 +65,7 @@ class OhmPiHardware:
_readings.append([elapsed_seconds(start_time), self.tx.current, self.rx.voltage]) _readings.append([elapsed_seconds(start_time), self.tx.current, self.rx.voltage])
sample+=1 sample+=1
sleep_time = start_time + datetime.timedelta(seconds = sample * sampling_rate / 1000) - lap sleep_time = start_time + datetime.timedelta(seconds = sample * sampling_rate / 1000) - lap
print(f'start_time: {start_time}, lap: {lap}, sample: {sample}, sleep_time: {sleep_time.total_seconds()} seconds') print(f'expected_end_time: {start_time+datetime.timedelta(seconds = sample * sampling_rate / 1000)}, lap: {lap}, sample: {sample}, sleep_time: {sleep_time.total_seconds()} seconds')
time.sleep(np.min([0, np.abs(sleep_time.total_seconds())])) time.sleep(np.min([0, np.abs(sleep_time.total_seconds())]))
self.readings = np.array(_readings) self.readings = np.array(_readings)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment