Explorar o código

Merge mp_flipper from https://github.com/ofabel/mp-flipper

Willy-JL hai 1 ano
pai
achega
d82679fa48

+ 8 - 1
mp_flipper/CHANGELOG.md

@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 
 ## [Unreleased]
 ## [Unreleased]
 
 
+## [1.6.0] - 2024-11-17
+
+### Added
+
+* Enabled extra functions for the `random` module.
+
 ## [1.5.0] - 2024-10-06
 ## [1.5.0] - 2024-10-06
 
 
 ### Added
 ### Added
@@ -156,7 +162,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 * Basic build setup
 * Basic build setup
 * Minimal working example
 * Minimal working example
 
 
-[Unreleased]: https://github.com/ofabel/mp-flipper/compare/v1.5.0...dev
+[Unreleased]: https://github.com/ofabel/mp-flipper/compare/v1.6.0...dev
+[1.6.0]: https://github.com/ofabel/mp-flipper/compare/v1.5.0...v1.6.0
 [1.5.0]: https://github.com/ofabel/mp-flipper/compare/v1.4.0...v1.5.0
 [1.5.0]: https://github.com/ofabel/mp-flipper/compare/v1.4.0...v1.5.0
 [1.4.0]: https://github.com/ofabel/mp-flipper/compare/v1.3.0...v1.4.0
 [1.4.0]: https://github.com/ofabel/mp-flipper/compare/v1.3.0...v1.4.0
 [1.3.0]: https://github.com/ofabel/mp-flipper/compare/v1.2.0...v1.3.0
 [1.3.0]: https://github.com/ofabel/mp-flipper/compare/v1.2.0...v1.3.0

+ 1 - 1
mp_flipper/application.fam

@@ -5,7 +5,7 @@ App(
     entry_point="upython",
     entry_point="upython",
     stack_size=4 * 1024,
     stack_size=4 * 1024,
     fap_category="Tools",
     fap_category="Tools",
-    fap_version="1.5",
+    fap_version="1.6",
     fap_description="Compile and execute MicroPython scripts",
     fap_description="Compile and execute MicroPython scripts",
     fap_icon="icon.png",
     fap_icon="icon.png",
     fap_icon_assets="images",
     fap_icon_assets="images",

+ 5 - 0
mp_flipper/docs/pages/conf.py

@@ -25,6 +25,11 @@ import io
 
 
 copy_dict(flipperzero.io, io)
 copy_dict(flipperzero.io, io)
 
 
+import flipperzero.random
+import random
+
+copy_dict(flipperzero.random, random)
+
 now = datetime.datetime.now()
 now = datetime.datetime.now()
 
 
 project = "uPython"
 project = "uPython"

+ 17 - 1
mp_flipper/docs/pages/reference.rst

@@ -452,7 +452,7 @@ Functions
 I/O
 I/O
 ---
 ---
 
 
-Read and write files on the SD card.
+Read and write SD card files.
 
 
 Constants
 Constants
 ~~~~~~~~~
 ~~~~~~~~~
@@ -475,6 +475,22 @@ Classes
 .. autoclass:: io.TextFileIO
 .. autoclass:: io.TextFileIO
    :members: name, read, readline, readlines, readable, writable, write, flush, seek, tell, close, __enter__, __exit__, __del__
    :members: name, read, readline, readlines, readable, writable, write, flush, seek, tell, close, __enter__, __exit__, __del__
 
 
+Random
+------
+
+Generate pseudo-random number for various use cases. 
+
+Functions
+~~~~~~~~~
+
+.. autofunction:: random.random
+.. autofunction:: random.uniform
+.. autofunction:: random.randrange
+.. autofunction:: random.getrandbits
+.. autofunction:: random.randint
+.. autofunction:: random.choice
+.. autofunction:: random.seed
+
 Built-In
 Built-In
 --------
 --------
 
 

+ 4 - 3
mp_flipper/docs/pages/roadmap.md

@@ -5,16 +5,17 @@ Here you can see what to expect from future releases.
 
 
 ## Next Release
 ## Next Release
 
 
-* Improved `print` function.
-* UART
+* SPI
 * I2C
 * I2C
 * Maybe USB HID
 * Maybe USB HID
 
 
+_The next release might takes the form of a fork of the official firmware._
+_Check out [this issue](https://github.com/ofabel/mp-flipper/issues/4) for details._
+
 ## Planned
 ## Planned
 
 
 * I2C
 * I2C
 * NFC
 * NFC
-* UART
 * USB HID
 * USB HID
 * Subghz
 * Subghz
 * Bluetooth
 * Bluetooth

+ 87 - 0
mp_flipper/flipperzero/random.py

@@ -0,0 +1,87 @@
+def random() -> float:
+    '''
+    Get a random float value between 0.0 (inclusive) and 1.0 (exclusive).
+
+    :returns: The random value.
+
+    .. versionadded:: 1.6.0
+    '''
+    pass
+
+def randrange(start: int, stop: int, step: int = 1) -> int:
+    '''
+    Get a random integer between ``start`` (inclusive) and ``stop`` 
+    (exclusive) with an optional ``step`` between the values.
+
+    :param start: The start value.
+    :param stop: The end value.
+    :param step: The optional step value.
+    :returns: The random value.
+
+    .. versionadded:: 1.6.0
+
+    .. hint::
+
+        This function does only generate integer values.
+    '''
+    pass
+
+def randint(a: int, b: int) -> int:
+    '''
+    Get a random integer between ``a`` (inclusive) and ``b`` (inclusive).
+
+    :param a: The lower value.
+    :param b: The upper value.
+    :returns: The random value.
+
+    .. versionadded:: 1.6.0
+    '''
+    pass
+
+def choice[T](seq: list[T]) -> T:
+    '''
+    Get a random element from the provided sequence.
+
+    :param seq: The sequence to use.
+    :returns: A random element.
+
+    .. versionadded:: 1.6.0
+    '''
+    pass
+
+def getrandbits(k: int) -> int:
+    '''
+    Get ``k`` random bits. 
+
+    :param k: The number of bits.
+    :returns: The random bits.
+
+    .. versionadded:: 1.6.0
+    '''
+    pass
+
+def uniform(a: float, b: float) -> float:
+    '''
+    Get a random float value between ``a`` (inclusive) and ``b`` (inclusive).
+
+    :param a: The lower value.
+    :param b: The upper value.
+    :returns: The random value.
+
+    .. versionadded:: 1.6.0
+    '''
+    pass
+
+def seed(a: int) -> None:
+    '''
+    Initialize the random number generator. 
+
+    :param a: The initialization value to use.
+
+    .. versionadded:: 1.6.0
+
+    .. hint::
+
+        Random generator seeding is done automatically, so there is no need to call this function.
+    '''
+    pass

+ 1 - 1
mp_flipper/lib/micropython/.gitsubtree

@@ -1 +1 @@
-https://github.com/ofabel/mp-flipper 29091048ae9a613070da21b373062a450f7ecd08 /
+https://github.com/ofabel/mp-flipper 242fff05599d97faafab563a827dd86791c0cbee /

+ 1 - 1
mp_flipper/pyproject.toml

@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
 
 
 [project]
 [project]
 name = "flipperzero"
 name = "flipperzero"
-version = "1.5.0"
+version = "1.6.0"
 authors = [
 authors = [
     { name = "Oliver Fabel" },
     { name = "Oliver Fabel" },
 ]
 ]