示例#1
0
    changed = False
    if status != enabled:
        changed = True
        update_led(status)
        fanshim.set_fan(status)
    enabled = status
    return changed


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


fanshim = FanShim()
fanshim.set_hold_time(1.0)
fanshim.set_fan(False)
armed = True
enabled = False
last_change = 0

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):
示例#2
0
    global enabled
    changed = False
    if status != enabled:
        changed = True
        fanshim.set_fan(status)
    enabled = status
    return changed


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


fanshim = FanShim(disable_button=args.nobutton, disable_led=args.noled)
fanshim.set_hold_time(1.0)
fanshim.set_fan(False)
armed = True
enabled = False
led_busy = Lock()
enable = False
is_fast = False
last_change = 0
min_temp = 30
max_temp = 85
signal.signal(signal.SIGTERM, clean_exit)

if args.noled:
    led_busy.acquire()
    fanshim.set_light(0, 0, 0)
示例#3
0
def set_automatic(status):
    global armed, last_change
    armed = status
    last_change = 0


if args.threshold > -1 or args.hysteresis > -1:
    print("""
The --threshold and --hysteresis parameters have been deprecated.
Use --on-threshold and --off-threshold instead!
""")
    sys.exit(1)


fanshim = FanShim()
fanshim.set_hold_time(1.0)
fanshim.set_fan(False)
armed = True
enabled = False
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()
示例#4
0
#!/usr/bin/env python3
from fanshim import FanShim
import time
import colorsys

fanshim = FanShim()
fanshim.set_fan(False)

try:
    while True:
        h = time.time() / 25.0
        r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
        fanshim.set_light(r, g, b, brightness=0.05)
        time.sleep(1.0 / 60)

except KeyboardInterrupt:
    pass
示例#5
0
#!/usr/bin/env python3
from fanshim import FanShim
import time
import colorsys

fanshim = FanShim()
fanshim.set_fan(False)

try:
    while True:
        h = time.time() / 25.0
        r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
        fanshim.set_light(r, g, b)
        time.sleep(1.0 / 60)

except KeyboardInterrupt:
    pass
示例#6
0
#!/usr/bin/env python3
import signal, os
from fanshim import FanShim

fanshim = FanShim()

# Set time for long press on button to 2 sec
fanshim.set_hold_time(2.0)


# control for button on FansHim fan hat
@fanshim_on_release()
def releade_handler(was_held):
    if was_held:
        # system shutdown, on long press
        os.system("sudo shutdown")
    else:
        # system reboot, on short press
        os.system("sudo reboot")


try:
    signal.pause()
except KeyboardInterrupt:
    pass
from fanshim import FanShim

fanshim = FanShim()

# Set fan status
def set_fan(action=False):
    if action == True:
        status = "Enabled"
    else:
        status = "Disabled"
    fanshim.set_fan(action)

    return status

# Get fan status
def get_fan():
    status = fanshim.get_fan()
    if status == 1:
        status = "Enabled"
    else:
        status = "Disabled"

    return status
示例#8
0
import cv2
import numpy as np
from app.utils import find_objects, raspberry_utils, gopigo_controls
import datetime
import argparse
from easygopigo3 import EasyGoPiGo3
import math
import time
from picamera.array import PiRGBArray
from picamera import PiCamera
import argparse
from fanshim import FanShim


fanshim = FanShim()
fanshim.set_fan(True)

utils = raspberry_utils.Utils()

cap = None
easy = EasyGoPiGo3()
easy.set_left_eye_color((10,20,30))

# def center_cone():
# 	b_box_rec = cones_data['cone-0']['bouding_box_center']
# 	print(f"Center of the rectangle-{b_box_rec}")
# 	print(f"Center of the screen-{center_of_the_screen}")
# 	cv2.line(frame_back, b_box_rec, center_of_the_screen, [0, 255, 0], 3)
# 	if center_of_the_screen[0] != b_box_rec[0]: # if the angle is not equal to 90 only do thistohis else we are getting divde by 0 error
# 		angle = int(math.atan((b_box_rec[1] - center_of_the_screen[1])/(b_box_rec[0] - center_of_the_screen[0])) * 180/math.pi )
# 	else:
示例#9
0
    global enabled
    changed = False
    if status != enabled:
        changed = True
        fanshim.set_fan(status)
    enabled = status
    return changed


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


fanshim = FanShim()
fanshim.set_hold_time(1.0)
fanshim.set_fan(False)
fanshim.pwm_freq = args.freq
fanshim.pwm_speed = args.speed
armed = True
enabled = False
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)
示例#10
0
#!/usr/bin/python3
# bot.py

import os, discord, random, time, wordladderlist
from fanshim import FanShim

fanshim = FanShim()

def episodepicker():
  """ Picks the episode, intro, and packages them together and returns message """
  episodelist = ['ep.78 James Bond\'s Cousins', \
  'ep.77 ON MY GIRLFRIENDS BIRTHDAY???', \
  'ep.76 How Far Up The Egg Do The Pants Go?', \
  'ep.75 The Night Before Puzzmis w/ J.P. Riddles', \
  'ep.74 Booty Butt', \
  'ep.73 Sharkest Heart', \
  'ep.72 Skull & Boneheads', \
  'ep.71 Kid Friendly Episode (really!)', \
  'ep.70 Hundie Dollie Giveaway Returns! AKA Rap for Daddy!', \
  'ep.69 Dirty Sexy Riddles', \
  'ep.68 The Birds, the Bees, the Nicholas Cages', \
  'ep.67 Bleh Riddle Riddle 2!', \
  'ep.66 On the Ground, In Disguise', \
  'ep.65 Watson Can You Hear Me?', \
  'ep.64 The Purple Episode', \
  'ep.63 A Pun in the Pool', \
  'ep.62 Hey Riddle City Part 2!', \
  'ep.61 Fun at songs', 'ep.60 Floor Soup!', \
  'ep.59 That Sucks! That Rules!', \
  'ep.58 Flirty Chef!', \
  'ep.57 The Question is the Answer! with the teachers lounge', \
示例#11
0
def set_automatic(status):
    global armed, last_change
    armed = status
    last_change = 0


parser = argparse.ArgumentParser()
parser.add_argument('--threshold', type=float, default=37.0, help='Temperature threshold in degrees C to enable fan')
parser.add_argument('--hysteresis', type=float, default=2.0, help='Distance from threshold before fan is disabled')
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')

args = parser.parse_args()

fanshim = FanShim(poll_time=args.delay/10)
fanshim.set_hold_time(1.0)
fanshim.set_fan(False)
armed = True
enabled = False
last_change = 0

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


@fanshim.on_release()
def release_handler(was_held):
    global armed