Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 145 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ rand_core = "0.6.4"
rand_xoshiro = "0.6.0"
percent-encoding = "2.3.1"
chrono = { version = "0.4.38", features = ["serde", "clock"], default-features = false }
image = { version = "0.25.6", features = ["bmp", "png"], default-features = false }
ureq = { version = "3.0.11", features = ["json"] }
12 changes: 9 additions & 3 deletions crates/core/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::trmnl::TrmnlClient;
use crate::view::keyboard::Layout;
use std::path::Path;
use std::collections::{BTreeMap, VecDeque};
Expand All @@ -19,7 +20,7 @@ use crate::geom::Rectangle;
use crate::device::CURRENT_DEVICE;
use crate::library::Library;
use crate::font::Fonts;
use crate::rtc::Rtc;
use crate::rtc::{Rtc, AlarmManager};

const KEYBOARD_LAYOUTS_DIRNAME: &str = "keyboard-layouts";
const DICTIONARIES_DIRNAME: &str = "dictionaries";
Expand All @@ -28,7 +29,8 @@ const INPUT_HISTORY_SIZE: usize = 32;

pub struct Context {
pub fb: Box<dyn Framebuffer>,
pub rtc: Option<Rtc>,
pub alarm_manager: Option<AlarmManager>,
pub trmnl_client: Option<TrmnlClient>,
pub display: Display,
pub settings: Settings,
pub library: Library,
Expand All @@ -55,7 +57,11 @@ impl Context {
let dims = fb.dims();
let rotation = CURRENT_DEVICE.transformed_rotation(fb.rotation());
let rng = Xoroshiro128Plus::seed_from_u64(Local::now().timestamp_subsec_nanos() as u64);
Context { fb, rtc, display: Display { dims, rotation },

let alarm_manager = rtc.map(AlarmManager::new);
let trmnl_client = settings.trmnl.is_some().then(|| TrmnlClient::new());

Context { fb, alarm_manager, trmnl_client, display: Display { dims, rotation },
library, settings, fonts, dictionaries: BTreeMap::new(),
keyboard_layouts: BTreeMap::new(), input_history: FxHashMap::default(),
battery, frontlight, lightsensor, notification_index: 0,
Expand Down
3 changes: 3 additions & 0 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ pub mod rtc;
pub mod settings;
pub mod font;
pub mod context;
pub mod trmnl;
pub mod gesture;

pub use rtc::{AlarmType, AlarmManager};

pub use anyhow;
pub use fxhash;
pub use chrono;
Expand Down
Loading