From ca4cde7f516d4d5781d78f8826257d3c60a6696e Mon Sep 17 00:00:00 2001 From: Titon Barua Date: Wed, 1 Jan 2025 13:39:58 -0500 Subject: [PATCH] Fixed some bugs in example code given in the README --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 87b1970..a0fd70b 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,8 @@ sensor = MS5837SensorBar30( pressure_osr=_OSR_RATE, temperature_osr=_OSR_RATE) -task = sensor.async_read() while True: + task = sensor.async_read() pres, temp = asyncio.run(task) print(f"P: {pres} KPa, T: {temp} deg-C") time.sleep(1.0) @@ -115,9 +115,12 @@ sensor = MS5837SensorBar30( temperature_osr=_OSR_RATE) depth_estimator = NaiveWaterDepthEstimator(sensor, _WATER_DENSITY) +ref_pres = depth_estimator.set_ref_pressure() +print(f"Reference pressure set to: {ref_pres:.3f} KPa") + while True: - depth = depth_estimator.read_depth() - print("Depth: {:.2f} cm".format(depth / 100.0)) + depth_m = depth_estimator.read_depth() + print("Depth: {:.2f} cm".format(depth_m * 100.0)) time.sleep(1.0) ``` @@ -146,25 +149,25 @@ sensors, one MS5837-30BA and another MS5837-02BA were connected to I2C channels Benchmark blocking reads: ```bash -mpremote exec `from rp2040_tests import *; benchmark_blocking_read(SENSOR_BAR30)` +mpremote exec 'from rp2040_tests import *; benchmark_blocking_read(SENSOR_BAR30)' ``` Benchmark asynchronous reads: ```bash -mpremote exec `from rp2040_tests import *; benchmark_async_read(SENSOR_BAR02)` +mpremote exec 'from rp2040_tests import *; benchmark_async_read(SENSOR_BAR02)' ``` Continuously print pressure and temperature data: ```bash -mpremote exec `from rp2040_tests import *; print_data(SENSOR_BAR30)` +mpremote exec 'from rp2040_tests import *; print_data(SENSOR_BAR30)' ``` Continuously print depth data: ```bash -mpremote exec `from rp2040_tests import *; print_data(SENSOR_BAR02)` +mpremote exec 'from rp2040_tests import *; print_data(SENSOR_BAR02)' ```