def heightGetValue(): """ Get plant, lamp height, update database, adjust height. """ lightStartup.wait() plantHeight = pyCamera.getCameraData() lampHeight = serialRequest('LH') writeDatabase(plantHeight, lampHeight, writeTable='height') heightDiff = readDatabase(readTable='user_height') desiredLampHeight = plantHeight + heightDiff[0] difference = abs(float(lampHeight) - desiredLampHeight) shiftDistance = "%d" % (difference) if lampHeight > desiredLampHeight: response = serialRequest('L+' + shiftDistance) elif lampHeight < desiredLampHeight: response = serialRequest('L-' + shiftDistance) lightStartup.clear() heightGetValue()
def heightGetValue(): """ Get plant, lamp height, update database, adjust height. """ lightStartup.wait() plantHeight = pyCamera.getCameraData() lampHeight = serialRequest('LH') writeDatabase(plantHeight, lampHeight, writeTable = 'height') heightDiff = readDatabase(readTable = 'user_height') desiredLampHeight = plantHeight + heightDiff[0] difference = abs(float(lampHeight) - desiredLampHeight) shiftDistance = "%d" % (difference) if lampHeight > desiredLampHeight: response = serialRequest('L-' + shiftDistance) elif lampHeight < desiredLampHeight: response = serialRequest('L+' + shiftDistance) lightStartup.clear() heightGetValue()
import pyCamera as cam plant_height_mm = cam.getCameraData() print plant_height_mm