GithubHelp home page GithubHelp logo

numworks / epsilon-sample-app-rust Goto Github PK

View Code? Open in Web Editor NEW
49.0 11.0 10.0 463 KB

A sample Rust app for the NumWorks graphing calculator

License: BSD 3-Clause "New" or "Revised" License

Rust 100.00%
rust numworks embedded

epsilon-sample-app-rust's Introduction

Sample Rust app for Epsilon

Build

Sample Rust app for the NumWorks graphing calculator

This is a sample Rust app to use on a NumWorks calculator. Yes, you can now use Rust to write code for a graphing calculator!

fn eadk_main() {
    for _ in 0..100 {
        let c = eadk::Color { rgb565: random_u16() };
        let r = eadk::Rect { x: random_coordinate(), y: random_coordinate(), width: random_coordinate(), height: random_coordinate() };
        eadk::display::push_rect_uniform(r, c);
    }
    loop {}
}

Build the app

To build this sample app, you will need to install an embedded ARM rust compiler as well as Node.js. The SDK for Epsilon apps is shipped as an npm module called nwlink that will automatically be installed at compile time.

brew install rustup node # Or equivalent on your OS
rustup-init
rustup target add thumbv7em-none-eabihf
cargo build

Run the app

The app is sent over to the calculator using the DFU protocol over USB.

# Now connect your NumWorks calculator to your computer using the USB cable
cargo run

Notes

The NumWorks calculator runs Epsilon, a tailor-made calculator operating system. Starting from version 16, Epsilon allows installing custom binary apps. To run this sample app, make sure your calculator is up-to-date by visiting https://my.numworks.com.

Due to the embedded nature of Epsilon, the Rust app has to be no_std. The interface that an app can use to interact with the OS is essentially a short list of system calls. Feel free to browse the code of Epsilon itself if you want to get an in-depth look.

Please note that any custom app is removed when resetting the calculator.

License

This sample app is distributed under the terms of the BSD License. See LICENSE for details.

Trademarks

NumWorks and Rust are a registered trademarks.

epsilon-sample-app-rust's People

Contributors

ecco avatar emilienumworks avatar emmanumworks avatar gabrielnumworks avatar hugonumworks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

epsilon-sample-app-rust's Issues

License choise and compatibility with the GNU GPL

The BSD 4-clauses seems like it's not really a good license for this kind of repository, since the whole purpose of the external app system in the beginning was to avoid licensing problems with software using the GNU GPL.

Since this license is incompatible with the GNU GPL, I would suggest to change it for a BSD 3-clauses, which is compatible with said GNU GPL. An even better license would be a MIT license, since it's better suited for thins kind of boilerplate repositories (or even public domain, but I don't think this is ever going to happen).

Make cargo output a .nwa file

I couldn't find how to customize the executable filename. For now the executable is epsilon-sample-app but it should be epsilon-sample-app.nwa.

Apparently it's something you can tweak if you come up with a custom rustc target, but that might be overkill.

Unable to set up an allocator

I'm unable to get an app with an allocator to build. I tried using simple_chunk_allocator to create a small region of memory that I could allocate dynamically.

I set it up like this in the main.rs module.

#![feature(const_mut_refs)]
#![feature(allocator_api)]
#![feature(default_alloc_error_handler)]

static mut HEAP: PageAligned<[u8; 4096]> = heap!(chunks = 256, chunksize = 16);
static mut HEAP_BITMAP: PageAligned<[u8; 2]> = heap_bitmap!(chunks = 16);
#[global_allocator]
static ALLOCATOR: GlobalChunkAllocator =
    unsafe { GlobalChunkAllocator::new(HEAP.deref_mut_const(), HEAP_BITMAP.deref_mut_const()) };

Cargo has no problem building it, but when nwlink runs, I get these errors:

    Finished release [optimized] target(s) in 1.15s
     Running `nwlink install-nwa target/thumbv7em-none-eabihf/release/numworks-app`
Upload [----------------------------------------] 0% | ETA: 0s/home/carson/.nvm/versions/node/v16.9.1/bin/nwlink: app.nwa:(.ARM.exidx.text.__rust_alloc+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/carson/.nvm/versions/node/v16.9.1/bin/nwlink: app.nwa:(.ARM.exidx.text.__rust_dealloc+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/carson/.nvm/versions/node/v16.9.1/bin/nwlink: app.nwa:(.ARM.exidx.text.__rust_realloc+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/carson/.nvm/versions/node/v16.9.1/bin/nwlink: app.nwa:(.ARM.exidx.text.__rust_alloc_error_handler+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'

can't draw rectangles with more than 65637 pixels on Epsilon 18.2.0?

Hello, I was trying to display an image on the whole calculator screen, but strange things happened, sometimes the numworks crashed, other times I couldn't restart the app because "exam mode was enabled" (I never enabled it),
so I tried to figure out where this bug came from and found that if I tried to draw a rectangle with push_rect(rect: Rect, pixels: &[Color]) with more than 65637 white pixels (which is very close to 2^16) , the calculator was crashing, the same thing with more pixels with random colors created weird things like enabling the exam mode or crash when starting other applications.
here is the code:

#[no_mangle]
pub fn main() {
    push_rect(
        Rect {
            x: 0,
            y: 0,
            width: 10,
            height: 10,
        },
        &[Color { rgb565: u16::MAX }; 65637],
    );
}

(The only things I changed other than this are adding #[derive(Clone, Copy) to Color and the build.rs and .cargo/config files)

I don't know much about how numworks works, but I found this bug quite weird and I didn't see any issue about it on the different numworks github repositories
is this normal? is there a fix?

Does it works in epsilon 18.2.3?

I don't really understand, since epsilon 16, (with n110) the epsilon is supposed to be locked but we can unlock it with Phi. In epsilon 18.2.3 we can't anymore so can we add apps to the numworks even if it is locked?

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.