-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing Constructor in ds18x20.pyi #17
Comments
@havenith """DS18x20 temperature sensor driver
"""
from typing import Any, List
from onewire import OneWire
class DS18X20:
"""
DS18X20 library for MicroPython
"""
def __init__(self, onewire: OneWire):
"""
ToDo
DS18X20 library for MicroPython
https://mpython.readthedocs.io/en/master/library/mPython/ds18x20.html
"""
pass
def convert_temp(self):
"""
Convert the raw temperature data into degrees celsius and return as a fixed point with 2 decimal places.
"""
pass
def read_scratch(self, rom) -> bytearray:
"""
Read the scratchpad memory of the addressed device. 9 bytes of data will be returned
"""
pass
def read_temp(self, rom) -> int:
"""
Get the temperature reading of the addressed device as degree Celsuis. In
case of an CRC error, None is returned.
Warning: After power up and before a conversion cycle has been performed,
the DS18x20 sensors will return the value 85°C. Since this is also a valid
return value, the calling app must decide, whether it is a reasonable value
in the given context.
"""
pass
def scan(self) -> List[Any]:
"""
Return the list of DS18x2x devices on the bus. Only devices with
rom type 0x10, 0x22 and 0x22 are selected.
"""
pass
def write_scratch(self, rom, buf):
"""
Write to the scratchpad of the addressed devices. data shall be three bytes.
The first two bytes are the high and low alarm temperature. The third by is
the configuration. See the DS18B20 data sheet for details.
"""
pass
def const():
pass ps. try the above with the following from machine import Pin
from onewire import OneWire
from ds18x20 import DS18X20
ds_pin = Pin(4)
ds_sensor = DS18X20(OneWire(ds_pin)) have fun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disclaimer: I'm new to Pico, Pico-Stub/Pico-Go and Python.
When I follow typical examples of using ds18x20, a onewire instance is passed to construct the DS18X20 object. Something like:
Doing this in a Visual Studio Code project with the pico-go extension, results in
Expected no arguments to "DS18X20" constructor Pylance reportGeneralTypeIssues
It seems to my untrained eye that the interface is missing a constructor definition? Perhaps this was not added, for good reason, but adding the following to ds18x20.pyi seems to resolve the issue:
The text was updated successfully, but these errors were encountered: