-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
360 changed files
with
80,579 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/dist/ | ||
/venv/ | ||
/flipperzero/__init__.py | ||
.vscode | ||
.clang-format | ||
.clangd | ||
.editorconfig | ||
.env | ||
.ufbt | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [1.3.0] | ||
|
||
### Added | ||
|
||
* Simple ADC support for the `flipperzero` module: | ||
* Read raw value. | ||
* Read voltage. | ||
* Simple PWM support for the `flipperzero` module: | ||
* Start a signal. | ||
* Stop a signal. | ||
* Check the status. | ||
* Infrared support for the `flipperzero` module: | ||
* Receive a signal. | ||
* Transmit a signal. | ||
* Check the status. | ||
* Reset used GPIO pins upon script termination. | ||
* Improved GPIO related functions to prevent user errors. | ||
* Published [Python package on PyPI](https://pypi.org/project/flipperzero/) for code completion support. | ||
|
||
### Changed | ||
|
||
* The GPIO init function `flipperzero.gpio_init_pin` returns a boolean value. | ||
|
||
## [1.2.0] - 2024-09-05 | ||
|
||
### Added | ||
|
||
* Constants for all musical notes from C0 up to B8. | ||
* Constants for minimum and maximum speaker volumes. | ||
* Simple GPIO support for the `flipperzero` module: | ||
* Initialize a pin. | ||
* Read from a pin. | ||
* Write to a pin. | ||
* Handle interrupts. | ||
|
||
### Fixed | ||
|
||
* Message box alignment parameters `h` and `v` are now correctly evaluated. | ||
|
||
## [1.1.0] - 2024-08-28 | ||
|
||
### Added | ||
|
||
* Display splash screen upon application start. | ||
* API documentation on [GitHub pages](https://ofabel.github.io/mp-flipper/). | ||
|
||
## [1.0.0] - 2024-08-22 | ||
|
||
### Added | ||
|
||
* First stable release on the [application catalog](https://github.com/flipperdevices/flipper-application-catalog). | ||
|
||
### Changed | ||
|
||
* Application ID is now `upython` | ||
|
||
## [0.5.0-beta.1] - 2024-08-04 | ||
|
||
### Added | ||
|
||
* Message dialog support. | ||
* Update to the latest 0.104.0 firmware. | ||
|
||
### Removed | ||
|
||
* Disabled various Python builtins to shrink binary size. | ||
|
||
## [0.4.0-beta.1] - 2024-04-14 | ||
|
||
### Added | ||
|
||
* [Library](https://github.com/ofabel/mp-flipper/tree/lib) to include in the [firmware repository](https://github.com/ofabel/flipperzero-firmware). | ||
* All generated files from the build prozess are now [part of the repository](https://github.com/ofabel/mp-flipper/tree/lib-release). | ||
* Enabled split heap support for MicroPython: | ||
* The runtime can allocate and free heap memory. | ||
* Allows to start the Python process with small heap. | ||
* Enabled scheduler support (required for interrupt handling). | ||
* Enabled support for module `__init__` functions. | ||
* Stabilized `flipperzero` module API: | ||
* Canvas support has now a proper implementation. | ||
* Interrupts from buttons are supported. | ||
|
||
## [0.3.0-alpha.1] - 2024-04-04 | ||
|
||
### Added | ||
|
||
* Floating point support | ||
* Extend `flipperzero` module with support for: | ||
* Speaker, set volume and frequency | ||
* Canvas, very wacky implementation | ||
|
||
## [0.2.0-alpha.1] - 2024-04-03 | ||
|
||
### Added | ||
|
||
* Support for external imports | ||
* Python `time` module support | ||
* Python `random` module support | ||
* Basic `flipperzero` module with support for: | ||
* Vibration | ||
* LED | ||
* Backlight | ||
* Some test Python scripts | ||
|
||
## [0.1.0-alpha.1] - 2024-04-01 | ||
|
||
### Added | ||
|
||
* Basic build setup | ||
* Minimal working example | ||
|
||
[Unreleased]: https://github.com/ofabel/mp-flipper/compare/v1.3.0...HEAD | ||
[1.3.0]: https://github.com/ofabel/mp-flipper/compare/v1.2.0...v1.3.0 | ||
[1.2.0]: https://github.com/ofabel/mp-flipper/compare/v1.1.0...v1.2.0 | ||
[1.1.0]: https://github.com/ofabel/mp-flipper/compare/v1.0.0...v1.1.0 | ||
[1.0.0]: https://github.com/ofabel/mp-flipper/compare/v0.5.0-beta.1...v1.0.0 | ||
[0.5.0-beta.1]: https://github.com/ofabel/mp-flipper/compare/v0.4.0-beta.1...v0.5.0-beta.1 | ||
[0.4.0-beta.1]: https://github.com/ofabel/mp-flipper/compare/v0.3.0-alpha.1...v0.4.0-beta.1 | ||
[0.3.0-alpha.1]: https://github.com/ofabel/mp-flipper/compare/v0.2.0-alpha.1...v0.3.0-alpha.1 | ||
[0.2.0-alpha.1]: https://github.com/ofabel/mp-flipper/compare/v0.1.0-alpha.1...v0.2.0-alpha.1 | ||
[0.1.0-alpha.1]: https://github.com/ofabel/mp-flipper/releases/tag/v0.1.0-alpha.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
=========== | ||
|
||
Copyright (c) 2024 Oliver Fabel | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.PHONY: update | ||
update: | ||
git submodule update --remote lib/micropython && git add lib/micropython | ||
|
||
.PHONY: build-fap | ||
build-fap: update | ||
ufbt build | ||
|
||
.PHONY: launch | ||
launch: build-fap | ||
ufbt launch | ||
|
||
.PHONY: clean | ||
clean: | ||
ufbt -c | ||
|
||
.PHONY: build-pages | ||
build-pages: | ||
rm -rf ./dist/pages ./flipperzero/__init__.py | ||
cat ./flipperzero/_*.py > ./flipperzero/__init__.py | ||
source venv/bin/activate && sphinx-build docs/pages dist/pages | ||
|
||
.PHONY: publish-pages | ||
publish-pages: build-pages | ||
./publish.sh pages | ||
|
||
.PHONY: build-python | ||
build-python: | ||
source venv/bin/activate && hatch build | ||
|
||
.PHONY: publish-python | ||
publish-python: build-python | ||
source venv/bin/activate && hatch publish dist/python/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
![License](https://img.shields.io/github/license/ofabel/mp-flipper) | ||
![Version](https://img.shields.io/github/v/tag/ofabel/mp-flipper) | ||
![](https://img.shields.io/github/issues/ofabel/mp-flipper) | ||
|
||
# MicroPython Flipper Zero | ||
|
||
The application is now available on the official [Flipper Lab](https://lab.flipper.net/apps/upython). | ||
For more information on how to programm your Flipper with Python, check out the [documentation](https://ofabel.github.io/mp-flipper/) on GitHub pages. | ||
|
||
This branch contains the [FAP](https://developer.flipper.net/flipperzero/doxygen/apps_on_sd_card.html) version of the [MicroPython](https://micropython.org/) support for the famous [Flipper Zero](https://flipperzero.one/) gadget. | ||
The results of the preceding research phase is still available in the [poc](https://github.com/ofabel/mp-flipper/tree/poc) branch. | ||
The [lib](https://github.com/ofabel/mp-flipper/tree/lib) branch of this repository contains just the MicroPython library. | ||
The progress of further research on what can be achieved when moving functionality to the firmware can be found in the [fork of the original firmware](https://github.com/ofabel/flipperzero-firmware/tree/ofa/micropython). | ||
|
||
## Usage | ||
|
||
Just place your Python files somewhere on the SD card (e.g. by using the [qFlipper](https://flipperzero.one/downloads) app). | ||
|
||
The application just starts with an open file browser: | ||
|
||
![](./assets/file-browser.png) | ||
|
||
Here you can select any Python file to compile and execute from the SD card: | ||
|
||
![](./assets/tic-tac-toe.png) | ||
|
||
## Disclaimer | ||
|
||
This FAP version requires about 80 kB from SRAM to start (needed for the Python runtime and compiler). | ||
Due to memory fragmentation it's possible, that the application crashes when you start it. | ||
If this happens, just try again (the crash doesn't harm your device). | ||
|
||
Sadly, REPL support is only available in fhe [firmware fork](https://github.com/ofabel/flipperzero-firmware/tree/ofa/micropython) version. | ||
|
||
## Setup and Build | ||
|
||
This section is only relevant, if you want to build the FAP on your own. | ||
|
||
### Requirements | ||
|
||
* [Git](https://git-scm.com/) | ||
* [Make](https://www.gnu.org/software/make/) | ||
* [uFBT](https://pypi.org/project/ufbt/) available in your `PATH` (or you have to adjust the [Makefile](./Makefile)) | ||
* [Flipper Zero](https://flipperzero.one/) | ||
|
||
### Setup | ||
|
||
```bash | ||
git clone --recurse-submodules [email protected]:ofabel/mp-flipper.git | ||
``` | ||
|
||
### Build | ||
|
||
Just open a terminal and run the Makefile targets: | ||
|
||
```bash | ||
make build | ||
``` | ||
|
||
You can also build an launch the application on the attached Flipper Zero device in one command: | ||
|
||
```bash | ||
make launch | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
App( | ||
appid="upython", | ||
name="uPython", | ||
apptype=FlipperAppType.EXTERNAL, | ||
entry_point="upython", | ||
stack_size=4 * 1024, | ||
fap_category="Tools", | ||
fap_version="1.3", | ||
fap_description="Compile and execute MicroPython scripts", | ||
fap_icon="icon.png", | ||
fap_icon_assets="images", | ||
fap_author="Oliver Fabel", | ||
fap_file_assets="examples", | ||
fap_weburl="https://github.com/ofabel/mp-flipper", | ||
sources=[ | ||
"*.c*", | ||
"!./lib/micropython", | ||
"!./lib/micropython-port", | ||
"!./docs/pages", | ||
"!./flipperzero", | ||
"!./venv", | ||
"!./dist", | ||
], | ||
fap_private_libs=[ | ||
Lib( | ||
name="micropython", | ||
cflags=[ | ||
"-Wno-error", | ||
"-w", | ||
# | ||
# required for floating point support | ||
# | ||
"-mcpu=cortex-m4", | ||
"-mfloat-abi=hard", | ||
"-mfpu=fpv4-sp-d16", | ||
"-mthumb", | ||
"-fsingle-precision-constant", | ||
"-fno-math-errno", | ||
], | ||
cincludes=["."] | ||
), | ||
Lib( | ||
name="micropython-port", | ||
cflags=[ | ||
"-Wno-error", | ||
"-w", | ||
# | ||
# required for floating point support | ||
# | ||
"-mcpu=cortex-m4", | ||
"-mfloat-abi=hard", | ||
"-mfpu=fpv4-sp-d16", | ||
"-mthumb", | ||
"-fsingle-precision-constant", | ||
"-fno-math-errno", | ||
], | ||
cincludes=["."] | ||
), | ||
] | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## 1.3 | ||
|
||
* Added simple ADC support: read value and voltage. | ||
* Added simple PWM support: start, stop, check status. | ||
* Added infrared support: receive and transmit a signal, check status. | ||
* Added success indicator to GPIO init function. | ||
* Reset used GPIO pins upon script termination. | ||
* Improved GPIO related functions to prevent user errors. | ||
* Published Python package on PyPI for code completion support. | ||
|
||
## 1.2 | ||
|
||
* Added simple GPIO support: initialize, read, write, interrupts. | ||
* Added constants for musical note frequencies from C0 up to B8. | ||
* Some minor fixes in the dialog functions. | ||
|
||
## 1.1 | ||
|
||
* Display splash screen upon application start. | ||
* API documentation available on GitHub pages. | ||
|
||
## 1.0 | ||
|
||
* Initial stable release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# MicroPython | ||
|
||
MicroPython is a version of the popular Python programming language, especially tailored for the hardware requirements of small microcontrollers, like the Flipper Zero. | ||
Instead of supporting the full standard library, only a subset is implemented, carefully selected with the requirements of a microcontroller environment in mind. | ||
But this should not limit your creativity and ability to create great applications at all. | ||
|
||
## API | ||
|
||
Visit the repository website on GitHub or scan the QR code on the welcome screen. | ||
|
||
## Disclaimer | ||
|
||
Running MicroPython is a heavy task for the Flipper. | ||
This does sometimes lead to an _Out of Memory_ error. | ||
**This doesn't harm your Flipper.** |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.