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:
parent
4c654ec969
commit
1751076592
2614 changed files with 349009 additions and 0 deletions
|
@ -0,0 +1,50 @@
|
|||
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""PWMOut Class for RP2040s with u2if"""
|
||||
from .rp2040_u2if import rp2040_u2if
|
||||
|
||||
|
||||
class PWMOut:
|
||||
"""Base Pulse Width Modulation Output Class"""
|
||||
|
||||
def __init__(self, pin, *, frequency=500, duty_cycle=0, variable_frequency=False):
|
||||
rp2040_u2if.pwm_configure(
|
||||
pin,
|
||||
frequency=frequency,
|
||||
duty_cycle=duty_cycle,
|
||||
variable_frequency=variable_frequency,
|
||||
)
|
||||
|
||||
self._pin = pin
|
||||
|
||||
def __del__(self):
|
||||
self.deinit()
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, t, value, traceback):
|
||||
self.deinit()
|
||||
|
||||
def deinit(self):
|
||||
"""Deinit PWM."""
|
||||
rp2040_u2if.pwm_deinit(self._pin)
|
||||
|
||||
@property
|
||||
def duty_cycle(self):
|
||||
"""The PWM's output duty cycle, 16-bit."""
|
||||
return rp2040_u2if.pwm_get_duty_cycle(self._pin)
|
||||
|
||||
@duty_cycle.setter
|
||||
def duty_cycle(self, duty_cycle):
|
||||
rp2040_u2if.pwm_set_duty_cycle(self._pin, duty_cycle)
|
||||
|
||||
@property
|
||||
def frequency(self):
|
||||
"""The PWM's output frequency in Hertz."""
|
||||
return rp2040_u2if.pwm_get_frequency(self._pin)
|
||||
|
||||
@frequency.setter
|
||||
def frequency(self, frequency):
|
||||
rp2040_u2if.pwm_set_frequency(self._pin, frequency)
|
Loading…
Add table
Add a link
Reference in a new issue