Skip to content

About

Dual-fan EC controller and pywebview UI for Lenovo ThinkPad P50

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

P50 FanControl

Platform Hardware Python License

Direct dual-fan ACPI Embedded Controller (EC) control for the Lenovo ThinkPad P50 on Windows 10/11 — featuring independent or linked CPU & GPU fan curves, live RPM & dual-temperature telemetry, stepped manual detents, system tray integration, and a native dark workstation UI.

P50 FanControl UI


What is this & How does it work? (Simple Explanation)

ThinkPad workstations have two separate cooling fans — Fan 1 (CPU / Left) and Fan 2 (GPU / Right) — managed by a tiny microcontroller on the motherboard called the Embedded Controller (EC).

Normally, Windows and Lenovo's BIOS decide fan speeds on their own, often letting the laptop run hot and quiet before suddenly ramping up. P50 FanControl talks directly to the EC over standard ACPI I/O ports (0x62 and 0x66) using inpoutx64:

  1. Selects a fan via EC register 0x31 (bit 0: 0 = Fan 1 CPU, 1 = Fan 2 GPU).
  2. Reads live speed & temps from EC tachometer registers 0x84/0x85 (direct 16-bit RPM), CPU sensor 0x78, and GPU-zone sensor 0x79 (plus nvidia-smi when the Quadro dGPU is awake).
  3. Sets fan mode via register 0x2F (HFSP):
    • 0x80 — BIOS Auto (hands control back to Lenovo BIOS)
    • 0x00–0x07 — Manual / Smart Curve stepped levels (0 = off, 7 = max regulated)
    • 0x40 — Full Speed (disengaged maximum RPM)
  4. Always restores BIOS Auto (0x80) when you close the app or press Ctrl+C.

⚠️ Hardware Warning & Disclaimer

Read before using:

  • This software performs direct low-level I/O port writes (0x62/0x66) to your ThinkPad's Embedded Controller via the inpoutx64 kernel driver.
  • Tested on: Lenovo ThinkPad P50 (20EQ series, Windows 11 x64). Other ThinkPad models may use different EC register maps — do not run blindly on unsupported hardware without verifying EC registers with --probe first.
  • Setting fans to Level 0 (OFF) under load can cause thermal throttling or shutdown. An advisory Temp Advisor alerts you if CPU ≥ 90 °C or GPU ≥ 85 °C and offers a one-click switch to Performance mode, without overriding your control.
  • Provided "AS IS" under the MIT License — use at your own risk.

Features

  • Native Dark Workstation UI — Hosted in a standalone pywebview (Edge WebView2) window with custom ThinkPad-inspired icon and P50 FanControl taskbar identity (no browser chrome).
  • Dual-Fan Independent or Linked Control — Control Fan 1 (CPU) and Fan 2 (GPU) together (SYNC: LINKED) or independently (F1 / F2).
  • Interactive Smart Curve — Drag-and-drop SVG response curve (30–100 °C × L0–MAX) with 3 built-in profiles (Silent, Balanced, Performance) and configurable hysteresis (1–10 °C) to prevent fan hunting.
  • Dual Temperature Readout — Displays both CPU (EC 0x78) and GPU (NVML when active / EC 0x79 when Optimus is sleeping) with live cursors on the curve.
  • Advisory Temp Alert — Non-intrusive banner recommends switching to Performance mode when CPU ≥ 90 °C or GPU ≥ 85 °C (never overrides your chosen mode).
  • 5s Fan Pulse Test & Task Autostart — Verify both fans spin up cleanly on demand, and optionally register a Windows Scheduled Task (ONLOGON, highest privileges).
  • Headless CLI & Daemon Mode — Scriptable CLI for --info, --probe, --mode, and --daemon.

Quick Start

1. Requirements

  • Windows 10 / 11 (x64) on a Lenovo ThinkPad P50
  • Python 3.10+
  • Administrator privileges (required by inpoutx64.dll for ACPI EC port I/O)

2. Install Dependencies

pip install -r requirements.txt

3. Launch

Double-click P50Fan.bat (or P50Fan.pyw) — or run from an elevated terminal:

python -m p50fan

CLI Usage

python -m p50fan --info                   # Live dual-fan RPM + CPU/GPU temperatures
python -m p50fan --probe                  # Read-only 256-byte ACPI EC RAM dump
python -m p50fan --mode full              # Both fans -> Full Speed (0x40)
python -m p50fan --mode manual --level 4  # Manual level 0..7 (8 = Full Speed)
python -m p50fan --mode bios              # Hand control back to BIOS Auto (0x80)
python -m p50fan --daemon                 # Headless Smart Curve loop (Ctrl+C -> BIOS Auto)

Project Structure

P50Fan/
├── P50Fan.pyw              # Windowless GUI launcher
├── P50Fan.bat              # Double-click / CLI wrapper
├── p50fan.ico              # Custom 4x supersampled ThinkPad turbine icon
├── requirements.txt        # Python dependencies
├── DOCS.md                 # Full technical documentation & HTTP API reference
├── LICENSE                 # MIT License
├── assets/
│   └── preview.png         # UI screenshot
├── driver/
│   ├── inpoutx64.dll       # User-mode ACPI port I/O bridge
│   └── license.txt         # InpOutx64 license
└── p50fan/
    ├── ec.py               # Thread-safe ACPI EC (0x62/0x66) driver
    ├── portio.py           # InpOutx64 DLL loader
    ├── sensors.py          # CPU (0x78) + GPU (NVML / EC 0x79) + psutil
    ├── controller.py       # Dual-fan loop, Smart Curve + hysteresis, temp advisor
    ├── config.py           # Persistent JSON profiles (%APPDATA%\P50Fan\config.json)
    ├── webui.py            # Local HTTP API + native pywebview window host
    ├── tray.py             # Win32 system tray icon
    ├── app.py              # CLI & GUI entrypoint
    └── static/index.html   # Workstation UI (HTML/CSS/SVG)

For full register tables, HTTP API endpoints, and troubleshooting, see DOCS.md.

About

Dual-fan EC controller and pywebview UI for Lenovo ThinkPad P50

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages