checked PC_CONTROL_CODES with mypy

This commit is contained in:
2025-08-09 10:53:17 +02:00
parent 45459ee231
commit 224fae39f7
4 changed files with 30 additions and 22 deletions

View File

@@ -95,9 +95,11 @@ def getTemp() -> dict:
continue
# continue
return MDict
else:
return {"error": "unidentified"}
def setSpeed(inSpeeDict: dict) -> None:
def setSpeed(inSpeeDict: dict) -> int:
bpavrg = 0
# default
@@ -109,18 +111,20 @@ def setSpeed(inSpeeDict: dict) -> None:
outfanprcntg = int((bpavrg / (HIGH_FAN_TRSHD - LOW_FAN_TRSHD)) * TEMP_FACTOR)
# os.system(f"echo setting {outfanprcntg}%")
return outfanprcntg
# Set fan speed
if outfanprcntg >= 20:
MDserial.write((f"{SETFANCMND} {str(outfanprcntg)} \n\r").encode())
print(f"setting {outfanprcntg}%", flush=True)
return 0
return outfanprcntg
else:
# Set default value
MDserial.write((f"{SETFANCMND} {str(DEFOUTPRCNTG)} \n\r").encode())
return 1
return DEFOUTPRCNTG
# If something goes super wrong
return -1
return 1