This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import LEDCollection, LEDBoard, OutputDeviceError, DigitalOutputDevice | |
from gpiozero.threads import GPIOThread | |
from gpiozero.exc import OutputDeviceError | |
from itertools import cycle | |
from time import sleep | |
class SevenSegmentDisplay(LEDBoard): | |
""" | |
Extends :class:`LEDBoard` for a 7 segment LED display | |
7 segment displays have either 7 or 8 pins, 7 pins for the digit display |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
from time import sleep | |
def count(time_to_sleep): | |
while True: | |
i = 0 | |
print(i) | |
i += 1 | |
sleep(time_to_sleep) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A terminal slack streamer | |
# pre-requisites | |
# - colorama : pip install colorama | |
# - slackclient : pip install slackclient | |
# - a legacy slack api token : https://api.slack.com/custom-integrations/legacy-tokens | |
from slackclient import SlackClient | |
from colorama import init, Fore, Back | |
import time | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
An adaptation of Adafruit's thermal camera example which | |
uses the sense hat to display temperatures. | |
Martin O'Hanlon | |
@martinohanlon | |
stuffaboutco.de | |
""" | |
from sense_hat import SenseHat | |
from Adafruit_AMG88xx import Adafruit_AMG88xx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bluedot import BlueDot | |
from subprocess import call | |
# create a function which will be called when then bluedot is double pressed / swiped | |
def shutdown_pi(): | |
call("sudo halt", shell=True) | |
# create the blue dot | |
bd = BlueDot() | |
# call the shutdown_pi function when its double pressed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this python script will find the directory python.exe and python/Scripts | |
# and add them to the windows path | |
import subprocess | |
import sys | |
import os | |
def add_to_PATH(paths): | |
# create the paths to add to the PATH | |
path_to_add = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from picamera import PiCamera, PiCameraCircularIO, PiVideoFrameType | |
from picamera.array import PiRGBArray | |
from time import sleep | |
import io | |
import cv2 | |
def diff_image(t0, t1, t2): | |
d1 = cv2.absdiff(t2, t1) | |
d2 = cv2.absdiff(t1, t0) | |
return cv2.bitwise_and(d1, d2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from guizero import App, TextBox, Text | |
def count(): | |
result.value = len(text_to_count.value) - 1 | |
app = App(title="character count") | |
instruction = Text(app, text="Put your text here") | |
text_to_count = TextBox(app, multiline = True, width=60, height=25, command=count) | |
text_to_count.when_key_released = count | |
result = Text(app, text="0") |
OlderNewer