Skip to content
Open
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
18 changes: 17 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"crates/emulator",
"crates/importer",
"crates/fetcher",
"crates/display",
]

[profile.release-minsized]
Expand Down
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
crate-type = ["rlib"]

[dependencies]
display = { path = "../display" }
bitflags = "2.6.0"
downcast-rs = "1.2.1"
lazy_static = "1.5.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/battery/kobo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs::File;
use std::path::Path;
use std::io::{Read, Seek, SeekFrom};
use anyhow::{Error, format_err};
use crate::device::CURRENT_DEVICE;
use display::device::CURRENT_DEVICE;
use super::{Battery, Status};

const BATTERY_INTERFACES: [&str; 3] = ["/sys/class/power_supply/bd71827_bat",
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use walkdir::WalkDir;
use rand_core::SeedableRng;
use rand_xoshiro::Xoroshiro128Plus;
use crate::dictionary::{Dictionary, load_dictionary_from_file};
use crate::framebuffer::{Framebuffer, Display};
use display::framebuffer::{Framebuffer, Display};
use crate::view::ViewId;
use crate::helpers::{load_json, IsHidden};
use crate::settings::Settings;
use crate::frontlight::Frontlight;
use crate::lightsensor::LightSensor;
use crate::battery::Battery;
use crate::geom::Rectangle;
use crate::device::CURRENT_DEVICE;
use display::geom::Rectangle;
use display::device::CURRENT_DEVICE;
use crate::library::Library;
use crate::font::Fonts;
use crate::rtc::Rtc;
Expand Down
5 changes: 3 additions & 2 deletions crates/core/src/document/djvu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use std::os::unix::ffi::OsStrExt;
use super::{Document, Location, TextLocation, BoundedText, TocEntry};
use super::{chapter, chapter_relative};
use crate::metadata::TextAlign;
use crate::framebuffer::Pixmap;
use crate::geom::{Rectangle, Boundary, CycleDir};
use display::framebuffer::Pixmap;
use display::geom::{Rectangle, Boundary, CycleDir};
use display::bndr;

impl Into<DjvuRect> for Rectangle {
fn into(self) -> DjvuRect {
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/document/epub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use fxhash::FxHashMap;
use zip::ZipArchive;
use percent_encoding::percent_decode_str;
use anyhow::{Error, format_err};
use crate::framebuffer::Pixmap;
use display::framebuffer::Pixmap;
use crate::helpers::{Normalize, decode_entities};
use crate::document::{Document, Location, TextLocation, TocEntry, BoundedText, chapter_from_uri};
use crate::unit::pt_to_px;
use crate::geom::{Boundary, CycleDir};
use display::geom::{Boundary, CycleDir};
use super::pdf::PdfOpener;
use super::html::dom::{XmlTree, NodeRef};
use super::html::engine::{Page, Engine, ResourceFetcher};
Expand Down
5 changes: 3 additions & 2 deletions crates/core/src/document/html/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use xi_unicode::LineBreakIterator;
use percent_encoding::percent_decode_str;
use septem::Roman;
use crate::helpers::{Normalize, decode_entities};
use crate::framebuffer::{Framebuffer, Pixmap};
use display::framebuffer::{Framebuffer, Pixmap};
use crate::font::{FontOpener, FontFamily};
use crate::document::{Document, Location};
use crate::document::pdf::PdfOpener;
use crate::unit::{mm_to_px, pt_to_px};
use crate::geom::{Point, Vec2, Rectangle, Edge};
use display::geom::{Point, Vec2, Rectangle, Edge};
use crate::settings::{HYPHEN_PENALTY, STRETCH_TOLERANCE};
use crate::settings::{DEFAULT_FONT_SIZE, DEFAULT_MARGIN_WIDTH, DEFAULT_TEXT_ALIGN, DEFAULT_LINE_HEIGHT};
use super::parse::{parse_display, parse_edge, parse_float, parse_text_align, parse_text_indent};
Expand All @@ -31,6 +31,7 @@ use super::layout::{hyph_lang, collapse_margins, DEFAULT_HYPH_LANG, HYPHENATION_
use super::layout::{EM_SPACE_RATIOS, WORD_SPACE_RATIOS, FONT_SPACES};
use super::style::{StyleSheet, specified_values};
use super::xml::XmlExt;
use display::{rect, pt};

const DEFAULT_DPI: u16 = 300;
const DEFAULT_WIDTH: u32 = 1404;
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/document/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use std::fmt::Debug;
use fxhash::FxHashMap;
use lazy_static::lazy_static;
use kl_hyphenate::{Standard, Language, Load};
use crate::color::Color;
use crate::geom::{Point, Rectangle, Edge};
use display::color::Color;
use display::geom::{Point, Rectangle, Edge};
use crate::font::{FontFamily, Font, RenderPlan};
pub use crate::metadata::TextAlign;
use crate::color::BLACK;
use display::color::BLACK;

pub const DEFAULT_HYPH_LANG: &str = "en";

Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/document/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use std::fs::{self, File};
use std::path::{Path, PathBuf};
use fxhash::FxHashMap;
use anyhow::Error;
use crate::framebuffer::Pixmap;
use display::framebuffer::Pixmap;
use crate::helpers::{Normalize, decode_entities};
use crate::document::{Document, Location, TextLocation, TocEntry, BoundedText};
use crate::unit::pt_to_px;
use crate::geom::{Boundary, Edge, CycleDir};
use display::geom::{Boundary, Edge, CycleDir};
use self::dom::{XmlTree, NodeRef};
use self::layout::{RootData, StyleData, DrawState, LoopContext};
use self::layout::{DrawCommand, TextCommand, ImageCommand, TextAlign};
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/document/html/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use regex::Regex;
use super::layout::{FontKind, FontStyle, FontWeight, WordSpacing};
use super::layout::{TextAlign, Display, Float, ListStyleType};
use super::layout::{InlineMaterial, GlueMaterial, PenaltyMaterial};
use crate::geom::Edge;
use crate::color::{Color, BLACK, WHITE};
use display::geom::Edge;
use display::color::{Color, BLACK, WHITE};
use crate::unit::{pt_to_px, pc_to_px, mm_to_px, in_to_px};
use crate::unit::{POINTS_PER_INCH, PICAS_PER_INCH, MILLIMETERS_PER_INCH, CENTIMETERS_PER_INCH};

Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/document/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ use self::djvu::DjvuOpener;
use self::pdf::PdfOpener;
use self::epub::EpubDocument;
use self::html::HtmlDocument;
use crate::geom::{Boundary, CycleDir};
use display::geom::{Boundary, CycleDir};
use crate::metadata::{TextAlign, Annotation};
use crate::framebuffer::Pixmap;
use display::framebuffer::Pixmap;
use crate::settings::INTERNAL_CARD_ROOT;
use crate::device::CURRENT_DEVICE;
use display::device::CURRENT_DEVICE;

pub const BYTES_PER_PAGE: f64 = 2048.0;

Expand Down
5 changes: 3 additions & 2 deletions crates/core/src/document/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ use std::os::unix::ffi::OsStrExt;
use super::{Document, Location, TextLocation, BoundedText, TocEntry};
use super::{chapter, chapter_relative};
use crate::metadata::TextAlign;
use crate::geom::{Boundary, CycleDir};
use display::geom::{Boundary, CycleDir};
use crate::unit::pt_to_px;
use crate::framebuffer::Pixmap;
use display::framebuffer::Pixmap;
use display::vec2;

const USER_STYLESHEET: &str = "css/html-user.css";

Expand Down
9 changes: 5 additions & 4 deletions crates/core/src/font/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ use anyhow::{Error, format_err};
use thiserror::Error;
use globset::Glob;
use walkdir::WalkDir;
use crate::color::Color;
use crate::geom::{Point, Vec2};
use display::color::Color;
use display::geom::{Point, Vec2};
use crate::helpers::IsHidden;
use crate::framebuffer::Framebuffer;
use crate::device::CURRENT_DEVICE;
use display::framebuffer::Framebuffer;
use display::device::CURRENT_DEVICE;
use display::pt;

// Font sizes in 1/64th of a point
pub const FONT_SIZES: [u32; 3] = [349, 524, 629];
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/frontlight/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Serialize, Deserialize};
pub use self::standard::StandardFrontlight;
pub use self::natural::NaturalFrontlight;
pub use self::premixed::PremixedFrontlight;
use crate::geom::lerp;
use display::geom::lerp;

#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
pub struct LightLevels {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/frontlight/natural.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::PathBuf;
use fxhash::FxHashMap;
use lazy_static::lazy_static;
use anyhow::Error;
use crate::device::{CURRENT_DEVICE, Model};
use display::device::{CURRENT_DEVICE, Model};
use super::{Frontlight, LightLevels};

const FRONTLIGHT_INTERFACE: &str = "/sys/class/backlight";
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/frontlight/premixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::Write;
use std::fs::File;
use std::fs::OpenOptions;
use anyhow::Error;
use crate::device::CURRENT_DEVICE;
use display::device::CURRENT_DEVICE;
use super::{Frontlight, LightLevels};

const FRONTLIGHT_WHITE: &str = "/sys/class/backlight/mxc_msp430.0/brightness";
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/gesture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::f64;
use std::time::Duration;
use std::thread;
use crate::unit::mm_to_px;
use crate::input::{DeviceEvent, FingerStatus, ButtonCode, ButtonStatus};
use display::input::{DeviceEvent, FingerStatus, ButtonCode, ButtonStatus};
use crate::view::Event;
use crate::device::CURRENT_DEVICE;
use crate::geom::{Point, Vec2, Dir, DiagDir, Axis, nearest_segment_point, elbow};
use display::device::CURRENT_DEVICE;
use display::geom::{Point, Vec2, Dir, DiagDir, Axis, nearest_segment_point, elbow};

pub const TAP_JITTER_MM: f32 = 6.0;
pub const HOLD_JITTER_MM: f32 = 1.5;
Expand Down
6 changes: 0 additions & 6 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#[macro_use] pub mod geom;

mod unit;
pub mod color;
pub mod device;
pub mod framebuffer;
pub mod frontlight;
pub mod lightsensor;
pub mod battery;
pub mod input;
pub mod helpers;
mod dictionary;
pub mod document;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use fxhash::FxHashMap;
use serde::{Serialize, Deserialize};
use lazy_static::lazy_static;
use titlecase::titlecase;
use crate::geom::Point;
use display::geom::Point;
use crate::document::{Document, SimpleTocEntry, TextLocation};
use crate::document::asciify;
use crate::document::epub::EpubDocument;
Expand Down
19 changes: 3 additions & 16 deletions crates/core/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ mod preset;

use std::env;
use std::ops::Index;
use std::fmt::{self, Debug};
use std::path::PathBuf;
use std::collections::{BTreeMap, HashMap};
use fxhash::FxHashSet;
use serde::{Serialize, Deserialize};
use crate::metadata::{SortMethod, TextAlign};
use crate::frontlight::LightLevels;
use crate::color::{Color, BLACK};
use crate::device::CURRENT_DEVICE;
use display::color::{Color, BLACK};
use display::device::CURRENT_DEVICE;
use display::input::ButtonScheme;
use crate::unit::mm_to_px;

pub use self::preset::{LightPreset, guess_frontlight};
Expand Down Expand Up @@ -42,19 +42,6 @@ pub enum RotationLock {
Current,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ButtonScheme {
Natural,
Inverted,
}

impl fmt::Display for ButtonScheme {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Debug::fmt(self, f)
}
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum IntermKind {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/settings/preset.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chrono::{Local, Timelike};
use serde::{Serialize, Deserialize};
use crate::frontlight::LightLevels;
use crate::geom::circular_distances;
use display::geom::circular_distances;

const MINUTES_PER_DAY: u16 = 24 * 60;

Expand Down
9 changes: 5 additions & 4 deletions crates/core/src/view/battery.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::device::CURRENT_DEVICE;
use crate::framebuffer::{Framebuffer, UpdateMode};
use crate::geom::{Rectangle, BorderSpec, CornerSpec};
use crate::color::{BLACK, WHITE, BATTERY_FILL};
use display::device::CURRENT_DEVICE;
use display::framebuffer::{Framebuffer, UpdateMode};
use display::geom::{Rectangle, BorderSpec, CornerSpec};
use display::color::{BLACK, WHITE, BATTERY_FILL};
use display::{rect, pt};
use super::{View, ViewId, Event, Hub, Bus, Id, ID_FEEDER, RenderQueue, RenderData};
use super::{THICKNESS_LARGE, THICKNESS_MEDIUM, BORDER_RADIUS_SMALL};
use super::icon::ICONS_PIXMAPS;
Expand Down
12 changes: 7 additions & 5 deletions crates/core/src/view/button.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use crate::device::CURRENT_DEVICE;
use crate::geom::{Rectangle, CornerSpec, BorderSpec};
use display::device::CURRENT_DEVICE;
use display::geom::{Rectangle, CornerSpec, BorderSpec};
use crate::font::{Fonts, font_from_style, NORMAL_STYLE};
use super::{View, Event, Hub, Bus, Id, ID_FEEDER, RenderQueue, RenderData};
use super::{THICKNESS_MEDIUM, BORDER_RADIUS_LARGE};
use crate::framebuffer::{Framebuffer, UpdateMode};
use crate::input::{DeviceEvent, FingerStatus};
use display::framebuffer::{Framebuffer, UpdateMode};
use display::input::{DeviceEvent, FingerStatus};
use crate::gesture::GestureEvent;
use crate::color::{TEXT_NORMAL, TEXT_INVERTED_HARD};
use display::color::{TEXT_NORMAL, TEXT_INVERTED_HARD};
use crate::unit::scale_by_dpi;
use crate::context::Context;
use display::pt;


pub struct Button {
id: Id,
Expand Down
9 changes: 5 additions & 4 deletions crates/core/src/view/calculator/bottom_bar.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::framebuffer::Framebuffer;
use display::framebuffer::Framebuffer;
use crate::view::{View, Event, Hub, Bus, Id, ID_FEEDER, RenderQueue, ViewId};
use crate::view::filler::Filler;
use crate::view::labeled_icon::LabeledIcon;
use crate::gesture::GestureEvent;
use crate::input::DeviceEvent;
use crate::geom::{Rectangle, divide};
use display::input::DeviceEvent;
use display::geom::{Rectangle, divide};
use crate::font::Fonts;
use crate::color::WHITE;
use display::color::WHITE;
use display::rect;
use crate::context::Context;

#[derive(Debug)]
Expand Down
Loading