More consistent bluetooth notify
This commit is contained in:
@ -4,9 +4,6 @@ use log::*; //{trace, debug, info, warn, error}
|
||||
use anyhow::Result;
|
||||
use async_channel::{unbounded, Receiver, Sender};
|
||||
|
||||
use crate::dispatch;
|
||||
use crate::commands::Commands as Dispatch_Commands;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Commands {
|
||||
StartUp,
|
||||
@ -20,17 +17,15 @@ pub type RecvQ = Receiver<Commands>;
|
||||
pub struct MotorDriverDebug{
|
||||
endpoint: SendQ,
|
||||
recv_q: RecvQ,
|
||||
dispatch: dispatch::SendQ,
|
||||
}
|
||||
|
||||
/// Debug / example version of Motor Driver.
|
||||
impl MotorDriverDebug {
|
||||
pub fn new(send_q: dispatch::SendQ) -> Self {
|
||||
pub fn new() -> Self {
|
||||
let (s,r) = unbounded();
|
||||
MotorDriverDebug {
|
||||
endpoint: s,
|
||||
recv_q: r,
|
||||
dispatch:send_q
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,17 +51,14 @@ impl MotorDriverDebug {
|
||||
|
||||
pub async fn start_up(&self) -> Result<()> {
|
||||
warn!("Starting motor, direction: Up");
|
||||
self.dispatch.send(Dispatch_Commands::NotifyMotorUp).await?;
|
||||
Ok(())
|
||||
}
|
||||
pub async fn start_down(&self) -> Result<()> {
|
||||
warn!("Starting motor, direction: Down");
|
||||
self.dispatch.send(Dispatch_Commands::NotifyMotorDown).await?;
|
||||
Ok(())
|
||||
}
|
||||
pub async fn stop(&self) -> Result<()> {
|
||||
warn!("Stopping motor");
|
||||
self.dispatch.send(Dispatch_Commands::NotifyMotorStopping).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user