Ejemplo n.º 1
0
    sleep(1.0)  # some slack to establish the connection

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()

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):
        global armed
        if was_held:
            set_automatic(not armed)
        elif not armed:
Ejemplo n.º 2
0
#!/usr/bin/python3

import time, datetime
from fanshim import FanShim
from gpiozero import CPUTemperature
'''
Uses fanshim for cooling raspberry pi from Pimoroni.
When  the pi reaches 70 F, cools for 60 seconds and
LED on fanshim lights up a muted white while fan runs.
When 60 second fan runtime ends, fan and LED turn off.
Temp is checked every 5 seconds when fan not running.

Make file executable, and schedule to run at boot. 
'''

fanshim = FanShim()
cpu = CPUTemperature()

while True:
    if cpu.temperature >= 70:
        fanshim.set_fan(True)
        fanshim.set_light(50, 50, 50)  # rgb 255
        time.sleep(60)
        fanshim.set_light(0, 0, 0)  # rgb 255
    else:
        fanshim.set_fan(False)
        time.sleep(5)
Ejemplo n.º 3
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
Ejemplo n.º 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
Ejemplo n.º 5
0
  'PuzzBot is currently listening to', \
  'PuzzBot serving up a hot plate of', \
  'Phoebe P. Peabody Beebee told PuzzBot she loves', \
  'RiddieKitty told PuzzBot he loves', \
  "JP Riddles said his favorite was popcorn farts, but PuzzBot thinks he meant", \
  'Santa Baby, play', \
  "Smashmouth won't return PuzzBot's calls.", \
  "PuzzBot's favorite episode is"]

  introrandom = random.choice(intros)
  episoderandom = random.choice(episodelist)
  episodesuggestion = ('*bzzzt*... {0} {1}'.format(introrandom, episoderandom))
  return episodesuggestion

# BOOT NOTIFICATION
fanshim.set_light(200, 0, 0) # rgb 255
time.sleep(0.5)
fanshim.set_light(255, 0, 255) # rgb 255
time.sleep(1)
fanshim.set_light(200, 0, 0) # rgb 255
time.sleep(0.5)
fanshim.set_light(0, 0, 0)

# IDENTIFIERS
myid = 'MY ID REMOVED'
token = 'TOKEN REMOVED'
client = discord.Client()

# CONNECT MESSAGE
@client.event
async def on_ready():