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
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "resmon"
version = "2.35.2"
version = "2.36.0"
edition = "2021"
authors = ["Emulsion Labs"]
description = "Ultra-light taskbar resource monitor for Windows 10/11"
Expand Down
2 changes: 1 addition & 1 deletion res/resmon.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="ResourceMonitor" version="2.35.2.0"/>
<assemblyIdentity type="win32" name="ResourceMonitor" version="2.36.0.0"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security><requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
Expand Down
2 changes: 1 addition & 1 deletion setup.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; Inno Setup script. Build the exe first: cargo build --release
#define MyAppName "Resource Monitor"
#define MyAppVersion "2.35.2"
#define MyAppVersion "2.36.0"
#define MyAppPublisher "Emulsion Labs"
#define MyAppURL "https://github.com/rajhansgithub/Windows_Resource_Monitoring_Tool"
#define MyAppExeName "ResourceMonitor.exe"
Expand Down
64 changes: 59 additions & 5 deletions src/liquid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,12 @@ impl Pen<'_> {
}
}

/// A charging bolt in a box 12 x 20 units at (0, 0).
fn bolt(&mut self, c: Rgba) {
let p: Vec<P> = [(7.0, 0.0), (0.0, 12.0), (5.5, 12.0), (4.0, 20.0), (12.0, 8.0), (6.5, 8.0)].to_vec();
self.fill(&[p], false, c);
}

/// Dots carried along a curve (case into the buds).
fn flow(&mut self, p: [f32; 8]) {
for i in 0..3 {
Expand All @@ -837,8 +843,11 @@ impl Pen<'_> {
}

/// The parts that are not fills: outlines, seams, ports, lights, charge.
fn deco(&mut self, d: Dev, st: St, vals: [f32; 3]) {
fn deco(&mut self, d: Dev, sts: [St; 3]) {
// Earbuds: what is not a fill (the case's light, the cable) belongs to the case.
let st = if d.three() { sts[1] } else { sts[0] };
let chg = st == St::Charging;
let fed = [sts[0] == St::Charging, sts[2] == St::Charging];
match d {
Dev::Battery => {
self.outline(&rr(7.0, 29.0, 80.0, 42.0, 7.0), 1.0);
Expand Down Expand Up @@ -890,7 +899,12 @@ impl Pen<'_> {
self.line(&[(29.0, 53.0), (71.0, 53.0)], 0.5);
if chg {
self.cable(50.0, 74.0, 0.0, 1.0, 6.0);
}
// The case charges the bud that says so.
if fed[0] {
self.flow([29.0, 61.0, 27.0, 61.5, 25.5, 62.0, 23.5, 62.5]);
}
if fed[1] {
self.flow([71.0, 61.0, 73.0, 61.5, 74.5, 62.0, 76.5, 62.5]);
}
}
Expand All @@ -912,7 +926,11 @@ impl Pen<'_> {
self.disc(50.0, 62.0, 1.5, alpha(led, a));
if chg {
self.cable(50.0, 75.0, 0.0, 1.0, 3.0);
}
if fed[0] {
self.flow([32.0, 60.0, 30.0, 60.0, 29.0, 62.0, 27.0, 64.0]);
}
if fed[1] {
self.flow([68.0, 60.0, 70.0, 60.0, 71.0, 62.0, 73.0, 64.0]);
}
}
Expand Down Expand Up @@ -992,10 +1010,15 @@ impl Pen<'_> {
}
}
}
let _ = vals;
}
}

/// A charging bolt `h` px tall with its top left at (x, y).
pub fn bolt(cv: &mut Canvas, x: f32, y: f32, h: f32, c: Rgba, tk: &Tokens) {
let ink = Ink { fg: tk.fg, panel: tk.panel, track: tk.track, fill: tk.accent_fill, warn: tk.warn, crit: tk.crit, on: tk.on_accent, dots: false };
Pen { cv, ox: x.round() as i32, oy: y.round() as i32, k: h / 20.0, t: 0.0, th: 1.0, ink }.bolt(c);
}

/// The state one part of `d` is drawn in at level `v` (0..100). A low device's parts go by their
/// own level: a full case is not red because the buds are low.
pub fn part_state(d: Dev, st: St, v: f32) -> St {
Expand All @@ -1016,6 +1039,13 @@ fn mask_k(k: f32) -> f32 {
/// width in pixels.
#[allow(clippy::too_many_arguments)]
pub fn draw(cv: &mut Canvas, d: Dev, x: f32, y: f32, k: f32, vals: [f32; 3], st: St, t: f32, tk: &Tokens, th: f32) {
let sts = if d.three() { vals.map(|v| part_state(d, st, v)) } else { [st; 3] };
draw_parts(cv, d, x, y, k, vals, sts, t, tk, th);
}

/// `draw` with a state for each part (left, case, right).
#[allow(clippy::too_many_arguments)]
pub fn draw_parts(cv: &mut Canvas, d: Dev, x: f32, y: f32, k: f32, vals: [f32; 3], sts: [St; 3], t: f32, tk: &Tokens, th: f32) {
if k <= 0.05 {
return;
}
Expand All @@ -1025,10 +1055,10 @@ pub fn draw(cv: &mut Canvas, d: Dev, x: f32, y: f32, k: f32, vals: [f32; 3], st:
let regs = regions_of(d);
for (i, r) in regs.iter().enumerate() {
let v = if d.three() { vals[r.vi] } else { vals[0] };
p.region(d, i, r, (v / 100.0).clamp(0.0, 1.0), part_state(d, st, v));
let st = if d.three() { sts[r.vi] } else { sts[0] };
p.region(d, i, r, (v / 100.0).clamp(0.0, 1.0), st);
}
// Earbuds: the parts that are not fills (the case's light) belong to the case.
p.deco(d, if d.three() { part_state(d, st, vals[1]) } else { st }, vals);
p.deco(d, sts);
}

#[cfg(test)]
Expand Down Expand Up @@ -1124,6 +1154,30 @@ mod tests {
assert_eq!(part_state(Dev::Mouse, St::Low, 90.0), St::Low, "a device with one level is as it was");
}

/// Only the part that charges changes: left bud charging leaves the right bud and the case alone.
#[test]
fn each_part_charges_by_itself() {
let tk = crate::look::tokens_for(crate::look::Look::Lime, true);
for d in [Dev::Earbuds, Dev::Pods] {
let shot = |sts: [St; 3]| {
let mut cv = Canvas::new();
cv.resize(400, 400);
cv.clear(tk.panel);
draw_parts(&mut cv, d, 0.0, 0.0, 4.0, [50.0, 60.0, 50.0], sts, 0.4, &tk, 1.7);
cv.pixels().to_vec()
};
let (n, c) = (St::Normal, St::Charging);
let calm = shot([n, n, n]);
let diff = |v: &[u32], x0: usize, x1: usize| (0..400).flat_map(|y| (x0..x1).map(move |x| y * 400 + x)).filter(|&i| v[i] != calm[i]).count();
let left = shot([c, n, n]);
assert!(diff(&left, 0, 33 * 4) > 0 && diff(&left, 50 * 4, 400) == 0, "{d:?}: left bud");
let right = shot([n, n, c]);
assert!(diff(&right, 67 * 4, 400) > 0 && diff(&right, 0, 50 * 4) == 0, "{d:?}: right bud");
let case = shot([n, c, n]);
assert!(diff(&case, 33 * 4, 67 * 4) > 0 && diff(&case, 0, 22 * 4) == 0 && diff(&case, 78 * 4, 400) == 0, "{d:?}: case");
}
}

#[test]
fn only_activity_moves() {
assert!(!St::Normal.moves());
Expand Down
7 changes: 6 additions & 1 deletion src/modbt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ struct Pods {
/// Decodes Apple manufacturer data (company id already stripped):
/// `[0x07, len, 0x01, model hi, model lo, status, pods, flags|case, lid, ...]`.
fn decode(b: &[u8]) -> Option<Pods> {
if b.len() < 9 || b[0] != 0x07 {
// `01` = the message with model and levels. Other forms (`07 11 06 ..`, sent by buds away from
// their phone) hold scrambled bytes: read as levels they give random numbers.
if b.len() < 9 || b[0] != 0x07 || b[2] != 0x01 {
return None;
}
let model_id = u16::from_be_bytes([b[3], b[4]]);
Expand Down Expand Up @@ -433,6 +435,9 @@ mod tests {
fn rejects_other_types() {
assert!(decode(&[0x10, 0x05, 0x01]).is_none());
assert!(decode(&[0x07, 0x19]).is_none());
// Heard on a real PC: scrambled, not left 55 % charging, right 85 %, case 100 %.
assert!(decode(&[0x07, 0x11, 0x06, 0x5F, 0x81, 0x5D, 0x58, 0xAA, 0xF8, 0xEE, 0x34]).is_none());
assert!(decode(&[0x07, 0x11, 0x06, 0x50, 0x50, 0x50, 0x74, 0xAC, 0x2C, 0x39, 0x92]).is_none());
}

#[test]
Expand Down
Loading
Loading