Skip to content

Commit

Permalink
Minor changes to utils and main OLED file
Browse files Browse the repository at this point in the history
  • Loading branch information
slabua committed Apr 8, 2024
1 parent 1a66543 commit 6a621d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
4 changes: 2 additions & 2 deletions OLED/picomotodash_oled_ws10d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
27 changes: 6 additions & 21 deletions OLED/picomotodash_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 6a621d5

Please sign in to comment.