Ejemplo n.º 1
0
 def waitForEvent(self, emptyBuffer=False):
     jevent = self.sense.stick.wait_for_event(emptybuffer=emptyBuffer)
     evtInstance = Event(
         'com.apamax.sensehat.InputEvent', {
             "actionValue": jevent.action,
             "directionValue": jevent.direction,
             "timestamp": jevent.timestamp
         })
     return evtInstance
Ejemplo n.º 2
0
	def _createDeviceEvent(self, addr, dev):
		asyncio.run(dev.update())
		self.devices[addr] = dev;
		return Event("kasa.Device", {
			"address":addr, 
			"id":dev.device_id, 
			"powerState":dev.is_on,
			"model":dev.model,
			"deviceType":str(dev.device_type),
			"sysinfo":dev.sys_info,
			"hwinfo":dev.hw_info,
		})
Ejemplo n.º 3
0
 def getAccelerometerRaw(self):
     '''		
  	Gets the raw x, y and z axis accelerometer data    
  	@return event representing the acceleration intensity of the axis in Gs
  
  	'''
     x, y, z = sense.get_accelerometer_raw().values()
     evtInstance = Event('com.apamax.sensehat.IMUDataRaw', {
         "x": x,
         "y": y,
         "z": z
     })
     return evtInstance
Ejemplo n.º 4
0
 def getGyroscopeRaw(self):
     '''		
  	Gets the raw x, y and z axis gyroscope data     
  	@return event representing the rotational intensity of the axis in radians per second
  
  	'''
     x, y, z = sense.get_gyroscope_raw().values()
     evtInstance = Event('com.apamax.sensehat.IMUDataRaw', {
         "x": x,
         "y": y,
         "z": z
     })
     return evtInstance
Ejemplo n.º 5
0
    def getOrientation(self):
        '''
     	@return event with pitch, roll and yaw representing the angle of the axis in degrees
     
		'''

        pitch, roll, yaw = self.sense.get_orientation().values()
        evtInstance = Event('com.apamax.sensehat.IMUData', {
            "pitch": pitch,
            "roll": roll,
            "yaw": yaw
        })
        return evtInstance
Ejemplo n.º 6
0
    def getEvents(self):

        events = list()
        for event in self.sense.stick.get_events():
            evtInstance = Event(
                'com.apamax.sensehat.InputEvent', {
                    "actionValue": jevent.action,
                    "directionValue": jevent.direction,
                    "timestamp": jevent.timestamp
                })
            events.append(evtInstance)

        return events
Ejemplo n.º 7
0
    def getCompassRaw(self):
        '''
		
     	Gets the raw x, y and z axis magnetometer data     
     	@return event representing the magnetic intensity of the axis in microteslas (uT)
     
     	'''
        x, y, z = self.sense.get_compass_raw().values()
        evtInstance = Event('com.apamax.sensehat.IMUDataRaw', {
            "x": x,
            "y": y,
            "z": z
        })
        return evtInstance
Ejemplo n.º 8
0
    def getOrientationDegrees(self):
        '''		
     	Gets the current orientation in degrees using the aircraft principal axes of pitch, roll and yaw
     
     	@return event with pitch, roll and yaw values. Values are Floats representing the angle of the axis in degrees
     
		'''

        pitch, roll, yaw = self.sense.get_orientation_degrees().values()
        evtInstance = Event('com.apamax.sensehat.IMUData', {
            "pitch": pitch,
            "roll": roll,
            "yaw": yaw
        })
        return evtInstance
Ejemplo n.º 9
0
    def getAccelerometer(self):
        '''
		Calls set_imu_config in Python core to disable the magnetometer and gyroscope
        then gets the current orientation from the accelerometer only
     
        @return Object representing the angle of the axis in degrees
             
		'''

        pitch, roll, yaw = self.sense.get_accelerometer().values()
        evtInstance = Event('com.apamax.sensehat.IMUData', {
            "pitch": pitch,
            "roll": roll,
            "yaw": yaw
        })
        return evtInstance
Ejemplo n.º 10
0
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)
Ejemplo n.º 12
0
def pushed_right(event):
    if event.action == ACTION_RELEASED:
        joyevt = Event('Control', {"controlType": 4})
        Correlator.sendTo("monitor_messages", joyevt)
Ejemplo n.º 13
0
	def _sendResponseEvent(self, channel, eventType, body):
		Correlator.sendTo(channel, Event(eventType, body))
Ejemplo n.º 14
0
 def pushed_right(event):
     if event.action == ACTION_RELEASED:
         joyevt = Event('com.apamax.sensehat.JoystickControl',
                        {"controlType": 4})
         Correlator.sendTo("sensedhat_data", joyevt)