mirror of
https://codeberg.org/Fl1tzi/microdeck.git
synced 2024-05-20 03:21:04 +00:00
use Box instead of Cell
This commit is contained in:
parent
366b08c850
commit
7edb88192c
|
@ -8,7 +8,7 @@ use hidapi::HidApi;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
sync::Arc, cell::Cell,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use streamdeck::{
|
use streamdeck::{
|
||||||
asynchronous::{AsyncStreamDeck, ButtonStateUpdate},
|
asynchronous::{AsyncStreamDeck, ButtonStateUpdate},
|
||||||
|
@ -106,7 +106,7 @@ impl Device {
|
||||||
let b = btn.clone();
|
let b = btn.clone();
|
||||||
|
|
||||||
runtime.spawn(async move {
|
runtime.spawn(async move {
|
||||||
start_module(ser, b, module, dev, Cell::new(button_receiver)).await
|
start_module(ser, b, module, dev, Box::new(button_receiver)).await
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
self.modules
|
self.modules
|
||||||
|
|
|
@ -8,7 +8,6 @@ pub use deck_driver as streamdeck;
|
||||||
use futures_util::Future;
|
use futures_util::Future;
|
||||||
use image::DynamicImage;
|
use image::DynamicImage;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use std::cell::Cell;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::{error::Error, sync::Arc};
|
use std::{error::Error, sync::Arc};
|
||||||
|
@ -51,7 +50,7 @@ pub async fn start_module(
|
||||||
button: Arc<Button>,
|
button: Arc<Button>,
|
||||||
module_function: ModuleFunction,
|
module_function: ModuleFunction,
|
||||||
device: Arc<AsyncStreamDeck>,
|
device: Arc<AsyncStreamDeck>,
|
||||||
br: Cell<mpsc::Receiver<HostEvent>>
|
br: ChannelReceiver
|
||||||
) {
|
) {
|
||||||
debug!("STARTED");
|
debug!("STARTED");
|
||||||
let da = DeviceAccess::new(device, button.index).await;
|
let da = DeviceAccess::new(device, button.index).await;
|
||||||
|
@ -110,7 +109,7 @@ impl DeviceAccess {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ReturnError = Box<dyn Error + Send + Sync>;
|
pub type ReturnError = Box<dyn Error + Send + Sync>;
|
||||||
pub type ChannelReceiver = Cell<mpsc::Receiver<HostEvent>>;
|
pub type ChannelReceiver = Box<mpsc::Receiver<HostEvent>>;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Module {
|
pub trait Module {
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl Module for Counter {
|
||||||
button_receiver: ChannelReceiver,
|
button_receiver: ChannelReceiver,
|
||||||
_config: Arc<Button>,
|
_config: Arc<Button>,
|
||||||
) -> Result<(), ReturnError> {
|
) -> Result<(), ReturnError> {
|
||||||
let mut button_receiver = button_receiver.into_inner();
|
let mut button_receiver = button_receiver;
|
||||||
|
|
||||||
let font_data: &[u8] = include_bytes!("../../fonts/SpaceGrotesk.ttf");
|
let font_data: &[u8] = include_bytes!("../../fonts/SpaceGrotesk.ttf");
|
||||||
let font: Font<'static> = Font::try_from_bytes(font_data).unwrap();
|
let font: Font<'static> = Font::try_from_bytes(font_data).unwrap();
|
||||||
|
|
Loading…
Reference in a new issue