From 6a621d5f6d8d906c8d68afbf06f5efd1649205dd Mon Sep 17 00:00:00 2001 From: Salvatore La Bua Date: Tue, 9 Apr 2024 00:59:29 +0900 Subject: [PATCH] Minor changes to utils and main OLED file --- OLED/picomotodash_oled_ws10d.py | 4 ++-- OLED/picomotodash_utils.py | 27 ++++++--------------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/OLED/picomotodash_oled_ws10d.py b/OLED/picomotodash_oled_ws10d.py index 3337661..6d6a2ed 100644 --- a/OLED/picomotodash_oled_ws10d.py +++ b/OLED/picomotodash_oled_ws10d.py @@ -18,7 +18,7 @@ from picomotodash_gps import GPS as pmdGPS from picomotodash_mpu9250 import MPU as pmdMPU -from picomotodash_neopx import NEOPX as pdmNEOPX +from picomotodash_neopx import NEOPX as pmdNEOPX from picomotodash_rpm import RPM as pmdRPM from picomotodash_utils import moving_avg, normalise_avg, read_gps, read_mpu @@ -66,7 +66,7 @@ # Neopixel setup PIN_NUM = 3 NUM_LEDS = 37 -neopixel_ring = pdmNEOPX(pin=PIN_NUM, n=NUM_LEDS) +neopixel_ring = pmdNEOPX(pin=PIN_NUM, n=NUM_LEDS) # RPM setup PWM2RPM_FACTOR = 10 diff --git a/OLED/picomotodash_utils.py b/OLED/picomotodash_utils.py index 6b1f47a..f45a5a8 100644 --- a/OLED/picomotodash_utils.py +++ b/OLED/picomotodash_utils.py @@ -14,21 +14,6 @@ def _log(data): log_file.flush() -def ds_scan_roms(ds_sensor, resolution): - roms = ds_sensor.scan() - for rom in roms: - if resolution == 9: - config = b"\x00\x00\x1f" - elif resolution == 10: - config = b"\x00\x00\x3f" - elif resolution == 11: - config = b"\x00\x00\x5f" - elif resolution == 12: - config = b"\x00\x00\x7f" - ds_sensor.write_scratch(rom, config) - return roms - - def map_range(value, in_range, out_range): (a, b), (c, d) = in_range, out_range return (value - a) / (b - a) * (d - c) + c @@ -75,15 +60,15 @@ def read_adc(adc): return adc.read_u16() +def read_builtin_temp(adc): + CONVERSION_FACTOR = 3.3 / 65535 + reading = read_adc(adc) * CONVERSION_FACTOR + return 27 - (reading - 0.706) / 0.001721 + + def read_gps(gps): gps.update_gps(verbose=False) def read_mpu(mpu): mpu.update_mpu() - - -def read_builtin_temp(adc): - CONVERSION_FACTOR = 3.3 / 65535 - reading = read_adc(adc) * CONVERSION_FACTOR - return 27 - (reading - 0.706) / 0.001721