From 53c6fcd9177dd8aea8d183a3212dee904791fed5 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Fri, 15 Apr 2022 02:11:34 +0200 Subject: [PATCH] Add wiring pi (for test and doc) --- Cargo.lock | Bin 49482 -> 49884 bytes Cargo.toml | 1 + build.rs | 4 ++++ src/main.rs | 7 +++++++ 4 files changed, 12 insertions(+) create mode 100644 build.rs diff --git a/Cargo.lock b/Cargo.lock index 0dfd7cf0428def6664487d060586176891d312e7..ce30f6a4267e05ba0dfeb2b149fb7d7435ccf100 100644 GIT binary patch delta 269 zcmX@r#C)ffd4q%rmx5AxW>IEddO_x7MK-C;`X*C_#nN-~la#p1Qj3Z+^YavJ6_gD0 zjPwjAPgD+Yut-WZv`9%cuuL>HOENP^O#z}b3zMW|%ak+&1M^g40|OHSGfTt7H1ovd z6vJc_Lkn}0w8X?@QwvMeq_m{TfqoL3kGe0Z(16;CVULLtS8;x6QF1EC;`Gdt$%zso z9$96Hc`2zyWvMwSsd@TErNt$>FlXxl)hL^rB_WED2?%{C@eg*W$kEUlRQ``|+WmyZl3 diff --git a/Cargo.toml b/Cargo.toml index cd677b7..f56d4c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,3 +21,4 @@ serde_json = "1.0" serde_derive = "1.0" libsqlite3-sys = { version = "*", features = ["bundled"] } uuid = { version = "0.8", features = ["serde", "v4"] } +wiringpi = { git = "https://github.com/jvandervelden/rust-wiringpi.git " } diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..028e4bf --- /dev/null +++ b/build.rs @@ -0,0 +1,4 @@ +fn main() { + #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] + println!("cargo:rustc-link-lib=dylib=wiringPi"); +} diff --git a/src/main.rs b/src/main.rs index 623c982..355c704 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ extern crate core; use actix_web::{middleware, web, App, HttpServer}; use actix_web::middleware::normalize::TrailingSlash; use env_logger::{Builder, Env}; +use wiringpi::pin::Value::High; mod db; mod handlers; @@ -20,6 +21,12 @@ async fn main() -> std::io::Result<()> { Builder::from_env(Env::default().default_filter_or("info")).init(); + let pi = wiringpi::setup(); + + //Use WiringPi pin 0 as output + let pin = pi.output_pin(0); + pin.digital_write(High); + HttpServer::new(|| { App::new() .wrap(middleware::DefaultHeaders::new()