Skip to content

Refactor UI components to use PySide6 and update requirements#158

Open
mariusserafin wants to merge 26 commits into
mnh-jansson:mainfrom
mariusserafin:main
Open

Refactor UI components to use PySide6 and update requirements#158
mariusserafin wants to merge 26 commits into
mnh-jansson:mainfrom
mariusserafin:main

Conversation

@mariusserafin
Copy link
Copy Markdown

@mariusserafin mariusserafin commented Mar 10, 2026

Refactor UI components to use PySide6
Makita LXT Protocol Expansion

Added comments and updated package versions in requirements.txt
This stylesheet defines the industrial dark theme for the OBI-1 application, including styles for buttons, text fields, and other UI elements.
Full support for all Makita LXT battery types, BTC04 calculations, and bug fixes verified against real BL1860B hardware data.

Added:

All 5 battery types — Type 0 (standard/newest), Type 2, Type 3, Type 5 (F0513), Type 6 (10-cell BL36xx)
BTC04 type detection sequence — probes cc dc 0b (type 0), cc dc 0a (type 2), cc d4 2c (type 3); type 5 detected from ROM ID byte 3 < 100; type 6 from basic_info byte 17 == 30
State of Charge (type 0 only) — charge level register mapped to 0–7 scale with labels
Health — type 0 uses hardware register; types 2/3 use BTC04 formula from overdischarge and overload counters
Overdischarge count and % — per-type commands with BTC04 formula
Overload count and % — per-type commands with BTC04 formula
Reset Battery Message — 32-byte clean frame write via CLEAN_FRAME_CMD + STORE_CMD with confirmation dialog
Type 6 temperature formula — (-40x + 9323) / 100
F0513 temperature — correct 1/10 Kelvin → °C conversion
F0513 LED/reset buttons disabled — not supported on type 5

Fixed:


Charge count — corrected byte offset to response[38:40]; nibble-swap both bytes, reverse, mask & 0x0FFF
Overload 0xFF sentinel — 0xFF treated as "not applicable" and clamped to 0 before BTC04 calculations
Updated error handling in serial communication and improved user feedback for connection issues.
Early BL1830 non-B (~2008, TH-only BMS) returns correct byte count
but all-0xFF payload — data registers don't exist on that hardware.

- bail out before type probing/field parsing when basic info is all-FF
- show explicit warning dialog identifying pre-type-0 BMS
- populate tree with raw hex dump for debug visibility
he mnh-jansson OBI wiki documents that MC908JK3E-based boards
(LIP5002, LIPW001) have no cell monitoring or protection circuit
implemented at all. Charging these packs on any charger is unsafe.

- add KNOWN_BOARDS table mapping MCU family → support/safety status
- all-0xFF detection now shows a critical "Do Not Charge" dialog
  with explicit fire/explosion warning and board-swap recommendation
- F0513 entry flagged as experimental (rosvall protocol, not validated)
…X improvements

Refactored core Makita LXT path and serial interface handling.
Improves protocol correctness, prevents unsafe operations, and stabilizes UI behavior.

Files changed:
- arduino_obi.py
- main.py
- makita_lxt.py

--- arduino_obi.py ---

- Unified sync/async serial execution into _execute_serial()
  (shared retry, logging, validation)
- Expanded “no data” detection:
  - all 0xFF
  - all 0x00
  - 0xFF followed by zeros
- Prevents invalid Type 3 register data from being parsed as valid
- Preserves all-0xFF behavior for MC908JK3E detection
- Added `connected` signal
- Added request_async() wrapper

--- main.py ---

- Lock module/interface selection while connected
- Unlock on disconnect

--- makita_lxt.py ---

Protocol and safety refactor:

- Added provenance markers to all commands:
  [confirmed], [inferred], [dangerous], [persistent]
- Introduced KNOWN_BOARDS table (MCU, safety, support status)

Safety:

- Detect MC908JK3E via all-0xFF and show “unsafe BMS” warning
- Added locked-battery warning (FET bypass risk)
- Added destructive confirmation for reset-message operation

Read flow:

- Introduced MakitaCommandRunner state machine
- Explicit sequence: read → detect → model → complete
- Improved Type 2 probe handling:
  - sends test-mode-exit after failed probe

Protocol fixes:

- Type 5 (F0513):
  - marked experimental / unsupported
  - corrected cell voltage commands (removed 0xCC prefix)
- Type 6:
  - fixed data command (bare d4)
  - fixed temperature parsing
  - corrected voltage formula (6000 - x/10)

Validation:

- Added bounds checks for type detection (prevents short-read misclassification)

UX:

- Export CSV / JSON (timestamp + version)
- Clipboard copy
- Clear button restores read state
- Capability-gated write actions (runtime + UI protection)

Notes:

- Type 0/2/3 decoding remains field-validated
- Rosvall nibble-based layout not yet fully integrated
…X improvements

Refactored core Makita LXT path and serial interface handling.
Improves protocol correctness, prevents unsafe operations, and stabilizes UI behavior.

Files changed:
- arduino_obi.py
- main.py
- makita_lxt.py

--- arduino_obi.py ---

- Unified sync/async serial execution into _execute_serial()
  (shared retry, logging, validation)
- Expanded “no data” detection:
  - all 0xFF
  - all 0x00
  - 0xFF followed by zeros
- Prevents invalid Type 3 register data from being parsed as valid
- Preserves all-0xFF behavior for MC908JK3E detection
- Added `connected` signal
- Added request_async() wrapper

--- main.py ---

- Lock module/interface selection while connected
- Unlock on disconnect

--- makita_lxt.py ---

Protocol and safety refactor:

- Added provenance markers to all commands:
  [confirmed], [inferred], [dangerous], [persistent]
- Introduced KNOWN_BOARDS table (MCU, safety, support status)

Safety:

- Detect MC908JK3E via all-0xFF and show “unsafe BMS” warning
- Added locked-battery warning (FET bypass risk)
- Added destructive confirmation for reset-message operation

Read flow:

- Introduced MakitaCommandRunner state machine
- Explicit sequence: read → detect → model → complete
- Improved Type 2 probe handling:
  - sends test-mode-exit after failed probe

Protocol fixes:

- Type 5 (F0513):
  - marked experimental / unsupported
  - corrected cell voltage commands (removed 0xCC prefix)
- Type 6:
  - fixed data command (bare d4)
  - fixed temperature parsing
  - corrected voltage formula (6000 - x/10)

Validation:

- Added bounds checks for type detection (prevents short-read misclassification)

UX:

- Export CSV / JSON (timestamp + version)
- Clipboard copy
- Clear button restores read state
- Capability-gated write actions (runtime + UI protection)

Notes:

- Type 0/2/3 decoding remains field-validated
- Rosvall nibble-based layout not yet fully integrated
Refactor serial communication logic and improve error handling.
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