View demo.py
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, Text, Drawing, Combo, Box, Slider, PushButton | |
def start(event): | |
painting.start_event = event | |
def draw(event): | |
painting.line( | |
painting.start_event.x, painting.start_event.y, | |
event.x, event.y, | |
color=color_picker.value, |
View img_pad.py
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 utility for padding image files. | |
""" | |
from PIL import Image, ImageOps, UnidentifiedImageError | |
import os.path | |
def find_files(path, file_names=[], extensions=[]): | |
def valid_file(file_path): |
View sense_hat_shaken.py
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 sense_hat import SenseHat | |
def display_acceleration(x, y, z): | |
print("{:06.2f}|{:06.2f}|{:06.2f}".format(x, y, z)) | |
sense = SenseHat() | |
while True: | |
acceleration = sense.get_accelerometer_raw() | |
x = acceleration['x'] |
View sense_hat_move.py
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 sense_hat import SenseHat | |
def display_acceleration(x, y, z): | |
print("{:06.2f}|{:06.2f}|{:06.2f}".format(x, y, z)) | |
sense = SenseHat() | |
while True: | |
acceleration = sense.get_accelerometer_raw() | |
x = acceleration['x'] |
View sensehat_tilt.py
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 sense_hat import SenseHat | |
sense = SenseHat() | |
tilt = "flat" | |
def display_orientation(yaw, pitch, roll, tilt): | |
print("{:06.2f}|{:06.2f}|{:06.2f}|{}".format(yaw, pitch, roll, tilt)) | |
while True: | |
pos = sense.get_orientation() |
View blinkt_remote.py
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 remote controlled light using Blue Dot and a pimoroni blinkt. | |
# install packages - sudo pip3 install bluedot, blinkt, colorzero | |
import blinkt | |
from bluedot import BlueDot | |
from signal import pause | |
from colorzero import Color | |
from threading import Event | |
class BlinktDot(): |
View guizero_stopmotion.py
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 is a simple gui for creating stop motion animations using the Pi camera | |
# martin@ohanlonweb.com | |
# stuffaboutcode.com | |
# Instructions: | |
# - Connect a camera module | |
# - Enable the camera (Menu > Preferences > Raspberry Pi Configuration, Interfaces, Camera) | |
# - Install the relevant modules, open a terminal (Menu > Accessories > Terminal) and run: | |
# - sudo pip3 install guizero | |
# - sudo pip3 install imageio |
View char_count.py
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") |
View detect_motion.py
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) |
NewerOlder