コード例 #1
0
	def __init__(self):
		super(HeartRateDownEmulatorTask, self).__init__(actuatorType=ActuatorData.HEART_RATE_ACTUATOR_TYPE_DOWN, simpleName="HEART_RATE_ACTUATOR_TYPE_DOWN", actuatorName = ConfigConst.HEART_RATE_DOWN_ACTUATOR_NAME)
		self.sh = SenseHAT(emulate=True)
		configUtil = ConfigUtil()
		flag = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)
		if flag:
			self.sh = SenseHAT(emulate=True)
		else:
			self.sh = SenseHAT(emulate=False)
コード例 #2
0
	def __init__(self):
		super(LedDisplayEmulatorTask, self).__init__(actuatorType=ActuatorData.LED_DISPLAY_ACTUATOR_TYPE,
													 simpleName="LED_Display", actuatorName = ConfigConst.LED_ACTUATOR_NAME)
		self.sh = SenseHAT(emulate=True)
		configUtil = ConfigUtil()
		flag = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)
		if flag:
			self.sh = SenseHAT(emulate=True)
		else:
			self.sh = SenseHAT(emulate=False)
	def __init__(self, dataSet=None):
		super(BodyTemperatureSensorEmulatorTask, self).__init__(SensorData.BODY_TEMP_SENSOR_TYPE,
															minVal=SensorDataGenerator.LOW_NORMAL_INDOOR_TEMP,
															maxVal=SensorDataGenerator.HI_NORMAL_INDOOR_TEMP,
															sensorName= ConfigConst.BODY_TEMP_SENSOR_NAME)
		self.sh = SenseHAT(emulate=True)
		configUtil = ConfigUtil()
		flag = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)
		if flag:
			self.sh = SenseHAT(emulate=True)
		else:
			self.sh = SenseHAT(emulate=False)
 def __init__(self):
     super(BodyTemperatureUpEmulatorTask, self).__init__(
         actuatorType=ActuatorData.BODY_TEMP_ACTUATOR_TYPE_UP,
         simpleName="BODY_TEMP_ACTUATOR_TYPE_UP",
         actuatorName=ConfigConst.BODY_TEMP_UP_ACTUATOR_NAME)
     self.sh = SenseHAT(emulate=True)
     configUtil = ConfigUtil()
     flag = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE,
                                  ConfigConst.ENABLE_SENSE_HAT_KEY)
     if flag:
         self.sh = SenseHAT(emulate=True)
     else:
         self.sh = SenseHAT(emulate=False)
	def __init__(self):
		super(HumidifierEmulatorTask, self).__init__(actuatorType = ActuatorData.HUMIDIFIER_ACTUATOR_TYPE, simpleName = "HUMIDIFIER")
		if(ConfigConst.ENABLE_SENSE_HAT_KEY == True):
			self.enableEmulation = True
		elif(ConfigConst.ENABLE_SENSE_HAT_KEY == False):
			self.enableEmulation = False
		self.sh = SenseHAT(emulate = self.enableEmulation)
コード例 #6
0
	def __init__(self, dataSet = None):
		super(TemperatureSensorEmulatorTask, self).__init__(SensorData.TEMP_SENSOR_TYPE, minVal = SensorDataGenerator.LOW_NORMAL_INDOOR_TEMP, maxVal = SensorDataGenerator.HI_NORMAL_INDOOR_TEMP)
		if(ConfigConst.ENABLE_SENSE_HAT_KEY == True):
			self.enableEmulation = True
		elif(ConfigConst.ENABLE_SENSE_HAT_KEY == False):
			self.enableEmulation = False
		self.sh = SenseHAT(emulate = self.enableEmulation)
    def __init__(self, dataSet=None):
        super(HeartRateSensorEmulatorTask, self).__init__(SensorData.HEART_RATE_SENSOR_TYPE,
                                                         minVal=SensorDataGenerator.LOW_NORMAL_ENV_HUMIDITY,
                                                         maxVal=SensorDataGenerator.HI_NORMAL_ENV_HUMIDITY,
                                                         sensorName=ConfigConst.HEART_RATE_SENSOR_NAME)
        # Create an instance of SenseHAT and set the emulate flag to True if running the emulator, or False if using real hardware
        # This can be read from ConfigUtil using the ConfigConst.CONSTRAINED_DEVICE section and the ConfigConst.ENABLE_SENSE_HAT_KEY
        # If the ConfigConst.ENABLE_SENSE_HAT_KEY is False, set the emulate flag to True, otherwise set to False
        self.sh = SenseHAT(emulate=True)
        configUtil = ConfigUtil()
        flag = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)

        if flag:
            self.sh = SenseHAT(emulate=True)
        else:
            self.sh = SenseHAT(emulate=False)
コード例 #8
0
 def __init__(self):
     super(BloodPressureUpEmulatorTask, self).__init__(
         actuatorType=ActuatorData.BLOOD_PRESSURE_ACTUATOR_TYPE_UP,
         simpleName="BLOOD_PRESSURE_ACTUATOR_TYPE_UP",
         actuatorName=ConfigConst.BLOOD_PRESSURE_UP_ACTUATOR_NAME)
     # Create an instance of SenseHAT and set the emulate flag to True if running the emulator, or False if using real hardware
     # This can be read from ConfigUtil using the ConfigConst.CONSTRAINED_DEVICE section and the ConfigConst.ENABLE_SENSE_HAT_KEY
     # If the ConfigConst.ENABLE_SENSE_HAT_KEY is False, set the emulate flag to True, otherwise set to False
     self.sh = SenseHAT(emulate=True)
     configUtil = ConfigUtil()
     flag = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE,
                                  ConfigConst.ENABLE_SENSE_HAT_KEY)
     if flag:
         self.sh = SenseHAT(emulate=True)
     else:
         self.sh = SenseHAT(emulate=False)
コード例 #9
0
 def __init__(self):
     super(HvacEmulatorTask,
           self).__init__(actuatorType=ActuatorData.HVAC_ACTUATOR_TYPE,
                          simpleName="HVAC")
     enableEmulation = False
     if ConfigConst.ENABLE_SENSE_HAT_KEY == True:
         enableEmulation = True
     self.sh = SenseHAT(emulate=enableEmulation)
コード例 #10
0
 def setUpClass(self):
     logging.basicConfig(
         format='%(asctime)s:%(module)s:%(levelname)s:%(message)s',
         level=logging.DEBUG)
     logging.info(
         "Testing SenseHatEmulatorQuickTest class [using SenseHAT emulator]..."
     )
     self.sh = SenseHAT(emulate=True)
 def __init__(self):
     super(LedDisplayEmulatorTask, self).__init__(
         actuatorType=ActuatorData.LED_DISPLAY_ACTUATOR_TYPE,
         simpleName="LED_Display")
     if (ConfigConst.ENABLE_SENSE_HAT_KEY == True):
         self.enableEmulation = True
     elif (ConfigConst.ENABLE_SENSE_HAT_KEY == False):
         self.enableEmulation = False
     self.sh = SenseHAT(emulate=self.enableEmulation)
 def __init__(self, dataSet=None):
     super(PressureSensorEmulatorTask, self).__init__(
         SensorData.PRESSURE_SENSOR_TYPE,
         minVal=SensorDataGenerator.LOW_NORMAL_ENV_PRESSURE,
         maxVal=SensorDataGenerator.HI_NORMAL_ENV_PRESSURE)
     if (ConfigConst.ENABLE_SENSE_HAT_KEY == True):
         self.enableEmulation = True
     elif (ConfigConst.ENABLE_SENSE_HAT_KEY == False):
         self.enableEmulation = False
     self.sh = SenseHAT(emulate=self.enableEmulation)
 def __init__(self, dataSet=None):
     super(HumiditySensorEmulatorTask, self).__init__(
         SensorData.HUMIDITY_SENSOR_TYPE,
         minVal=SensorDataGenerator.LOW_NORMAL_ENV_HUMIDITY,
         maxVal=SensorDataGenerator.HI_NORMAL_ENV_HUMIDITY)
     if (ConfigConst.ENABLE_SENSE_HAT_KEY == True):
         self.enableEmulation = True
     elif (ConfigConst.ENABLE_SENSE_HAT_KEY == False):
         self.enableEmulation = False
     self.sh = SenseHAT(emulate=self.enableEmulation)
コード例 #14
0
	def __init__(self, dataSet = None):
		super(PressureSensorEmulatorTask, self).__init__(SensorData.PRESSURE_SENSOR_TYPE, minVal = SensorDataGenerator.LOW_NORMAL_ENV_PRESSURE, maxVal = SensorDataGenerator.HI_NORMAL_ENV_PRESSURE)
		configUtil = ConfigUtil()
		#get ENABLE_SENSE_HAT_KEY value (bool)
		enableSenseHAT = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)
		if enableSenseHAT is False:
			enableEmulation = True
		else:
			enableEmulation = False
		# create senseHAT instance
		self.sh = SenseHAT(emulate=enableEmulation)
コード例 #15
0
ファイル: monitor_final.py プロジェクト: cajturner/pisense-1
def main():
    with SenseHAT() as hat:
        hat.stick.stream = True
        for a, anim in switcher(hat.stick, hat.environ):
            if anim == 'fade':
                hat.screen.fade_to(a, duration=0.5)
            elif anim == 'right':
                hat.screen.slide_to(a, direction='left', duration=0.5)
            elif anim == 'left':
                hat.screen.slide_to(a, direction='right', duration=0.5)
            else:
                hat.screen.array = a
コード例 #16
0
    def __call__(self, args=None):
        parser = terminal.configure_parser(__doc__, log_params=False)
        parser.add_argument(
            '--status-queue',
            metavar='ADDR',
            default=const.STATUS_QUEUE,
            help="The address of the queue used to report status to monitors "
            "(default: %(default)s)")
        parser.add_argument(
            '--control-queue',
            metavar='ADDR',
            default=const.CONTROL_QUEUE,
            dest='master_queue',
            help="The address of the queue a monitor can use to control the "
            "master (default: %(default)s)")
        parser.add_argument(
            '-r',
            '--rotate',
            metavar='DEGREES',
            default=0,
            type=int,
            help="The rotation of the HAT in degrees; must be 0 (the default) "
            "90, 180, or 270")
        try:
            config = parser.parse_args(args)
            config.control_queue = 'inproc://quit'
        except:  # pylint: disable=bare-except
            return terminal.error_handler(*sys.exc_info())

        with SenseHAT() as hat:
            hat.rotation = config.rotate
            ctx = transport.Context()
            quit_queue = ctx.socket(transport.PULL,
                                    protocol=protocols.task_control)
            quit_queue.bind(config.control_queue)
            try:
                stick = StickTask(config, hat)
                stick.start()
                screen = ScreenTask(config, hat)
                screen.start()
                msg, data = quit_queue.recv_msg()
                assert msg == 'QUIT'
                #signal.sigwait({signal.SIGINT, signal.SIGTERM})
            except KeyboardInterrupt:
                pass
            finally:
                screen.quit()
                screen.join()
                stick.quit()
                stick.join()
                ctx.close()
                hat.screen.fade_to(array(Color('black')))
コード例 #17
0
	def __init__(self):
		super(HumidifierEmulatorTask, self).__init__(actuatorType = ActuatorData.HUMIDIFIER_ACTUATOR_TYPE, simpleName = "HUMIDIFIER")
		# Create an instance of SenseHAT and set the emulate flag to True if running the emulator, or False if using real hardware
		# This can be read from ConfigUtil using the ConfigConst.CONSTRAINED_DEVICE section and the ConfigConst.ENABLE_SENSE_HAT_KEY
		# If the ConfigConst.ENABLE_SENSE_HAT_KEY is False, set the emulate flag to True, otherwise set to False
		configUtil = ConfigUtil()
		#get ENABLE_SENSE_HAT_KEY value (bool)
		enableSenseHAT = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)
		if enableSenseHAT is False:
			enableEmulation = True
		else:
			enableEmulation = False
		# create senseHAT instance
		self.sh = SenseHAT(emulate=enableEmulation)
コード例 #18
0
 def __init__(self):
     """
     Initialization of class.
     Create an instance of HvacEmulatorTask
     """
     super(SprinklerMasterEmulatorTask, self).__init__(actuatorType = ActuatorData.SPRINKLER_MASTER_ACTUATOR_TYPE, simpleName = "SPRI_MASTER")
     # Create an instance of SenseHAT and set the emulate flag to True if running the emulator, or False if using real hardware
     # This can be read from ConfigUtil using the ConfigConst.CONSTRAINED_DEVICE section and the ConfigConst.ENABLE_SENSE_HAT_KEY
     # If the ConfigConst.ENABLE_SENSE_HAT_KEY is False, set the emulate flag to True, otherwise set to False
     configUtil = ConfigUtil()
     if configUtil.getBoolean(section= ConfigConst.CONSTRAINED_DEVICE, key= ConfigConst.ENABLE_SENSE_HAT_KEY):
         enableEmulation = False 
     else:
         enableEmulation = True
     
     self.sh = SenseHAT(emulate = enableEmulation)
コード例 #19
0
 def __init__(self):
     """
     Constructor of HvacEmulatorTask.
     Init emulated or not SenseHAT instance according to config.
     """
     super(HvacEmulatorTask, self).__init__(actuatorType=ActuatorData.HVAC_ACTUATOR_TYPE,
                                            simpleName=ConfigConst.HVAC_ACTUATOR_NAME)
     self.enableEmulation = True
     configUtil = ConfigUtil()
     enableSenseHAT = configUtil.getBoolean(ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)
     if enableSenseHAT is True:
         self.enableEmulation = False
     else:
         self.enableEmulation = True
     self.sh = SenseHAT(emulate=self.enableEmulation)
     pass
     pass
コード例 #20
0
    def __call__(self, args=None):
        parser = terminal.configure_parser(__doc__, log_params=False)
        parser.add_argument(
            '--status-queue',
            metavar='ADDR',
            default=const.STATUS_QUEUE,
            help="The address of the queue used to report status to monitors "
            "(default: %(default)s)")
        parser.add_argument(
            '--control-queue',
            metavar='ADDR',
            default=const.CONTROL_QUEUE,
            help="The address of the queue a monitor can use to control the "
            "master (default: %(default)s)")
        parser.add_argument(
            '-r',
            '--rotate',
            metavar='DEGREES',
            default=0,
            type=int,
            help="The rotation of the HAT in degrees; must be 0 (the default) "
            "90, 180, or 270")
        try:
            config = parser.parse_args(args)
        except:  # pylint: disable=bare-except
            return terminal.error_handler(*sys.exc_info())

        with SenseHAT() as hat:
            hat.rotation = config.rotate
            ctx = zmq.Context()
            try:
                stick = StickTask(config, hat)
                stick.start()
                screen = ScreenTask(config, hat)
                screen.start()
                signal.sigwait({signal.SIGINT, signal.SIGTERM})
            except KeyboardInterrupt:
                pass
            finally:
                screen.quit()
                screen.join()
                stick.quit()
                stick.join()
                ctx.destroy(linger=1000)
                ctx.term()
                hat.screen.fade_to(array(Color('black')))
コード例 #21
0
	def __init__(self, dataSet = None):
		"""
		Initialization of class.
		Create an instance of TemperatureSensorEmulatorTask
		"""
		# Create an instance of SenseHAT and set the emulate flag to True if running the emulator, or False if using real hardware
		# This can be read from ConfigUtil using the ConfigConst.CONSTRAINED_DEVICE section and the ConfigConst.ENABLE_SENSE_HAT_KEY
		# If the ConfigConst.ENABLE_SENSE_HAT_KEY is False, set the emulate flag to True, otherwise set to False
		super(TemperatureSensorEmulatorTask, self).__init__(SensorData.TEMP_SENSOR_TYPE, minVal = SensorDataGenerator.LOW_NORMAL_ENV_TEMP, maxVal = SensorDataGenerator.HI_NORMAL_ENV_TEMP)
		
		configUtil = ConfigUtil()
		if configUtil.getBoolean(section= ConfigConst.CONSTRAINED_DEVICE, key= ConfigConst.ENABLE_SENSE_HAT_KEY):
			enableEmulation = False 
		else:
			enableEmulation = True
			
		self.sh = SenseHAT(emulate = enableEmulation)
コード例 #22
0
 def __init__(self, dataSet=None):
     super(HumiditySensorEmulatorTask, self).__init__(
         SensorData.HUMIDITY_SENSOR_TYPE,
         minVal=SensorDataGenerator.LOW_NORMAL_ENV_HUMIDITY,
         maxVal=SensorDataGenerator.HI_NORMAL_ENV_HUMIDITY)
     # Create an instance of SenseHAT and set the emulate flag to True if running the emulator, or False if using real hardware
     # This can be read from ConfigUtil using the ConfigConst.CONSTRAINED_DEVICE section and the ConfigConst.ENABLE_SENSE_HAT_KEY
     # If the ConfigConst.ENABLE_SENSE_HAT_KEY is False, set the emulate flag to True, otherwise set to False
     configUtil = ConfigUtil()
     #get ENABLE_SENSE_HAT_KEY value (bool)
     enableSenseHAT = configUtil.getBoolean(
         ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)
     if enableSenseHAT is False:
         enableEmulation = True
     else:
         enableEmulation = False
     #create senseHAT instance
     self.sh = SenseHAT(emulate=enableEmulation)
 def __init__(self, dataSet=None):
     """
     Constructor of PressureSensorEmulatorTask
     Using super class constructor to init
     :param dataSet: Dict for construct object with given data
     """
     super(PressureSensorEmulatorTask, self).__init__(
         sensorType=SensorData.PRESSURE_SENSOR_TYPE,
         dataSet=dataSet,
         minVal=SensorDataGenerator.LOW_NORMAL_ENV_PRESSURE,
         maxVal=SensorDataGenerator.HI_NORMAL_ENV_PRESSURE)
     self.enableEmulation = True
     configUtil = ConfigUtil()
     enableSenseHAT = configUtil.getBoolean(
         ConfigConst.CONSTRAINED_DEVICE, ConfigConst.ENABLE_SENSE_HAT_KEY)
     if enableSenseHAT is True:
         self.enableEmulation = False
     else:
         self.enableEmulation = True
     self.sh = SenseHAT(emulate=self.enableEmulation)
     pass
コード例 #24
0
from __future__ import division  # for py2.x compatibility
from pisense import SenseHAT, array
from colorzero import Color
from time import sleep

hat = SenseHAT()
offset = 0.0
while True:
    rainbow = array([
        Color(h=(x + y) / 14 + offset, s=1, v=1) for x in range(8)
        for y in range(8)
    ])
    hat.screen.array = rainbow
    offset += 0.05
    sleep(0.05)
コード例 #25
0
 def __init__(self):
     self.hat = SenseHAT(emulate=True)
     self.hat.screen.clear()
     self.hat.environ._interval = 1
     self.running = False
     self.opentsdb = OpenTSDBClient()
コード例 #26
0
ファイル: monitor_manual.py プロジェクト: cajturner/pisense-1
def main():
    with SenseHAT() as hat:
        hat.stick.stream = True
        for a in switcher(hat.stick, hat.environ):
            hat.screen.array = a
        hat.screen.fade_to(array(Color('black')))
コード例 #27
0
ファイル: aspi.py プロジェクト: coderdojo-futurix/aspi
from threading import Timer, Thread
from queue import Queue
from collections import OrderedDict
import logzero
import os
import time
import locale
import math
import sys
import signal
import picamera
import picamera.array
import numpy as np

# Global AstroPi device objects
sense_hat = SenseHAT()
cpu = CPUTemperature()
camera = picamera.PiCamera()

# Default values
MIN_LOG_PERIOD_IN_SECS = 2
MIN_IMG_PERIOD_IN_SECS = 5
SHUTDOWN_TIMEOUT_IN_SECS = 3 * 60
DEFAULT_DURATION_IN_SECS = 3 * 60 * 60 - SHUTDOWN_TIMEOUT_IN_SECS
DEFAULT_SIZE_PER_LOGFILE_IN_BYTES = 30 * 1024 * 1024
DEFAULT_LOG_PERIOD_IN_SECS = 5
DEFAULT_IMG_PERIOD_IN_SECS = 10
DEFAULT_LOGFILE_PREFIX = "sense_hat_logger"
PICAMERA_SENSOR_MODE_2_RESOLUTION = (2592, 1944)
ASTROPI_ORIENTATION = 270
ENABLE_DEBUG = False
コード例 #28
0
ファイル: joystick_dot.py プロジェクト: cajturner/pisense-1
def movements(events):
    for event in events:
        if event.pressed:
            try:
                yield {
                    'left':  (-1, 0),
                    'right': (1, 0),
                    'up':    (0, -1),
                    'down':  (0, 1),
                }[event.direction]
            except KeyError:
                break  # enter exits

def arrays(moves):
    a = array(Color('black'))  # blank screen
    x = y = 3
    a[y, x] = Color('white')
    yield a  # initial position
    for dx, dy in moves:
        a[y, x] = Color('black')
        x = max(0, min(7, x + dx))
        y = max(0, min(7, y + dy))
        a[y, x] = Color('white')
        yield a
    a[y, x] = Color('black')
    yield a  # end with a blank display

with SenseHAT() as hat:
    for a in arrays(movements(hat.stick)):
        hat.screen.array = a
コード例 #29
0
ファイル: monitor_auto.py プロジェクト: cajturner/pisense-1
def main():
    with SenseHAT() as hat:
        for a in switcher(hat.environ):
            hat.screen.array = a