示例#1
0
	def waitForChange(self, timeState, triggerState):
		startTime = time()
		while time() - startTime < LCD_DURATION:
			if self.changeState(triggerState, startTime):
				return True
		lcd.clear()
		self.state = timeState
		return True
示例#2
0
	def closeApp(self):
		print("Bye!")
		lcd.displayString("     (.)(.)     ", 1)
		lcd.displayString("      BYE!      ", 2)
		sleep(1)
		lcd.clear()
		lcd.backlight(0)
		return False
示例#3
0
	def updateClock(self, timeState, triggerState):
		startTime = time()
		currentTime = clock.getTimeString()
		while time() - startTime < LCD_DURATION:
			if (currentTime is not clock.getTimeString()):
				currentTime = clock.getTimeString()
				lcd.displayString(currentTime, 1)
				# lcd.displayString(str(currentDistance.get()).zfill(3), 2)
				humidityString = "H:" + thSource.getHumidity() + "%"
				temperatureString = "T:" + thSource.getTemperature() + "*C"
				lcd.displayTwoElementsJustified(temperatureString, humidityString, 2, LCD_CHARINLINE)
			if self.changeState(triggerState, startTime):
				return True
		lcd.clear()
		self.state = timeState
		return True
示例#4
0
	def changeState(self, nextState, startTime):
		distance = proximitySensor.getDistance()
		if ((distance < PROXIMITY_DISTANCE) and (time() - startTime  > STATE_MACHINE_WAIT)):
			closeCount = time()
			if distance < CLOSE_DISTANCE:
				print("Distance: " + str(distance) + " Counting to close!")
				while (proximitySensor.getDistance() < CLOSE_DISTANCE):
					if time() - closeCount > CLOSE_TIME:
						self.state = 99
						lcd.clear()
						return True
				print("Closing stopped.")
			self.state = nextState
			lcd.clear()
			return True
		else:
			return False
示例#5
0
		loggingProcess = Thread(target=loggingToGoogle, args=(GDOCS_OAUTH_JSON, GDOCS_SPREADSHEET_NAME, LOGGING_FREQUENCY, thSource, weatherSource, smogSource))
		loggingProcess.daemon = True
		loggingProcess.start()

		stateMachine = stateMachine()

		print("Meteo Station started!")
		while work:
			try:
				work = stateMachine.executeState()
			except:
				work = True

		loggingProcess.stop = True
		distanceProcess.stop = True
		smogProcess.stop = True
		weatherProcess.stop = True
		thProcess.stop = True
		del proximitySensor
		del smogSource
	except:
		loggingProcess.stop = True
		distanceProcess.stop = True
		smogProcess.stop = True
		weatherProcess.stop = True
		thProcess.stop = True
		lcd.clear()
		lcd.backlight(0)
		del proximitySensor
		del smogSource