Skip to content

Conversation

@AhmedYasserrr
Copy link
Collaborator

This PR introduces a major API overhaul and prepares the codebase for v0.2.0 release.


API Changes

Refactor: from functions to class-based interface

We’ve moved from standalone functional calls to a structured, class-based API via ECController.
This improves maintainability and aligns with typical Pythonic design.

Old Approach:

get_max_temperature()
set_fan_duty(75)
is_on_ac()

New Approach:

ec = ECController()
ec.get_max_temp()
ec.set_fan_duty(75, fan_idx=0)
ec.is_on_ac()

New Capabilities

Fan Control:

  • Get/set fan RPM per fan or all fans.
  • Set duty cycle per fan or globally.

Temperature Monitoring:

  • Read temperatures per sensor or all sensors.
  • Retrieve sensor metadata with get_temp_info(sensor_idx).
  • Get max temperatures, optionally ignoring battery sensor.

Documentation Updates

  • Replaced function-based docs with object-oriented examples.
  • Added full method reference for ECController.
  • Described return structure of ECTempInfo.

Tests Added

  • Implemented comparison tests for all getter functions (get_fan_rpm, get_temp, etc.) against raw ectool output to ensure API correctness and consistency.

AhmedYasserrr and others added 14 commits July 6, 2025 18:24
* Refactored C ectool functions to return error codes instead of printing or exiting.
* Added standard error codes (e.g. `EC_ERR_INIT`, `EC_ERR_READMEM`).
* Introduced a C++ `ECController` class to wrap the C API, throwing C++ exceptions with clear error messages.
* Exposed `ECController` to Python using pybind11 bindings.
* Updated CMake to support the new C++ and pybind11 build flow.
- Implement ec_get_fan_rpm() to read RPM for a specific fan
- Implement ec_get_all_fan_rpm() to read RPMs for all fans at once
- Implement ec_set_fan_target_rpm() to set RPM for a specific fan
- Implement ec_set_all_fan_target_rpm() to set RPM for all fans
[FEATURE] Expose more ectool functions in pyectool
@AhmedYasserrr AhmedYasserrr merged commit d5f79db into main Aug 3, 2025
11 checks passed
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.

2 participants