mirror of
https://github.com/anatolykopyl/cat-fountain.git
synced 2026-03-26 12:55:38 +00:00
Added a tiny oled display
This commit is contained in:
23
image.py
Normal file
23
image.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
|
import Adafruit_GPIO.SPI as SPI
|
||||||
|
import Adafruit_SSD1306
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
RST = 24
|
||||||
|
disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST)
|
||||||
|
|
||||||
|
disp.begin()
|
||||||
|
disp.clear()
|
||||||
|
disp.display()
|
||||||
|
|
||||||
|
image = Image.open('cat.png').convert('1')
|
||||||
|
|
||||||
|
def cat():
|
||||||
|
disp.image(image)
|
||||||
|
disp.display()
|
||||||
|
|
||||||
|
def no_cat():
|
||||||
|
disp.clear()
|
||||||
|
disp.display()
|
||||||
6
main.py
6
main.py
@@ -5,6 +5,8 @@ import importlib.util
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from image import *
|
||||||
|
|
||||||
IM_WIDTH = 1280
|
IM_WIDTH = 1280
|
||||||
IM_HEIGHT = 720
|
IM_HEIGHT = 720
|
||||||
|
|
||||||
@@ -110,7 +112,11 @@ def pet_detector(frame, detection_time):
|
|||||||
detection_time += 1
|
detection_time += 1
|
||||||
else:
|
else:
|
||||||
detection_time = 0
|
detection_time = 0
|
||||||
|
no_cat()
|
||||||
print(detection_time)
|
print(detection_time)
|
||||||
|
if detection_time >= 2:
|
||||||
|
cat()
|
||||||
|
|
||||||
|
|
||||||
return frame, detection_time
|
return frame, detection_time
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user