From afa19a67dca0055396a18fd8e77acbe1cf67b2e7 Mon Sep 17 00:00:00 2001 From: ZennDev1337 Date: Mon, 11 Sep 2023 09:24:37 +0200 Subject: [PATCH] added support to create new projects --- Cargo.lock | 7 ++++++ Cargo.toml | 1 + README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ run | 5 ++-- run.bat | 2 +- 5 files changed, 86 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e93f88..2b0b7d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,6 +31,13 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "cracker" +version = "0.1.0" +dependencies = [ + "arduboy-rust", +] + [[package]] name = "critical-section" version = "1.1.2" diff --git a/Cargo.toml b/Cargo.toml index 535e69e..5154ab3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,5 +15,6 @@ members = [ "Examples/rustacean", "Examples/snake", "Project/game", + "Project/cracker", ] resolver = "2" diff --git a/README.md b/README.md index 0467f15..a92b745 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,80 @@ Windows: .\run.bat tone ``` +# Create a new project + +In the root of the repo use the command: + +(Don't use "-" in the name because of a cargo feature that takes the "-" and mixes sometimes with a "\_". You will have some weird behavior with the run tool.) + +```bash +cargo new --lib ./Project/newproject +``` + +Then open the Cargo.toml in your new project and add the following dependencies and settings: + +```toml +[lib] +crate-type = ["staticlib"] + +[dependencies] + +arduboy-rust = { path = "../../arduboy-rust" } +``` + +Next jump in your lib.rs file and add the following: + +```rust +#![no_std] +#![allow(non_upper_case_globals)] + +//Include the Arduboy Library +#[allow(unused_imports)] +use arduboy_rust::prelude::*; +#[allow(dead_code)] +const arduboy: Arduboy2 = Arduboy2::new(); + +// Progmem data + +// dynamic ram variables + +// The setup() function runs once when you turn your Arduboy on +#[no_mangle] +pub unsafe extern "C" fn setup() { + // put your setup code here, to run once: +} + +// The loop() function repeats forever after setup() is done +#[no_mangle] +#[export_name = "loop"] +pub unsafe extern "C" fn loop_() { + // put your main code here, to run repeatedly: +} +``` + +Now the last step. Go in the Cargo.toml in the root directory and add your project: + +```toml +[workspace] +members = [ + {All other Projects...} + "Project/newproject", +] +resolver = "2" +``` + +To run and upload your game use the run tool + +```bash +# Linux +./run newproject +``` + +```ps1 +# Windows +.\run.bat newproject +``` + ## 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](https://github.com/Seeker14491/ArduboyRust#creating-and-building-an-arduboy-crate) diff --git a/run b/run index ed6bf41..40fadac 100755 --- a/run +++ b/run @@ -52,6 +52,7 @@ elif [ "$option" = "demo7" ] then upload else - echo Usage: for uploading your game \|./run.sh - echo Usage: for uploading an example game \| ./run.sh \ + upload + # echo Usage: for uploading your game \|./run.sh + # echo Usage: for uploading an example game \| ./run.sh \ fi diff --git a/run.bat b/run.bat index d035a50..3ee0417 100644 --- a/run.bat +++ b/run.bat @@ -40,7 +40,7 @@ goto :eof ) else if %option%==demo7 ( goto :run ) else ( - goto :help + goto :run ) :run