|
| 1 | +# [framework-ledmatrix] - Board Support for the [Framework LED Matrix] |
| 2 | + |
| 3 | +You should include this crate if you are writing code that you want to run on |
| 4 | +a [Frameworkg LED Matrix]. |
| 5 | + |
| 6 | +This crate includes the [rp2040-hal], but also configures each pin of the |
| 7 | +RP2040 chip according to how it is connected up on the module. |
| 8 | + |
| 9 | +[Framework LED Matrix]: https://frame.work/tw/en/products/16-led-matrix |
| 10 | +[framework-ledmatrix]: https://github.com/rp-rs/rp-hal-boards/tree/main/boards/framework-ledmatrix |
| 11 | +[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal |
| 12 | +[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/ |
| 13 | + |
| 14 | +## Using |
| 15 | + |
| 16 | +To use this crate, your `Cargo.toml` file should contain: |
| 17 | + |
| 18 | +```toml |
| 19 | +framework-ledmatrix = "0.1.0" |
| 20 | +``` |
| 21 | + |
| 22 | +In your program, you will need to call `framework_ledmatrix::Pins::new` to create |
| 23 | +a new `Pins` structure. This will set up all the GPIOs for any on-board |
| 24 | +devices. See the [examples](./examples) folder for more details. |
| 25 | + |
| 26 | +## Examples |
| 27 | + |
| 28 | +### General Instructions |
| 29 | + |
| 30 | +To compile an example, clone the _rp-hal-boards_ repository and run: |
| 31 | + |
| 32 | +```console |
| 33 | +rp-hal-boards/boards/framework-ledmatrix $ cargo build --release --example <name> |
| 34 | +``` |
| 35 | + |
| 36 | +You will get an ELF file called |
| 37 | +`./target/thumbv6m-none-eabi/release/examples/<name>`, where the `target` |
| 38 | +folder is located at the top of the _rp-hal-boards_ repository checkout. Normally |
| 39 | +you would also need to specify `--target=thumbv6m-none-eabi` but when |
| 40 | +building examples from this git repository, that is set as the default. |
| 41 | + |
| 42 | +If you want to convert the ELF file to a UF2 and automatically copy it to the |
| 43 | +USB drive exported by the RP2040 bootloader, simply boot your board into |
| 44 | +bootloader mode and run: |
| 45 | + |
| 46 | +```console |
| 47 | +rp-hal-boards/boards/framework-ledmatrix $ cargo run --release --example <name> |
| 48 | +``` |
| 49 | + |
| 50 | +If you get an error about not being able to find `elf2uf2-rs`, try: |
| 51 | + |
| 52 | +```console |
| 53 | +$ cargo install elf2uf2-rs |
| 54 | +``` |
| 55 | +then try repeating the `cargo run` command above. |
| 56 | + |
| 57 | +### From Scratch |
| 58 | + |
| 59 | +To start a basic project from scratch, create a project using `cargo new project-name`. Within the |
| 60 | +project directory, run `cargo add framework-ledmatrix`, `cargo add cortex-m-rt`, and `cargo add panic-halt`. The |
| 61 | +first command will add this HAL (Hardware Abstraction Layer), the second is required for the `#[entry]` macro, and _panic-halt_ creates a simple panic function, which just halts. |
| 62 | + |
| 63 | +You'll also need to copy the cargo config file from the [repo](https://github.com/rp-rs/rp-hal-boards/blob/main/.cargo/config.toml). It specifies the target and optimizing flags to the linker. You'll also need to copy [_memory.x_](https://github.com/rp-rs/rp-hal-boards/blob/main/memory.x) to your project root. This file tells the linker the flash and RAM layout, so it won't clobber the bootloader or write to an out of bounds memory address. |
| 64 | + |
| 65 | +The simplest working example, which does nothing except loop forever, is: |
| 66 | + |
| 67 | +```ignore |
| 68 | +#![no_std] |
| 69 | +#![no_main] |
| 70 | +use framework_ledmatrix::entry; |
| 71 | +use panic_halt as _; |
| 72 | +#[entry] |
| 73 | +fn see_doesnt_have_to_be_called_main() -> ! { |
| 74 | + loop {} |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +It can be placed in _/src/main.rs_. |
| 79 | + |
| 80 | +You can use `cargo run` to compile and install it. |
| 81 | +**Note**: You won't see any activity since this program does nothing. You can use the examples provided |
| 82 | +to add more functionality. |
| 83 | + |
| 84 | +### [ledtest](./examples/ledtest.rs) |
| 85 | + |
| 86 | +Lights up every single LED one after another. It goes back into bootloader mode |
| 87 | +when the system goes to sleep. This makes it easy for you to reflash it to |
| 88 | +other firmware. |
| 89 | + |
| 90 | +## Contributing |
| 91 | + |
| 92 | +Contributions are what make the open source community such an amazing place to |
| 93 | +be learn, inspire, and create. Any contributions you make are **greatly |
| 94 | +appreciated**. |
| 95 | + |
| 96 | +The steps are: |
| 97 | + |
| 98 | +1. Fork the Project by clicking the 'Fork' button at the top of the page. |
| 99 | +2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) |
| 100 | +3. Make some changes to the code or documentation. |
| 101 | +4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) |
| 102 | +5. Push to the Feature Branch (`git push origin feature/AmazingFeature`) |
| 103 | +6. Create a [New Pull Request](https://github.com/rp-rs/rp-hal-boards/pulls) |
| 104 | +7. An admin will review the Pull Request and discuss any changes that may be required. |
| 105 | +8. Once everyone is happy, the Pull Request can be merged by an admin, and your work is part of our project! |
| 106 | + |
| 107 | +## Code of Conduct |
| 108 | + |
| 109 | +Contribution to this crate is organized under the terms of the [Rust Code of |
| 110 | +Conduct][CoC], and the maintainer of this crate, the [rp-rs team], promises |
| 111 | +to intervene to uphold that code of conduct. |
| 112 | + |
| 113 | +[CoC]: CODE_OF_CONDUCT.md |
| 114 | +[rp-rs team]: https://github.com/orgs/rp-rs/teams/rp-rs |
| 115 | + |
| 116 | +## License |
| 117 | + |
| 118 | +The contents of this repository are dual-licensed under the _MIT OR Apache |
| 119 | +2.0_ License. That means you can choose either the MIT license or the |
| 120 | +Apache-2.0 license when you re-use this code. See `MIT` or `APACHE2.0` for more |
| 121 | +information on each specific license. |
| 122 | + |
| 123 | +Any submissions to this project (e.g. as Pull Requests) must be made available |
| 124 | +under these terms. |
0 commit comments