Git Product home page Git Product logo

rust-for-arduboy's Introduction

Rust for Arduboy

Running Rust on the Arduboy miniature game system.

The most important first. I didn't create this project from scratch, @Seeker14491 the legend has already done a lot in his old project ArduboyRust

I just updated and completed the project.

What do i mean by completed?

I provided all the important functions from the Arduboy2 library in a safe Rust API.

Most of the Arduboy2 funktions can be called the same way like in C.

How to use this Project

First clone the repo

git clone https://github.com/ZennDev1337/Rust-for-Arduboy

Install PlatformIO Core on your system. I recommend the pip install if you don't want to configure a new path variable for pio. Otherwise, you will know how to do that.

The rust-analyzer will complain about a missing test crate to fix this add the following rule to the lsp settings :

{
  "rust-analyzer.checkOnSave.allTargets": false
}

If your using Visual Studio Code: Create a folder named .vscode and a file named settings.json inside. Past the setting above in the new file. (I have excluded my .vscode folder because I have many different settings there that you don't need)

Your game is located in the Project/game folder. This is also the folder you are working in

Inside the game folder you will find a lib.rs file which contains the setup and loop function as you know it from a normal Arduboy C project.

You can find the Docs here:

or you can use the following command to open the arduboy-rust Crate docs locally

cargo doc -p arduboy-rust --open

Most of the time you will use the prelude. There is listed witch funktionality you will have.

And last but not least there are multiple examples inside of the Examples folder which shows you how to use the functions. I will from time to time also upload my projects to the Example folder so you have as much ressurces as possible.

Usage of the run tool

The run script only work if you use the given folder structure!

requirements:

  • Python3.11 or higher
  • PlatformIO Core must be installed
  • The Arduboy must be plugged in
  • You are in the root directory of this project

All builded .hex files are saved inside of arduboy-rust/Wrapper-Project/build/<GAMENAME>.hex after you uploaded them to the Arduboy.

To upload your own game to the Arduboy use:

Linux:

python ./run.py <Project_Name>

Windows:

python .\run.py <Project_Name>

All commands:

Usage build and upload Project:
  run.py list                     Get a list of all Projects
  run.py new <Project-Name>       Create a new game in the Project folder
  run.py <Project-Name>           For uploading a game

Usage FX-Data build and upload:
  run.py fxbuild <Project-Name>   Build your fxdata
  run.py fxupload <Project-Name>  Upload your fxdata
  run.py fxall <Project-Name>     Build and Upload your fxdata
                                  and the game in one step

List of all the Example Games:

ZennDev1337 Games

  • drboy

Rust Games

  • snake
  • rustacean

The demo games / tutorials from the official Arduboy forum [Rewritten in Rust]

Usage of the FX Chip

requirements:

python3 -m pip install pyserial pillow

You need to create a fxdata folder in your project directory.

Don't forget to uncomment the ArduboyFX_Library line in the import_config.h file.

run Commands:

|Project_Dir
->fxdata
  ->fxdata.txt
->src
  ->lib.rs
>cargo.toml

You also need a fxdata.txt file in this new folder.

See the examples in Examples/ArduboyFX.

More information:

run Commands:

  • fxbuild is used to build the fxdata.dat file.
  • fxupload is used to upload the fxdata.dat file.
  • fxall is used to build and upload the fxdata.dat file and build and upload the game all in one step.

Linux:

python ./run.py fxbuild <Project_Name>
python ./run.py fxupload <Project_Name>
python ./run.py fxall <Project_Name>

Windows:

python .\run.py fxbuild <Project_Name>
python .\run.py fxupload <Project_Name>
python .\run.py fxall <Project_Name>

Convert the fxdata.h file to Rust

FXdata Converter by ZennDev1337

Create a new project

In the root of the repo use the command:

python ./run.py new <Project-Name>

To run and upload your game use the run tool

# Linux
python ./run.py <Project-Name>
# Windows
python .\run.py <Project-Name>

Creating and building an Arduboy crate [Outdated]

You can find instructions on how all build steps work in detail here ArduboyRust creating and building an arduboy crate

Linking the static library to the Arduino C++ project [Outdated]

Instructions on how to link all the static libraries in the Arduino C++ project can be found here ArduboyRust linking the static library to the arduino c++ project

Credits

Thanks to @Seeker14491 who wrote ArduboyRust, the starting point for me to create my own project based on this project. (you are a hero <3)

Thanks to @simon-i1-h who wrote arduboy-hello-rs, the proof of concept that inspired me to try Rust on the Arduboy.

License

You can license it under either one of those licenses:

Whichever you may prefer.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.