Skip to content

Gradual speed change and auto reconnect to websockets#21

Merged
s-h-a-d-o-w merged 22 commits intos-h-a-d-o-w:masterfrom
yurii-sio2:master
Feb 5, 2025
Merged

Gradual speed change and auto reconnect to websockets#21
s-h-a-d-o-w merged 22 commits intos-h-a-d-o-w:masterfrom
yurii-sio2:master

Conversation

@yurii-sio2
Copy link
Contributor

@yurii-sio2 yurii-sio2 commented Dec 2, 2024

  1. Added gradual change of fan speed to target speed.
    Since the cooling system has a certain inertia, even with a sharp increase in CPU/GPU temperature, there is no need to change the fan speed urgently. A gradual change in speed adds acoustic comfort when using a laptop.
    This is especially noticeable during short-term increases in system load (3-6 seconds), when fans often change rotation speed from minimum to maximum and back.

Since the controller does not support a smooth change of fans speed, a step-by-step algorithm was implemented. The fan speed is being changed step by step until it reaches the target speed.
The logic for calculating the steps is as follows:

  • At the moment when a new speed needs to be applied, the difference between the previous "applied" and "final target" speeds is measured.
  • The average value between them is calculated. This is the "new target speed".
  • If there is less than 5% between the "new target speed" and the "final target speed", then the value of the "final target" is assigned to the "new target".
  • The calculated "new target" speed is applied to the fans.
  1. In web interface added a function to auto reconnect to websockets when connection was lost (for example, after wake up of laptop from sleep).

  2. Also added autoclosing of toas messages about websocket connection changes.

@s-h-a-d-o-w
Copy link
Owner

Nice!
While I've already tried it out and looks good functionally, I'm very swamped at the moment, so it'll take me a bit to give proper feedback regarding polish.

@s-h-a-d-o-w
Copy link
Owner

Alright, here are some minor changes that I would like to see before merging:

  1. Since these are two different topics, please split the websocket handling out to a seperate PR.
  2. Bring up to date with master since this has made me aware that a precommit hook is needed. You will have to adjust some things to pass linting.
  3. Use successToast and errorToast - modify them accordingly.
  4. Split up websocket error and reconnection handlers (the point being different toast messages - they should both still try to reconnect), remove the onopen toast (because if there's no connection, the user will see the connection attempt toasts anyway) and after maximum reconnect attempts are reached, show a toast that doesn't automatically disappear.

@s-h-a-d-o-w
Copy link
Owner

s-h-a-d-o-w commented Feb 4, 2025

Since I haven't heard from you, I have decided to tackle this myself.
For some reason, I encountered linting problems on this branch and decided to use the opportunity to modernize the whole project.

UPDATE: Oh, interesting. I don't believe I changed anything about the logic but tests that I added aren't passing. But don't worry about it, I'll handle finishing this.

@yurii-sio2
Copy link
Contributor Author

I'm sorry for not replaying. I don't have anough time now to complete the tasks.
Glad, that you continue working on the project! 👍

@s-h-a-d-o-w s-h-a-d-o-w merged commit 538425b into s-h-a-d-o-w:master Feb 5, 2025
1 check 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