DeskPi-Team / deskpi

DeskPi Pro is the Ultimate Case Kit for Raspberry Pi 4 with Full Size HDMI/2.5 Hard Disk Support and Safe Power Button, It has QC 3.0 Power Supply inside and New ICE Tower Cooler inside.
GNU General Public License v3.0
143 stars 46 forks source link

When using custom speeds(FAN SPEED INPUT NEEDS 3 DIGIT VALUES) #108

Closed jojobrogess closed 2 years ago

jojobrogess commented 2 years ago

As a user, I input 25 50 60 70 85 90 100(etc) Because that's how I see fan speeds. BUT from what I know about how the serial code works, it needs 3 digit values.

Am I wrong in assuming these user input values aren't being translated into the correct 3 digit values? I don't see it anywhere.


Okay so I tested on my setup, Libreelec, and the serial port DOES accept 2 digit values(doesn't throw errorspwm_50), BUT it doesn't set the fan speed to 50%, it sets it to seemingly 100%(or maybe it reverted to my settings, which are normally at 0% or 100% for testing).

Now all of this could be MY CODE, since it's been cut and hobbled together, and I could have missed something. PLUS Libreelec is a pretty specific OS.

BUT from what it looks like from the installer files here, there isn't a recommendation to use 3 digit values as inputs. There also isn't code to check whether the user input a 2 digit value and then add a 0 in the front or if they entered a 3 digit value.

IDK how other OS's serial's deal with that. But for me, using python serial 3.5, it doesn't accept pwm_50 as 50% fan speed.


Might be a smart idea to either change the users input(add a 0 in front) Or to tell the user to input a 3 digit value for fan speed so everything works correctly.

jojobrogess commented 2 years ago

Adding fan_speed_level=$(printf %03d "$((10#$fan_speed_level))" ) after line 36 in the deskpi-config file (technically for me, it's a different line)

has allowed me to write user input values of single or double digits 3, 30 as triple digit(leading zero) 003, 030.

I can't test it on the installer.sh for this repo, since I'm not running that one.

But it works on Libreelec, though I do suspect that a more elegant solution is possible and that this "fix" probably wouldn't work for all the supported OS's. but something along the lines of what I just wrote should be possible anywhere in linux.