remove warning and use rustfmt
This commit is contained in:
parent
142fdb44d7
commit
517e98dea2
41
src/main.rs
41
src/main.rs
|
@ -1,13 +1,13 @@
|
|||
mod bluetooth;
|
||||
mod patterns;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
use crate::patterns::PixelColor;
|
||||
use bluer::gatt::remote::Characteristic;
|
||||
use patterns::Strip;
|
||||
use std::convert::TryFrom;
|
||||
use std::time::Duration;
|
||||
use tokio::sync::watch;
|
||||
use crate::patterns::PixelColor;
|
||||
use tokio::sync::watch::error::SendError;
|
||||
|
||||
const SERVICE_UUID: bluer::Uuid = bluer::Uuid::from_u128(0xadaf0900c33242a893bd25e905756cb8);
|
||||
const PIXEL_DATA_UUID: bluer::Uuid = bluer::Uuid::from_u128(0xadaf0903c33242a893bd25e905756cb8);
|
||||
|
@ -22,20 +22,20 @@ async fn main() -> bluer::Result<()> {
|
|||
|
||||
let mut pixels = Vec::<PixelColor>::new();
|
||||
|
||||
for _ in 0..STRIP_SIZE{
|
||||
pixels.push(PixelColor{
|
||||
red: 255, green: 0, blue:0
|
||||
for _ in 0..STRIP_SIZE {
|
||||
pixels.push(PixelColor {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
let strip = Strip::<STRIP_SIZE> {
|
||||
strip : <[PixelColor; 25]>::try_from(pixels).unwrap()
|
||||
strip: <[PixelColor; 25]>::try_from(pixels).unwrap(),
|
||||
};
|
||||
|
||||
let (tx, rx) = watch::channel(Strip::<STRIP_SIZE>::default());
|
||||
|
||||
|
||||
for device in devices {
|
||||
bluetooth::connect(&device, 3).await?;
|
||||
let char = bluetooth::get_char(&device, SERVICE_UUID, PIXEL_DATA_UUID).await?;
|
||||
|
@ -52,13 +52,22 @@ async fn main() -> bluer::Result<()> {
|
|||
}
|
||||
}
|
||||
loop {
|
||||
|
||||
tx.send(strip);
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
tx.send(Strip::<STRIP_SIZE>::default());
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
|
||||
match tx.send(strip) {
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
match tx.send(Strip::<STRIP_SIZE>::default()) {
|
||||
Ok(_) => {}
|
||||
Err(_) => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// fn create_pattern_list() -> Vec<patterns>
|
||||
|
|
|
@ -19,7 +19,6 @@ impl fmt::Display for PixelColor {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
impl Default for PixelColor {
|
||||
fn default() -> Self {
|
||||
PixelColor {
|
||||
|
@ -30,8 +29,6 @@ impl Default for PixelColor {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Strip<const N: usize> {
|
||||
pub strip: [PixelColor; N],
|
||||
|
|
Loading…
Reference in New Issue
Block a user