Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
115 changes: 106 additions & 9 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions contrib/Settings-sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inverted = false
sleep-cover = true
# Automatically enters shared mode when connected to a computer.
auto-share = false
# Automatically synchronize the device time via NTP when WiFi connects.
# This will also set the correct timezon, it uses
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
# time.cloudflare.com and ipapi.co
auto-time = false
# Defines how the back and forward buttons are mapped to the
# *page forward* and *page backward* actions.
# Possible values: "natural", "inverted".
Expand Down
9 changes: 2 additions & 7 deletions crates/cadmus/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use cadmus_core::input::{
};
use cadmus_core::library::Library;
use cadmus_core::lightsensor::{KoboLightSensor, LightSensor};
use cadmus_core::rtc::{AlarmType, EnsureAlarmOutcome, PastDueAction, Rtc};
use cadmus_core::rtc::{AlarmType, EnsureAlarmOutcome, PastDueAction};
use cadmus_core::settings::versioned::SettingsManager;
use cadmus_core::settings::{
ButtonScheme, IntermKind, IntermissionDisplay, LoggingSettings, RotationLock, Settings,
Expand Down Expand Up @@ -65,7 +65,6 @@ use tracing::{Level, debug, error, info, warn};

pub const APP_NAME: &str = "Cadmus";
const FB_DEVICE: &str = "/dev/fb0";
const RTC_DEVICE: &str = "/dev/rtc0";
const TOUCH_INPUTS: [&str; 5] = [
"/dev/input/by-path/platform-2-0010-event",
"/dev/input/by-path/platform-1-0038-event",
Expand Down Expand Up @@ -119,9 +118,6 @@ fn build_context(
fonts: Fonts,
database: Database,
) -> Result<Context, Error> {
let rtc = Rtc::new(RTC_DEVICE)
.map_err(|e| warn!(error = %e, "Can't open RTC device"))
.ok();
let mut settings = settings;

if settings.libraries.is_empty() {
Expand Down Expand Up @@ -162,7 +158,6 @@ fn build_context(

Ok(Context::new(
fb,
rtc,
library,
database,
settings,
Expand Down Expand Up @@ -790,7 +785,7 @@ pub fn run() -> Result<(), Error> {
#[cfg(feature = "tracing")]
tracing::trace!(event = ?evt, "handling event");

background_tasks.handle_event(&evt, &tx, &context.database, &context.settings);
background_tasks.handle_event(&evt, &tx, &context);

match evt {
Event::Device(de) => match de {
Expand Down
3 changes: 3 additions & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ chrono = { version = "0.4.42", features = [
"serde",
"clock",
], default-features = false }
chrono-tz = "0.8"
reqwest = { version = "0.13.1", default-features = false, features = [
"blocking",
"form",
"json",
"rustls-no-provider",
] }
rustls = { workspace = true }
sntpc = { version = "0.10", features = ["std", "sync"] }
sntpc-net-std = "1.2"
webpki-roots = "1.0.5"

ctor = "1.0"
Expand Down
3 changes: 3 additions & 0 deletions crates/core/i18n/en-GB/cadmus_core.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ notification-downloading-dictionary-progress = Downloading { $lang } ({ $downloa
notification-dictionary-indexing = Indexing "{ $name }"
notification-not-online = WiFi must be connected for this action.
notification-refresh-rate-invalid = Refresh rate must be a number between 0 and 255.
notification-time-sync-failed = Time sync failed

# Common
cancel = Cancel
Expand All @@ -31,6 +32,7 @@ top-menu-restart-app = Restart {-app-name}
top-menu-suspend = Suspend
top-menu-quit = Quit
top-menu-power-off = Power Off
top-menu-sync-time = Sync Time

# Settings - Button Scheme
settings-button-scheme-natural = Natural
Expand All @@ -46,6 +48,7 @@ settings-general-auto-power-off = Auto Power Off (days)
settings-general-auto-power-off-input = Auto Power Off (days, 0 = never)
settings-general-auto-suspend = Auto Suspend (minutes)
settings-general-auto-suspend-input = Auto Suspend (minutes, 0 = never)
settings-general-auto-time = Automatic Time Sync
settings-general-button-scheme = Button Scheme
settings-general-enable-auto-share = Enable Auto Share
settings-general-enable-sleep-cover = Enable Sleep Cover
Expand Down
9 changes: 5 additions & 4 deletions crates/core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::geom::Rectangle;
use crate::helpers::{Fingerprint, Fp, IsHidden, load_json};
use crate::library::Library;
use crate::lightsensor::LightSensor;
use crate::rtc::{AlarmManager, Rtc};
use crate::rtc::AlarmManager;
use crate::settings::Settings;
use crate::view::ViewId;
use crate::view::keyboard::Layout;
Expand Down Expand Up @@ -57,7 +57,6 @@ pub struct Context {
impl Context {
pub fn new(
fb: Box<dyn Framebuffer>,
rtc: Option<Rtc>,
library: Library,
database: Database,
settings: Settings,
Expand All @@ -69,7 +68,10 @@ 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);
let alarm_manager = rtc.map(AlarmManager::new);
let alarm_manager = CURRENT_DEVICE
.rtc()
.ok()
.map(|rtc| AlarmManager::new(rtc.clone()));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Context {
fb,
alarm_manager,
Expand Down Expand Up @@ -241,7 +243,6 @@ pub mod test_helpers {
database.migrate().expect("failed to run migrations");
Context::new(
Box::new(Pixmap::new(600, 800, 1)),
None,
Library::new(Path::new("/tmp"), &database, "test").unwrap(),
database,
Settings::default(),
Expand Down
Loading
Loading