Skip to content

File activity.py#

File List > build > lib.linux-armv7l-cpython-311 > pypisoundmicro > activity.py

Go to the documentation of this file

from ._utils import copy_doc
from . import Element, ElementName
from .swig import pypisoundmicro as psm
from typing import Self, Type, Union
from .types import ActivityType, Pin

@copy_doc(psm.Activity)
class Activity(Element):

    @classmethod
    def setup_activity(cls: Type[Self], name: Union[str, ElementName, psm.ElementName], pin: Pin, activity: ActivityType) -> Self:
        """
        Set up an activity element.
        See also: upisnd_setup_activity
        """
        if isinstance(name, str):
            name = psm.ElementName.regular(name)
        elif isinstance(name, ElementName):
            name = name._name
        native_obj = psm.Activity.setupActivity(name, pin, activity)
        return cls(native_obj)

    @property
    def activity_type(self) -> ActivityType:
        """ Get the activity of the element."""
        return self._native_obj.getActivity()