From 1caadde5edcc7b0d8b02a9f276b23052899f9de2 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Wed, 21 Aug 2024 13:38:26 +0100 Subject: [PATCH] Corrections --- src/micropython/beta/typeshed.en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/micropython/beta/typeshed.en.json b/src/micropython/beta/typeshed.en.json index 970639000..c200d0663 100644 --- a/src/micropython/beta/typeshed.en.json +++ b/src/micropython/beta/typeshed.en.json @@ -37,7 +37,7 @@ "/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, Optional, 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\n\nclass AudioRecording:\n \"\"\"The ``AudioRecording`` object contains audio data and the sampling rate\n associated to it (V2 only).\n\n The size of the internal buffer will depend on the ``rate``\n (number of samples per second) and ``duration`` parameters.\n The larger these values are, the more memory that will be used.\n\n When an ``AudioRecording`` is used to record data from the microphone,\n a higher sampling rate produces better sound quality,\n but it also uses more memory.\n\n During playback, increasing the sampling rate speeds up the sound\n and decreasing the sample rate slows it down.\n \n The data inside an ``AudioRecording`` is not easy to modify, so the\n ``AudioTrack`` class is provided to help access the audio data like a list.\n The method ``AudioRecording.track()`` can be used to create an ``AudioTrack``,\n and its arguments ``start_ms`` and ``end_ms`` can be used to slice portions\n of the data.\n \"\"\"\n\n def __init__(\n self,\n duration: int = -1,\n rate: int = 11_000\n ):\n \"\"\"Create a new ``AudioRecording``.\n\n Example: ``my_recording = AudioRecording(duration=5000)``\n\n :param duration: Indicates how many milliseconds of audio this instance can store.\n :param rate: The sampling rate at which data will be stored via the microphone, or played via the ``audio.play()`` function.\n \"\"\"\n\n def copy(self) -> None:\n \"\"\"Create a copy of the ``AudioRecording``.\n\n Example: ``copy = my_recording.copy()``\n\n :return: A copy of the ``AudioRecording``.\n \"\"\"\n\n def track(self, start_ms: int = 0, end_ms: int = -1) -> AudioTrack:\n \"\"\"Create an ``AudioTrack`` instance from a portion of the data in this ``AudioRecording`` instance.\n\n Example: ``first_second = my_recording.track(0, 1000)``\n\n :param start_ms: (default=0) Where to start of the track in milliseconds.\n :param end_ms: (default=-1) The end of the track in milliseconds. If the default value of ``-1`` is provided it will end the track at the end of the AudioRecording.\n :return: An ``AudioTrack`` backed by the sample data between ``start_ms`` and ``end_ms``.\n \"\"\"\n\nclass AudioTrack:\n \"\"\" The ``AudioTrack`` object points to the data provided by the input buffer,\n which can be an ``AudioRecording``, another ``AudioTrack``,\n or a buffer-like object like a ``bytearray`` (V2 only).\n \"\"\"\n\n def __init__(\n self,\n buffer: Union[bytearray, AudioRecording, AudioTrack],\n rate: Optional[int] = None\n ):\n \"\"\"Create a new ``AudioTrack``.\n\n When the input buffer has an associated rate (e.g. an ``AudioRecording``\n or ``AudioTrack``), the rate is copied. If the buffer object does not have\n a rate, the default value of 11_000 is used.\n\n Example: ``my_track = AudioTrack(bytearray(4096))``\n\n An ``AudioTrack`` can be created from an ``AudioRecording``, another\n ``AudioTrack``, or a ``bytearray`` and individual bytes can be accessed and\n modified like elements in a list::\n\n my_track = AudioTrack(bytearray(100))\n # Create a square wave\n half_length = len(my_track) // 2\n for i in range(half_length):\n my_track[i] = 255\n for i in range(half_length, len(my_track)):\n my_track[i] = 0\n\n Or smaller AudioTracks can be created using slices, useful to send them\n via radio or serial::\n\n recording = microphone.record(duration=2000)\n track = AudioTrack(recording)\n packet_size = 32\n for i in range(0, len(track), packet_size):\n radio.send_bytes(track[i:i+packet_size])\n\n :param buffer: The buffer containing the audio data.\n :param rate: (default=None) The sampling rate at which data will be stored via the microphone, or played via the ``audio.play()`` function. \n \"\"\"\n\n def set_rate(self, sample_rate: int) -> None:\n \"\"\"Configure the sampling rate associated with the data in the\n ``AudioTrack`` instance.\n\n\n Changes to an ``AudioTrack`` rate won't affect the original source rate,\n so multiple instances pointing to the same buffer can have different\n rates and the original buffer rate would stay unmodified.\n\n Example: ``my_track.set_rate(22_000)``\n \"\"\"\n\n def get_rate(self) -> int:\n \"\"\"Get the sampling rate associated with the data in the\n ``AudioRecording`` instance.\n\n Example: ``current_rate = my_track.get_rate()``\n\n :return: The configured sample rate.\n \"\"\"\n\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: AudioTrack) -> AudioTrack: ...\n def __iadd__(self, v: AudioTrack) -> AudioTrack: ...\n def __sub__(self, v: AudioTrack) -> AudioTrack: ...\n def __isub__(self, v: AudioTrack) -> AudioTrack: ...\n def __mul__(self, v: float) -> AudioTrack: ...\n def __imul__(self, v: float) -> AudioTrack: ...\n\n\nclass AudioFrame:\n \"\"\"An ``AudioFrame`` object is a list of 32 samples each of which is a unsigned byte\n (whole number between 0 and 255).\n\n It takes just over 4 ms to play a single frame.\n\n Example::\n\n frame = AudioFrame()\n for i in range(len(frame)):\n frame[i] = 252 - i * 8\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: ...", + "/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, Optional, Union, overload\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\n\nclass AudioRecording:\n \"\"\"The ``AudioRecording`` object contains audio data and the sampling rate\n associated to it (V2 only).\n\n The size of the internal buffer will depend on the ``rate``\n (number of samples per second) and ``duration`` parameters.\n The larger these values are, the more memory that will be used.\n\n When an ``AudioRecording`` is used to record data from the microphone,\n a higher sampling rate produces better sound quality,\n but it also uses more memory.\n\n During playback, increasing the sampling rate speeds up the sound\n and decreasing the sample rate slows it down.\n \n The data inside an ``AudioRecording`` is not easy to modify, so the\n ``AudioTrack`` class is provided to help access the audio data like a list.\n The method ``AudioRecording.track()`` can be used to create an ``AudioTrack``,\n and its arguments ``start_ms`` and ``end_ms`` can be used to slice portions\n of the data.\n \"\"\"\n\n def __init__(\n self,\n duration: int = -1,\n rate: int = 11_000\n ):\n \"\"\"Create a new ``AudioRecording``.\n\n Example: ``my_recording = AudioRecording(duration=5000)``\n\n :param duration: Indicates how many milliseconds of audio this instance can store.\n :param rate: The sampling rate at which data will be stored via the microphone, or played via the ``audio.play()`` function.\n \"\"\"\n\n def copy(self) -> None:\n \"\"\"Create a copy of the ``AudioRecording``.\n\n Example: ``copy = my_recording.copy()``\n\n :return: A copy of the ``AudioRecording``.\n \"\"\"\n\n def track(self, start_ms: int = 0, end_ms: int = -1) -> AudioTrack:\n \"\"\"Create an ``AudioTrack`` instance from a portion of the data in this ``AudioRecording`` instance.\n\n Example: ``first_second = my_recording.track(0, 1000)``\n\n :param start_ms: (default=0) Where to start of the track in milliseconds.\n :param end_ms: (default=-1) The end of the track in milliseconds. If the default value of ``-1`` is provided it will end the track at the end of the AudioRecording.\n :return: An ``AudioTrack`` backed by the sample data between ``start_ms`` and ``end_ms``.\n \"\"\"\n\nclass AudioTrack:\n \"\"\" The ``AudioTrack`` object points to the data provided by the input buffer,\n which can be an ``AudioRecording``, another ``AudioTrack``,\n or a buffer-like object like a ``bytearray`` (V2 only).\n \"\"\"\n\n def __init__(\n self,\n buffer: Union[bytearray, AudioRecording, AudioTrack],\n rate: Optional[int] = None\n ):\n \"\"\"Create a new ``AudioTrack``.\n\n When the input buffer has an associated rate (e.g. an ``AudioRecording``\n or ``AudioTrack``), the rate is copied. If the buffer object does not have\n a rate, the default value of 11_000 is used.\n\n Example: ``my_track = AudioTrack(bytearray(4096))``\n\n An ``AudioTrack`` can be created from an ``AudioRecording``, another\n ``AudioTrack``, or a ``bytearray`` and individual bytes can be accessed and\n modified like elements in a list::\n\n my_track = AudioTrack(bytearray(100))\n # Create a square wave\n half_length = len(my_track) // 2\n for i in range(half_length):\n my_track[i] = 255\n for i in range(half_length, len(my_track)):\n my_track[i] = 0\n\n Or smaller AudioTracks can be created using slices, useful to send them\n via radio or serial::\n\n recording = microphone.record(duration=2000)\n track = AudioTrack(recording)\n packet_size = 32\n for i in range(0, len(track), packet_size):\n radio.send_bytes(track[i:i+packet_size])\n\n :param buffer: The buffer containing the audio data.\n :param rate: (default=None) The sampling rate at which data will be stored via the microphone, or played via the ``audio.play()`` function. \n \"\"\"\n\n def set_rate(self, sample_rate: int) -> None:\n \"\"\"Configure the sampling rate associated with the data in the\n ``AudioTrack`` instance.\n\n\n Changes to an ``AudioTrack`` rate won't affect the original source rate,\n so multiple instances pointing to the same buffer can have different\n rates and the original buffer rate would stay unmodified.\n\n Example: ``my_track.set_rate(22_000)``\n \"\"\"\n\n def get_rate(self) -> int:\n \"\"\"Get the sampling rate associated with the data in the\n ``AudioRecording`` instance.\n\n Example: ``current_rate = my_track.get_rate()``\n\n :return: The configured sample rate.\n \"\"\"\n\n def copyfrom(self, other: Union[bytearray, AudioRecording, AudioTrack]) -> None:\n \"\"\"Overwrite the data in this ``AudioTrack`` with the data from another\n ``AudioTrack``, ``AudioRecording``, or buffer-like object like a\n ``bytearray`` instance.\n\n If the input buffer is smaller than the available space in this\n instance, the rest of the data is left untouched.\n If it is larger, it will stop copying once this instance is filled.\n \n :param other: Buffer-like instance from which to copy the data.\n \"\"\"\n\n def __len__(self) -> int: ...\n\n\n @overload\n def __getitem__(self, i: int) -> int: ...\n @overload\n def __getitem__(self, s: slice) -> AudioTrack: ...\n def __setitem__(self, i: int, x: int) -> None: ...\n\n def __add__(self, v: AudioTrack) -> AudioTrack: ...\n def __iadd__(self, v: AudioTrack) -> AudioTrack: ...\n def __sub__(self, v: AudioTrack) -> AudioTrack: ...\n def __isub__(self, v: AudioTrack) -> AudioTrack: ...\n def __mul__(self, v: float) -> AudioTrack: ...\n def __imul__(self, v: float) -> AudioTrack: ...\n\n\nclass AudioFrame:\n \"\"\"An ``AudioFrame`` object is a list of 32 samples each of which is a unsigned byte\n (whole number between 0 and 255).\n\n It takes just over 4 ms to play a single frame.\n\n Example::\n\n frame = AudioFrame()\n for i in range(len(frame)):\n frame[i] = 252 - i * 8\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: ...", "/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",