Skip to content

This commit introduces a complete, user-friendly Tkinter GUI for the …#51

Open
KillaVolt wants to merge 1 commit intomnh-jansson:masterfrom
KillaVolt:M18GUI
Open

This commit introduces a complete, user-friendly Tkinter GUI for the …#51
KillaVolt wants to merge 1 commit intomnh-jansson:masterfrom
KillaVolt:M18GUI

Conversation

@KillaVolt
Copy link

…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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant