Skip to content

Commit 7fcad46

Browse files
authored
publish 0.3.5 (#40)
1 parent 0a09b8d commit 7fcad46

File tree

13 files changed

+865
-945
lines changed

13 files changed

+865
-945
lines changed

marauder/Cargo.lock

Lines changed: 663 additions & 630 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

marauder/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
[package]
22
name = "marauder"
3-
version = "0.4.0"
3+
version = "0.3.5"
44
authors = ["Pierre Fenoll <pierrefenoll@gmail.com>"]
55
edition = "2021"
66

77
[dependencies]
88
async-stream = "0.3"
99
atomic = "0.5"
1010
chrono = "0.4"
11+
clap = { version = "4", features = ["derive"] }
1112
crc-any = { version = "2", default-features = false, features = ["heapless"] }
1213
env_logger = "0.9"
1314
futures = { version = "0.3", default-features = false, features = ["alloc"] }
@@ -22,12 +23,11 @@ quick-xml = { version = "0.22", features = ["serialize"] }
2223
rand = "0.8"
2324
serde = { version = "1", features = ["derive"] }
2425
serde_json = "1"
25-
structopt = "0.3"
2626
tokio = { version = "1", features = ["rt-multi-thread", "time", "fs", "macros", "net"] }
2727
tokio-stream = { version = "0.1", features = ["net"] }
2828
tonic = { version = "0.6", features = ["compression"] }
2929
tower = { version = "0.4" }
30-
uuid = { version = "0.8", features = ["v4"] }
30+
uuid = { version = "1", features = ["v4"] }
3131

3232
[build-dependencies]
3333
tonic-build = { version = "0.6", features = ["compression"] }

marauder/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ all: src/strokes/strokes_generated.rs lint
1818
ls -lh $(BIN)
1919

2020
fmt:
21-
cargo fmt
21+
cargo +nightly fmt
2222

2323
lint: fmt
2424
cross clippy --target=$(TARGET) #-- -W clippy::pedantic
@@ -47,7 +47,7 @@ whiteboard: HOST ?= http://fknwkdacd.com:10000
4747
whiteboard: WEBHOST ?= http://fknwkdacd.com:18888/s
4848
whiteboard: EXE = whiteboard
4949
whiteboard: fmt
50-
cross build --target=$(TARGET) --release --bin $(EXE) #--locked #--frozen #--offline
50+
cross build --target=$(TARGET) --release --bin $(EXE) --locked #--frozen #--offline
5151
ssh $(DEVICE) 'killall -q -9 $(EXE) || true; systemctl stop xochitl || true'
5252
rsync -a --stats --progress $(BIN) $(DEVICE):
5353
ssh $(DEVICE) 'RUST_BACKTRACE=1 RUST_LOG=debug WHITEBOARD_WEBHOST=$(WEBHOST) ./$(EXE) --host=$(HOST) | tail -f'

marauder/rustfmt.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
edition = "2021"
2+
group_imports = "StdExternalCrate"
3+
imports_granularity = "Crate"
4+
unstable_features = true# For group_imports
5+
use_field_init_shorthand = true
6+
use_small_heuristics = "Max"

marauder/src/bin/experiments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use std::{env, fs};
2+
13
use marauder::unipen;
2-
use std::env;
3-
use std::fs;
44

55
// turn image drawing to hand sketch
66
///rainy stlye movie romantic

marauder/src/bin/marauder.rs

Lines changed: 55 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,38 @@
22
extern crate log;
33
extern crate env_logger;
44

5+
use std::{
6+
collections::VecDeque,
7+
process::Command,
8+
sync::{
9+
atomic::{AtomicBool, Ordering},
10+
Mutex,
11+
},
12+
thread::sleep,
13+
time::Duration,
14+
};
15+
516
use atomic::Atomic;
6-
use chrono::DateTime;
7-
use chrono::Local;
8-
use libremarkable::appctx;
9-
use libremarkable::appctx::ApplicationContext;
10-
use libremarkable::battery;
11-
use libremarkable::framebuffer::cgmath;
12-
use libremarkable::framebuffer::cgmath::EuclideanSpace;
13-
use libremarkable::framebuffer::common::*;
14-
use libremarkable::framebuffer::refresh::PartialRefreshMode;
15-
use libremarkable::framebuffer::storage;
16-
use libremarkable::framebuffer::FramebufferDraw;
17-
use libremarkable::framebuffer::FramebufferIO;
18-
use libremarkable::framebuffer::FramebufferRefresh;
19-
use libremarkable::image;
20-
use libremarkable::image::GenericImage;
21-
use libremarkable::input::gpio;
22-
use libremarkable::input::multitouch;
23-
use libremarkable::input::wacom;
24-
use libremarkable::input::InputDevice;
25-
use libremarkable::input::InputEvent;
26-
use libremarkable::ui_extensions::element::UIConstraintRefresh;
27-
use libremarkable::ui_extensions::element::UIElement;
28-
use libremarkable::ui_extensions::element::UIElementHandle;
29-
use libremarkable::ui_extensions::element::UIElementWrapper;
30-
use once_cell::sync::Lazy;
17+
use chrono::{DateTime, Local};
18+
use libremarkable::{
19+
appctx,
20+
appctx::ApplicationContext,
21+
battery,
22+
framebuffer::{
23+
cgmath, cgmath::EuclideanSpace, common::*, storage, FramebufferDraw, FramebufferIO,
24+
FramebufferRefresh, PartialRefreshMode,
25+
},
26+
image,
27+
image::GenericImage,
28+
input::{
29+
GPIOEvent, InputDevice, InputEvent, MultitouchEvent, PhysicalButton, WacomEvent, WacomPen,
30+
},
31+
ui_extensions::element::{UIConstraintRefresh, UIElement, UIElementHandle, UIElementWrapper},
32+
};
3133
// use rand::Rng;
3234
use marauder::modes::draw::DrawMode;
33-
use marauder::modes::touch::TouchMode;
34-
use marauder::strokes::Strokes;
35-
use marauder::unipen;
36-
use std::collections::VecDeque;
37-
use std::process::Command;
38-
use std::sync::atomic::AtomicBool;
39-
use std::sync::atomic::Ordering;
40-
use std::sync::Mutex;
41-
use std::thread::sleep;
42-
use std::time::Duration;
35+
use marauder::{modes::touch::TouchMode, strokes::Strokes, unipen};
36+
use once_cell::sync::Lazy;
4337
// use marauder::shapes::*;
4438

4539
// This region will have the following size at rest:
@@ -150,10 +144,8 @@ fn on_zoom_out(app: &mut ApplicationContext, _element: UIElementHandle) {
150144
.copy_from(&resized, CANVAS_REGION.width / 8, CANVAS_REGION.height / 8)
151145
.unwrap();
152146

153-
framebuffer.draw_image(
154-
new_image.as_rgb8().unwrap(),
155-
CANVAS_REGION.top_left().cast().unwrap(),
156-
);
147+
framebuffer
148+
.draw_image(new_image.as_rgb8().unwrap(), CANVAS_REGION.top_left().cast().unwrap());
157149
framebuffer.partial_refresh(
158150
&CANVAS_REGION,
159151
PartialRefreshMode::Async,
@@ -182,10 +174,8 @@ fn on_blur_canvas(app: &mut ApplicationContext, _element: UIElementHandle) {
182174
)
183175
.blur(0.6f32);
184176

185-
framebuffer.draw_image(
186-
dynamic.as_rgb8().unwrap(),
187-
CANVAS_REGION.top_left().cast().unwrap(),
188-
);
177+
framebuffer
178+
.draw_image(dynamic.as_rgb8().unwrap(), CANVAS_REGION.top_left().cast().unwrap());
189179
framebuffer.partial_refresh(
190180
&CANVAS_REGION,
191181
PartialRefreshMode::Async,
@@ -325,13 +315,9 @@ fn loop_companion(app: &mut ApplicationContext) {
325315
// ## Input Handlers
326316
// ####################
327317

328-
fn on_wacom_input(app: &mut ApplicationContext, input: wacom::WacomEvent) {
318+
fn on_wacom_input(app: &mut ApplicationContext, input: WacomEvent) {
329319
match input {
330-
wacom::WacomEvent::Draw {
331-
position,
332-
pressure,
333-
tilt: _,
334-
} => {
320+
WacomEvent::Draw { position, pressure, tilt: _ } => {
335321
// debug!("{} {} {}", position.x, position.y, pressure);
336322

337323
let mut wacom_stack = WACOM_HISTORY.lock().unwrap();
@@ -361,7 +347,7 @@ fn on_wacom_input(app: &mut ApplicationContext, input: wacom::WacomEvent) {
361347
DrawMode::Erase(s) => (color::WHITE, s * 3),
362348
};
363349

364-
wacom_stack.push_back((position.cast().unwrap(), pressure as i32));
350+
wacom_stack.push_back((position.cast().unwrap(), i32::from(pressure)));
365351
while wacom_stack.len() >= 3 {
366352
let framebuffer = app.get_framebuffer_ref();
367353
let points = vec![
@@ -400,14 +386,14 @@ fn on_wacom_input(app: &mut ApplicationContext, input: wacom::WacomEvent) {
400386
);
401387
}
402388
}
403-
wacom::WacomEvent::InstrumentChange { pen, state } => {
389+
WacomEvent::InstrumentChange { pen, state } => {
404390
match pen {
405-
wacom::WacomPen::ToolPen => {
391+
WacomPen::ToolPen => {
406392
// Whether the pen is in range
407393
let in_range = state;
408394
WACOM_IN_RANGE.store(in_range, Ordering::Relaxed);
409395
}
410-
wacom::WacomPen::Touch => {
396+
WacomPen::Touch => {
411397
// Whether the pen is actually making contact
412398
let making_contact = state;
413399
if !making_contact {
@@ -422,11 +408,7 @@ fn on_wacom_input(app: &mut ApplicationContext, input: wacom::WacomEvent) {
422408
_ => unreachable!(),
423409
}
424410
}
425-
wacom::WacomEvent::Hover {
426-
position: _,
427-
distance,
428-
tilt: _,
429-
} => {
411+
WacomEvent::Hover { position: _, distance, tilt: _ } => {
430412
// If the pen is hovering, don't record its coordinates as the origin of the next line
431413
if distance > 1 {
432414
let mut wacom_stack = WACOM_HISTORY.lock().unwrap();
@@ -438,11 +420,9 @@ fn on_wacom_input(app: &mut ApplicationContext, input: wacom::WacomEvent) {
438420
};
439421
}
440422

441-
fn on_touch_handler(app: &mut ApplicationContext, input: multitouch::MultitouchEvent) {
423+
fn on_touch_handler(app: &mut ApplicationContext, input: MultitouchEvent) {
442424
let framebuffer = app.get_framebuffer_ref();
443-
if let multitouch::MultitouchEvent::Press { finger }
444-
| multitouch::MultitouchEvent::Move { finger } = input
445-
{
425+
if let MultitouchEvent::Press { finger } | MultitouchEvent::Move { finger } = input {
446426
let position = finger.pos;
447427
if !CANVAS_REGION.contains_point(&position.cast().unwrap()) {
448428
return;
@@ -508,11 +488,11 @@ fn on_touch_handler(app: &mut ApplicationContext, input: multitouch::MultitouchE
508488
}
509489
}
510490

511-
fn on_button_press(app: &mut ApplicationContext, input: gpio::GPIOEvent) {
491+
fn on_button_press(app: &mut ApplicationContext, input: GPIOEvent) {
512492
let (btn, new_state) = match input {
513-
gpio::GPIOEvent::Press { button } => (button, true),
514-
gpio::GPIOEvent::Unpress { button } => (button, false),
515-
_ => return,
493+
GPIOEvent::Press { button } => (button, true),
494+
GPIOEvent::Unpress { button } => (button, false),
495+
GPIOEvent::Unknown => return,
516496
};
517497

518498
// Ignoring the unpressed event
@@ -526,7 +506,7 @@ fn on_button_press(app: &mut ApplicationContext, input: gpio::GPIOEvent) {
526506
}
527507

528508
match btn {
529-
gpio::PhysicalButton::RIGHT => {
509+
PhysicalButton::RIGHT => {
530510
let new_state = if app.is_input_device_active(InputDevice::Multitouch) {
531511
app.deactivate_input_device(InputDevice::Multitouch);
532512
"Enable Touch"
@@ -536,31 +516,23 @@ fn on_button_press(app: &mut ApplicationContext, input: gpio::GPIOEvent) {
536516
};
537517

538518
if let Some(ref elem) = app.get_element_by_name("tooltipRight") {
539-
if let UIElement::Text {
540-
ref mut text,
541-
scale: _,
542-
foreground: _,
543-
border_px: _,
544-
} = elem.write().inner
519+
if let UIElement::Text { ref mut text, scale: _, foreground: _, border_px: _ } =
520+
elem.write().inner
545521
{
546-
*text = new_state.to_string();
522+
*text = new_state.to_owned();
547523
}
548524
}
549525
app.draw_element("tooltipRight");
550526
}
551-
gpio::PhysicalButton::MIDDLE | gpio::PhysicalButton::LEFT => {
552-
app.clear(btn == gpio::PhysicalButton::MIDDLE);
527+
PhysicalButton::MIDDLE | PhysicalButton::LEFT => {
528+
app.clear(btn == PhysicalButton::MIDDLE);
553529
app.draw_elements();
554530
}
555-
gpio::PhysicalButton::POWER => {
556-
Command::new("systemctl")
557-
.arg("start")
558-
.arg("xochitl")
559-
.spawn()
560-
.unwrap();
531+
PhysicalButton::POWER => {
532+
Command::new("systemctl").arg("start").arg("xochitl").spawn().unwrap();
561533
std::process::exit(0);
562534
}
563-
gpio::PhysicalButton::WAKEUP => {
535+
PhysicalButton::WAKEUP => {
564536
info!("WAKEUP button(?) pressed(?)");
565537
}
566538
};

marauder/src/bin/ujipenchars.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use std::{env, fs};
2+
13
use marauder::unipen;
2-
use std::env;
3-
use std::fs;
44

55
fn main() {
66
let args: Vec<String> = env::args().collect();

0 commit comments

Comments
 (0)