From a17ea50edb5e26156be3ee5d754e75b15414047f Mon Sep 17 00:00:00 2001 From: Grace Date: Tue, 9 Apr 2024 09:21:02 +0100 Subject: [PATCH] Update typeshed for Image.SMILE doc --- src/micropython/main/typeshed.en.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/micropython/main/typeshed.en.json b/src/micropython/main/typeshed.en.json index 65cd3519b..bc1ca4af5 100644 --- a/src/micropython/main/typeshed.en.json +++ b/src/micropython/main/typeshed.en.json @@ -11,10 +11,10 @@ "/typeshed/stdlib/log.pyi": "\"\"\"Log data to your micro:bit V2.\"\"\"\n\nfrom typing import Literal, Mapping, Optional, Union, overload\n\nMILLISECONDS = 1\n\"\"\"Milliseconds timestamp format.\"\"\"\n\nSECONDS = 10\n\"\"\"Seconds timestamp format.\"\"\"\n\nMINUTES = 600\n\"\"\"Minutes timestamp format.\"\"\"\n\nHOURS = 36000\n\"\"\"Hours timestamp format.\"\"\"\n\nDAYS = 864000\n\"\"\"Days timestamp format.\"\"\"\n\ndef set_labels(\n *labels: str, timestamp: Optional[Literal[1, 10, 36000, 864000]] = SECONDS\n) -> None:\n \"\"\"Set up the log file header.\n\n Example: ``log.set_labels('X', 'Y', 'Z', timestamp=log.MINUTES)``\n\n Ideally this function should be called a single time, before any data is\n logged, to configure the data table header once.\n\n If a log file already exists when the program starts, or if this function\n is called multiple times, it will check the labels already defined in the\n log file. If this function call contains any new labels not already\n present, it will generate a new header row with the additional columns.\n\n By default the first column contains a timestamp for each row. The time\n unit can be selected via the timestamp argument.\n\n :param *labels: Any number of positional arguments, each corresponding to an entry in the log header.\n :param timestamp: Select the timestamp unit that will be automatically added as the first column in every row. Timestamp values can be one of ``log.MILLISECONDS``, ``log.SECONDS``, ``log.MINUTES``, ``log.HOURS``, ``log.DAYS`` or ``None`` to disable the timestamp. The default value is ``log.SECONDS``.\n \"\"\"\n ...\n\n@overload\ndef add(\n data_dictionary: Optional[Mapping[str, Union[str, int, float]]],\n) -> None:\n \"\"\"Add a data row to the log by passing a dictionary of headers and values.\n\n Example: ``log.add({ 'temp': temperature() })``\n\n Each call to this function adds a row to the log.\n\n New labels not previously specified via the set_labels function, or by a\n previous call to this function, will trigger a new header entry to be added\n to the log with the extra labels.\n\n Labels previously specified and not present in a call to this function will\n be skipped with an empty value in the log row.\n\n :param data_dictionary: The data to log as a dictionary with a key for each header.\n \"\"\"\n ...\n\n@overload\ndef add(**kwargs: Union[str, int, float]) -> None:\n \"\"\"Add a data row to the log using keyword arguments.\n\n Example: ``log.add(temp=temperature())``\n\n Each call to this function adds a row to the log.\n\n New labels not previously specified via the set_labels function, or by a\n previous call to this function, will trigger a new header entry to be added\n to the log with the extra labels.\n\n Labels previously specified and not present in a call to this function will\n be skipped with an empty value in the log row.\n \"\"\"\n ...\n\ndef delete(full=False):\n \"\"\"Deletes the contents of the log, including headers.\n\n Example: ``log.delete()``\n\n To add the log headers again the ``set_labels`` function should to be called after this function.\n\n There are two erase modes; \u201cfull\u201d completely removes the data from the physical storage,\n and \u201cfast\u201d invalidates the data without removing it.\n\n :param full: ``True`` selects a \u201cfull\u201d erase and ``False`` selects the \u201cfast\u201d erase method.\n \"\"\"\n ...\n\ndef set_mirroring(serial: bool):\n \"\"\"Configure mirroring of the data logging activity to the serial output.\n\n Example: ``log.set_mirroring(True)``\n\n Serial mirroring is disabled by default. When enabled, it will print to serial each row logged into the log file.\n\n :param serial: ``True`` enables mirroring data to the serial output.\n \"\"\"\n ...\n", "/typeshed/stdlib/love.pyi": "def badaboom() -> None: ...\n", "/typeshed/stdlib/machine.pyi": "\"\"\"Low-level utilities.\n\"\"\"\nfrom typing import Any\nfrom .microbit import MicroBitDigitalPin\n\ndef unique_id() -> bytes:\n \"\"\"Get a byte string with a unique identifier of a board.\n\n Example: ``machine.unique_id()``\n\n :return: An identifier that varies from one board instance to another.\n \"\"\"\n ...\n\ndef reset() -> None:\n \"\"\"Reset the device in a manner similar to pushing the external RESET button.\n\n Example: ``machine.reset()``\n \"\"\"\n ...\n\ndef freq() -> int:\n \"\"\"Get the CPU frequency in hertz.\n\n Example: ``machine.freq()``\n\n :return: The CPU frequency.\n \"\"\"\n ...\n\ndef disable_irq() -> Any:\n \"\"\"Disable interrupt requests.\n\n Example: ``interrupt_state = machine.disable_irq()``\n\n :return: the previous IRQ state which should be considered an opaque value\n\n The return value should be passed to the ``enable_irq`` function to restore\n interrupts to their original state.\n \"\"\"\n ...\n\ndef enable_irq(state: Any) -> None:\n \"\"\"Re-enable interrupt requests.\n\n Example: ``machine.enable_irq(interrupt_state)``\n\n :param state: The value that was returned from the most recent call to the ``disable_irq`` function.\n \"\"\"\n ...\n\ndef time_pulse_us(\n pin: MicroBitDigitalPin, pulse_level: int, timeout_us: int = 1000000\n) -> int:\n \"\"\"Time a pulse on a pin.\n\n Example: ``time_pulse_us(pin0, 1)``\n\n If the current input value of the pin is different to ``pulse_level``, the\n function first waits until the pin input becomes equal to\n ``pulse_level``, then times the duration that the pin is equal to\n ``pulse_level``. If the pin is already equal to ``pulse_level`` then timing\n starts straight away.\n\n :param pin: The pin to use\n :param pulse_level: 0 to time a low pulse or 1 to time a high pulse\n :param timeout_us: A microsecond timeout\n :return: The duration of the pulse in microseconds, or -1 for a timeout waiting for the level to match ``pulse_level``, or -2 on timeout waiting for the pulse to end\n \"\"\"\n ...\n\nclass mem:\n \"\"\"The class for the ``mem8``, ``mem16`` and ``mem32`` memory views.\"\"\"\n\n def __getitem__(self, address: int) -> int:\n \"\"\"Access a value from memory.\n\n :param address: The memory address.\n :return: The value at that address as an integer.\n \"\"\"\n ...\n def __setitem__(self, address: int, value: int) -> None:\n \"\"\"Set a value at the given address.\n\n :param address: The memory address.\n :param value: The integer value to set.\n \"\"\"\n ...\n\nmem8: mem\n\"\"\"8-bit (byte) view of memory.\"\"\"\n\nmem16: mem\n\"\"\"16-bit view of memory.\"\"\"\n\nmem32: mem\n\"\"\"32-bit view of memory.\"\"\"\n", - "/typeshed/stdlib/math.pyi": "\"\"\"Mathematical functions.\n\"\"\"\n\nfrom typing import Tuple\n\ndef acos(x: float) -> float:\n \"\"\"Calculate the inverse cosine.\n\n Example: ``math.acos(1)``\n\n :param x: A number\n :return: The inverse cosine of ``x``\n \"\"\"\n ...\n\ndef asin(x: float) -> float:\n \"\"\"Calculate the inverse sine.\n\n Example: ``math.asin(0)``\n\n :param x: A number\n :return: The inverse sine of ``x``\n \"\"\"\n ...\n\ndef atan(x: float) -> float:\n \"\"\"Calculate the inverse tangent.\n\n Example: ``math.atan(0)``\n\n :param x: A number\n :return: The inverse tangent of ``x``\n \"\"\"\n ...\n\ndef atan2(y: float, x: float) -> float:\n \"\"\"Calculate the principal value of the inverse tangent of ``y/x``.\n\n Example: ``math.atan2(0, -1)``\n\n :param y: A number\n :param x: A number\n :return: The principal value of the inverse tangent of ``y/x``\n \"\"\"\n ...\n\ndef ceil(x: float) -> float:\n \"\"\"Round a number towards positive infinity.\n\n Example: ``math.ceil(0.1)``\n\n :param x: A number\n :return: ``x`` rounded towards positive infinity.\n \"\"\"\n ...\n\ndef copysign(x: float, y: float) -> float:\n \"\"\"Calculate ``x`` with the sign of ``y``.\n\n Example: ``math.copysign(1, -1)``\n\n :param x: A number\n :param y: The source of the sign for the return value\n :return: ``x`` with the sign of ``y``\n \"\"\"\n ...\n\ndef cos(x: float) -> float:\n \"\"\"Calculate the cosine of ``x``.\n\n Example: ``math.cos(0)``\n\n :param x: A number\n :return: The cosine of ``x``\n \"\"\"\n ...\n\ndef degrees(x: float) -> float:\n \"\"\"Convert radians to degrees.\n\n Example: ``math.degrees(2 * math.pi)``\n\n :param x: A value in radians\n :return: The value converted to degrees\"\"\"\n ...\n\ndef exp(x: float) -> float:\n \"\"\"Calculate the exponential of ``x``.\n\n Example: ``math.exp(1)``\n\n :param x: A number\n :return: The exponential of ``x``.\n \"\"\"\n ...\n\ndef fabs(x: float) -> float:\n \"\"\"Return the absolute value of ``x``.\n\n Example: ``math.fabs(-0.1)``\n\n :param x: A number\n :return: The absolute value of ``x``\n \"\"\"\n ...\n\ndef floor(x: float) -> int:\n \"\"\"Round a number towards negative infinity.\n\n Example: ``math.floor(0.9)``\n\n :param x: A number\n :return: ``x`` rounded towards negative infinity.\n \"\"\"\n ...\n\ndef fmod(x: float, y: float) -> float:\n \"\"\"Calculate the remainder of ``x/y``.\n\n Example: ``math.fmod(10, 3)``\n\n :param x: The numerator\n :param y: The denominator\n \"\"\"\n ...\n\ndef frexp(x: float) -> Tuple[float, int]:\n \"\"\"Decomposes a floating-point number into its mantissa and exponent.\n\n Example: ``mantissa, exponent = math.frexp(2)``\n\n The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e``\n exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise\n the relation ``0.5 <= abs(m) < 1`` holds.\n\n :param x: A floating-point number\n :return: A tuple of length two containing its mantissa then exponent\n \"\"\"\n ...\n\ndef isfinite(x: float) -> bool:\n \"\"\"Check if a value is finite.\n\n Example: ``math.isfinite(float('inf'))``\n\n :param x: A number.\n :return: ``True`` if ``x`` is finite, ``False`` otherwise.\n \"\"\"\n ...\n\ndef isinf(x: float) -> bool:\n \"\"\"Check if a value is infinite.\n\n Example: ``math.isinf(float('-inf'))``\n\n :param x: A number.\n :return: ``True`` if ``x`` is infinite, ``False`` otherwise.\n \"\"\"\n ...\n\ndef isnan(x: float) -> bool:\n \"\"\"Check is a value is not-a-number (NaN).\n\n Example: ``math.isnan(float('nan'))``\n\n :param x: A number\n :return: ``True`` if ``x`` is not-a-number (NaN), ``False`` otherwise.\"\"\"\n ...\n\ndef ldexp(x: float, exp: int) -> float:\n \"\"\"Calculate ``x * (2**exp)``.\n\n Example: ``math.ldexp(0.5, 2)``\n\n :param x: A number\n :param exp: Integer exponent\n :return: ``x * (2**exp)``\n \"\"\"\n ...\n\ndef log(x: float, base: float = e) -> float:\n \"\"\"Calculate the logarithm of ``x`` to the given base (defaults to natural logorithm).\n\n Example: ``math.log(math.e)``\n\n With one argument, return the natural logarithm of x (to base e).\n\n With two arguments, return the logarithm of x to the given base, calculated as ``log(x)/log(base)``.\n\n :param x: A number\n :param base: The base to use\n :return: The natural logarithm of ``x``\n \"\"\"\n ...\n\ndef modf(x: float) -> Tuple[float, float]:\n \"\"\"Calculate the fractional and integral parts of ``x``.\n\n Example: ``fractional, integral = math.modf(1.5)``\n\n :param x: A number\n :return: A tuple of two floats representing the fractional then integral parts of ``x``.\n\n Both the fractional and integral values have the same sign as ``x``.\n \"\"\"\n ...\n\ndef pow(x: float, y: float) -> float:\n \"\"\"Returns ``x`` to the power of ``y``.\n\n Example: ``math.pow(4, 0.5)``\n\n :param x: A number\n :param y: The exponent\n :return: ``x`` to the power of ``y``\n \"\"\"\n ...\n\ndef radians(x: float) -> float:\n \"\"\"Convert a degrees to radians.\n\n Example: ``math.radians(360)``\n\n :param x: A value in degrees\n :return: The value converted to radians\n \"\"\"\n ...\n\ndef sin(x: float) -> float:\n \"\"\"Calculate the sine of ``x``.\n\n Example: ``math.sin(math.pi/2)``\n\n :param x: A number\n :return: The sine of ``x``\n \"\"\"\n ...\n\ndef sqrt(x: float) -> float:\n \"\"\"Calculate the square root of ``x``.\n\n Example: ``math.sqrt(4)``\n\n :param x: A number\n :return: The square root of ``x``\n \"\"\"\n ...\n\ndef tan(x: float) -> float:\n \"\"\"Calculate the tangent of ``x``.\n\n Example: ``math.tan(0)``\n\n :param x: A number\n :return: The tangent of ``x``.\n \"\"\"\n ...\n\ndef trunc(x: float) -> int:\n \"\"\"Round a number towards 0.\n\n Example: ``math.trunc(-0.9)``\n\n :param x: A number\n :return: ``x`` rounded towards zero.\n \"\"\"\n ...\n\ne: float\n\"\"\"Base of the natural logarithm\"\"\"\n\npi: float\n\"\"\"The ratio of a circle's circumference to its diameter\"\"\"\n", + "/typeshed/stdlib/math.pyi": "\"\"\"Mathematical functions.\n\"\"\"\n\nfrom typing import Tuple\n\ndef acos(x: float) -> float:\n \"\"\"Calculate the inverse cosine.\n\n Example: ``math.acos(1)``\n\n :param x: A number\n :return: The inverse cosine of ``x``\n \"\"\"\n ...\n\ndef asin(x: float) -> float:\n \"\"\"Calculate the inverse sine.\n\n Example: ``math.asin(0)``\n\n :param x: A number\n :return: The inverse sine of ``x``\n \"\"\"\n ...\n\ndef atan(x: float) -> float:\n \"\"\"Calculate the inverse tangent.\n\n Example: ``math.atan(0)``\n\n :param x: A number\n :return: The inverse tangent of ``x``\n \"\"\"\n ...\n\ndef atan2(y: float, x: float) -> float:\n \"\"\"Calculate the principal value of the inverse tangent of ``y/x``.\n\n Example: ``math.atan2(0, -1)``\n\n :param y: A number\n :param x: A number\n :return: The principal value of the inverse tangent of ``y/x``\n \"\"\"\n ...\n\ndef ceil(x: float) -> float:\n \"\"\"Round a number towards positive infinity.\n\n Example: ``math.ceil(0.1)``\n\n :param x: A number\n :return: ``x`` rounded towards positive infinity.\n \"\"\"\n ...\n\ndef copysign(x: float, y: float) -> float:\n \"\"\"Calculate ``x`` with the sign of ``y``.\n\n Example: ``math.copysign(1, -1)``\n\n :param x: A number\n :param y: The source of the sign for the return value\n :return: ``x`` with the sign of ``y``\n \"\"\"\n ...\n\ndef cos(x: float) -> float:\n \"\"\"Calculate the cosine of ``x``.\n\n Example: ``math.cos(0)``\n\n :param x: A number\n :return: The cosine of ``x``\n \"\"\"\n ...\n\ndef degrees(x: float) -> float:\n \"\"\"Convert radians to degrees.\n\n Example: ``math.degrees(2 * math.pi)``\n\n :param x: A value in radians\n :return: The value converted to degrees\"\"\"\n ...\n\ndef exp(x: float) -> float:\n \"\"\"Calculate the exponential of ``x``.\n\n Example: ``math.exp(1)``\n\n :param x: A number\n :return: The exponential of ``x``.\n \"\"\"\n ...\n\ndef fabs(x: float) -> float:\n \"\"\"Return the absolute value of ``x``.\n\n Example: ``math.fabs(-0.1)``\n\n :param x: A number\n :return: The absolute value of ``x``\n \"\"\"\n ...\n\ndef floor(x: float) -> int:\n \"\"\"Round a number towards negative infinity.\n\n Example: ``math.floor(0.9)``\n\n :param x: A number\n :return: ``x`` rounded towards negative infinity.\n \"\"\"\n ...\n\ndef fmod(x: float, y: float) -> float:\n \"\"\"Calculate the remainder of ``x/y``.\n\n Example: ``math.fmod(10, 3)``\n\n :param x: The numerator\n :param y: The denominator\n \"\"\"\n ...\n\ndef frexp(x: float) -> Tuple[float, int]:\n \"\"\"Decomposes a floating-point number into its mantissa and exponent.\n\n Example: ``mantissa, exponent = math.frexp(2)``\n\n The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e``\n exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise\n the relation ``0.5 <= abs(m) < 1`` holds.\n\n :param x: A floating-point number\n :return: A tuple of length two containing its mantissa then exponent\n \"\"\"\n ...\n\ndef isfinite(x: float) -> bool:\n \"\"\"Check if a value is finite.\n\n Example: ``math.isfinite(float('inf'))``\n\n :param x: A number.\n :return: ``True`` if ``x`` is finite, ``False`` otherwise.\n \"\"\"\n ...\n\ndef isinf(x: float) -> bool:\n \"\"\"Check if a value is infinite.\n\n Example: ``math.isinf(float('-inf'))``\n\n :param x: A number.\n :return: ``True`` if ``x`` is infinite, ``False`` otherwise.\n \"\"\"\n ...\n\ndef isnan(x: float) -> bool:\n \"\"\"Check if a value is not-a-number (NaN).\n\n Example: ``math.isnan(float('nan'))``\n\n :param x: A number\n :return: ``True`` if ``x`` is not-a-number (NaN), ``False`` otherwise.\"\"\"\n ...\n\ndef ldexp(x: float, exp: int) -> float:\n \"\"\"Calculate ``x * (2**exp)``.\n\n Example: ``math.ldexp(0.5, 2)``\n\n :param x: A number\n :param exp: Integer exponent\n :return: ``x * (2**exp)``\n \"\"\"\n ...\n\ndef log(x: float, base: float = e) -> float:\n \"\"\"Calculate the logarithm of ``x`` to the given base (defaults to natural logorithm).\n\n Example: ``math.log(math.e)``\n\n With one argument, return the natural logarithm of x (to base e).\n\n With two arguments, return the logarithm of x to the given base, calculated as ``log(x)/log(base)``.\n\n :param x: A number\n :param base: The base to use\n :return: The natural logarithm of ``x``\n \"\"\"\n ...\n\ndef modf(x: float) -> Tuple[float, float]:\n \"\"\"Calculate the fractional and integral parts of ``x``.\n\n Example: ``fractional, integral = math.modf(1.5)``\n\n :param x: A number\n :return: A tuple of two floats representing the fractional then integral parts of ``x``.\n\n Both the fractional and integral values have the same sign as ``x``.\n \"\"\"\n ...\n\ndef pow(x: float, y: float) -> float:\n \"\"\"Returns ``x`` to the power of ``y``.\n\n Example: ``math.pow(4, 0.5)``\n\n :param x: A number\n :param y: The exponent\n :return: ``x`` to the power of ``y``\n \"\"\"\n ...\n\ndef radians(x: float) -> float:\n \"\"\"Convert a degrees to radians.\n\n Example: ``math.radians(360)``\n\n :param x: A value in degrees\n :return: The value converted to radians\n \"\"\"\n ...\n\ndef sin(x: float) -> float:\n \"\"\"Calculate the sine of ``x``.\n\n Example: ``math.sin(math.pi/2)``\n\n :param x: A number\n :return: The sine of ``x``\n \"\"\"\n ...\n\ndef sqrt(x: float) -> float:\n \"\"\"Calculate the square root of ``x``.\n\n Example: ``math.sqrt(4)``\n\n :param x: A number\n :return: The square root of ``x``\n \"\"\"\n ...\n\ndef tan(x: float) -> float:\n \"\"\"Calculate the tangent of ``x``.\n\n Example: ``math.tan(0)``\n\n :param x: A number\n :return: The tangent of ``x``.\n \"\"\"\n ...\n\ndef trunc(x: float) -> int:\n \"\"\"Round a number towards 0.\n\n Example: ``math.trunc(-0.9)``\n\n :param x: A number\n :return: ``x`` rounded towards zero.\n \"\"\"\n ...\n\ne: float\n\"\"\"Base of the natural logarithm\"\"\"\n\npi: float\n\"\"\"The ratio of a circle's circumference to its diameter\"\"\"\n", "/typeshed/stdlib/micropython.pyi": "\"\"\"MicroPython internals.\"\"\"\n\nfrom typing import Any, TypeVar, overload\n\n_T = TypeVar(\"_T\")\n\ndef const(expr: _T) -> _T:\n \"\"\"Used to declare that the expression is a constant so that the compiler can\n optimise it.\n\n The use of this function should be as follows::\n\n from micropython import const\n CONST_X = const(123)\n CONST_Y = const(2 * CONST_X + 1)\n\n Constants declared this way are still accessible as global variables from\n outside the module they are declared in. On the other hand, if a constant\n begins with an underscore then it is hidden, it is not available as a\n global variable, and does not take up any memory during execution.\n\n :param expr: A constant expression.\n \"\"\"\n ...\n\n@overload\ndef opt_level() -> int:\n \"\"\"Get the current optimisation level for the compilation of scripts.\n\n Example: ``micropython.opt_level()``\n\n The optimisation level controls the following compilation features:\n\n - Assertions: at level 0 assertion statements are enabled and compiled\n into the bytecode; at levels 1 and higher assertions are not compiled.\n\n - Built-in ``__debug__`` variable: at level 0 this variable expands to\n True; at levels 1 and higher it expands to False.\n\n - Source-code line numbers: at levels 0, 1 and 2 source-code line number\n are stored along with the bytecode so that exceptions can report the\n line number they occurred at; at levels 3 and higher line numbers are\n not stored.\n\n :return: An integer representing the current level.\n \"\"\"\n ...\n\n@overload\ndef opt_level(level: int) -> None:\n \"\"\"Sets the optimisation level for subsequent compilation of scripts.\n\n Example: ``micropython.opt_level(1)``\n\n The optimisation level controls the following compilation features:\n\n - Assertions: at level 0 assertion statements are enabled and compiled\n into the bytecode; at levels 1 and higher assertions are not compiled.\n\n - Built-in ``__debug__`` variable: at level 0 this variable expands to\n True; at levels 1 and higher it expands to False.\n\n - Source-code line numbers: at levels 0, 1 and 2 source-code line number\n are stored along with the bytecode so that exceptions can report the\n line number they occurred at; at levels 3 and higher line numbers are\n not stored.\n\n The default optimisation level is usually level 0.\n\n :param level: An integer optimisation level.\n \"\"\"\n ...\n\ndef mem_info(verbose: Any = None) -> None:\n \"\"\"Print information about currently used memory.\n\n Example: ``micropython.mem_info()``\n\n :param verbose: If the ``verbose`` argument is given then extra information is printed.\n \"\"\"\n ...\n\ndef qstr_info(verbose: Any = None) -> None:\n \"\"\"Print information about currently interned strings.\n\n Example: ``micropython.qstr_info()``\n\n :param verbose: If the ``verbose`` argument is given then extra information is printed.\n\n The information that is printed is implementation dependent, but currently\n includes the number of interned strings and the amount of RAM they use. In\n verbose mode it prints out the names of all RAM-interned strings.\n \"\"\"\n ...\n\ndef stack_use() -> int:\n \"\"\"Return an integer representing the current amount of stack that is being\n used.\n\n Example: ``micropython.stack_use()``\n\n The absolute value of this is not particularly useful, rather it\n should be used to compute differences in stack usage at different points.\n\n :return: An integer representing current stack use.\n \"\"\"\n ...\n\ndef heap_lock() -> None:\n \"\"\"Lock the heap.\n\n Example: ``micropython.heap_lock()``\n\n When locked no memory allocation can occur and a ``MemoryError`` will be\n raised if any heap allocation is attempted.\n \"\"\"\n ...\n\ndef heap_unlock() -> None:\n \"\"\"Unlock the heap.\n\n Example: ``micropython.heap_unlock()``\n\n When locked no memory allocation can occur and a ``MemoryError`` will be\n raised if any heap allocation is attempted.\n \"\"\"\n ...\n\ndef kbd_intr(chr: int) -> None:\n \"\"\"Set the character that will raise a ``KeyboardInterrupt`` exception.\n\n Example: ``micropython.kbd_intr(-1)``\n\n :param chr: Character code to raise the interrupt or -1 to disable capture of Ctrl-C.\n\n By default this is set to 3 during script execution, corresponding to Ctrl-C.\n Passing -1 to this function will disable capture of Ctrl-C, and passing 3\n will restore it.\n\n This function can be used to prevent the capturing of Ctrl-C on the\n incoming stream of characters that is usually used for the REPL, in case\n that stream is used for other purposes.\n \"\"\"\n ...\n", "/typeshed/stdlib/music.pyi": "\"\"\"Create and play melodies.\n\"\"\"\nfrom typing import Optional, Tuple, Union, List\n\nfrom .microbit import MicroBitDigitalPin, pin0\n\nDADADADUM: Tuple[str, ...]\n\"\"\"Melody: the opening to Beethoven\u2019s 5th Symphony in C minor.\"\"\"\n\nENTERTAINER: Tuple[str, ...]\n\"\"\"Melody: the opening fragment of Scott Joplin\u2019s Ragtime classic \u201cThe Entertainer\u201d.\"\"\"\n\nPRELUDE: Tuple[str, ...]\n\"\"\"Melody: the opening of the first Prelude in C Major of J.S.Bach\u2019s 48 Preludes and Fugues.\"\"\"\n\nODE: Tuple[str, ...]\n\"\"\"Melody: the \u201cOde to Joy\u201d theme from Beethoven\u2019s 9th Symphony in D minor.\"\"\"\n\nNYAN: Tuple[str, ...]\n\"\"\"Melody: the Nyan Cat theme (http://www.nyan.cat/).\n\nThe composer is unknown. This is fair use for educational porpoises (as they say in New York).\"\"\"\n\nRINGTONE: Tuple[str, ...]\n\"\"\"Melody: something that sounds like a mobile phone ringtone.\n\nTo be used to indicate an incoming message.\n\"\"\"\n\nFUNK: Tuple[str, ...]\n\"\"\"Melody: a funky bass line for secret agents and criminal masterminds.\"\"\"\n\nBLUES: Tuple[str, ...]\n\"\"\"Melody: a boogie-woogie 12-bar blues walking bass.\"\"\"\n\nBIRTHDAY: Tuple[str, ...]\n\"\"\"Melody: \u201cHappy Birthday to You\u2026\u201d\n\nFor copyright status see: http://www.bbc.co.uk/news/world-us-canada-34332853\n\"\"\"\n\nWEDDING: Tuple[str, ...]\n\"\"\"Melody: the bridal chorus from Wagner\u2019s opera \u201cLohengrin\u201d.\"\"\"\n\nFUNERAL: Tuple[str, ...]\n\"\"\"Melody: the \u201cfuneral march\u201d otherwise known as Fr\u00e9d\u00e9ric Chopin\u2019s Piano Sonata No. 2 in B\u266d minor, Op. 35.\"\"\"\n\nPUNCHLINE: Tuple[str, ...]\n\"\"\"Melody: a fun fragment that signifies a joke has been made.\"\"\"\n\nPYTHON: Tuple[str, ...]\n\"\"\"Melody: John Philip Sousa\u2019s march \u201cLiberty Bell\u201d aka, the theme for \u201cMonty Python\u2019s Flying Circus\u201d (after which the Python programming language is named).\"\"\"\n\nBADDY: Tuple[str, ...]\n\"\"\"Melody: silent movie era entrance of a baddy.\"\"\"\n\nCHASE: Tuple[str, ...]\n\"\"\"Melody: silent movie era chase scene.\"\"\"\n\nBA_DING: Tuple[str, ...]\n\"\"\"Melody: a short signal to indicate something has happened.\"\"\"\n\nWAWAWAWAA: Tuple[str, ...]\n\"\"\"Melody: a very sad trombone.\"\"\"\n\nJUMP_UP: Tuple[str, ...]\n\"\"\"Melody: for use in a game, indicating upward movement.\"\"\"\n\nJUMP_DOWN: Tuple[str, ...]\n\"\"\"Melody: for use in a game, indicating downward movement.\"\"\"\n\nPOWER_UP: Tuple[str, ...]\n\"\"\"Melody: a fanfare to indicate an achievement unlocked.\"\"\"\n\nPOWER_DOWN: Tuple[str, ...]\n\"\"\"Melody: a sad fanfare to indicate an achievement lost.\"\"\"\n\ndef set_tempo(ticks: int = 4, bpm: int = 120) -> None:\n \"\"\"Sets the approximate tempo for playback.\n\n Example: ``music.set_tempo(bpm=120)``\n\n :param ticks: The number of ticks constituting a beat.\n :param bpm: An integer determining how many beats per minute.\n\n Suggested default values allow the following useful behaviour:\n\n - music.set_tempo() \u2013 reset the tempo to default of ticks = 4, bpm = 120\n - music.set_tempo(ticks=8) \u2013 change the \u201cdefinition\u201d of a beat\n - music.set_tempo(bpm=180) \u2013 just change the tempo\n\n To work out the length of a tick in milliseconds is very simple arithmetic:\n 60000/bpm/ticks_per_beat. For the default values that\u2019s\n 60000/120/4 = 125 milliseconds or 1 beat = 500 milliseconds.\n \"\"\"\n ...\n\ndef get_tempo() -> Tuple[int, int]:\n \"\"\"Gets the current tempo as a tuple of integers: ``(ticks, bpm)``.\n\n Example: ``ticks, beats = music.get_tempo()``\n\n :return: The temp as a tuple with two integer values, the ticks then the beats per minute.\n \"\"\"\n ...\n\ndef play(\n music: Union[str, List[str], Tuple[str, ...]],\n pin: Optional[MicroBitDigitalPin] = pin0,\n wait: bool = True,\n loop: bool = False,\n) -> None:\n \"\"\"Plays music.\n\n Example: ``music.play(music.NYAN)``\n\n :param music: music specified in `a special notation `_\n :param pin: the output pin for use with an external speaker (default ``pin0``), ``None`` for no sound.\n :param wait: If ``wait`` is set to ``True``, this function is blocking.\n :param loop: If ``loop`` is set to ``True``, the tune repeats until ``stop`` is called or the blocking call is interrupted.\n\n Many built-in melodies are defined in this module.\n \"\"\"\n ...\n\ndef pitch(\n frequency: int,\n duration: int = -1,\n pin: Optional[MicroBitDigitalPin] = pin0,\n wait: bool = True,\n) -> None:\n \"\"\"Play a note.\n\n Example: ``music.pitch(185, 1000)``\n\n :param frequency: An integer frequency\n :param duration: A millisecond duration. If negative then sound is continuous until the next call or a call to ``stop``.\n :param pin: Optional output pin (default ``pin0``).\n :param wait: If ``wait`` is set to ``True``, this function is blocking.\n\n For example, if the frequency is set to 440 and the length to\n 1000 then we hear a standard concert A for one second.\n\n You can only play one pitch on one pin at any one time.\n \"\"\"\n ...\n\ndef stop(pin: Optional[MicroBitDigitalPin] = pin0) -> None:\n \"\"\"Stops all music playback on the built-in speaker and any pin outputting sound.\n\n Example: ``music.stop()``\n\n :param pin: An optional argument can be provided to specify a pin, e.g. ``music.stop(pin1)``.\n \"\"\"\n\ndef reset() -> None:\n \"\"\"Resets ticks, bpm, duration and octave to their default values.\n\n Example: ``music.reset()``\n\n Values:\n - ``ticks = 4``\n - ``bpm = 120``\n - ``duration = 4``\n - ``octave = 4``\n \"\"\"\n ...\n", - "/typeshed/stdlib/neopixel.pyi": "\"\"\"Individually addressable RGB and RGBW LED strips.\n\"\"\"\nfrom .microbit import MicroBitDigitalPin\nfrom typing import Tuple\n\nclass NeoPixel:\n def __init__(self, pin: MicroBitDigitalPin, n: int, bpp: int = 3) -> None:\n \"\"\"Initialise a new strip of neopixel LEDs controlled via a pin.\n\n Example: ``np = neopixel.NeoPixel(pin0, 8)``\n\n To support RGBW neopixels, a third argument can be passed to\n ``NeoPixel`` to indicate the number of bytes per pixel (``bpp``).\n For RGBW, this is is 4 rather than the default of 3 for RGB and GRB.\n\n Each pixel is addressed by a position (starting from 0). Neopixels are\n given RGB (red, green, blue) / RGBW (red, green, blue, white) values\n between 0-255 as a tuple. For example, in RGB, ``(255,255,255)`` is\n white. In RGBW, ``(255,255,255,0)`` or ``(0,0,0,255)`` is white.\n\n See `the online docs `_ for warnings and other advice.\n\n :param pin: The pin controlling the neopixel strip.\n :param n: The number of neopixels in the strip.\n :param bpp: Bytes per pixel. For RGBW neopixel support, pass 4 rather than the default of 3 for RGB and GRB.\n \"\"\"\n ...\n def clear(self) -> None:\n \"\"\"Clear all the pixels.\n\n Example: ``np.clear()``\n \"\"\"\n ...\n def show(self) -> None:\n \"\"\"Show the pixels.\n\n Example: ``np.show()``\n\n Must be called for any updates to become visible.\n \"\"\"\n ...\n def write(self) -> None:\n \"\"\"Show the pixels (micro:bit V2 only).\n\n Example: ``np.write()``\n\n Must be called for any updates to become visible.\n\n Equivalent to ``show``.\n \"\"\"\n ...\n def fill(self, colour: Tuple[int, ...]) -> None:\n \"\"\"Colour all pixels a given RGB/RGBW value.\n\n Example: ``np.fill((0, 0, 255))``\n\n :param colour: A tuple of the same length as the number of bytes per pixel (bpp).\n\n Use in conjunction with ``show()`` to update the neopixels.\n \"\"\"\n ...\n def __setitem__(self, key: int, value: Tuple[int, ...]) -> None:\n \"\"\"Set a pixel colour.\n\n Example: ``np[0] = (255, 0, 0)``\n\n :param key: The pixel number.\n :param value: The colour.\n \"\"\"\n def __getitem__(self, key: int) -> Tuple[int, ...]:\n \"\"\"Get a pixel colour.\n\n Example: ``r, g, b = np[0]``\n\n :param key: The pixel number.\n :return: The colour tuple.\n \"\"\"\n def __len__(self) -> int:\n \"\"\"Get length of this pixel strip.\n\n Example: ``len(np)``\n \"\"\"\n", + "/typeshed/stdlib/neopixel.pyi": "\"\"\"Individually addressable RGB and RGBW LED strips.\n\"\"\"\nfrom .microbit import MicroBitDigitalPin\nfrom typing import Tuple\n\nclass NeoPixel:\n def __init__(self, pin: MicroBitDigitalPin, n: int, bpp: int = 3) -> None:\n \"\"\"Initialise a new strip of neopixel LEDs controlled via a pin.\n\n Example: ``np = neopixel.NeoPixel(pin0, 8)``\n\n To support RGBW neopixels, a third argument can be passed to\n ``NeoPixel`` to indicate the number of bytes per pixel (``bpp``).\n For RGBW, this is is 4 rather than the default of 3 for RGB and GRB.\n\n Each pixel is addressed by a position (starting from 0). Neopixels are\n given RGB (red, green, blue) / RGBW (red, green, blue, white) values\n between 0-255 as a tuple. For example, in RGB, ``(255,255,255)`` is\n white. In RGBW, ``(255,255,255,0)`` or ``(0,0,0,255)`` is white.\n\n See `the online docs `_ for warnings and other advice.\n\n :param pin: The pin controlling the neopixel strip.\n :param n: The number of neopixels in the strip.\n :param bpp: Bytes per pixel. For RGBW neopixel support, pass 4 rather than the default of 3 for RGB and GRB.\n \"\"\"\n ...\n def clear(self) -> None:\n \"\"\"Clear all the pixels.\n\n Example: ``np.clear()``\n \"\"\"\n ...\n def show(self) -> None:\n \"\"\"Show the pixels.\n\n Example: ``np.show()``\n\n Must be called for any updates to become visible.\n \"\"\"\n ...\n def write(self) -> None:\n \"\"\"Show the pixels (micro:bit V2 only).\n\n Example: ``np.write()``\n\n Must be called for any updates to become visible.\n\n Equivalent to ``show``.\n \"\"\"\n ...\n def fill(self, colour: Tuple[int, ...]) -> None:\n \"\"\"Colour all pixels a given RGB/RGBW value (micro:bit V2 only).\n\n Example: ``np.fill((0, 0, 255))``\n\n :param colour: A tuple of the same length as the number of bytes per pixel (bpp).\n\n Use in conjunction with ``show()`` to update the neopixels.\n \"\"\"\n ...\n def __setitem__(self, key: int, value: Tuple[int, ...]) -> None:\n \"\"\"Set a pixel colour.\n\n Example: ``np[0] = (255, 0, 0)``\n\n :param key: The pixel number.\n :param value: The colour.\n \"\"\"\n def __getitem__(self, key: int) -> Tuple[int, ...]:\n \"\"\"Get a pixel colour.\n\n Example: ``r, g, b = np[0]``\n\n :param key: The pixel number.\n :return: The colour tuple.\n \"\"\"\n def __len__(self) -> int:\n \"\"\"Get length of this pixel strip.\n\n Example: ``len(np)``\n \"\"\"\n", "/typeshed/stdlib/os.pyi": "\"\"\"Access the file system.\n\"\"\"\n\nfrom typing import Tuple\nfrom typing import List\n\ndef listdir() -> List[str]:\n \"\"\"List files.\n\n Example: ``os.listdir()``\n\n :return: A list of the names of all the files contained within the local\n persistent on-device file system.\n \"\"\"\n ...\n\ndef remove(filename: str) -> None:\n \"\"\"Remove (delete) a file.\n\n Example: ``os.remove('data.txt')``\n\n :param filename: The file to delete.\n\n If the file does not exist an ``OSError`` exception will occur.\n \"\"\"\n ...\n\ndef size(filename: str) -> int:\n \"\"\"Returns the size of a file.\n\n Example: ``os.size('data.txt')``\n\n :param filename: The file\n :return: The size in bytes.\n\n If the file does not exist an ``OSError`` exception will occur.\n \"\"\"\n\nclass uname_result(Tuple[str, str, str, str, str]):\n \"\"\"Result of ``os.uname()``\"\"\"\n sysname: str\n \"\"\"Operating system name.\"\"\"\n\n nodename: str\n \"\"\"Name of machine on network (implementation-defined).\"\"\"\n\n release: str\n \"\"\"Operating system release.\"\"\"\n \n version: str\n \"\"\"Operating system version.\"\"\"\n \n machine: str\n \"\"\"Hardware identifier.\"\"\"\n\ndef uname() -> uname_result:\n \"\"\"Returns information identifying the current operating system.\n\n Example: ``os.uname()``\n\n The return value is an object with five attributes:\n\n - ``sysname`` - operating system name\n - ``nodename`` - name of machine on network (implementation-defined)\n - ``release`` - operating system release\n - ``version`` - operating system version\n - ``machine`` - hardware identifier\n\n There is no underlying operating system in MicroPython. As a result the\n information returned by the ``uname`` function is mostly useful for\n versioning details.\n \"\"\"\n ...\n", "/typeshed/stdlib/power.pyi": "\"\"\"Manage the power modes of the micro:bit (V2 only).\n\"\"\"\n\nfrom microbit import MicroBitDigitalPin, Button\nfrom typing import Optional, Tuple, Union\n\ndef off() -> None:\n \"\"\"Power down the board to the lowest possible power mode.\n\n Example: ``power.off()``\n\n This is the equivalent to pressing the reset button for a few seconds,\n to set the board in \"Off mode\".\n\n The micro:bit will only wake up if the reset button is pressed or,\n if on battery power, when a USB cable is connected.\n\n When the board wakes up it will start for a reset state, so your program\n will start running from the beginning.\n \"\"\"\n ...\n\ndef deep_sleep(\n ms: Optional[int] = None,\n wake_on: Optional[\n Union[MicroBitDigitalPin, Button] | Tuple[MicroBitDigitalPin | Button, ...]\n ] = None,\n run_every: bool = True,\n) -> None:\n \"\"\"Set the micro:bit into a low power mode where it can wake up and continue operation.\n\n Example: ``power.deep_sleep(wake_on=(button_a, button_b))``\n\n The program state is preserved and when it wakes up it will resume\n operation where it left off.\n\n Deep Sleep mode will consume more battery power than Off mode.\n\n The wake up sources are configured via arguments.\n\n The board will always wake up when receiving UART data, when the reset\n button is pressed (which resets the board) or, in battery power,\n when the USB cable is inserted.\n\n When the ``run_every`` parameter is set to ``True`` (the default), any\n function scheduled with ``run_every`` will momentarily wake up the board\n to run and when it finishes it will go back to sleep.\n\n :param ms: A time in milliseconds to wait before it wakes up.\n :param wake_on: A single instance or a tuple of pins and/or buttons to wake up the board, e.g. ``deep_sleep(wake_on=button_a)`` or ``deep_sleep(wake_on=(pin0, pin2, button_b))``.\n :param run_every: A boolean to configure if the functions scheduled with ``microbit.run_every`` will continue to run while it sleeps.\n \"\"\"\n ...\n", "/typeshed/stdlib/radio.pyi": "\"\"\"Communicate between micro:bits with the built-in radio.\n\"\"\"\n\nfrom _typeshed import WriteableBuffer\nfrom typing import Optional, Tuple\n\nRATE_1MBIT: int\n\"\"\"Constant used to indicate a throughput of 1 MBit a second.\"\"\"\n\nRATE_2MBIT: int\n\"\"\"Constant used to indicate a throughput of 2 MBit a second.\"\"\"\n\ndef on() -> None:\n \"\"\"Turns the radio on.\n\n Example: ``radio.on()``\n\n This needs to be explicitly called since the radio draws power and takes\n up memory that you may otherwise need.\n \"\"\"\n ...\n\ndef off() -> None:\n \"\"\"Turns off the radio, saving power and memory.\n\n Example: ``radio.off()``\n \"\"\"\n ...\n\ndef config(\n length: int = 32,\n queue: int = 3,\n channel: int = 7,\n power: int = 6,\n address: int = 0x75626974,\n group: int = 0,\n data_rate: int = RATE_1MBIT,\n) -> None:\n \"\"\"Configures the radio.\n\n Example: ``radio.config(group=42)``\n\n The default configuration is suitable for most use.\n\n :param length: (default=32) defines the maximum length, in bytes, of a message sent via the radio.\n It can be up to 251 bytes long (254 - 3 bytes for S0, LENGTH and S1 preamble).\n :param queue: (default=3) specifies the number of messages that can be stored on the incoming message queue.\n If there are no spaces left on the queue for incoming messages, then the incoming message is dropped.\n :param channel: (default=7) an integer value from 0 to 83 (inclusive) that defines an arbitrary \"channel\" to which the radio is tuned.\n Messages will be sent via this channel and only messages received via this channel will be put onto the incoming message queue. Each step is 1MHz wide, based at 2400MHz.\n :param power: (default=6) is an integer value from 0 to 7 (inclusive) to indicate the strength of signal used when broadcasting a message.\n The higher the value the stronger the signal, but the more power is consumed by the device. The numbering translates to positions in the following list of dBm (decibel milliwatt) values: -30, -20, -16, -12, -8, -4, 0, 4.\n :param address: (default=0x75626974) an arbitrary name, expressed as a 32-bit address, that's used to filter incoming packets at the hardware level, keeping only those that match the address you set.\n The default used by other micro:bit related platforms is the default setting used here.\n :param group: (default=0) an 8-bit value (0-255) used with the ``address`` when filtering messages.\n Conceptually, \"address\" is like a house/office address and \"group\" is like the person at that address to which you want to send your message.\n :param data_rate: (default=``radio.RATE_1MBIT``) indicates the speed at which data throughput takes place.\n Can be one of the following constants defined in the ``radio`` module: ``RATE_250KBIT``, ``RATE_1MBIT`` or ``RATE_2MBIT``.\n\n If ``config`` is not called then the defaults described above are assumed.\n \"\"\"\n ...\n\ndef reset() -> None:\n \"\"\"Reset the settings to their default values.\n\n Example: ``radio.reset()``\n\n The defaults as as per the ``config`` function above.\n \"\"\"\n ...\n\ndef send_bytes(message: bytes) -> None:\n \"\"\"Sends a message containing bytes.\n\n Example: ``radio.send_bytes(b'hello')``\n\n :param message: The bytes to send.\n \"\"\"\n ...\n\ndef receive_bytes() -> Optional[bytes]:\n \"\"\"Receive the next incoming message on the message queue.\n\n Example: ``radio.receive_bytes()``\n\n :return: The message bytes if any, otherwise ``None``.\n \"\"\"\n ...\n\ndef receive_bytes_into(buffer: WriteableBuffer) -> Optional[int]:\n \"\"\"Copy the next incoming message on the message queue into a buffer.\n\n Example: ``radio.receive_bytes_info(buffer)``\n\n :param buffer: The target buffer. The message is truncated if larger than the buffer.\n :return: ``None`` if there are no pending messages, otherwise it returns the length of the message (which might be more than the length of the buffer).\n \"\"\"\n ...\n\ndef send(message: str) -> None:\n \"\"\"Sends a message string.\n\n Example: ``radio.send('hello')``\n\n This is the equivalent of ``radio.send_bytes(bytes(message, 'utf8'))`` but with ``b'\\x01\\x00\\x01'``\n prepended to the front (to make it compatible with other platforms that target the micro:bit).\n\n :param message: The string to send.\n \"\"\"\n ...\n\ndef receive() -> Optional[str]:\n \"\"\"Works in exactly the same way as ``receive_bytes`` but returns whatever was sent.\n\n Example: ``radio.receive()``\n\n Equivalent to ``str(receive_bytes(), 'utf8')`` but with a check that the the first\n three bytes are ``b'\\x01\\x00\\x01'`` (to make it compatible with other platforms that\n may target the micro:bit).\n\n :return: The message with the prepended bytes stripped and converted to a string.\n\n A ``ValueError`` exception is raised if conversion to string fails.\n \"\"\"\n ...\n\ndef receive_full() -> Optional[Tuple[bytes, int, int]]:\n \"\"\"Returns a tuple containing three values representing the next incoming message on the message queue.\n\n Example: ``radio.receive_full()``\n\n If there are no pending messages then ``None`` is returned.\n\n The three values in the tuple represent:\n\n - the next incoming message on the message queue as bytes.\n - the RSSI (signal strength): a value between 0 (strongest) and -255 (weakest) as measured in dBm.\n - a microsecond timestamp: the value returned by ``time.ticks_us()`` when the message was received.\n\n For example::\n\n details = radio.receive_full()\n if details:\n msg, rssi, timestamp = details\n\n This function is useful for providing information needed for triangulation\n and/or trilateration with other micro:bit devices.\n\n :return: ``None`` if there is no message, otherwise a tuple of length three with the bytes, strength and timestamp values.\n \"\"\"\n ...\n", @@ -35,12 +35,12 @@ "/typeshed/stdlib/usys.pyi": "from sys import *\n", "/typeshed/stdlib/utime.pyi": "from time import *\n", "/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(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 Celcius.\"\"\"\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 The default touch mode for the pins on the edge connector is ``resistive``.\n 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 :return: ``True`` if the pin is being touched with a finger, otherwise return ``False``.\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 :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/__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(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 The default touch mode for the pins on the edge connector is ``resistive``.\n 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 :return: ``True`` if the pin is being touched with a finger, otherwise return ``False``.\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 :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 mouth 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[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 custom audio frames.\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 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 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 \"\"\"Tremelo 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 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: ...\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[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 custom audio frames.\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 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 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 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: ...\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/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\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", "/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",