Skip to content

Commit

Permalink
code
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslavskis committed Sep 26, 2020
1 parent 228f193 commit f5c22ef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Empty file added mpu6050.rs
Empty file.
22 changes: 19 additions & 3 deletions src/sbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ use std::time::Duration;
use crate::config_parse::sbus_receiver_conifg;
use rppal::uart::{Parity, Uart};


pub struct controller_values {
ch1:i32,
ch2:i32,
ch3:i32,
ch4:i32
}
pub fn sbus_uart_init() -> Uart {
let values=sbus_receiver_conifg();

Expand All @@ -15,18 +22,27 @@ pub fn sbus_uart_init() -> Uart {
}
let mut uart = Uart::with_path(values.port,values.baudrate, _parity, values.data_bits, values.stop_bit).expect("COULD SET UART");
uart.set_read_mode(1, Duration::default()).expect("COULD SET UART MODE");
return uart;
return uart
}
pub fn read_sbus( mut uart:Uart) -> Result<(), Box<dyn Error>> {
pub fn read_sbus( mut uart:Uart) -> controller_values {
let mut buffer = [0u8; 1];
loop {
// Fill the buffer variable with any incoming data.
if uart.read(&mut buffer).expect("COuld not read uart") > 0 {
println!("Received byte: {}", buffer[0]);
}
let values=controller_values{
ch1:1000,
ch2:1000,
ch3:1000,
ch4:1000,
};

return values

}

}
pub fn sbus_verison() -> &'static str {
return "S_BUS MODULE VERSION 25/09/2020";
return "S_BUS MODULE VERSION 25/09/2020"
}

0 comments on commit f5c22ef

Please sign in to comment.