CurrentRangerApp

Started by vitormhenrique, April 04, 2026, 03:16:17 AM

vitormhenrique

Hey everyone, I got inspired by the python CurrentRanger GUI but I needed some more functionality, mainly battery calculations.

I built a cross platform app that should work on Mac (requires bypassing apple quarantine), linux and windows, but only tested on Mac.





Full features list:

Serial Connection & Device Management
Auto-discovery — automatically enumerates and scores serial ports by VID/PID (0x239a), name patterns, and description
One-click connect at 230400 baud (also supports 115200, 57600, 9600)
USB logging bootstrap — automatically enables USB data streaming on connect
Cross-platform serial — macOS (cu.* rewrite, PTY support), Windows, Linux
Monotonic timestamps — Instant-based anchor ensures strictly ordered samples even through NTP adjustments
Batched sample delivery — 50ms or 100-sample batches for efficient frontend updates
Dedicated OS thread for serial I/O (blocking reads, never blocks the UI)
Real-Time Chart (uPlot)
500K+ sample rendering with hardware-accelerated uPlot
Live current readout auto-formatted (A / mA / µA / nA)
30 FPS animation loop (throttled, pauses when not visible)
Time window presets: 5s, 10s, 30s, 1m, 5m, All
Pause / Resume with automatic USB logging toggle
Mouse wheel zoom, click-drag pan, drag-to-select region
Auto or manual Y-axis scaling with min/max inputs
Min-max envelope downsampling preserving peaks and valleys
NaN gap breaks between acquisition sessions (line breaks cleanly)
Overview minimap with viewport rectangle, click-drag navigation, and marker rendering

Live & Selection Statistics
Window stats: average, peak, min current; sample rate (Hz); sample count; duration
Selection stats: drag any region for avg, peak, min, duration, samples, rate
Charge & Energy Integration
Trapezoidal-rule integration over all samples or a selected region
Configurable supply voltage (default 3.3V)
Results: Coulombs, mAh, Ah; Joules, mWh, Wh; duration; average current; sample count

Battery Tools
Runtime estimator: input battery capacity + average current → estimated runtime
Required capacity estimator: input desired runtime + average current → required battery mAh
Auto-detects average current from chart or selection
Derating factors: regulator efficiency, depth of discharge, aging margin

Markers & Annotations
Point markers (single timestamp, vertical line) and range markers (shaded region)
7 categories: Note, Boot, Idle, Sleep, Radio TX, Sensor Sample, Custom — each with distinct colors
Create via: right-click chart, press M key, or panel button
Right-click a selection to create a range marker spanning it
Edit inline in the markers panel (label, note, color, category)
Click a marker to navigate the chart to that timestamp
Click a range marker on the chart to select its region and compute stats
Rendered on both the main chart and the minimap

Device Configuration (Full Panel)
Range selection: mA, µA, nA (manual) or autoranging
Low-Pass Filter (LPF) toggle
BIAS / bidirectional mode toggle
Logging format cycle: EXPONENT, NANOS, MICROS, MILLIS, ADC
ADC sampling speed: AVG, FAST, SLOW
Auto-off mode: DEFAULT (10 min), DISABLED, SMART
GPIO range indication toggle (SCK/MISO/MOSI header pins)
USB / Bluetooth logging toggles
EEPROM calibration: ADC Gain, ADC Offset, LDO voltage — increment/decrement with live display
Reset all settings to factory defaults (with confirmation)
Print serial menu (query firmware version and calibration values)

Workspace Save / Load
.crws JSON format (versioned schema v1)
Persists: all samples, markers, settings, device status, chart state
Atomic writes (.tmp → rename) to prevent corruption
Future version detection — rejects workspaces from newer schema versions
Data Export
CSV: time_unix_s, elapsed_s, current_a, current_ma, current_ua, current_na with metadata header
JSON: versioned export with timestamp, voltage, all samples, all markers
Clear samples with confirmation dialog

Console (Built-in Log Viewer)
Structured logs with 2000-entry ring buffer
Level filtering: DEBUG, INFO, WARN, ERROR (color-coded, toggleable)
Source filtering with autocomplete
Auto-scroll (disengages on manual scroll-up)
Copy all visible logs to clipboard
Captures: API calls, serial events, connection status, device status, chart events, workspace operations
Status Bar
Connection state (color-coded: green/yellow/red)
Connected port name, total sample count, "last sample N seconds ago"
Error and status message display
Docs link and donation link

Keyboard Shortcuts
M — add point marker at cursor (or range marker if selection active)
Enter — confirm marker popup
Escape — cancel marker popup/editing
Mock Device (for Development & Testing)
Full CurrentRanger R3 firmware simulator with PTY-based serial emulation
12 waveform types: Steady DC, Sine, Pulse, Sawtooth, Brownian Noise, Sleep/Wake, Random, Step Up/Down/Ping-Pong, Exponential Decay, Burst
Interactive TUI (ratatui) with waveform selector, parameter controls, sparkline display
Responds to all single-char firmware commands

Cross-Platform
macOS (Apple Silicon + Intel) — .dmg
Windows — .exe installer + .msi
Linux — .deb + .AppImage
Built with GitHub Actions CI/CD
Tech Stack
Rust + Tauri v2 backend
React 18 + TypeScript frontend
Zustand state management
uPlot charting
Tailwind CSS (Catppuccin Mocha dark theme)
Vite bundler

Documentation:
https://vitormhenrique.github.io/CurrentRangerApp

Source code:
https://github.com/vitormhenrique/CurrentRangerApp

I need some help testing the app!

Felix

Nice work, thank you for sharing!

vitormhenrique

Just a quick update, the mac app is now signed, so installation should be straightforward!

Felix

That's great, thanks for the update!