moved command to common
This commit is contained in:
parent
18d0a57583
commit
d900308c5d
5 changed files with 17 additions and 19 deletions
|
@ -4,3 +4,4 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.219", default-features = false, features = ["serde_derive", "derive"] }
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
}
|
||||
#![no_std]
|
||||
use serde::Deserialize;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
#[derive(Deserialize, Default)]
|
||||
pub struct Command {
|
||||
pub left: f32,
|
||||
pub right: f32,
|
||||
}
|
||||
|
|
8
robot-controller/Cargo.lock
generated
8
robot-controller/Cargo.lock
generated
|
@ -105,6 +105,13 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
version = "1.2.0"
|
||||
|
@ -238,6 +245,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"arduino-hal",
|
||||
"avr-device",
|
||||
"common",
|
||||
"embedded-hal 1.0.0",
|
||||
"nb 1.1.0",
|
||||
"panic-halt",
|
||||
|
|
|
@ -18,6 +18,7 @@ embedded-hal = "1.0"
|
|||
avr-device = "0.7.0"
|
||||
serde = { version = "1.0.219", default-features = false, features = ["serde_derive", "derive"] }
|
||||
postcard = "1.1.2"
|
||||
common = { path = "../common" }
|
||||
|
||||
[dependencies.arduino-hal]
|
||||
git = "https://github.com/rahix/avr-hal"
|
||||
|
|
|
@ -12,8 +12,8 @@ use arduino_hal::pac::USART0;
|
|||
use arduino_hal::port::mode::*;
|
||||
use arduino_hal::prelude::*;
|
||||
use avr_device::interrupt::{self, Mutex};
|
||||
use common::Command;
|
||||
use panic_halt as _;
|
||||
use serde::Deserialize;
|
||||
|
||||
fn shift_out(data_pin: &mut Pin<Output, PB0>, clock_pin: &mut Pin<Output, PD4>, data: &u8) {
|
||||
for i in 0..8 {
|
||||
|
@ -157,12 +157,6 @@ fn main() -> ! {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct Command {
|
||||
left: f32,
|
||||
right: f32,
|
||||
}
|
||||
|
||||
fn decode_command() -> Command {
|
||||
let mut input = interrupt::free(|cs| {
|
||||
INPUT_LINE.borrow(cs).borrow().clone()
|
||||
|
|
Loading…
Reference in a new issue