def poll(plugin, interval): while (True): try: doWaitCursor(8) #2 secs plugin.getLogger().info( "TemperatureMonitor Thread triggers every " + str(interval) + " secs") evt = Event('Temperature', {"reading": sense.temp}) Correlator.sendTo("monitor_messages", evt) showTemp() doWaitCursor(8) #2 secs showSystemStatus(plugin) except: plugin.getLogger().error("Poll Thread Exception: %s", sys.exc_info()[1]) time.sleep(interval)
def pollTemperature(plugin, interval): #temperatures = [32.6, 32.8, 32.9, 32.4, 32.7, 32.8, 32.6, 45] #temperatureIdx = 0 plugin.getLogger().info("***** Temperature is read every " + str(interval) + " seconds") while(True): try: #temperature = temperatures[temperatureIdx] #temperatureIdx = temperatureIdx + 1 #if temperatureIdx > len(temperatures) -1: # temperatureIdx = 0 temperature = round(getTemperatureFromSenseHat(),2) plugin.getLogger().info("temperature is " + str(temperature)) evt = Event('Temperature', {"reading": str(temperature)}) Correlator.sendTo("monitor_messages", evt) except: plugin.getLogger().error("Poll Thread exception: %s", sys.exc_info()[1]) time.sleep(interval)
def pushed_right(event): if event.action == ACTION_RELEASED: joyevt = Event('Control', {"controlType": 4}) Correlator.sendTo("monitor_messages", joyevt)
def _sendResponseEvent(self, channel, eventType, body): Correlator.sendTo(channel, Event(eventType, body))
def pushed_right(event): if event.action == ACTION_RELEASED: joyevt = Event('com.apamax.sensehat.JoystickControl', {"controlType": 4}) Correlator.sendTo("sensedhat_data", joyevt)