FakeGPIO, FakePicamera zum Simulieren auf Entwickler-Maschine
This commit is contained in:
parent
50a3d6f29f
commit
5a460f7b54
27
FakeGPIO/__init__.py
Normal file
27
FakeGPIO/__init__.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
BOARD = 1
|
||||||
|
HIGH = 1
|
||||||
|
LOW = 0
|
||||||
|
OUT = 1
|
||||||
|
IN = 0
|
||||||
|
FALLING = 0
|
||||||
|
RISING = 1
|
||||||
|
|
||||||
|
|
||||||
|
def setmode(x):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def setwarnings(x):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def setup(gpio, mode, initial=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def output(gpio, state):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def add_event_detect(gpio, edge, callback, bouncetime=None):
|
||||||
|
pass
|
||||||
BIN
FakeGPIO/__init__.pyc
Normal file
BIN
FakeGPIO/__init__.pyc
Normal file
Binary file not shown.
28
FakePicamera/__init__.py
Normal file
28
FakePicamera/__init__.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
|
class Overlay(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.alpha = 0
|
||||||
|
|
||||||
|
|
||||||
|
class PiCamera(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.resolution = None
|
||||||
|
|
||||||
|
def start_preview(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def add_overlay(self, *args, **kwargs):
|
||||||
|
return Overlay()
|
||||||
|
|
||||||
|
def remove_overlay(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def capture(self, filename, format, *args, **kwargs):
|
||||||
|
print("FAKE: capture(%s, %s)" % (filename, format))
|
||||||
|
img = Image.new("RGB", self.resolution, (255, 255, 255))
|
||||||
|
img.save(filename, format)
|
||||||
|
|
||||||
|
def close(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
BIN
FakePicamera/__init__.pyc
Normal file
BIN
FakePicamera/__init__.pyc
Normal file
Binary file not shown.
16
photobox.py
16
photobox.py
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import imp
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -8,13 +9,20 @@ from math import floor
|
|||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
import RPi.GPIO as GPIO
|
|
||||||
import picamera
|
|
||||||
import pygame
|
import pygame
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
# ~ import server
|
try:
|
||||||
|
imp.find_module('RPi')
|
||||||
|
import RPi.GPIO as GPIO
|
||||||
|
except ImportError:
|
||||||
|
import FakeGPIO as GPIO
|
||||||
|
|
||||||
|
try:
|
||||||
|
imp.find_module('picamera')
|
||||||
|
import picamera
|
||||||
|
except ImportError:
|
||||||
|
import FakePicamera as picamera
|
||||||
|
|
||||||
__all__ = ["monotonic_time"]
|
__all__ = ["monotonic_time"]
|
||||||
|
|
||||||
@ -222,7 +230,7 @@ def waitForBegin():
|
|||||||
|
|
||||||
def countdown(camera, pad, img):
|
def countdown(camera, pad, img):
|
||||||
sleep(PIC_INTERVAL)
|
sleep(PIC_INTERVAL)
|
||||||
o = camera.add_overlay(pad.tostring(), size=img.size)
|
o = camera.add_overlay(pad.tobytes(), size=img.size)
|
||||||
o.alpha = OVERLAY_ALPHA
|
o.alpha = OVERLAY_ALPHA
|
||||||
o.layer = 3
|
o.layer = 3
|
||||||
sleep(TEXT_INTERVAL)
|
sleep(TEXT_INTERVAL)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user