Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions examples/automatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
parser.add_argument('--threshold', type=float, default=-1, help='Temperature threshold in degrees C to enable fan')
parser.add_argument('--hysteresis', type=float, default=-1, help='Distance from threshold before fan is disabled')

parser.add_argument('--off-threshold', type=float, default=55.0, help='Temperature threshold in degrees C to enable fan')
parser.add_argument('--on-threshold', type=float, default=65.0, help='Temperature threshold in degrees C to disable fan')
parser.add_argument('--off-threshold', type=float, default=55.0, help='Temperature threshold in degrees C to disable fan')
parser.add_argument('--on-threshold', type=float, default=65.0, help='Temperature threshold in degrees C to enable fan')
parser.add_argument('--delay', type=float, default=2.0, help='Delay, in seconds, between temperature readings')
parser.add_argument('--preempt', action='store_true', default=False, help='Monitor CPU frequency and activate cooling premptively')
parser.add_argument('--verbose', action='store_true', default=False, help='Output temp and fan status messages')
Expand Down Expand Up @@ -71,9 +71,9 @@ def set_fan(status):


def set_automatic(status):
global armed, last_change
global armed
armed = status
last_change = 0



if args.threshold > -1 or args.hysteresis > -1:
Expand All @@ -92,20 +92,13 @@ def set_automatic(status):
led_busy = Lock()
enable = False
is_fast = False
last_change = 0
signal.signal(signal.SIGTERM, clean_exit)

if args.noled:
led_busy.acquire()
fanshim.set_light(0, 0, 0)
led_busy.release()

t = get_cpu_temp()
if t >= args.threshold:
last_change = get_cpu_temp()
set_fan(True)


if not args.nobutton:
@fanshim.on_release()
def release_handler(was_held):
Expand Down Expand Up @@ -142,12 +135,9 @@ def held_handler():
enable = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wont currently work because enable is no longer used. Probably need to refactor preempt into armed so it doesn't interfere with manual mode.

elif armed:
if t >= args.on_threshold:
enable = True
set_fan(True)
elif t <= args.off_threshold:
enable = False

if set_fan(enable):
last_change = t
set_fan(False)

if not args.noled:
update_led_temperature(t)
Expand Down