events: implement a first attempt at an eventing system
This commit is contained in:
@@ -23,6 +23,9 @@ use super::Board;
|
||||
|
||||
use crate::buffers::BufferedSurfacePool;
|
||||
use crate::buffers::Pixbuf;
|
||||
use crate::events::Event;
|
||||
use crate::events::EventBus;
|
||||
use crate::lib8::interpolate::lerp8by8;
|
||||
use crate::mappings::StrideMapping;
|
||||
use crate::task::FixedSizeScheduler;
|
||||
use crate::task::Task;
|
||||
@@ -55,6 +58,10 @@ pub mod i2s {
|
||||
}
|
||||
|
||||
impl<'d> Output for I2SOutput<'d> {
|
||||
fn on_event(&mut self, event: &crate::events::Event) {
|
||||
|
||||
}
|
||||
|
||||
fn blank(&mut self) {
|
||||
self.pixbuf.blank();
|
||||
}
|
||||
@@ -307,7 +314,7 @@ impl Task for WifiTask {
|
||||
self.connect();
|
||||
}
|
||||
|
||||
fn tick(&mut self ) {
|
||||
fn tick(&mut self, event: &Event, bus: &mut EventBus) {
|
||||
if self.connection_check.tick() {
|
||||
let cur_state = *self.state.lock().unwrap();
|
||||
|
||||
@@ -322,10 +329,12 @@ impl Task for WifiTask {
|
||||
log::info!("online: {:?}", cur_state);
|
||||
|
||||
self.last_state = cur_state;
|
||||
}
|
||||
|
||||
let now: DateTime<Utc> = std::time::SystemTime::now().into();
|
||||
log::info!("Current time: {} status={:?}", now.format("%d/%m/%Y %T"), self.ntp.get_sync_status());
|
||||
match cur_state {
|
||||
WifiState::Connected => bus.push(Event::new_input_event(crate::events::InputEvent::NetworkOnline)),
|
||||
_ => bus.push(Event::new_input_event(crate::events::InputEvent::NetworkOffline))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user