Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Sensor values are updated now
Browse files Browse the repository at this point in the history
better debug output while in daemon mode
  • Loading branch information
Nama committed Jun 29, 2020
1 parent 46298dc commit 7ac867f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions suckcontrol/suckcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from threading import Thread
from signal import signal, SIGINT

ui.CONFIG["verbose"] = False
ui.CONFIG["verbose"] = True
ui.CONFIG['color'] = 'never'
terminate = False

Expand Down Expand Up @@ -49,7 +49,6 @@ def get_hardware_sensors(handle, config):
sensor.set_Name(config['main'][ident])
except TypeError:
pass
ui.debug(sensor.Name)
for shw in hw.SubHardware:
shw.Update()
for sensor in shw.Sensors:
Expand All @@ -60,7 +59,6 @@ def get_hardware_sensors(handle, config):
sensor.set_Name(config['main'][ident])
except TypeError:
pass
ui.debug(sensor.Name)
return sensors_all


Expand All @@ -74,6 +72,8 @@ def _control_speed(sensors_all, temp, control, points):
to_set = None
temp_value = int(sensor_temp.Value)
control_value = int(sensor_control.Value)
ui.debug('Control: {}'.format(sensor_control.Name))
ui.debug('Temp: {}'.format(temp_value))
if temp_value < points[0][0]:
# Temp is below first point
ui.debug('Too cold')
Expand All @@ -91,14 +91,12 @@ def _control_speed(sensors_all, temp, control, points):
point_next = points[next]
if temp_value in range(point[0], point_next[0]):
# Temp is between point[0] and point_next[0]
ui.debug(point)
xp = [point[0], point_next[0]]
fp = [point[1], point_next[1]]
to_set = interp(temp_value, xp, fp)
break
ui.debug(sensor_control.Name, control_value, to_set)
ui.debug('Before change: {}\nAfter change: {}\n'.format(control_value, to_set))
if control_value != to_set and to_set is not None:
ui.debug(to_set)
try:
sensor_control.Control.SetSoftware(to_set)
except AttributeError:
Expand Down Expand Up @@ -129,6 +127,8 @@ def start(handle, config, sensors_all):
ui.debug('daemon started')
while True:
sleep(1)
# Update the sensor values
sensors_all = get_hardware_sensors(handle, config)
if terminate:
# Wait for SIGTERM
stop(handle)
Expand Down

0 comments on commit 7ac867f

Please sign in to comment.