This commit introduces a complete, user-friendly Tkinter GUI for the …#51
Open
KillaVolt wants to merge 1 commit intomnh-jansson:masterfrom
Open
This commit introduces a complete, user-friendly Tkinter GUI for the …#51KillaVolt wants to merge 1 commit intomnh-jansson:masterfrom
KillaVolt wants to merge 1 commit intomnh-jansson:masterfrom
Conversation
…M18 protocol tool,
designed to make battery interrogation and charger simulation accessible to users who
are not comfortable with command-line workflows. The GUI is packaged as `m18_gui.py`
and integrates fully with the existing `m18.py` protocol implementation.
IMPORTANT NOTE — NOT YET TESTED:
--------------------------------
This GUI has NOT been tested with actual hardware at the time of submission.
The author currently does not have the USB-to-TTL hardware available but will
acquire it within ~24 hours. Full validation of:
- Connection to FTDI/CP2102 adapters
- Reset/calibration behavior
- Snapshot reads
- Charger simulation timing
- Keepalive behaviour
- Custom charger profile application
will be performed once hardware is available.
This commit should be reviewed as a **functional draft** pending real-world verification.
Major features:
---------------
1. Connection Management
- Auto-detection and refresh of available serial ports.
- Clean Connect/Disconnect workflow with status indicators.
- Safe fallback to idle mode (`TX low`) when appropriate.
2. Main Controls UI
- Buttons for "Idle", "Health report", and "Copy all registers to clipboard".
- All output is displayed in a unified scrollable log panel.
3. Interactive Python Console
- Executes arbitrary Python code with `m` exposed as the active M18 object.
- Captures stdout/stderr for display in the log panel.
- Safe, isolated execution environment.
4. Full Charger Simulation Mode (USB-only, protocol-level simulation)
- Allows selecting a profile: Gentle, Normal, Aggressive, or Custom.
- Completely rewritten simulation controller with:
• Reset → configure(2) → keepalive → configure(1) negotiation sequence
• Periodic keepalive packets on a configurable simulated baud interval
• Clean teardown returning the pack to idle state
• Threaded execution with cancellation via Stop button
- Simulation-only disclaimer clearly shown (no actual current flows via USB).
5. Profile Parameter Display
- Shows cutoff and max current in BOTH:
• Raw protocol units
• Human-friendly amps (raw / 1000)
- Ensures users understand the simulated charging intensity.
6. Custom Profile Editor (advanced mode)
- Grid layout:
Raw units Amps
Cutoff: [ ] [ ]
Max: [ ] [ ]
- Full two-way synchronization:
• Editing raw updates amps (raw/1000)
• Editing amps updates raw (amps*1000)
- Validation prevents invalid or out-of-range values (< 20000).
- Designed for maximum usability for non-technical users.
7. Simulation Baudrate Control (conceptual only)
- Does not modify actual UART baudrate (fixed at 4800).
- Adjusts simulation keepalive timing to mimic different charger behaviors.
8. Dependency Auto-Installer
- Automatically installs `pyserial` and `requests` if missing.
- Uses a Tkinter popup with progress bar for user visibility.
- Ensures GUI runs even on clean systems.
9. Integration with Existing Codebase
- No changes made to m18 protocol logic.
- ALL overrides (cutoff/max current) are temporary and restored after simulation.
- CLI workflow remains untouched.
10. Robust Error Handling
- Extensive try/except protection around serial operations.
- Graceful thread termination.
- Meaningful GUI feedback through dialogs and output logs.
Purpose of this submission:
---------------------------
This commit is intended for **early review and feedback**.
The GUI is feature-complete but **requires real hardware testing** before merging into
upstream or being released for end-user use.
Hardware arrival is expected within 24 hours; thorough verification will follow.
Future enhancement ideas:
-------------------------
- Live telemetry polling during simulation (voltage, temp, imbalance)
- GUI for brute-force register exploration
- Integrated wiring guide / hardware sanity checker
- Improved interactive console autocomplete
This commit substantially enhances the usability of the M18 protocol tooling while
remaining fully backward-compatible with existing workflows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…M18 protocol tool,
designed to make battery interrogation and charger simulation accessible to users who are not comfortable with command-line workflows. The GUI is packaged as
m18_gui.pyand integrates fully with the existingm18.pyprotocol implementation.IMPORTANT NOTE — NOT YET TESTED:
This GUI has NOT been tested with actual hardware at the time of submission. The author currently does not have the USB-to-TTL hardware available but will acquire it within ~24 hours. Full validation of:
will be performed once hardware is available.
This commit should be reviewed as a functional draft pending real-world verification.
Major features:
Connection Management
TX low) when appropriate.Main Controls UI
Interactive Python Console
mexposed as the active M18 object.Full Charger Simulation Mode (USB-only, protocol-level simulation)
Profile Parameter Display
Custom Profile Editor (advanced mode)
Raw units Amps
Cutoff: [ ] [ ]
Max: [ ] [ ]
• Editing raw updates amps (raw/1000)
• Editing amps updates raw (amps*1000)
Simulation Baudrate Control (conceptual only)
Dependency Auto-Installer
pyserialandrequestsif missing.Integration with Existing Codebase
Robust Error Handling
Purpose of this submission:
This commit is intended for early review and feedback. The GUI is feature-complete but requires real hardware testing before merging into upstream or being released for end-user use.
Hardware arrival is expected within 24 hours; thorough verification will follow.
Future enhancement ideas:
This commit substantially enhances the usability of the M18 protocol tooling while remaining fully backward-compatible with existing workflows.