j5.components.piezo module¶
Classes for Piezo support.
-
class
j5.components.piezo.
Note
[source]¶ -
An enumeration of notes.
An enumeration of notes from scientific pitch notation and their related frequencies in Hz.
-
A6
= 1760.0¶
-
A7
= 3520.0¶
-
B6
= 1975.5¶
-
B7
= 3951.1¶
-
C6
= 1047.0¶
-
C7
= 2093.0¶
-
C8
= 4186.0¶
-
D6
= 1174.7¶
-
D7
= 2349.3¶
-
E6
= 1318.5¶
-
E7
= 2637.0¶
-
F6
= 1396.9¶
-
F7
= 2793.8¶
-
G6
= 1568.0¶
-
G7
= 3136.0¶
-
-
class
j5.components.piezo.
Piezo
(identifier: int, backend: j5.components.piezo.PiezoInterface)[source]¶ Bases:
j5.components.component.Component
A standard piezo.
-
buzz
(duration: Union[int, float, datetime.timedelta], pitch: Union[int, float, j5.components.piezo.Note]) → None[source]¶ Queue a note to be played.
Float and integer durations are measured in seconds.
Parameters: - duration – length to play for:
- pitch – pitch of buzz.
-
identifier
¶ An integer to identify the component on a board.
Returns: component identifier.
-
static
interface_class
() → Type[j5.components.piezo.PiezoInterface][source]¶ Get the interface class that is required to use this component.
Returns: interface class.
-
static
verify_duration
(duration: datetime.timedelta) → None[source]¶ Verify that a duration is valid.
Parameters: duration – duration to validate.
Raises: - TypeError – duration must be a timedelta.
- ValueError – duration cannot be negative.
-
static
verify_pitch
(pitch: Union[int, float, j5.components.piezo.Note]) → None[source]¶ Verify that a pitch is valid.
Parameters: pitch – pitch to validate.
Raises: - TypeError – Pitch must be float or Note
- ValueError – Frequency must be greater than zero
-
-
class
j5.components.piezo.
PiezoInterface
[source]¶ Bases:
j5.components.component.Interface
An interface containing the methods required to control an piezo.