added the dependency to the project to circumvent crates.io and updated all projects

This commit is contained in:
Zenn 2023-08-06 18:34:36 +02:00
parent c591b2c272
commit 50819abc50
31 changed files with 1422 additions and 14 deletions

View file

@ -0,0 +1,26 @@
use core::ffi::{c_long, c_ulong};
extern "C" {
#[link_name = "arduino_random_between"]
fn arduino_random_between_raw(min: c_long, max: c_long) -> c_long;
#[link_name = "arduino_random_less_than"]
fn arduino_random_less_than_raw(max: c_long) -> c_long;
#[link_name = "arduino_delay"]
fn arduino_delay(ms: c_ulong);
}
/// A Arduino function to get a random number between 2 numbers
/// seed based
pub fn random_between(min: i32, max: i32) -> i32 {
unsafe { arduino_random_between_raw(min, max) }
}
/// A Arduino function to get a random number smaller than the number given
/// seed based
pub fn random_less_than(max: i32) -> i32 {
unsafe { arduino_random_less_than_raw(max) }
}
/// A Arduino function to pause the cpu circles for a given amount of ms
pub fn delay(ms: u32) {
unsafe { arduino_delay(ms) }
}