Skip to content

Commit

Permalink
Merge 9a82293 into ee7bb9a
Browse files Browse the repository at this point in the history
  • Loading branch information
SofieLewis committed Sep 26, 2019
2 parents ee7bb9a + 9a82293 commit e995de4
Showing 1 changed file with 6 additions and 16 deletions.
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
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

0 comments on commit e995de4

Please sign in to comment.