@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [1.6.0] - 2024-11-17
+
+### Added
+* Enabled extra functions for the `random` module.
## [1.5.0] - 2024-10-06
### Added
@@ -156,7 +162,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Basic build setup
* 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.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
@@ -5,7 +5,7 @@ App(
entry_point="upython",
stack_size=4 * 1024,
fap_category="Tools",
- fap_version="1.5",
+ fap_version="1.6",
fap_description="Compile and execute MicroPython scripts",
fap_icon="icon.png",
fap_icon_assets="images",
@@ -25,6 +25,11 @@ import io
copy_dict(flipperzero.io, io)
+import flipperzero.random
+import random
+copy_dict(flipperzero.random, random)
now = datetime.datetime.now()
project = "uPython"
@@ -452,7 +452,7 @@ Functions
I/O
---
-Read and write files on the SD card.
+Read and write SD card files.
Constants
~~~~~~~~~
@@ -475,6 +475,22 @@ Classes
.. autoclass:: io.TextFileIO
: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
--------
@@ -5,16 +5,17 @@ Here you can see what to expect from future releases.
## Next Release
-* Improved `print` function.
-* UART
+* SPI
* I2C
* 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
* NFC
* USB HID
* Subghz
* Bluetooth
@@ -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.
+ .. hint::
+ This function does only generate integer values.
+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.
+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.
+def getrandbits(k: int) -> int:
+ Get ``k`` random bits.
+ :param k: The number of bits.
+ :returns: The random bits.
+def uniform(a: float, b: float) -> float:
+ Get a random float value between ``a`` (inclusive) and ``b`` (inclusive).
+def seed(a: int) -> None:
+ Initialize the random number generator.
+ :param a: The initialization value to use.
+ Random generator seeding is done automatically, so there is no need to call this function.
@@ -1 +1 @@
-https://github.com/ofabel/mp-flipper 29091048ae9a613070da21b373062a450f7ecd08 /
+https://github.com/ofabel/mp-flipper 242fff05599d97faafab563a827dd86791c0cbee /
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "flipperzero"
-version = "1.5.0"
+version = "1.6.0"
authors = [
{ name = "Oliver Fabel" },
]