MikrofonSensor und TemperaturSenor die zwei Python programme funktionieren. mit den jeweiligen 2 json Datein. Beim TemperaturSensor wird im Terminal keine Wertre ausgegeben aber in der json Datei kann man die Temp und Hum sehen.

This commit is contained in:
Chiara 2025-05-28 14:53:44 +02:00
parent 4c654ec969
commit 1751076592
2614 changed files with 349009 additions and 0 deletions

View file

@ -0,0 +1,161 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Dan Halbert for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing`
================================================================================
Types needed for type annotation that are not in `typing`
* Author(s): Alec Delaney, Dan Halbert, Randy Hudson
"""
__version__ = "1.12.1"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Typing.git"
import array
from typing import TYPE_CHECKING, Optional, Union
# Protocol was introduced in Python 3.8, TypeAlias in 3.10
from typing_extensions import Protocol, TypeAlias
# pylint: disable=used-before-assignment
if TYPE_CHECKING:
import alarm
import audiocore
import audiomixer
import audiomp3
import rgbmatrix
import synthio
import ulab
from alarm.pin import PinAlarm
from alarm.time import TimeAlarm
from ulab.numpy import ndarray
# Lists below are alphabetized.
# More added in each conditional import.
__all__ = [
"Alarm",
"AudioSample",
"BlockDevice",
"ByteStream",
"FrameBuffer",
"ReadableBuffer",
"WriteableBuffer",
]
ReadableBuffer: TypeAlias = Union[
array.array,
bytearray,
bytes,
memoryview,
"rgbmatrix.RGBMatrix",
"ulab.numpy.ndarray",
]
"""Classes that implement the readable buffer protocol."""
WriteableBuffer: TypeAlias = Union[
array.array,
bytearray,
memoryview,
"rgbmatrix.RGBMatrix",
"ulab.numpy.ndarray",
]
"""Classes that implement the writeable buffer protocol."""
class ByteStream(Protocol):
"""Protocol for basic I/O operations on a byte stream.
Classes which implement this protocol include
* `io.BytesIO`
* `io.FileIO` (for a file open in binary mode)
* `busio.UART`
* `usb_cdc.Serial`
"""
def read(self, count: Optional[int] = None, /) -> Optional[bytes]:
"""Read ``count`` bytes from the stream.
If ``count`` bytes are not immediately available,
or if the parameter is not specified in the call,
the outcome is implementation-dependent.
"""
def write(self, buf: ReadableBuffer, /) -> Optional[int]:
"""Write the bytes in ``buf`` to the stream."""
class BlockDevice(Protocol):
"""Protocol for block device objects to enable a device to support
CircuitPython filesystems. Classes which implement this protocol
include `storage.VfsFat`.
"""
def readblocks(self, block_num: int, buf: bytearray) -> None:
"""Read aligned, multiples of blocks. Starting at
the block given by the index ``block_num``, read blocks
from the device into ``buf`` (an array of bytes). The number
of blocks to read is given by the length of ``buf``,
which will be a multiple of the block size.
"""
def writeblocks(self, block_num: int, buf: bytearray) -> None:
"""Write aligned, multiples of blocks, and require that
the blocks that are written to be first erased (if necessary)
by this method. Starting at the block given by the index
``block_num``, write blocks from ``buf`` (an array of bytes) to the
device. The number of blocks to write is given by the length
of ``buf``, which will be a multiple of the block size.
"""
def ioctl(self, operation: int, arg: Optional[int] = None) -> Optional[int]:
"""Control the block device and query its parameters. The operation to
perform is given by ``operation`` which is one of the following integers:
* 1 - initialise the device (``arg`` is unused)
* 2 - shutdown the device (``arg`` is unused)
* 3 - sync the device (``arg`` is unused)
* 4 - get a count of the number of blocks, should return an integer (``arg`` is unused)
* 5 - get the number of bytes in a block, should return an integer,
or ``None`` in which case the default value of 512 is used (``arg`` is unused)
* 6 - erase a block, arg is the block number to erase
As a minimum ``ioctl(4, ...)`` must be intercepted; for littlefs ``ioctl(6, ...)``
must also be intercepted. The need for others is hardware dependent.
Prior to any call to ``writeblocks(block, ...)`` littlefs issues ``ioctl(6, block)``.
This enables a device driver to erase the block prior to a write if the hardware
requires it. Alternatively a driver might intercept ``ioctl(6, block)`` and return 0
(success). In this case the driver assumes responsibility for detecting the need
for erasure.
Unless otherwise stated ``ioctl(operation, arg)`` can return ``None``. Consequently an
implementation can ignore unused values of ``operation``. Where ``operation`` is
intercepted, the return value for operations 4 and 5 are as detailed above. Other
operations should return 0 on success and non-zero for failure, with the value returned
being an ``OSError`` errno code.
"""
# These types may not be in adafruit-blinka, so use the string form instead of a resolved name.
AudioSample: TypeAlias = Union[
"audiocore.WaveFile",
"audiocore.RawSample",
"audiomixer.Mixer",
"audiomp3.MP3Decoder",
"synthio.MidiTrack",
]
"""Classes that implement the audiosample protocol.
You can play these back with `audioio.AudioOut`, `audiobusio.I2SOut` or `audiopwmio.PWMAudioOut`.
"""
FrameBuffer: TypeAlias = Union["rgbmatrix.RGBMatrix"]
"""Classes that implement the framebuffer protocol."""
Alarm: TypeAlias = Union["alarm.pin.PinAlarm", "alarm.time.TimeAlarm"]
"""Classes that implement alarms for sleeping and asynchronous notification.
You can use these alarms to wake up from light or deep sleep.
"""

View file

@ -0,0 +1,28 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing.device_drivers`
================================================================================
Type annotation definitions for device drivers. Used for `adafruit_register`.
* Author(s): Alec Delaney
"""
from adafruit_bus_device.i2c_device import I2CDevice
from adafruit_bus_device.spi_device import SPIDevice
from typing_extensions import Protocol # Safety import for Python 3.7
# pylint: disable=too-few-public-methods
class I2CDeviceDriver(Protocol):
"""Describes classes that are drivers utilizing `I2CDevice`"""
i2c_device: I2CDevice
# pylint: disable=too-few-public-methods
class SPIDeviceDriver(Protocol):
"""Describes classes that are drivers utilizing `SPIDevice`"""
spi_device: SPIDevice

View file

@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing.displayio`
================================================================================
Type annotation definitions used for displayio related components.
* Author(s): Tim Cocks
"""
from typing import TypeAlias, Union
from busdisplay import BusDisplay
from epaperdisplay import EPaperDisplay
AnyDisplay: TypeAlias = Union[BusDisplay, EPaperDisplay, "framebufferio.FramebufferDisplay"]

View file

@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
#
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing.http`
===========================
Type annotation definitions for HTTP and related objects
* Author(s): Alec Delaney
"""
from adafruit_requests import Response
# Protocol was introduced in Python 3.8.
from typing_extensions import Protocol
class HTTPProtocol(Protocol):
"""Protocol for HTTP request managers, like typical wifi managers"""
def get(self, url: str, **kw) -> Response:
"""Send HTTP GET request"""
def put(self, url: str, **kw) -> Response:
"""Send HTTP PUT request"""
def post(self, url: str, **kw) -> Response:
"""Send HTTP POST request"""
def patch(self, url: str, **kw) -> Response:
"""Send HTTP PATCH request"""
def delete(self, url: str, **kw) -> Response:
"""Send HTTP DELETE request"""

View file

@ -0,0 +1,43 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
#
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing.io`
================================================================================
Type annotation definitions for IO-related objects
* Author(s): Alec Delaney
"""
# Protocol was introduced in Python 3.8.
from typing_extensions import Protocol
class ROValueIO(Protocol):
"""Hardware objects, like `analogio.AnalogIn`, that have read-only
``value`` properties/attributes.
"""
@property
def value(self) -> float:
"""Value property, that may return an `int` or `float` depending
on the specifics of the class.
"""
class ValueIO(Protocol):
"""Hardware objects, like `analogio.AnalogOut`, that have read and
write ``value`` properties/attributes.
"""
@property
def value(self) -> float:
"""Value property, that may return an `int` or `float` depending
on the specifics of the class.
"""
# pylint: disable=no-self-use,unused-argument
@value.setter
def value(self, input_value: float, /): ...

View file

@ -0,0 +1,34 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
#
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing.led`
================================================================================
Type annotation definitions for LEDs.
* Author(s): Alec Delaney
"""
from typing import Tuple, Union
# Protocol was introduced in Python 3.8, TypeAlias in 3.10
from typing_extensions import Protocol, TypeAlias
ColorBasedColorUnion: TypeAlias = Union[int, Tuple[int, int, int]]
FillBasedColorUnion: TypeAlias = Union[ColorBasedColorUnion, Tuple[int, int, int, int]]
class ColorBasedLED(Protocol):
"""Protocol for LEDs using the :meth:`color` method"""
def color(self, value: ColorBasedColorUnion) -> None:
"""Sets the color of the LED"""
class FillBasedLED(Protocol):
"""Protocol for LEDs using the :meth:`fill` method"""
def fill(self, color: FillBasedColorUnion) -> None:
"""Sets the color of the LED"""

View file

@ -0,0 +1,65 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
#
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing.pil`
================================================================================
Type annotation definitions for PIL Images.
* Author(s): Alec Delaney
"""
from typing import Callable, Optional, Tuple
# Protocol was introduced in Python 3.8
from typing_extensions import Protocol
class PixelAccess(Protocol):
"""Type annotation for PIL's PixelAccess class"""
# pylint: disable=invalid-name
def __getitem__(self, xy: Tuple[int, int]) -> int:
"""Get pixels by x, y coordinate"""
class Image(Protocol):
"""Type annotation for PIL's Image class"""
# pylint: disable=too-many-arguments,invalid-name
@property
def mode(self) -> str:
"""The mode of the image"""
@property
def size(self) -> Tuple[int, int]:
"""The size of the image"""
def load(self) -> PixelAccess:
"""Load the image for quick pixel access"""
def convert(
self,
mode: str,
matrix: Optional[Tuple],
dither: Callable,
palette: int,
colors: int,
):
"""Returns a converted copy of this image."""
def rotate(
self,
angle: int,
resampling,
expand: int,
center: Tuple[int, int],
translate: Tuple[int, int],
fillcolor: int,
):
"""Returns a rotated copy of this image."""
def getpixel(self, xy: Tuple[int, int]):
"""Returns the pixel value at a given position."""

View file

@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Alec Delaney
#
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing.pwmio`
================================================================================
Type annotation definitions for PWMOut where Blinka doesn't otherwise define it.
* Author(s): Alec Delaney
"""
# # Protocol was introduced in Python 3.8.
from typing_extensions import Protocol
class PWMOut(Protocol):
"""Protocol that implements, at the bare minimum, the `duty_cycle` property"""
@property
def duty_cycle(self) -> int:
"""The duty cycle as a ratio using 16-bits"""
# pylint: disable=no-self-use,unused-argument
@duty_cycle.setter
def duty_cycle(self, duty_cycle: int) -> None: ...

View file

@ -0,0 +1,140 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 Kevin Conley
# SPDX-License-Identifier: MIT
"""
`circuitpython_typing.socket`
================================================================================
Type annotation definitions for sockets. Used for `adafruit_requests` and similar libraries.
* Author(s): Kevin Conley
"""
from ssl import SSLContext
from types import ModuleType
from typing import Any, Optional, Tuple, Union
# Protocol was introduced in Python 3.8, TypeAlias in 3.10
from typing_extensions import Protocol, TypeAlias
# Based on https://github.com/python/typeshed/blob/master/stdlib/_socket.pyi
__all__ = [
# alphabetized
"CircuitPythonSocketType",
"CommonCircuitPythonSocketType",
"CommonSocketType",
"InterfaceType",
"LegacyCircuitPythonSocketType",
"SSLContextType",
"SocketType",
"SocketpoolModuleType",
"StandardPythonSocketType",
"SupportsRecvInto",
"SupportsRecvWithFlags",
]
class CommonSocketType(Protocol):
"""Describes the common structure every socket type must have."""
def send(self, data: bytes, flags: int = ...) -> None:
"""Send data to the socket. The meaning of the optional flags kwarg is
implementation-specific."""
def settimeout(self, value: Optional[float]) -> None:
"""Set a timeout on blocking socket operations."""
def close(self) -> None:
"""Close the socket."""
class CommonCircuitPythonSocketType(CommonSocketType, Protocol):
"""Describes the common structure every CircuitPython socket type must have."""
def connect(
self,
address: Tuple[str, int],
conntype: Optional[int] = ...,
) -> None:
"""Connect to a remote socket at the provided (host, port) address. The conntype
kwarg optionally may indicate SSL or not, depending on the underlying interface.
"""
class LegacyCircuitPythonSocketType(CommonCircuitPythonSocketType, Protocol):
"""Describes the structure a legacy CircuitPython socket type must have."""
def recv(self, bufsize: int = ...) -> bytes:
"""Receive data from the socket. The return value is a bytes object representing
the data received. The maximum amount of data to be received at once is specified
by bufsize."""
class SupportsRecvWithFlags(Protocol):
"""Describes a type that posseses a socket recv() method supporting the flags kwarg."""
def recv(self, bufsize: int = ..., flags: int = ...) -> bytes:
"""Receive data from the socket. The return value is a bytes object representing
the data received. The maximum amount of data to be received at once is specified
by bufsize. The meaning of the optional flags kwarg is implementation-specific.
"""
class SupportsRecvInto(Protocol):
"""Describes a type that possesses a socket recv_into() method."""
def recv_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> int:
"""Receive up to nbytes bytes from the socket, storing the data into the provided
buffer. If nbytes is not specified (or 0), receive up to the size available in the
given buffer. The meaning of the optional flags kwarg is implementation-specific.
Returns the number of bytes received."""
class CircuitPythonSocketType(
CommonCircuitPythonSocketType,
SupportsRecvInto,
SupportsRecvWithFlags,
Protocol,
): # pylint: disable=too-many-ancestors
"""Describes the structure every modern CircuitPython socket type must have."""
class StandardPythonSocketType(CommonSocketType, SupportsRecvInto, SupportsRecvWithFlags, Protocol):
"""Describes the structure every standard Python socket type must have."""
def connect(self, address: Union[Tuple[Any, ...], str, bytes]) -> None:
"""Connect to a remote socket at the provided address."""
SocketType: TypeAlias = Union[
LegacyCircuitPythonSocketType,
CircuitPythonSocketType,
StandardPythonSocketType,
]
SocketpoolModuleType = ModuleType
class InterfaceType(Protocol):
"""Describes the structure every interface type must have."""
@property
def TLS_MODE(self) -> int: # pylint: disable=invalid-name
"""Constant representing that a socket's connection mode is TLS."""
# pylint: disable=too-few-public-methods
class _FakeSSLSocket:
"""Describes the structure every fake SSL socket type must have."""
class _FakeSSLContext:
"""Describes the structure every fake SSL context type must have."""
def wrap_socket(
self, socket: CircuitPythonSocketType, server_hostname: Optional[str] = None
) -> _FakeSSLSocket:
"""Wrap socket and return a new one that uses the methods from the original."""
SSLContextType: TypeAlias = Union[SSLContext, _FakeSSLContext]