diff --git a/src/micropython/beta/typeshed.en.json b/src/micropython/beta/typeshed.en.json index 352c0453a..61b85d873 100644 --- a/src/micropython/beta/typeshed.en.json +++ b/src/micropython/beta/typeshed.en.json @@ -37,11 +37,11 @@ "/typeshed/stdlib/_typeshed/__init__.pyi": "# Utility types for typeshed\n#\n# See the README.md file in this directory for more information.\n\nimport array\nimport sys\nfrom os import PathLike\nfrom typing import AbstractSet, Any, Container, Iterable, Protocol, Tuple, TypeVar, Union\nfrom typing_extensions import Literal, final\n\n_KT = TypeVar(\"_KT\")\n_KT_co = TypeVar(\"_KT_co\", covariant=True)\n_KT_contra = TypeVar(\"_KT_contra\", contravariant=True)\n_VT = TypeVar(\"_VT\")\n_VT_co = TypeVar(\"_VT_co\", covariant=True)\n_T = TypeVar(\"_T\")\n_T_co = TypeVar(\"_T_co\", covariant=True)\n_T_contra = TypeVar(\"_T_contra\", contravariant=True)\n\n# Use for \"self\" annotations:\n# def __enter__(self: Self) -> Self: ...\nSelf = TypeVar(\"Self\") # noqa Y001\n\n# stable\nclass IdentityFunction(Protocol):\n def __call__(self, __x: _T) -> _T: ...\n\nclass SupportsLessThan(Protocol):\n def __lt__(self, __other: Any) -> bool: ...\n\nSupportsLessThanT = TypeVar(\"SupportsLessThanT\", bound=SupportsLessThan) # noqa: Y001\n\nclass SupportsDivMod(Protocol[_T_contra, _T_co]):\n def __divmod__(self, __other: _T_contra) -> _T_co: ...\n\nclass SupportsRDivMod(Protocol[_T_contra, _T_co]):\n def __rdivmod__(self, __other: _T_contra) -> _T_co: ...\n\nclass SupportsLenAndGetItem(Protocol[_T_co]):\n def __len__(self) -> int: ...\n def __getitem__(self, __k: int) -> _T_co: ...\n\n# Mapping-like protocols\n\n# stable\nclass SupportsItems(Protocol[_KT_co, _VT_co]):\n def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: ...\n\n# stable\nclass SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):\n def keys(self) -> Iterable[_KT]: ...\n def __getitem__(self, __k: _KT) -> _VT_co: ...\n\n# stable\nclass SupportsGetItem(Container[_KT_contra], Protocol[_KT_contra, _VT_co]):\n def __getitem__(self, __k: _KT_contra) -> _VT_co: ...\n\n# stable\nclass SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, _VT]):\n def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ...\n def __delitem__(self, __v: _KT_contra) -> None: ...\n\n# These aliases are simple strings in Python 2.\nStrPath = Union[str, PathLike[str]] # stable\nBytesPath = Union[bytes, PathLike[bytes]] # stable\nStrOrBytesPath = Union[str, bytes, PathLike[str], PathLike[bytes]] # stable\n\nOpenTextModeUpdating = Literal[\n \"r+\",\n \"+r\",\n \"rt+\",\n \"r+t\",\n \"+rt\",\n \"tr+\",\n \"t+r\",\n \"+tr\",\n \"w+\",\n \"+w\",\n \"wt+\",\n \"w+t\",\n \"+wt\",\n \"tw+\",\n \"t+w\",\n \"+tw\",\n \"a+\",\n \"+a\",\n \"at+\",\n \"a+t\",\n \"+at\",\n \"ta+\",\n \"t+a\",\n \"+ta\",\n \"x+\",\n \"+x\",\n \"xt+\",\n \"x+t\",\n \"+xt\",\n \"tx+\",\n \"t+x\",\n \"+tx\",\n]\nOpenTextModeWriting = Literal[\"w\", \"wt\", \"tw\", \"a\", \"at\", \"ta\", \"x\", \"xt\", \"tx\"]\nOpenTextModeReading = Literal[\"r\", \"rt\", \"tr\", \"U\", \"rU\", \"Ur\", \"rtU\", \"rUt\", \"Urt\", \"trU\", \"tUr\", \"Utr\"]\nOpenTextMode = Union[OpenTextModeUpdating, OpenTextModeWriting, OpenTextModeReading]\nOpenBinaryModeUpdating = Literal[\n \"rb+\",\n \"r+b\",\n \"+rb\",\n \"br+\",\n \"b+r\",\n \"+br\",\n \"wb+\",\n \"w+b\",\n \"+wb\",\n \"bw+\",\n \"b+w\",\n \"+bw\",\n \"ab+\",\n \"a+b\",\n \"+ab\",\n \"ba+\",\n \"b+a\",\n \"+ba\",\n \"xb+\",\n \"x+b\",\n \"+xb\",\n \"bx+\",\n \"b+x\",\n \"+bx\",\n]\nOpenBinaryModeWriting = Literal[\"wb\", \"bw\", \"ab\", \"ba\", \"xb\", \"bx\"]\nOpenBinaryModeReading = Literal[\"rb\", \"br\", \"rbU\", \"rUb\", \"Urb\", \"brU\", \"bUr\", \"Ubr\"]\nOpenBinaryMode = Union[OpenBinaryModeUpdating, OpenBinaryModeReading, OpenBinaryModeWriting]\n\n# stable\nclass HasFileno(Protocol):\n def fileno(self) -> int: ...\n\nFileDescriptor = int # stable\nFileDescriptorLike = Union[int, HasFileno] # stable\n\n# stable\nclass SupportsRead(Protocol[_T_co]):\n def read(self, __length: int = ...) -> _T_co: ...\n\n# stable\nclass SupportsReadline(Protocol[_T_co]):\n def readline(self, __length: int = ...) -> _T_co: ...\n\n# stable\nclass SupportsNoArgReadline(Protocol[_T_co]):\n def readline(self) -> _T_co: ...\n\n# stable\nclass SupportsWrite(Protocol[_T_contra]):\n def write(self, __s: _T_contra) -> Any: ...\n\nReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any]] # stable\nWriteableBuffer = Union[bytearray, memoryview, array.array[Any]] # stable\n\n# stable\nif sys.version_info >= (3, 10):\n from types import NoneType as NoneType\nelse:\n # Used by type checkers for checks involving None (does not exist at runtime)\n @final\n class NoneType:\n def __bool__(self) -> Literal[False]: ...\n", "/typeshed/stdlib/microbit/__init__.pyi": "\"\"\"Pins, images, sounds, temperature and volume.\n\"\"\"\n\nfrom typing import Any, Callable, List, Optional, Tuple, Union, overload\n\nfrom _typeshed import ReadableBuffer\n\n# V2 only\nfrom . import accelerometer as accelerometer\nfrom . import audio as audio\nfrom . import compass as compass\nfrom . import display as display\nfrom . import i2c as i2c\nfrom . import microphone as microphone\nfrom . import speaker as speaker\nfrom . import spi as spi\nfrom . import uart as uart\n\ndef run_every(\n callback: Optional[Callable[[], None]] = None,\n days: int = 0,\n h: int = 0,\n min: int = 0,\n s: int = 0,\n ms: int = 0,\n) -> Callable[[Callable[[], None]], Callable[[], None]]:\n \"\"\"Schedule to run a function at the interval specified by the time arguments **V2 only**.\n\n Example: ``run_every(my_logging, min=5)``\n\n ``run_every`` can be used in two ways:\n\n As a Decorator - placed on top of the function to schedule. For example::\n\n @run_every(days=1, h=1, min=20, s=30, ms=50)\n def my_function():\n # Do something here\n\n As a Function - passing the callback as a positional argument. For example::\n\n def my_function():\n # Do something here\n run_every(my_function, s=30)\n\n Each argument corresponds to a different time unit and they are additive.\n So ``run_every(min=1, s=30)`` schedules the callback every minute and a half.\n\n When an exception is thrown inside the callback function it deschedules the\n function. To avoid this you can catch exceptions with ``try/except``.\n\n :param callback: Function to call at the provided interval. Omit when using as a decorator.\n :param days: Sets the day mark for the scheduling.\n :param h: Sets the hour mark for the scheduling.\n :param min: Sets the minute mark for the scheduling.\n :param s: Sets the second mark for the scheduling.\n :param ms: Sets the millisecond mark for the scheduling.\n \"\"\"\n\ndef panic(n: int) -> None:\n \"\"\"Enter a panic mode.\n\n Example: ``panic(127)``\n\n :param n: An arbitrary integer <= 255 to indicate a status.\n\n Requires restart.\n \"\"\"\n\ndef reset() -> None:\n \"\"\"Restart the board.\"\"\"\n\n\n@overload\ndef scale(value: float, from_: Tuple[float, float], to: Tuple[int, int]) -> int:\n \"\"\"Converts a value from a range to an integer range.\n\n Example: ``volume = scale(accelerometer.get_x(), from_=(-2000, 2000), to=(0, 255))``\n\n For example, to convert an accelerometer X value to a speaker volume.\n\n If one of the numbers in the ``to`` parameter is a floating point\n (i.e a decimal number like ``10.0``), this function will return a\n floating point number.\n\n temp_fahrenheit = scale(30, from_=(0.0, 100.0), to=(32.0, 212.0))\n\n :param value: A number to convert.\n :param from_: A tuple to define the range to convert from.\n :param to: A tuple to define the range to convert to.\n :return: The ``value`` converted to the ``to`` range.\n \"\"\"\n\n@overload\ndef scale(value: float, from_: Tuple[float, float], to: Tuple[float, float]) -> float:\n \"\"\"Converts a value from a range to a floating point range.\n\n Example: ``temp_fahrenheit = scale(30, from_=(0.0, 100.0), to=(32.0, 212.0))``\n\n For example, to convert temperature from a Celsius scale to Fahrenheit.\n\n If one of the numbers in the ``to`` parameter is a floating point\n (i.e a decimal number like ``10.0``), this function will return a\n floating point number.\n If they are both integers (i.e ``10``), it will return an integer::\n\n returns_int = scale(accelerometer.get_x(), from_=(-2000, 2000), to=(0, 255))\n\n :param value: A number to convert.\n :param from_: A tuple to define the range to convert from.\n :param to: A tuple to define the range to convert to.\n :return: The ``value`` converted to the ``to`` range.\n \"\"\"\n\ndef sleep(n: float) -> None:\n \"\"\"Wait for ``n`` milliseconds.\n\n Example: ``sleep(1000)``\n\n :param n: The number of milliseconds to wait\n\n One second is 1000 milliseconds, so::\n\n microbit.sleep(1000)\n\n will pause the execution for one second.\n \"\"\"\n\ndef running_time() -> int:\n \"\"\"Get the running time of the board.\n\n :return: The number of milliseconds since the board was switched on or restarted.\n \"\"\"\n\ndef temperature() -> int:\n \"\"\"Get the temperature of the micro:bit in degrees Celsius.\"\"\"\n\ndef set_volume(v: int) -> None:\n \"\"\"Sets the volume.\n\n Example: ``set_volume(127)``\n\n :param v: a value between 0 (low) and 255 (high).\n\n Out of range values will be clamped to 0 or 255.\n\n **V2** only.\n \"\"\"\n ...\n\nclass Button:\n \"\"\"The class for the buttons ``button_a`` and ``button_b``.\"\"\"\n\n def is_pressed(self) -> bool:\n \"\"\"Check if the button is pressed.\n\n :return: ``True`` if the specified button ``button`` is pressed, and ``False`` otherwise.\n \"\"\"\n ...\n def was_pressed(self) -> bool:\n \"\"\"Check if the button was pressed since the device started or the last time this method was called.\n\n Calling this method will clear the press state so\n that the button must be pressed again before this method will return\n ``True`` again.\n\n :return: ``True`` if the specified button ``button`` was pressed, and ``False`` otherwise\n \"\"\"\n ...\n def get_presses(self) -> int:\n \"\"\"Get the running total of button presses, and resets this total\n to zero before returning.\n\n :return: The number of presses since the device started or the last time this method was called\n \"\"\"\n ...\n\nbutton_a: Button\n\"\"\"The left button ``Button`` object.\"\"\"\n\nbutton_b: Button\n\"\"\"The right button ``Button`` object.\"\"\"\n\nclass MicroBitDigitalPin:\n \"\"\"A digital pin.\n\n Some pins support analog and touch features using the ``MicroBitAnalogDigitalPin`` and ``MicroBitTouchPin`` subclasses.\n \"\"\"\n\n NO_PULL: int\n PULL_UP: int\n PULL_DOWN: int\n def read_digital(self) -> int:\n \"\"\"Get the digital value of the pin.\n\n Example: ``value = pin0.read_digital()``\n\n :return: 1 if the pin is high, and 0 if it's low.\n \"\"\"\n ...\n def write_digital(self, value: int) -> None:\n \"\"\"Set the digital value of the pin.\n\n Example: ``pin0.write_digital(1)``\n\n :param value: 1 to set the pin high or 0 to set the pin low\"\"\"\n ...\n def set_pull(self, value: int) -> None:\n \"\"\"Set the pull state to one of three possible values: ``PULL_UP``, ``PULL_DOWN`` or ``NO_PULL``.\n\n Example: ``pin0.set_pull(pin0.PULL_UP)``\n\n :param value: The pull state from the relevant pin, e.g. ``pin0.PULL_UP``.\n \"\"\"\n ...\n def get_pull(self) -> int:\n \"\"\"Get the pull state on a pin.\n\n Example: ``pin0.get_pull()``\n\n :return: ``NO_PULL``, ``PULL_DOWN``, or ``PULL_UP``\n\n These are set using the ``set_pull()`` method or automatically configured\n when a pin mode requires it.\n \"\"\"\n ...\n def get_mode(self) -> str:\n \"\"\"Returns the pin mode.\n\n Example: ``pin0.get_mode()``\n\n When a pin is used for a specific function, like\n writing a digital value, or reading an analog value, the pin mode\n changes.\n\n :return: ``\"unused\"``, ``\"analog\"``, ``\"read_digital\"``, ``\"write_digital\"``, ``\"display\"``, ``\"button\"``, ``\"music\"``, ``\"audio\"``, ``\"touch\"``, ``\"i2c\"``, or ``\"spi\"``\n \"\"\"\n ...\n def write_analog(self, value: int) -> None:\n \"\"\"Output a PWM signal on the pin, with the duty cycle proportional to ``value``.\n\n Example: ``pin0.write_analog(254)``\n\n :param value: An integer or a floating point number between 0 (0% duty cycle) and 1023 (100% duty).\n \"\"\"\n def set_analog_period(self, period: int) -> None:\n \"\"\"Set the period of the PWM signal being output to ``period`` in milliseconds.\n\n Example: ``pin0.set_analog_period(10)``\n\n :param period: The period in milliseconds with a minimum valid value of 1ms.\n \"\"\"\n def set_analog_period_microseconds(self, period: int) -> None:\n \"\"\"Set the period of the PWM signal being output to ``period`` in microseconds.\n\n Example: ``pin0.set_analog_period_microseconds(512)``\n\n :param period: The period in microseconds with a minimum valid value of 256\u00b5s.\n \"\"\"\n\nclass MicroBitAnalogDigitalPin(MicroBitDigitalPin):\n \"\"\"A pin with analog and digital features.\"\"\"\n\n def read_analog(self) -> int:\n \"\"\"Read the voltage applied to the pin.\n\n Example: ``pin0.read_analog()``\n\n :return: An integer between 0 (meaning 0V) and 1023 (meaning 3.3V).\n \"\"\"\n\nclass MicroBitTouchPin(MicroBitAnalogDigitalPin):\n \"\"\"A pin with analog, digital and touch features.\"\"\"\n\n CAPACITIVE: int\n RESISTIVE: int\n def is_touched(self) -> bool:\n \"\"\"Check if the pin is being touched.\n\n Example: ``pin0.is_touched()``\n\n :return: ``True`` if the pin is being touched with a finger, otherwise return ``False``.\n \"\"\"\n ...\n\n def was_touched(self) -> bool:\n \"\"\"Check if the pin was touched since the last time this method was called.\n\n Example: ``pin0.was_touched()``\n\n :return: ``True`` or ``False`` to indicate if the pin was touched since the device started or since the last time this method was called.\n \"\"\"\n ...\n \n def get_touches(self) -> int:\n \"\"\"Get the number of times the pin was touched since the last time this method was called.\n\n Example: ``pin0.get_touches()``\n\n :return: The number of times the pin was touched since the device started or since the last time this method was called.\n \"\"\"\n ...\n\n def set_touch_mode(self, value: int) -> None:\n \"\"\"Set the touch mode for the pin.\n\n Example: ``pin0.set_touch_mode(pin0.CAPACITIVE)``\n\n The default touch mode for the pins on the edge connector is\n ``resistive``. The default for the logo pin **V2** is ``capacitive``.\n\n **Resistive touch**\n This test is done by measuring how much resistance there is between the\n pin and ground. A low resistance gives a reading of ``True``. To get\n a reliable reading using a finger you may need to touch the ground pin\n with another part of your body, for example your other hand.\n\n **Capacitive touch**\n This test is done by interacting with the electric field of a capacitor\n using a finger as a conductor. `Capacitive touch\n `_\n does not require you to make a ground connection as part of a circuit.\n\n :param value: ``CAPACITIVE`` or ``RESISTIVE`` from the relevant pin.\n \"\"\"\n ...\n\npin0: MicroBitTouchPin\n\"\"\"Pin with digital, analog and touch features.\"\"\"\n\npin1: MicroBitTouchPin\n\"\"\"Pin with digital, analog and touch features.\"\"\"\n\npin2: MicroBitTouchPin\n\"\"\"Pin with digital, analog and touch features.\"\"\"\n\npin3: MicroBitAnalogDigitalPin\n\"\"\"Pin with digital and analog features.\"\"\"\n\npin4: MicroBitAnalogDigitalPin\n\"\"\"Pin with digital and analog features.\"\"\"\n\npin5: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin6: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin7: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin8: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin9: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin10: MicroBitAnalogDigitalPin\n\"\"\"Pin with digital and analog features.\"\"\"\n\npin11: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin12: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin13: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin14: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin15: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin16: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin19: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin20: MicroBitDigitalPin\n\"\"\"Pin with digital features.\"\"\"\n\npin_logo: MicroBitTouchPin\n\"\"\"A touch sensitive logo pin on the front of the micro:bit, which by default is set to capacitive touch mode.\"\"\"\n\npin_speaker: MicroBitAnalogDigitalPin\n\"\"\"A pin to address the micro:bit speaker.\n\nThis API is intended only for use in Pulse-Width Modulation pin operations e.g. pin_speaker.write_analog(128).\n\"\"\"\n\nclass Image:\n \"\"\"An image to show on the micro:bit LED display.\n\n Given an image object it's possible to display it via the ``display`` API::\n\n display.show(Image.HAPPY)\n \"\"\"\n\n HEART: Image\n \"\"\"Heart image.\"\"\"\n\n HEART_SMALL: Image\n \"\"\"Small heart image.\"\"\"\n\n HAPPY: Image\n \"\"\"Happy face image.\"\"\"\n\n SMILE: Image\n \"\"\"Smiling face image.\"\"\"\n\n SAD: Image\n \"\"\"Sad face image.\"\"\"\n\n CONFUSED: Image\n \"\"\"Confused face image.\"\"\"\n\n ANGRY: Image\n \"\"\"Angry face image.\"\"\"\n\n ASLEEP: Image\n \"\"\"Sleeping face image.\"\"\"\n\n SURPRISED: Image\n \"\"\"Surprised face image.\"\"\"\n\n SILLY: Image\n \"\"\"Silly face image.\"\"\"\n\n FABULOUS: Image\n \"\"\"Sunglasses face image.\"\"\"\n\n MEH: Image\n \"\"\"Unimpressed face image.\"\"\"\n\n YES: Image\n \"\"\"Tick image.\"\"\"\n\n NO: Image\n \"\"\"Cross image.\"\"\"\n\n CLOCK12: Image\n \"\"\"Image with line pointing to 12 o'clock.\"\"\"\n\n CLOCK11: Image\n \"\"\"Image with line pointing to 11 o'clock.\"\"\"\n\n CLOCK10: Image\n \"\"\"Image with line pointing to 10 o'clock.\"\"\"\n\n CLOCK9: Image\n \"\"\"Image with line pointing to 9 o'clock.\"\"\"\n\n CLOCK8: Image\n \"\"\"Image with line pointing to 8 o'clock.\"\"\"\n\n CLOCK7: Image\n \"\"\"Image with line pointing to 7 o'clock.\"\"\"\n\n CLOCK6: Image\n \"\"\"Image with line pointing to 6 o'clock.\"\"\"\n\n CLOCK5: Image\n \"\"\"Image with line pointing to 5 o'clock.\"\"\"\n\n CLOCK4: Image\n \"\"\"Image with line pointing to 4 o'clock.\"\"\"\n\n CLOCK3: Image\n \"\"\"Image with line pointing to 3 o'clock.\"\"\"\n\n CLOCK2: Image\n \"\"\"Image with line pointing to 2 o'clock.\"\"\"\n\n CLOCK1: Image\n \"\"\"Image with line pointing to 1 o'clock.\"\"\"\n\n ARROW_N: Image\n \"\"\"Image of arrow pointing north.\"\"\"\n\n ARROW_NE: Image\n \"\"\"Image of arrow pointing north east.\"\"\"\n\n ARROW_E: Image\n \"\"\"Image of arrow pointing east.\"\"\"\n\n ARROW_SE: Image\n \"\"\"Image of arrow pointing south east.\"\"\"\n\n ARROW_S: Image\n \"\"\"Image of arrow pointing south.\"\"\"\n\n ARROW_SW: Image\n \"\"\"Image of arrow pointing south west.\"\"\"\n\n ARROW_W: Image\n \"\"\"Image of arrow pointing west.\"\"\"\n\n ARROW_NW: Image\n \"\"\"Image of arrow pointing north west.\"\"\"\n\n TRIANGLE: Image\n \"\"\"Image of a triangle pointing up.\"\"\"\n\n TRIANGLE_LEFT: Image\n \"\"\"Image of a triangle in the left corner.\"\"\"\n\n CHESSBOARD: Image\n \"\"\"Alternate LEDs lit in a chessboard pattern.\"\"\"\n\n DIAMOND: Image\n \"\"\"Diamond image.\"\"\"\n\n DIAMOND_SMALL: Image\n \"\"\"Small diamond image.\"\"\"\n\n SQUARE: Image\n \"\"\"Square image.\"\"\"\n\n SQUARE_SMALL: Image\n \"\"\"Small square image.\"\"\"\n\n RABBIT: Image\n \"\"\"Rabbit image.\"\"\"\n\n COW: Image\n \"\"\"Cow image.\"\"\"\n\n MUSIC_CROTCHET: Image\n \"\"\"Crotchet note image.\"\"\"\n\n MUSIC_QUAVER: Image\n \"\"\"Quaver note image.\"\"\"\n\n MUSIC_QUAVERS: Image\n \"\"\"Pair of quavers note image.\"\"\"\n\n PITCHFORK: Image\n \"\"\"Pitchfork image.\"\"\"\n\n XMAS: Image\n \"\"\"Christmas tree image.\"\"\"\n\n PACMAN: Image\n \"\"\"Pac-Man arcade character image.\"\"\"\n\n TARGET: Image\n \"\"\"Target image.\"\"\"\n\n TSHIRT: Image\n \"\"\"T-shirt image.\"\"\"\n\n ROLLERSKATE: Image\n \"\"\"Rollerskate image.\"\"\"\n\n DUCK: Image\n \"\"\"Duck image.\"\"\"\n\n HOUSE: Image\n \"\"\"House image.\"\"\"\n\n TORTOISE: Image\n \"\"\"Tortoise image.\"\"\"\n\n BUTTERFLY: Image\n \"\"\"Butterfly image.\"\"\"\n\n STICKFIGURE: Image\n \"\"\"Stick figure image.\"\"\"\n\n GHOST: Image\n \"\"\"Ghost image.\"\"\"\n\n SWORD: Image\n \"\"\"Sword image.\"\"\"\n\n GIRAFFE: Image\n \"\"\"Giraffe image.\"\"\"\n\n SKULL: Image\n \"\"\"Skull image.\"\"\"\n\n UMBRELLA: Image\n \"\"\"Umbrella image.\"\"\"\n\n SNAKE: Image\n \"\"\"Snake image.\"\"\"\n\n SCISSORS: Image\n \"\"\"Scissors image.\"\"\"\n\n ALL_CLOCKS: List[Image]\n \"\"\"A list containing all the CLOCK_ images in sequence.\"\"\"\n\n ALL_ARROWS: List[Image]\n \"\"\"A list containing all the ARROW_ images in sequence.\"\"\"\n @overload\n def __init__(self, string: str) -> None:\n \"\"\"Create an image from a string describing which LEDs are lit.\n\n ``string`` has to consist of digits 0-9 arranged into lines,\n describing the image, for example::\n\n image = Image(\"90009:\"\n \"09090:\"\n \"00900:\"\n \"09090:\"\n \"90009\")\n\n will create a 5\u00d75 image of an X. The end of a line is indicated by a\n colon. It's also possible to use newlines (\\\\n) insead of the colons.\n\n :param string: The string describing the image.\n \"\"\"\n ...\n @overload\n def __init__(\n self, width: int = 5, height: int = 5, buffer: ReadableBuffer = None\n ) -> None:\n \"\"\"Create an empty image with ``width`` columns and ``height`` rows.\n\n :param width: Optional width of the image\n :param height: Optional height of the image\n :param buffer: Optional array or bytes of ``width``\u00d7``height`` integers in range 0-9 to initialize the image\n\n Examples::\n\n Image(2, 2, b'\\x08\\x08\\x08\\x08')\n Image(2, 2, bytearray([9,9,9,9]))\n\n These create 2 x 2 pixel images at full brightness.\n \"\"\"\n ...\n def width(self) -> int:\n \"\"\"Get the number of columns.\n\n :return: The number of columns in the image\n \"\"\"\n ...\n def height(self) -> int:\n \"\"\"Get the number of rows.\n\n :return: The number of rows in the image\n \"\"\"\n ...\n def set_pixel(self, x: int, y: int, value: int) -> None:\n \"\"\"Set the brightness of a pixel.\n\n Example: ``my_image.set_pixel(0, 0, 9)``\n\n :param x: The column number\n :param y: The row number\n :param value: The brightness as an integer between 0 (dark) and 9 (bright)\n\n This method will raise an exception when called on any of the built-in\n read-only images, like ``Image.HEART``.\n \"\"\"\n ...\n def get_pixel(self, x: int, y: int) -> int:\n \"\"\"Get the brightness of a pixel.\n\n Example: ``my_image.get_pixel(0, 0)``\n\n :param x: The column number\n :param y: The row number\n :return: The brightness as an integer between 0 and 9.\n \"\"\"\n ...\n def shift_left(self, n: int) -> Image:\n \"\"\"Create a new image by shifting the picture left.\n\n Example: ``Image.HEART_SMALL.shift_left(1)``\n\n :param n: The number of columns to shift by\n :return: The shifted image\n \"\"\"\n ...\n def shift_right(self, n: int) -> Image:\n \"\"\"Create a new image by shifting the picture right.\n\n Example: ``Image.HEART_SMALL.shift_right(1)``\n\n :param n: The number of columns to shift by\n :return: The shifted image\n \"\"\"\n ...\n def shift_up(self, n: int) -> Image:\n \"\"\"Create a new image by shifting the picture up.\n\n Example: ``Image.HEART_SMALL.shift_up(1)``\n\n :param n: The number of rows to shift by\n :return: The shifted image\n \"\"\"\n ...\n def shift_down(self, n: int) -> Image:\n \"\"\"Create a new image by shifting the picture down.\n\n Example: ``Image.HEART_SMALL.shift_down(1)``\n\n :param n: The number of rows to shift by\n :return: The shifted image\n \"\"\"\n ...\n def crop(self, x: int, y: int, w: int, h: int) -> Image:\n \"\"\"Create a new image by cropping the picture.\n\n Example: ``Image.HEART.crop(1, 1, 3, 3)``\n\n :param x: The crop offset column\n :param y: The crop offset row\n :param w: The crop width\n :param h: The crop height\n :return: The new image\n \"\"\"\n ...\n def copy(self) -> Image:\n \"\"\"Create an exact copy of the image.\n\n Example: ``Image.HEART.copy()``\n\n :return: The new image\n \"\"\"\n ...\n def invert(self) -> Image:\n \"\"\"Create a new image by inverting the brightness of the pixels in the\n source image.\n\n Example: ``Image.SMALL_HEART.invert()``\n\n :return: The new image.\n \"\"\"\n ...\n def fill(self, value: int) -> None:\n \"\"\"Set the brightness of all the pixels in the image.\n\n Example: ``my_image.fill(5)``\n\n :param value: The new brightness as a number between 0 (dark) and 9 (bright).\n\n This method will raise an exception when called on any of the built-in\n read-only images, like ``Image.HEART``.\n \"\"\"\n ...\n def blit(\n self,\n src: Image,\n x: int,\n y: int,\n w: int,\n h: int,\n xdest: int = 0,\n ydest: int = 0,\n ) -> None:\n \"\"\"Copy an area from another image into this image.\n\n Example: ``my_image.blit(Image.HEART, 1, 1, 3, 3, 1, 1)``\n\n :param src: The source image\n :param x: The starting column offset in the source image\n :param y: The starting row offset in the source image\n :param w: The number of columns to copy\n :param h: The number of rows to copy\n :param xdest: The column offset to modify in this image\n :param ydest: The row offset to modify in this image\n\n Pixels outside the source image are treated as having a brightness of 0.\n\n ``shift_left()``, ``shift_right()``, ``shift_up()``, ``shift_down()``\n and ``crop()`` can are all implemented by using ``blit()``.\n\n For example, img.crop(x, y, w, h) can be implemented as::\n\n def crop(self, x, y, w, h):\n res = Image(w, h)\n res.blit(self, x, y, w, h)\n return res\n \"\"\"\n ...\n def __repr__(self) -> str:\n \"\"\"Get a compact string representation of the image.\"\"\"\n ...\n def __str__(self) -> str:\n \"\"\"Get a readable string representation of the image.\"\"\"\n ...\n def __add__(self, other: Image) -> Image:\n \"\"\"Create a new image by adding the brightness values from the two\n images for each pixel.\n\n Example: ``Image.HEART + Image.HAPPY``\n\n :param other: The image to add.\n \"\"\"\n ...\n def __sub__(self, other: Image) -> Image:\n \"\"\"Create a new image by subtracting the brightness values of the\n other image from this image.\n\n Example: ``Image.HEART - Image.HEART_SMALL``\n\n :param other: The image to subtract.\n \"\"\"\n ...\n def __mul__(self, n: float) -> Image:\n \"\"\"Create a new image by multiplying the brightness of each pixel by\n ``n``.\n\n Example: ``Image.HEART * 0.5``\n\n :param n: The value to multiply by.\n \"\"\"\n ...\n def __truediv__(self, n: float) -> Image:\n \"\"\"Create a new image by dividing the brightness of each pixel by\n ``n``.\n\n Example: ``Image.HEART / 2``\n\n :param n: The value to divide by.\n \"\"\"\n ...\n\nclass SoundEvent:\n LOUD: SoundEvent\n \"\"\"Represents the transition of sound events, from ``quiet`` to ``loud`` like clapping or shouting.\"\"\"\n\n QUIET: SoundEvent\n \"\"\"Represents the transition of sound events, from ``loud`` to ``quiet`` like speaking or background music.\"\"\"\n\nclass Sound:\n \"\"\"The built-in sounds can be called using ``audio.play(Sound.NAME)``.\"\"\"\n\n GIGGLE: Sound\n \"\"\"Giggling sound.\"\"\"\n\n HAPPY: Sound\n \"\"\"Happy sound.\"\"\"\n\n HELLO: Sound\n \"\"\"Greeting sound.\"\"\"\n\n MYSTERIOUS: Sound\n \"\"\"Mysterious sound.\"\"\"\n\n SAD: Sound\n \"\"\"Sad sound.\"\"\"\n\n SLIDE: Sound\n \"\"\"Sliding sound.\"\"\"\n\n SOARING: Sound\n \"\"\"Soaring sound.\"\"\"\n\n SPRING: Sound\n \"\"\"Spring sound.\"\"\"\n\n TWINKLE: Sound\n \"\"\"Twinkling sound.\"\"\"\n\n YAWN: Sound\n \"\"\"Yawning sound.\"\"\"\n", "/typeshed/stdlib/microbit/accelerometer.pyi": "\"\"\"Measure the acceleration of the micro:bit and recognise gestures.\n\"\"\"\n\nfrom typing import Tuple\n\ndef get_x() -> int:\n \"\"\"Get the acceleration measurement in the ``x`` axis in milli-g.\n\n Example: ``accelerometer.get_x()``\n\n :return: A positive or negative integer depending on direction in the range +/- 2000mg.\n \"\"\"\n ...\n\ndef get_y() -> int:\n \"\"\"Get the acceleration measurement in the ``y`` axis in milli-g.\n\n Example: ``accelerometer.get_y()``\n\n :return: A positive or negative integer depending on direction in the range +/- 2000mg.\n \"\"\"\n ...\n\ndef get_z() -> int:\n \"\"\"Get the acceleration measurement in the ``z`` axis in milli-g.\n\n Example: ``accelerometer.get_z()``\n\n :return: A positive or negative integer depending on direction in the range +/- 2000mg.\n \"\"\"\n ...\n\ndef get_values() -> Tuple[int, int, int]:\n \"\"\"Get the acceleration measurements in all axes at once as a tuple.\n\n Example: ``x, y, z = accelerometer.get_values()``\n\n :return: a three-element tuple of integers ordered as X, Y, Z, each value a positive or negative integer depending on direction in the range +/- 2000mg\n \"\"\"\n ...\n\ndef get_strength() -> int:\n \"\"\"Get the acceleration measurement of all axes combined, as a positive integer. This is the Pythagorean sum of the X, Y and Z axes.\n\n Example: ``accelerometer.get_strength()``\n\n :return: The combined acceleration strength of all the axes, in milli-g.\n \"\"\"\n ...\n\ndef current_gesture() -> str:\n \"\"\"Get the name of the current gesture.\n\n Example: ``accelerometer.current_gesture()``\n\n MicroPython understands the following gesture names: ``\"up\"``, ``\"down\"``,\n ``\"left\"``, ``\"right\"``, ``\"face up\"``, ``\"face down\"``, ``\"freefall\"``,\n ``\"3g\"``, ``\"6g\"``, ``\"8g\"``, ``\"shake\"``. Gestures are always\n represented as strings.\n\n :return: The current gesture\n \"\"\"\n ...\n\ndef is_gesture(name: str) -> bool:\n \"\"\"Check if the named gesture is currently active.\n\n Example: ``accelerometer.is_gesture('shake')``\n\n MicroPython understands the following gesture names: ``\"up\"``, ``\"down\"``,\n ``\"left\"``, ``\"right\"``, ``\"face up\"``, ``\"face down\"``, ``\"freefall\"``,\n ``\"3g\"``, ``\"6g\"``, ``\"8g\"``, ``\"shake\"``. Gestures are always\n represented as strings.\n\n :param name: The gesture name.\n :return: ``True`` if the gesture is active, ``False`` otherwise.\n \"\"\"\n ...\n\ndef was_gesture(name: str) -> bool:\n \"\"\"Check if the named gesture was active since the last call.\n\n Example: ``accelerometer.was_gesture('shake')``\n\n MicroPython understands the following gesture names: ``\"up\"``, ``\"down\"``,\n ``\"left\"``, ``\"right\"``, ``\"face up\"``, ``\"face down\"``, ``\"freefall\"``,\n ``\"3g\"``, ``\"6g\"``, ``\"8g\"``, ``\"shake\"``. Gestures are always\n represented as strings.\n\n :param name: The gesture name.\n :return: ``True`` if the gesture was active since the last call, ``False`` otherwise.\n \"\"\"\n\ndef get_gestures() -> Tuple[str, ...]:\n \"\"\"Return a tuple of the gesture history.\n\n Example: ``accelerometer.get_gestures()``\n\n Clears the gesture history before returning.\n\n Gestures are not updated in the background so there needs to be constant\n calls to some accelerometer method to do the gesture detection. Usually\n gestures can be detected using a loop with a small :func:`microbit.sleep` delay.\n\n :return: The history as a tuple, most recent last.\n \"\"\"\n ...\n\ndef set_range(value: int) -> None:\n \"\"\"Set the accelerometer sensitivity range, in g (standard gravity), to the closest values supported by the hardware, so it rounds to either ``2``, ``4``, or ``8`` g.\n\n Example: ``accelerometer.set_range(8)``\n\n :param value: New range for the accelerometer, an integer in ``g``.\n \"\"\"\n", - "/typeshed/stdlib/microbit/audio.pyi": "\"\"\"Play sounds using the micro:bit (import ``audio`` for V1 compatibility).\n\"\"\"\n\nfrom ..microbit import MicroBitDigitalPin, Sound, pin0\nfrom typing import ClassVar, Iterable, Union\n\ndef play(\n source: Union[AudioFrame, Iterable[AudioFrame], Sound, SoundEffect],\n wait: bool = True,\n pin: MicroBitDigitalPin = pin0,\n return_pin: Union[MicroBitDigitalPin, None] = None,\n) -> None:\n \"\"\"Play a built-in sound, sound effect or audio samples using ``AudioFrame``.\n\n Example: ``audio.play(Sound.GIGGLE)``\n\n :param source: A built-in ``Sound`` such as ``Sound.GIGGLE``, a ``SoundEffect`` or sample data as an ``AudioFrame`` object or an iterable of ``AudioFrame`` objects.\n :param wait: If ``wait`` is ``True``, this function will block until the sound is complete.\n :param pin: An optional argument to specify the output pin can be used to override the default of ``pin0``. If we do not want any sound to play we can use ``pin=None``.\n :param return_pin: Specifies a differential edge connector pin to connect to an external speaker instead of ground. This is ignored for the **V2** revision.\n \"\"\"\n\ndef is_playing() -> bool:\n \"\"\"Check whether a sound is playing.\n\n Example: ``audio.is_playing()``\n\n :return: ``True`` if audio is playing, otherwise ``False``.\"\"\"\n ...\n\ndef sound_level() -> int:\n \"\"\"Returns the average intensity of the sound played.\n\n Example: ``audio.sound_level()``\n\n :return: A number between 0 and 254, being the average intensity of the sound played from the most recent chunk of data.\"\"\"\n ...\n\ndef stop() -> None:\n \"\"\"Stop all audio playback.\n\n Example: ``audio.stop()``\n \"\"\"\n ...\n\nclass SoundEffect:\n \"\"\"A sound effect, composed by a set of parameters configured via the constructor or attributes.\"\"\"\n\n WAVEFORM_SINE: ClassVar[int]\n \"\"\"Sine wave option used for the ``waveform`` parameter.\"\"\"\n\n WAVEFORM_SAWTOOTH: ClassVar[int]\n \"\"\"Sawtooth wave option used for the ``waveform`` parameter.\"\"\"\n\n WAVEFORM_TRIANGLE: ClassVar[int]\n \"\"\"Triangle wave option used for the ``waveform`` parameter.\"\"\"\n\n WAVEFORM_SQUARE: ClassVar[int]\n \"\"\"Square wave option used for the ``waveform`` parameter.\"\"\"\n\n WAVEFORM_NOISE: ClassVar[int]\n \"\"\"Noise option used for the ``waveform`` parameter.\"\"\"\n\n SHAPE_LINEAR: ClassVar[int]\n \"\"\"Linear interpolation option used for the ``shape`` parameter.\"\"\"\n\n SHAPE_CURVE: ClassVar[int]\n \"\"\"Curve interpolation option used for the ``shape`` parameter.\"\"\"\n\n SHAPE_LOG: ClassVar[int]\n \"\"\"Logarithmic interpolation option used for the ``shape`` parameter.\"\"\"\n\n FX_NONE: ClassVar[int]\n \"\"\"No effect option used for the ``fx`` parameter.\"\"\"\n\n FX_TREMOLO: ClassVar[int]\n \"\"\"Tremolo effect option used for the ``fx`` parameter.\"\"\"\n\n FX_VIBRATO: ClassVar[int]\n \"\"\"Vibrato effect option used for the ``fx`` parameter.\"\"\"\n\n FX_WARBLE: ClassVar[int]\n \"\"\"Warble effect option used for the ``fx`` parameter.\"\"\"\n\n freq_start: int\n \"\"\"Start frequency in Hertz (Hz), a number between ``0`` and ``9999``\"\"\"\n\n freq_end: int\n \"\"\"End frequency in Hertz (Hz), a number between ``0`` and ``9999``\"\"\"\n\n duration: int\n \"\"\"Duration of the sound in milliseconds, a number between ``0`` and ``9999``\"\"\"\n\n vol_start: int\n \"\"\"Start volume value, a number between ``0`` and ``255``\"\"\"\n\n vol_end: int\n \"\"\"End volume value, a number between ``0`` and ``255``\"\"\"\n\n waveform: int\n \"\"\"Type of waveform shape, one of these values: ``WAVEFORM_SINE``, ``WAVEFORM_SAWTOOTH``, ``WAVEFORM_TRIANGLE``, ``WAVEFORM_SQUARE``, ``WAVEFORM_NOISE`` (randomly generated noise)\"\"\"\n\n fx: int\n \"\"\"Effect to add on the sound, one of the following values: ``FX_TREMOLO``, ``FX_VIBRATO``, ``FX_WARBLE``, or ``FX_NONE``\"\"\"\n\n shape: int\n \"\"\"The type of the interpolation curve between the start and end frequencies, different wave shapes have different rates of change in frequency. One of the following values: ``SHAPE_LINEAR``, ``SHAPE_CURVE``, ``SHAPE_LOG``\"\"\"\n\n def __init__(\n self,\n freq_start: int = 500,\n freq_end: int = 2500,\n duration: int = 500,\n vol_start: int = 255,\n vol_end: int = 0,\n waveform: int = WAVEFORM_SQUARE,\n fx: int = FX_NONE,\n shape: int = SHAPE_LOG,\n ):\n \"\"\"Create a new sound effect.\n\n Example: ``my_effect = SoundEffect(duration=1000)``\n\n All the parameters are optional, with default values as shown above, and\n they can all be modified via attributes of the same name. For example, we\n can first create an effect ``my_effect = SoundEffect(duration=1000)``,\n and then change its attributes ``my_effect.duration = 500``.\n\n :param freq_start: Start frequency in Hertz (Hz), a number between ``0`` and ``9999``.\n :param freq_end: End frequency in Hertz (Hz), a number between ``0`` and ``9999``.\n :param duration: Duration of the sound in milliseconds, a number between ``0`` and ``9999``.\n :param vol_start: Start volume value, a number between ``0`` and ``255``.\n :param vol_end: End volume value, a number between ``0`` and ``255``.\n :param waveform: Type of waveform shape, one of these values: ``WAVEFORM_SINE``, ``WAVEFORM_SAWTOOTH``, ``WAVEFORM_TRIANGLE``, ``WAVEFORM_SQUARE``, ``WAVEFORM_NOISE`` (randomly generated noise).\n :param fx: Effect to add on the sound, one of the following values: ``FX_TREMOLO``, ``FX_VIBRATO``, ``FX_WARBLE``, or ``FX_NONE``.\n :param shape: The type of the interpolation curve between the start and end frequencies, different wave shapes have different rates of change in frequency. One of the following values: ``SHAPE_LINEAR``, ``SHAPE_CURVE``, ``SHAPE_LOG``.\n \"\"\"\n def copy(self) -> SoundEffect:\n \"\"\"Create a copy of this ``SoundEffect``.\n\n Example: ``sound_2 = sound_1.copy()``\n\n :return: A copy of the SoundEffect.\n \"\"\"\n\nclass AudioFrame:\n \"\"\"An ``AudioFrame`` object is a list of samples, each of which is an unsigned byte\n (whole number between 0 and 255).\n\n The number of samples in an AudioFrame will depend on the\n ``rate`` (number of samples per second) and ``duration`` parameters.\n The total number of samples will always be a round up multiple of 32.\n\n On micro:bit V1 the constructor does not take any arguments,\n and an AudioFrame instance is always 32 bytes.\n\n For example, playing 32 samples at 7812 Hz takes just over 4 milliseconds\n (1/7812.5 * 32 = 0.004096 = 4096 microseconds).\n\n Example::\n\n frame = AudioFrame()\n for i in range(len(frame)):\n frame[i] = 252 - i * 8\n \"\"\"\n\n def __init__(\n self,\n duration: int = -1,\n rate: int = 7812\n ):\n \"\"\"Create a new ``AudioFrame``.\n\n Example: ``my_recording = AudioFrame(duration=5000)``\n\n :param duration: Indicates how many milliseconds of audio this instance can store (V2 only).\n :param rate: The sampling rate at which data will be stored via the microphone, or played via the ``audio.play()`` function (V2 only).\n \"\"\"\n\n def set_rate(self, sample_rate: int) -> None:\n \"\"\"Configure the sampling rate associated with the data in the\n ``AudioFrame`` instance (V2 only).\n\n Example: ``my_frame.set_rate(7812)``\n\n For recording from the microphone, increasing the sampling rate\n increases the sound quality, but reduces the length of audio it\n can store.\n\n During playback, increasing the sampling rate speeds up the sound\n and decreasing it slows it down.\n \"\"\"\n\n def get_rate(self) -> int:\n \"\"\"Get the sampling rate associated with the data in the\n ``AudioFrame`` instance (V2 only).\n\n Example: ``current_rate = my_frame.get_rate()``\n\n :return: The configured sampling rate for this ``AudioFrame`` instance.\n \"\"\"\n\n def copyfrom(self, other: AudioFrame) -> None:\n \"\"\"Overwrite the data in this ``AudioFrame`` with the data from another ``AudioFrame`` instance.\n\n Example: ``my_frame.copyfrom(source_frame)``\n\n :param other: ``AudioFrame`` instance from which to copy the data.\n \"\"\"\n def __len__(self) -> int: ...\n def __setitem__(self, key: int, value: int) -> None: ...\n def __getitem__(self, key: int) -> int: ...\n def __add__(self, v: AudioFrame) -> AudioFrame: ...\n def __iadd__(self, v: AudioFrame) -> AudioFrame: ...\n def __sub__(self, v: AudioFrame) -> AudioFrame: ...\n def __isub__(self, v: AudioFrame) -> AudioFrame: ...\n def __mul__(self, v: float) -> AudioFrame: ...\n def __imul__(self, v: float) -> AudioFrame: ...\n", + "/typeshed/stdlib/microbit/audio.pyi": "\"\"\"Play sounds using the micro:bit (import ``audio`` for V1 compatibility).\n\"\"\"\n\nfrom ..microbit import MicroBitDigitalPin, Sound, pin0\nfrom typing import ClassVar, Iterable, Union\n\ndef play(\n source: Union[AudioFrame, Iterable[AudioFrame], Sound, SoundEffect],\n wait: bool = True,\n pin: MicroBitDigitalPin = pin0,\n return_pin: Union[MicroBitDigitalPin, None] = None,\n) -> None:\n \"\"\"Play a built-in sound, sound effect or audio samples using ``AudioFrame``.\n\n Example: ``audio.play(Sound.GIGGLE)``\n\n :param source: A built-in ``Sound`` such as ``Sound.GIGGLE``, a ``SoundEffect`` or sample data as an ``AudioFrame`` object or an iterable of ``AudioFrame`` objects.\n :param wait: If ``wait`` is ``True``, this function will block until the sound is complete.\n :param pin: An optional argument to specify the output pin can be used to override the default of ``pin0``. If we do not want any sound to play we can use ``pin=None``.\n :param return_pin: Specifies a differential edge connector pin to connect to an external speaker instead of ground. This is ignored for the **V2** revision.\n \"\"\"\n\ndef is_playing() -> bool:\n \"\"\"Check whether a sound is playing.\n\n Example: ``audio.is_playing()``\n\n :return: ``True`` if audio is playing, otherwise ``False``.\"\"\"\n ...\n\ndef sound_level() -> int:\n \"\"\"Returns the sound pressure level produced by audio currently being played.\n\n Example: ``audio.sound_level()``\n\n :return: A representation of the output sound pressure level in the range 0 to 255.\"\"\"\n ...\n\ndef stop() -> None:\n \"\"\"Stop all audio playback.\n\n Example: ``audio.stop()``\n \"\"\"\n ...\n\nclass SoundEffect:\n \"\"\"A sound effect, composed by a set of parameters configured via the constructor or attributes.\"\"\"\n\n WAVEFORM_SINE: ClassVar[int]\n \"\"\"Sine wave option used for the ``waveform`` parameter.\"\"\"\n\n WAVEFORM_SAWTOOTH: ClassVar[int]\n \"\"\"Sawtooth wave option used for the ``waveform`` parameter.\"\"\"\n\n WAVEFORM_TRIANGLE: ClassVar[int]\n \"\"\"Triangle wave option used for the ``waveform`` parameter.\"\"\"\n\n WAVEFORM_SQUARE: ClassVar[int]\n \"\"\"Square wave option used for the ``waveform`` parameter.\"\"\"\n\n WAVEFORM_NOISE: ClassVar[int]\n \"\"\"Noise option used for the ``waveform`` parameter.\"\"\"\n\n SHAPE_LINEAR: ClassVar[int]\n \"\"\"Linear interpolation option used for the ``shape`` parameter.\"\"\"\n\n SHAPE_CURVE: ClassVar[int]\n \"\"\"Curve interpolation option used for the ``shape`` parameter.\"\"\"\n\n SHAPE_LOG: ClassVar[int]\n \"\"\"Logarithmic interpolation option used for the ``shape`` parameter.\"\"\"\n\n FX_NONE: ClassVar[int]\n \"\"\"No effect option used for the ``fx`` parameter.\"\"\"\n\n FX_TREMOLO: ClassVar[int]\n \"\"\"Tremolo effect option used for the ``fx`` parameter.\"\"\"\n\n FX_VIBRATO: ClassVar[int]\n \"\"\"Vibrato effect option used for the ``fx`` parameter.\"\"\"\n\n FX_WARBLE: ClassVar[int]\n \"\"\"Warble effect option used for the ``fx`` parameter.\"\"\"\n\n freq_start: int\n \"\"\"Start frequency in Hertz (Hz), a number between ``0`` and ``9999``\"\"\"\n\n freq_end: int\n \"\"\"End frequency in Hertz (Hz), a number between ``0`` and ``9999``\"\"\"\n\n duration: int\n \"\"\"Duration of the sound in milliseconds, a number between ``0`` and ``9999``\"\"\"\n\n vol_start: int\n \"\"\"Start volume value, a number between ``0`` and ``255``\"\"\"\n\n vol_end: int\n \"\"\"End volume value, a number between ``0`` and ``255``\"\"\"\n\n waveform: int\n \"\"\"Type of waveform shape, one of these values: ``WAVEFORM_SINE``, ``WAVEFORM_SAWTOOTH``, ``WAVEFORM_TRIANGLE``, ``WAVEFORM_SQUARE``, ``WAVEFORM_NOISE`` (randomly generated noise)\"\"\"\n\n fx: int\n \"\"\"Effect to add on the sound, one of the following values: ``FX_TREMOLO``, ``FX_VIBRATO``, ``FX_WARBLE``, or ``FX_NONE``\"\"\"\n\n shape: int\n \"\"\"The type of the interpolation curve between the start and end frequencies, different wave shapes have different rates of change in frequency. One of the following values: ``SHAPE_LINEAR``, ``SHAPE_CURVE``, ``SHAPE_LOG``\"\"\"\n\n def __init__(\n self,\n freq_start: int = 500,\n freq_end: int = 2500,\n duration: int = 500,\n vol_start: int = 255,\n vol_end: int = 0,\n waveform: int = WAVEFORM_SQUARE,\n fx: int = FX_NONE,\n shape: int = SHAPE_LOG,\n ):\n \"\"\"Create a new sound effect.\n\n Example: ``my_effect = SoundEffect(duration=1000)``\n\n All the parameters are optional, with default values as shown above, and\n they can all be modified via attributes of the same name. For example, we\n can first create an effect ``my_effect = SoundEffect(duration=1000)``,\n and then change its attributes ``my_effect.duration = 500``.\n\n :param freq_start: Start frequency in Hertz (Hz), a number between ``0`` and ``9999``.\n :param freq_end: End frequency in Hertz (Hz), a number between ``0`` and ``9999``.\n :param duration: Duration of the sound in milliseconds, a number between ``0`` and ``9999``.\n :param vol_start: Start volume value, a number between ``0`` and ``255``.\n :param vol_end: End volume value, a number between ``0`` and ``255``.\n :param waveform: Type of waveform shape, one of these values: ``WAVEFORM_SINE``, ``WAVEFORM_SAWTOOTH``, ``WAVEFORM_TRIANGLE``, ``WAVEFORM_SQUARE``, ``WAVEFORM_NOISE`` (randomly generated noise).\n :param fx: Effect to add on the sound, one of the following values: ``FX_TREMOLO``, ``FX_VIBRATO``, ``FX_WARBLE``, or ``FX_NONE``.\n :param shape: The type of the interpolation curve between the start and end frequencies, different wave shapes have different rates of change in frequency. One of the following values: ``SHAPE_LINEAR``, ``SHAPE_CURVE``, ``SHAPE_LOG``.\n \"\"\"\n def copy(self) -> SoundEffect:\n \"\"\"Create a copy of this ``SoundEffect``.\n\n Example: ``sound_2 = sound_1.copy()``\n\n :return: A copy of the SoundEffect.\n \"\"\"\n\nclass AudioFrame:\n \"\"\"An ``AudioFrame`` object is a list of samples, each of which is an unsigned byte\n (whole number between 0 and 255).\n\n The number of samples in an AudioFrame will depend on the\n ``rate`` (number of samples per second) and ``duration`` parameters.\n The total number of samples will always be a round up multiple of 32.\n\n On micro:bit V1 the constructor does not take any arguments,\n and an AudioFrame instance is always 32 bytes.\n\n For example, playing 32 samples at 7812 Hz takes just over 4 milliseconds\n (1/7812.5 * 32 = 0.004096 = 4096 microseconds).\n\n Example::\n\n frame = AudioFrame()\n for i in range(len(frame)):\n frame[i] = 252 - i * 8\n \"\"\"\n\n def __init__(\n self,\n duration: int = -1,\n rate: int = 7812\n ):\n \"\"\"Create a new ``AudioFrame``.\n\n Example: ``my_recording = AudioFrame(duration=5000)``\n\n :param duration: Indicates how many milliseconds of audio this instance can store (V2 only).\n :param rate: The sampling rate at which data will be stored via the microphone, or played via the ``audio.play()`` function (V2 only).\n \"\"\"\n\n def set_rate(self, sample_rate: int) -> None:\n \"\"\"Configure the sampling rate associated with the data in the\n ``AudioFrame`` instance (V2 only).\n\n Example: ``my_frame.set_rate(7812)``\n\n For recording from the microphone, increasing the sampling rate\n increases the sound quality, but reduces the length of audio it\n can store.\n\n During playback, increasing the sampling rate speeds up the sound\n and decreasing it slows it down.\n \"\"\"\n\n def get_rate(self) -> int:\n \"\"\"Get the sampling rate associated with the data in the\n ``AudioFrame`` instance (V2 only).\n\n Example: ``current_rate = my_frame.get_rate()``\n\n :return: The configured sampling rate for this ``AudioFrame`` instance.\n \"\"\"\n\n def copyfrom(self, other: AudioFrame) -> None:\n \"\"\"Overwrite the data in this ``AudioFrame`` with the data from another ``AudioFrame`` instance.\n\n Example: ``my_frame.copyfrom(source_frame)``\n\n :param other: ``AudioFrame`` instance from which to copy the data.\n \"\"\"\n def __len__(self) -> int: ...\n def __setitem__(self, key: int, value: int) -> None: ...\n def __getitem__(self, key: int) -> int: ...\n def __add__(self, v: AudioFrame) -> AudioFrame: ...\n def __iadd__(self, v: AudioFrame) -> AudioFrame: ...\n def __sub__(self, v: AudioFrame) -> AudioFrame: ...\n def __isub__(self, v: AudioFrame) -> AudioFrame: ...\n def __mul__(self, v: float) -> AudioFrame: ...\n def __imul__(self, v: float) -> AudioFrame: ...\n", "/typeshed/stdlib/microbit/compass.pyi": "\"\"\"Use the built-in compass.\n\"\"\"\n\ndef calibrate() -> None:\n \"\"\"Starts the calibration process.\n\n Example: ``compass.calibrate()``\n\n An instructive message will be scrolled to the user after which they will need\n to rotate the device in order to draw a circle on the LED display.\n \"\"\"\n ...\n\ndef is_calibrated() -> bool:\n \"\"\"Check is the compass is calibrated.\n\n Example: ``compass.is_calibrated()``\n\n :return: ``True`` if the compass has been successfully calibrated, ``False`` otherwise.\n \"\"\"\n ...\n\ndef clear_calibration() -> None:\n \"\"\"Undoes the calibration, making the compass uncalibrated again.\n\n Example: ``compass.clear_calibration()``\n \"\"\"\n ...\n\ndef get_x() -> int:\n \"\"\"Get the magnetic field strength on the ``x`` axis.\n\n Example: ``compass.get_x()``\n\n Call ``calibrate`` first or the results will be inaccurate.\n\n :return: A positive or negative integer in nano tesla representing the magnitude and direction of the field.\n \"\"\"\n ...\n\ndef get_y() -> int:\n \"\"\"Get the magnetic field strength on the ``y`` axis.\n\n Example: ``compass.get_y()``\n\n Call ``calibrate`` first or the results will be inaccurate.\n\n :return: A positive or negative integer in nano tesla representing the magnitude and direction of the field.\n \"\"\"\n ...\n\ndef get_z() -> int:\n \"\"\"Get the magnetic field strength on the ``z`` axis.\n\n Example: ``compass.get_z()``\n\n Call ``calibrate`` first or the results will be inaccurate.\n\n :return: A positive or negative integer in nano tesla representing the magnitude and direction of the field.\n \"\"\"\n ...\n\ndef heading() -> int:\n \"\"\"Get the compass heading.\n\n Example: ``compass.heading()``\n\n :return: An integer in the range from 0 to 360, representing the angle in degrees, clockwise, with north as 0.\n \"\"\"\n ...\n\ndef get_field_strength() -> int:\n \"\"\"Get the magnitude of the magnetic field around the device.\n\n Example: ``compass.get_field_strength()``\n\n :return: An integer indication of the magnitude of the magnetic field in nano tesla.\"\"\"\n ...\n", "/typeshed/stdlib/microbit/display.pyi": "\"\"\"Show text, images and animations on the 5\u00d75 LED display.\n\"\"\"\n\nfrom ..microbit import Image\nfrom typing import Union, overload, Iterable\n\ndef get_pixel(x: int, y: int) -> int:\n \"\"\"Get the brightness of the LED at column ``x`` and row ``y``.\n\n Example: ``display.get_pixel(0, 0)``\n\n :param x: The display column (0..4)\n :param y: The display row (0..4)\n :return: A number between 0 (off) and 9 (bright)\n \"\"\"\n ...\n\ndef set_pixel(x: int, y: int, value: int) -> None:\n \"\"\"Set the brightness of the LED at column ``x`` and row ``y``.\n\n Example: ``display.set_pixel(0, 0, 9)``\n\n :param x: The display column (0..4)\n :param y: The display row (0..4)\n :param value: The brightness between 0 (off) and 9 (bright)\n \"\"\"\n ...\n\ndef clear() -> None:\n \"\"\"Set the brightness of all LEDs to 0 (off).\n\n Example: ``display.clear()``\n \"\"\"\n ...\n\ndef show(\n image: Union[str, float, int, Image, Iterable[Image]],\n delay: int = 400,\n wait: bool = True,\n loop: bool = False,\n clear: bool = False,\n) -> None:\n \"\"\"Shows images, letters or digits on the LED display.\n\n Example: ``display.show(Image.HEART)``\n\n When ``image`` is an image or a list of images then each image is displayed in turn.\n If ``image`` is a string or number, each letter or digit is displayed in turn.\n\n :param image: A string, number, image or list of images to show.\n :param delay: Each letter, digit or image is shown with ``delay`` milliseconds between them.\n :param wait: If ``wait`` is ``True``, this function will block until the animation is finished, otherwise the animation will happen in the background.\n :param loop: If ``loop`` is ``True``, the animation will repeat forever.\n :param clear: If ``clear`` is ``True``, the display will be cleared after the sequence has finished.\n\n The ``wait``, ``loop`` and ``clear`` arguments must be specified using their keyword.\n \"\"\"\n ...\n\ndef scroll(\n text: Union[str, float, int],\n delay: int = 150,\n wait: bool = True,\n loop: bool = False,\n monospace: bool = False,\n) -> None:\n \"\"\"Scrolls a number or text on the LED display.\n\n Example: ``display.scroll('micro:bit')``\n\n :param text: The string to scroll. If ``text`` is an integer or float it is first converted to a string using ``str()``.\n :param delay: The ``delay`` parameter controls how fast the text is scrolling.\n :param wait: If ``wait`` is ``True``, this function will block until the animation is finished, otherwise the animation will happen in the background.\n :param loop: If ``loop`` is ``True``, the animation will repeat forever.\n :param monospace: If ``monospace`` is ``True``, the characters will all take up 5 pixel-columns in width, otherwise there will be exactly 1 blank pixel-column between each character as they scroll.\n\n The ``wait``, ``loop`` and ``monospace`` arguments must be specified\n using their keyword.\n \"\"\"\n ...\n\ndef on() -> None:\n \"\"\"Turn on the LED display.\n\n Example: ``display.on()``\n \"\"\"\n ...\n\ndef off() -> None:\n \"\"\"Turn off the LED display (disabling the display allows you to re-use the GPIO pins for other purposes).\n\n Example: ``display.off()``\n \"\"\"\n ...\n\ndef is_on() -> bool:\n \"\"\"Check whether the LED display is enabled.\n\n Example: ``display.is_on()``\n\n :return: ``True`` if the display is on, otherwise returns ``False``.\n \"\"\"\n ...\n\ndef read_light_level() -> int:\n \"\"\"Read the light level.\n\n Example: ``display.read_light_level()``\n\n Uses the display's LEDs in reverse-bias mode to sense the amount of light\n falling on the display.\n\n :return: An integer between 0 and 255 representing the light level, with larger meaning more light.\n \"\"\"\n ...\n", "/typeshed/stdlib/microbit/i2c.pyi": "\"\"\"Communicate with devices using the I\u00b2C bus protocol.\n\"\"\"\n\nfrom _typeshed import ReadableBuffer\nfrom ..microbit import MicroBitDigitalPin, pin19, pin20\nfrom typing import List\n\ndef init(\n freq: int = 100000, sda: MicroBitDigitalPin = pin20, scl: MicroBitDigitalPin = pin19\n) -> None:\n \"\"\"Re-initialize a peripheral.\n\n Example: ``i2c.init()``\n\n :param freq: clock frequency\n :param sda: ``sda`` pin (default 20)\n :param scl: ``scl`` pin (default 19)\n\n On a micro:bit V1 board, changing the I\u00b2C pins from defaults will make\n the accelerometer and compass stop working, as they are connected\n internally to those pins. This warning does not apply to the **V2**\n revision of the micro:bit as this has `separate I\u00b2C lines `_\n for the motion sensors and the edge connector.\n \"\"\"\n ...\n\ndef scan() -> List[int]:\n \"\"\"Scan the bus for devices.\n\n Example: ``i2c.scan()``\n\n :return: A list of 7-bit addresses corresponding to those devices that responded to the scan.\n \"\"\"\n ...\n\ndef read(addr: int, n: int, repeat: bool = False) -> bytes:\n \"\"\"Read bytes from a device.\n\n Example: ``i2c.read(0x50, 64)``\n\n :param addr: The 7-bit address of the device\n :param n: The number of bytes to read\n :param repeat: If ``True``, no stop bit will be sent\n :return: The bytes read\n \"\"\"\n ...\n\ndef write(addr: int, buf: ReadableBuffer, repeat: bool = False) -> None:\n \"\"\"Write bytes to a device.\n\n Example: ``i2c.write(0x50, bytes([1, 2, 3]))``\n\n :param addr: The 7-bit address of the device\n :param buf: A buffer containing the bytes to write\n :param repeat: If ``True``, no stop bit will be sent\n \"\"\"\n ...\n", - "/typeshed/stdlib/microbit/microphone.pyi": "\"\"\"Respond to sound using the built-in microphone (V2 only).\n\"\"\"\n\nfrom typing import Optional, Tuple\nfrom ..microbit import SoundEvent\nfrom ..microbit.audio import AudioFrame\n\ndef current_event() -> Optional[SoundEvent]:\n \"\"\"Get the last recorded sound event\n\n Example: ``microphone.current_event()``\n\n :return: The event, ``SoundEvent('loud')`` or ``SoundEvent('quiet')``.\n \"\"\"\n ...\n\ndef was_event(event: SoundEvent) -> bool:\n \"\"\"Check if a sound was heard at least once since the last call.\n\n Example: ``microphone.was_event(SoundEvent.LOUD)``\n\n This call clears the sound history before returning.\n\n :param event: The event to check for, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``\n :return: ``True`` if sound was heard at least once since the last call, otherwise ``False``.\n \"\"\"\n ...\n\ndef is_event(event: SoundEvent) -> bool:\n \"\"\"Check the most recent sound event detected.\n\n Example: ``microphone.is_event(SoundEvent.LOUD)``\n\n This call does not clear the sound event history.\n\n :param event: The event to check for, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``\n :return: ``True`` if sound was the most recent heard, ``False`` otherwise.\n \"\"\"\n ...\n\ndef get_events() -> Tuple[SoundEvent, ...]:\n \"\"\"Get the sound event history as a tuple.\n\n Example: ``microphone.get_events()``\n\n This call clears the sound history before returning.\n\n :return: A tuple of the event history with the most recent event last.\n \"\"\"\n ...\n\ndef set_threshold(event: SoundEvent, value: int) -> None:\n \"\"\"Set the threshold for a sound event.\n\n Example: ``microphone.set_threshold(SoundEvent.LOUD, 250)``\n\n A high threshold means the event will only trigger if the sound is very loud (>= 250 in the example).\n\n :param event: A sound event, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``.\n :param value: The threshold level in the range 0-255.\n \"\"\"\n ...\n\ndef sound_level() -> int:\n \"\"\"Get the sound pressure level.\n\n Example: ``microphone.sound_level()``\n\n :return: A representation of the sound pressure level in the range 0 to 255.\n \"\"\"\n ...\n\ndef record(duration: int, rate: int = 7812) -> AudioFrame:\n \"\"\"Record sound into an ``AudioFrame`` for the amount of time indicated by\n ``duration`` at the sampling rate indicated by ``rate``.\n\n Example: ``my_frame = microphone.record(3000)``\n\n The amount of memory consumed is directly related to the length of the\n recording and the sampling rate. The higher these values, the more memory\n it will use.\n\n A lower sampling rate will reduce both memory consumption and sound\n quality.\n\n If there isn't enough memory available a ``MemoryError`` will be raised.\n\n :param duration: How long to record in milliseconds.\n :param rate: Number of samples to capture per second.\n :return: An ``AudioFrame`` with the sound samples.\n \"\"\"\n ...\n\ndef record_into(buffer: AudioFrame, rate: int = 7812, wait: bool = True) -> None:\n \"\"\"Record sound into an existing ``AudioFrame`` until it is filled,\n or the ``stop_recording()`` function is called.\n\n Example: ``microphone.record_into(my_frame)``\n\n :param buffer: An ``AudioFrame`` to record sound.\n :param rate: Number of samples to capture per second.\n :param wait: When set to ``True`` it blocks until the recording is\n done, if it is set to ``False`` it will run in the background.\n \"\"\"\n ...\n\ndef is_recording() -> bool:\n \"\"\"Checks whether the microphone is currently recording.\n\n Example: ``is_recording = microphone.is_recording()``\n\n :return: ``True`` if the microphone is currently recording sound, otherwise returns ``False``.\n \"\"\"\n ...\n\ndef stop_recording() -> None:\n \"\"\"Stops a recording running in the background.\n\n Example: ``microphone.stop_recording()``\n \"\"\"\n ...\n\nSENSITIVITY_LOW: float;\n\"\"\"Low microphone sensitivity.\"\"\"\n\nSENSITIVITY_MEDIUM: float;\n\"\"\"Medium microphone sensitivity.\"\"\"\n\nSENSITIVITY_HIGH: float;\n\"\"\"High microphone sensitivity.\"\"\"\n\n\ndef set_sensitivity(gain: float) -> None:\n \"\"\"Configure the microphone sensitivity.\n\n Example: ``microphone.set_sensitivity(microphone.SENSITIVITY_HIGH)``\n\n The default sensitivity is ``microphone.SENSITIVITY_MEDIUM``.\n\n :param gain: The microphone gain. Use ``microphone.SENSITIVITY_LOW``, ``microphone.SENSITIVITY_MEDIUM``, ``microphone.SENSITIVITY_HIGH``, or a value between these levels.\n \"\"\"\n ...", + "/typeshed/stdlib/microbit/microphone.pyi": "\"\"\"Respond to sound using the built-in microphone (V2 only).\n\"\"\"\n\nfrom typing import Optional, Tuple\nfrom ..microbit import SoundEvent\nfrom ..microbit.audio import AudioFrame\n\ndef current_event() -> Optional[SoundEvent]:\n \"\"\"Get the last recorded sound event\n\n Example: ``microphone.current_event()``\n\n :return: The event, ``SoundEvent('loud')`` or ``SoundEvent('quiet')``.\n \"\"\"\n ...\n\ndef was_event(event: SoundEvent) -> bool:\n \"\"\"Check if a sound was heard at least once since the last call.\n\n Example: ``microphone.was_event(SoundEvent.LOUD)``\n\n This call clears the sound history before returning.\n\n :param event: The event to check for, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``\n :return: ``True`` if sound was heard at least once since the last call, otherwise ``False``.\n \"\"\"\n ...\n\ndef is_event(event: SoundEvent) -> bool:\n \"\"\"Check the most recent sound event detected.\n\n Example: ``microphone.is_event(SoundEvent.LOUD)``\n\n This call does not clear the sound event history.\n\n :param event: The event to check for, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``\n :return: ``True`` if sound was the most recent heard, ``False`` otherwise.\n \"\"\"\n ...\n\ndef get_events() -> Tuple[SoundEvent, ...]:\n \"\"\"Get the sound event history as a tuple.\n\n Example: ``microphone.get_events()``\n\n This call clears the sound history before returning.\n\n :return: A tuple of the event history with the most recent event last.\n \"\"\"\n ...\n\ndef set_threshold(event: SoundEvent, value: int) -> None:\n \"\"\"Set the threshold for a sound event.\n\n Example: ``microphone.set_threshold(SoundEvent.LOUD, 250)``\n\n The ``SoundEvent.LOUD`` event is triggered when the sound level crosses the \n threshold from \"quiet\" to \"loud\", and the ``SoundEvent.QUIET`` event is \n triggered when the sound level crosses from \"loud\" to \"quiet\".\n\n If the ``SoundEvent.LOUD`` threshold is set lower than the \n ``SoundEvent.QUIET`` threshold, then the ``SoundEvent.QUIET`` threshold \n will decrease by one unit below the ``SoundEvent.LOUD`` threshold. If the \n ``SoundEvent.QUIET`` threshold is set higher than the ``SoundEvent.LOUD``\n threshold, then the ``SoundEvent.LOUD`` threshold will increase by one unit \n above the ``SoundEvent.QUIET`` threshold.\n\n :param event: A sound event, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``.\n :param value: The threshold level in the range 0-255. Values outside this range will be clamped.\n \"\"\"\n ...\n\ndef sound_level() -> int:\n \"\"\"Get the sound pressure level.\n\n Example: ``microphone.sound_level()``\n\n :return: A representation of the sound pressure level in the range 0 to 255.\n \"\"\"\n ...\n\ndef record(duration: int, rate: int = 7812) -> AudioFrame:\n \"\"\"Record sound into an ``AudioFrame`` for the amount of time indicated by\n ``duration`` at the sampling rate indicated by ``rate``.\n\n Example: ``my_frame = microphone.record(3000)``\n\n The amount of memory consumed is directly related to the length of the\n recording and the sampling rate. The higher these values, the more memory\n it will use.\n\n A lower sampling rate will reduce both memory consumption and sound\n quality.\n\n If there isn't enough memory available a ``MemoryError`` will be raised.\n\n :param duration: How long to record in milliseconds.\n :param rate: Number of samples to capture per second.\n :return: An ``AudioFrame`` with the sound samples.\n \"\"\"\n ...\n\ndef record_into(buffer: AudioFrame, rate: int = 7812, wait: bool = True) -> None:\n \"\"\"Record sound into an existing ``AudioFrame`` until it is filled,\n or the ``stop_recording()`` function is called.\n\n Example: ``microphone.record_into(my_frame)``\n\n :param buffer: An ``AudioFrame`` to record sound.\n :param rate: Number of samples to capture per second.\n :param wait: When set to ``True`` it blocks until the recording is\n done, if it is set to ``False`` it will run in the background.\n \"\"\"\n ...\n\ndef is_recording() -> bool:\n \"\"\"Checks whether the microphone is currently recording.\n\n Example: ``is_recording = microphone.is_recording()``\n\n :return: ``True`` if the microphone is currently recording sound, otherwise returns ``False``.\n \"\"\"\n ...\n\ndef stop_recording() -> None:\n \"\"\"Stops a recording running in the background.\n\n Example: ``microphone.stop_recording()``\n \"\"\"\n ...\n\nSENSITIVITY_LOW: float;\n\"\"\"Low microphone sensitivity.\"\"\"\n\nSENSITIVITY_MEDIUM: float;\n\"\"\"Medium microphone sensitivity.\"\"\"\n\nSENSITIVITY_HIGH: float;\n\"\"\"High microphone sensitivity.\"\"\"\n\n\ndef set_sensitivity(gain: float) -> None:\n \"\"\"Configure the microphone sensitivity.\n\n Example: ``microphone.set_sensitivity(microphone.SENSITIVITY_HIGH)``\n\n The default sensitivity is ``microphone.SENSITIVITY_MEDIUM``.\n\n :param gain: The microphone gain. Use ``microphone.SENSITIVITY_LOW``, ``microphone.SENSITIVITY_MEDIUM``, ``microphone.SENSITIVITY_HIGH``, or a value between these levels.\n \"\"\"\n ...", "/typeshed/stdlib/microbit/speaker.pyi": "\"\"\"Control the built-in speaker (V2 only).\n\"\"\"\n\ndef off() -> None:\n \"\"\"Turn the speaker off.\n\n Example: ``speaker.off()``\n\n This does not disable sound output to an edge connector pin.\n \"\"\"\n ...\n\ndef on() -> None:\n \"\"\"Turn the speaker on.\n\n Example: ``speaker.on()``\n \"\"\"\n ...\n", "/typeshed/stdlib/microbit/spi.pyi": "\"\"\"Communicate with devices using the serial peripheral interface (SPI) bus.\n\"\"\"\n\nfrom _typeshed import ReadableBuffer, WriteableBuffer\nfrom ..microbit import pin13, pin14, pin15, MicroBitDigitalPin\n\ndef init(\n baudrate: int = 1000000,\n bits: int = 8,\n mode: int = 0,\n sclk: MicroBitDigitalPin = pin13,\n mosi: MicroBitDigitalPin = pin15,\n miso: MicroBitDigitalPin = pin14,\n) -> None:\n \"\"\"Initialize SPI communication.\n\n Example: ``spi.init()``\n\n For correct communication, the parameters have to be the same on both communicating devices.\n\n :param baudrate: The speed of communication.\n :param bits: The width in bits of each transfer. Currently only ``bits=8`` is supported. However, this may change in the future.\n :param mode: Determines the combination of clock polarity and phase - `see online table `_.\n :param sclk: sclk pin (default 13)\n :param mosi: mosi pin (default 15)\n :param miso: miso pin (default 14)\n \"\"\"\n ...\n\ndef read(nbytes: int) -> bytes:\n \"\"\"Read bytes.\n\n Example: ``spi.read(64)``\n\n :param nbytes: Maximum number of bytes to read.\n :return: The bytes read.\n \"\"\"\n ...\n\ndef write(buffer: ReadableBuffer) -> None:\n \"\"\"Write bytes to the bus.\n\n Example: ``spi.write(bytes([1, 2, 3]))``\n\n :param buffer: A buffer to read data from.\n \"\"\"\n ...\n\ndef write_readinto(out: WriteableBuffer, in_: ReadableBuffer) -> None:\n \"\"\"Write the ``out`` buffer to the bus and read any response into the ``in_`` buffer.\n\n Example: ``spi.write_readinto(out_buffer, in_buffer)``\n\n The length of the buffers should be the same. The buffers can be the same object.\n\n :param out: The buffer to write any response to.\n :param in_: The buffer to read data from.\n \"\"\"\n ...\n", "/typeshed/stdlib/microbit/uart.pyi": "\"\"\"Communicate with a device using a serial interface.\n\"\"\"\n\nfrom _typeshed import WriteableBuffer\nfrom ..microbit import MicroBitDigitalPin\nfrom typing import Optional, Union\n\nODD: int\n\"\"\"Odd parity\"\"\"\n\nEVEN: int\n\"\"\"Even parity\"\"\"\n\ndef init(\n baudrate: int = 9600,\n bits: int = 8,\n parity: Optional[int] = None,\n stop: int = 1,\n tx: Optional[MicroBitDigitalPin] = None,\n rx: Optional[MicroBitDigitalPin] = None,\n) -> None:\n \"\"\"Initialize serial communication.\n\n Example: ``uart.init(115200, tx=pin0, rx=pin1)``\n\n :param baudrate: The speed of communication.\n :param bits: The size of bytes being transmitted. micro:bit only supports 8.\n :param parity: How parity is checked, ``None``, ``uart.ODD`` or ``uart.EVEN``.\n :param stop: The number of stop bits, has to be 1 for micro:bit.\n :param tx: Transmitting pin.\n :param rx: Receiving pin.\n\n Initializing the UART on external pins will cause the Python console on\n USB to become unaccessible, as it uses the same hardware. To bring the\n console back you must reinitialize the UART without passing anything for\n ``tx`` or ``rx`` (or passing ``None`` to these arguments). This means\n that calling ``uart.init(115200)`` is enough to restore the Python console.\n\n For more details see `the online documentation `_.\n \"\"\"\n ...\n\ndef any() -> bool:\n \"\"\"Check if any data is waiting.\n\n Example: ``uart.any()``\n\n :return: ``True`` if any data is waiting, else ``False``.\n \"\"\"\n ...\n\ndef read(nbytes: Optional[int] = None) -> Optional[bytes]:\n \"\"\"Read bytes.\n\n Example: ``uart.read()``\n\n :param nbytes: If ``nbytes`` is specified then read at most that many bytes, otherwise read as many bytes as possible\n :return: A bytes object or ``None`` on timeout\n \"\"\"\n ...\n\ndef readinto(buf: WriteableBuffer, nbytes: Optional[int] = None) -> Optional[int]:\n \"\"\"Read bytes into the ``buf``.\n\n Example: ``uart.readinto(input_buffer)``\n\n :param buf: The buffer to write to.\n :param nbytes: If ``nbytes`` is specified then read at most that many bytes, otherwise read ``len(buf)`` bytes.\n :return: number of bytes read and stored into ``buf`` or ``None`` on timeout.\n \"\"\"\n ...\n\ndef readline() -> Optional[bytes]:\n \"\"\"Read a line, ending in a newline character.\n\n Example: ``uart.readline()``\n\n :return: The line read or ``None`` on timeout. The newline character is included in the returned bytes.\n \"\"\"\n ...\n\ndef write(buf: Union[bytes, str]) -> Optional[int]:\n \"\"\"Write a buffer to the bus.\n\n Example: ``uart.write('hello world')``\n\n :param buf: A bytes object or a string.\n :return: The number of bytes written, or ``None`` on timeout.\n\n Examples::\n\n uart.write('hello world')\n uart.write(b'hello world')\n uart.write(bytes([1, 2, 3]))\n \"\"\"\n ...\n",