no message
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
__author__ = 'asc'
|
||||
debug = True
|
||||
from random import random
|
||||
import Adafruit_BMP.BMP085 as BMP085
|
||||
|
||||
import configparser
|
||||
import time
|
||||
import logging
|
||||
@@ -17,7 +17,7 @@ class Camera:
|
||||
high_quality_compression_pct=85,
|
||||
debug = False,
|
||||
**kwargs):
|
||||
logger.debug("Initializing camera")
|
||||
logger.info("Initializing camera", extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
time.sleep(1)
|
||||
self.low_quality_resolution = low_quality_resolution
|
||||
self.low_quality_compression_pct = low_quality_compression_pct
|
||||
@@ -25,14 +25,14 @@ class Camera:
|
||||
self.high_quality_compression_pct = high_quality_compression_pct
|
||||
self.kwargs=kwargs
|
||||
self._debug = debug
|
||||
if self._debug == False:
|
||||
if not self._debug:
|
||||
import picamera
|
||||
self._cam = picamera.PiCamera(resolution=high_quality_resolution)
|
||||
# if "vflip" in kwargs.keys():
|
||||
for k in kwargs.keys():
|
||||
setattr(self._cam, k, kwargs.get(k))
|
||||
|
||||
logger.debug("Camera intialized")
|
||||
logger.debug("Camera intialized", extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
pass
|
||||
|
||||
@property
|
||||
@@ -46,7 +46,7 @@ class Camera:
|
||||
r = {}
|
||||
if not self._debug:
|
||||
if not no_high_quality:
|
||||
logger.debug('Taking high quality photo')
|
||||
logger.debug('Taking high quality photo', extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
self._cam.capture("temp_img_hi.jpg",
|
||||
resize=self.high_quality_resolution,
|
||||
quality=self.high_quality_compression_pct,
|
||||
@@ -56,7 +56,7 @@ class Camera:
|
||||
# img_hi = base64.b64encode(f.read())
|
||||
img_hi = str(base64.b64encode(f.read()),'ascii')
|
||||
r['hi']=("{}_hi.jpg".format(name), img_hi, "image/jpeg")
|
||||
logger.debug('High quality photo taken')
|
||||
logger.debug('High quality photo taken', extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
|
||||
if not no_low_quality:
|
||||
time.sleep(1)
|
||||
@@ -70,29 +70,31 @@ class Camera:
|
||||
img_lo = str(base64.b64encode(f.read()),'ascii')
|
||||
# img_lo = str(f.read())
|
||||
r['lo']=("{}_lo.jpg".format(name), img_lo, "image/jpeg")
|
||||
logger.debug('Low quality photo taken')
|
||||
logger.debug('Low quality photo taken', extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
else:
|
||||
if not no_high_quality:
|
||||
with open("temp_img_hi.jpg", 'rb') as f:
|
||||
img_hi = str(base64.b64encode(f.read()),'ascii')
|
||||
# img_hi = str(f.read(),'ascii')
|
||||
r['hi']=("{}_hi.jpg".format(name), img_hi, "image/jpeg")
|
||||
logger.info('High quality photo taken')
|
||||
logger.info('High quality photo taken', extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
|
||||
if not no_low_quality:
|
||||
with open("temp_img_lo.jpg", 'rb') as f:
|
||||
img_lo = str(base64.b64encode(f.read()),'ascii')
|
||||
# img_lo = str(f.read())
|
||||
r['lo']=("{}_lo.jpg".format(name), img_lo, "image/jpeg")
|
||||
logger.info('Low quality photo taken')
|
||||
logger.info('Low quality photo taken', extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
|
||||
return r
|
||||
|
||||
class Barometer:
|
||||
def __init__(self):
|
||||
logger.debug("Intializing barometer")
|
||||
self.bmp = BMP085.BMP085()
|
||||
logger.debug("Barometer intilized")
|
||||
def __init__(self, debug=False):
|
||||
logger.debug("Intializing barometer", extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
if not debug:
|
||||
import Adafruit_BMP.BMP085 as BMP085
|
||||
self.bmp = BMP085.BMP085()
|
||||
logger.debug("Barometer intilized", extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
pass
|
||||
|
||||
@property
|
||||
@@ -126,16 +128,21 @@ class Barometer:
|
||||
return alt
|
||||
|
||||
def read(self):
|
||||
logger.debug("Reading from barometer")
|
||||
logger.debug("Reading from barometer", extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
#refresh each instrument
|
||||
alt = self.altitude
|
||||
press = self.pressure
|
||||
temp = self.temperature
|
||||
if not debug:
|
||||
alt = self.altitude
|
||||
press = self.pressure
|
||||
temp = self.temperature
|
||||
else:
|
||||
temp = random()*100
|
||||
press = random()
|
||||
alt = random()*100000
|
||||
result = {"a":alt,
|
||||
"t":temp,
|
||||
"p":press,
|
||||
}
|
||||
logger.debug("Barometer reads {}".format(result))
|
||||
logger.debug("Barometer reads {}".format(result), extra={'MISSION_TIME': "", 'MISSION_ID':""})
|
||||
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user