From 81c442f656f06ddbdf9b79ab18de3d121dc7c7d1 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Mon, 21 Jun 2021 00:45:14 -0400 Subject: [PATCH] Add updates to sstv to allow for simulation --- sstv.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sstv.py b/sstv.py index 0853c7a..31d3064 100644 --- a/sstv.py +++ b/sstv.py @@ -1,9 +1,15 @@ from shutil import copyfile from PIL import Image, ImageFont, ImageDraw from pysstv import color -from picamera import PiCamera + import logging as log +try: + from picamera import PiCamera +except ModuleNotFoundError: + log.info("Running in simulator mode") + + def take_photo(): # This def is meant to take a photograph from the robot, # it should include all steps and error checking to raise the mast @@ -16,9 +22,12 @@ def take_photo(): # Software to take the photo should be here #copyfile('photos/camera_latest.jpg', 'working/working.jpg') log.debug('Initalizing camera.') - camera = PiCamera() - log.info('Saving photo.') - camera.capture('working/working.jpg') + try: + camera = PiCamera() + log.info('Saving photo.') + camera.capture('working/working.jpg') + except NameError: + log.info("Running in simulator mode, not replacing test pattern") def mark_photo(): log.info('Opening photo for viewing.')