当前位置: 首页>>代码示例>>Python>>正文


Python gpiozero.LED属性代码示例

本文整理汇总了Python中gpiozero.LED属性的典型用法代码示例。如果您正苦于以下问题:Python gpiozero.LED属性的具体用法?Python gpiozero.LED怎么用?Python gpiozero.LED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gpiozero的用法示例。


在下文中一共展示了gpiozero.LED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ReadProperty

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def ReadProperty(self, obj, arrayIndex=None):
        if _debug:
            BOPresentValue._debug("ReadProperty %r arrayIndex=%r", obj, arrayIndex)

        # access an array
        if arrayIndex is not None:
            raise ExecutionError(
                errorClass="property", errorCode="propertyIsNotAnArray"
            )
        

        ###TODO: obj._led is the LED object
        if _debug:
            BOPresentValue._debug("    - read led: %r", obj._led)
        
        if obj._led.value == 1:
            return "active"
        else:
            return "inactive" 
开发者ID:JoelBender,项目名称:bacpypes,代码行数:21,代码来源:binaryio.py

示例2: startwalking

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def startwalking():
    # Make the buzzer buzz on and off, half a second of
    # sound followed by half a second of silence
    print("Start walking")
    count = 1
    while count <= 4:
        print("Beep")
        buzzer.on()
        time.sleep(0.5)
        buzzer.off()
        time.sleep(0.5)
        count += 1


# Turn the buzzer off and wait for 2 seconds
# (If you have a second green 'pedestrian' LED, make it flash on and
# off for the two seconds) 
开发者ID:CamJam-EduKit,项目名称:EduKit1,代码行数:19,代码来源:7-TrafficLights-solution.py

示例3: flashingambergreen

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def flashingambergreen():
    print("Flashing amber and green")
    red.off()
    green.off()

    iCount = 1
    while iCount <= 6:
        yellow.on()
        time.sleep(0.5)
        yellow.off()
        time.sleep(0.5)
        iCount += 1
    green.on()


# Flash the amber for one more second
# (Turn the green 'pedestrian' LED off and the red on) 
开发者ID:CamJam-EduKit,项目名称:EduKit1,代码行数:19,代码来源:7-TrafficLights-solution.py

示例4: __init__

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def __init__(self, numLeds, pinout, activeHigh):
		super(PureGPIO, self).__init__(numLeds)

		if len(pinout) != numLeds:
			raise InterfaceInitError('Pure GPIO number of led versus pinout declaration missmatch')

		self._pinout 		= pinout
		self._activeHigh 	= activeHigh
		self._image 		= self._newArray()

		self._leds 		= []
		for pin in self._pinout:
			self._leds.append(LED(pin=pin, active_high=activeHigh, initial_value=False)) 
开发者ID:project-alice-assistant,项目名称:HermesLedControl,代码行数:15,代码来源:pureGPIO.py

示例5: __init__

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def __init__(self, hardware, global_brightness=AAPA102.MAX_BRIGHTNESS, order='rgb', bus=0, device=1, max_speed_hz=8000000, endFrame=255):
		super(APA102, self).__init__(hardware['numberOfLeds'])
		self._leds  = AAPA102(hardware['numberOfLeds'], global_brightness=global_brightness, order=order, bus=bus, device=device, max_speed_hz=max_speed_hz, endFrame=endFrame)

		try:
			self._power = LED(5)
		except:
			try:
				self._power = mraa.Gpio(5)
				self._power.dir(mraa.DIR_OUT)
			except Exception as e:
				self._logger.info('Device not using gpiozero or mraa, ignore power: {}'.format(e))

		self._hardware = hardware
		self._src = None
		if hardware.get('doa'):
			self._logger.info('Hardware is DOA capable')
			from libraries.seeedstudios.channel_picker import ChannelPicker
			from libraries.seeedstudios.source import Source

			lib = importlib.import_module('libraries.seeedstudios.' + hardware['doa'])
			klass = getattr(lib, 'DOA')

			self._src = Source(rate=hardware['rate'], channels=hardware['channels'])
			ch0 = ChannelPicker(channels=self._src.channels, pick=0)

			self._doa = klass(rate=hardware['rate'])
			self._src.link(ch0)
			self._src.link(self._doa) 
开发者ID:project-alice-assistant,项目名称:HermesLedControl,代码行数:31,代码来源:apa102.py

示例6: __init__

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def __init__(self, led_id, **kwargs):
        if _debug:
            RPiBinaryOutput._debug("__init__ %r %r", led_id, kwargs)
        BinaryOutputObject.__init__(self, **kwargs)

        # make an LED object
        self._led = LED(led_id)


#
#   __main__
# 
开发者ID:JoelBender,项目名称:bacpypes,代码行数:14,代码来源:binaryio.py

示例7: __init__

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def __init__(self):

        super().__init__()

        import gpiozero
        self.LED = gpiozero.LED
        self.RGBLED = gpiozero.RGBLED
        self.Button = gpiozero.Button
        self.GPIOPinInUse = gpiozero.GPIOPinInUse

        self._buttons = []
        self._lamps = []
        self._rgb = [] 
开发者ID:reuterbal,项目名称:photobooth,代码行数:15,代码来源:__init__.py

示例8: setLamp

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def setLamp(self, bcm_pin):

        try:
            self._lamps.append(self.LED(bcm_pin))
            return len(self._lamps) - 1
        except self.GPIOPinInUse:
            logging.error('Pin {} already in use!'.format(bcm_pin))
            return None 
开发者ID:reuterbal,项目名称:photobooth,代码行数:10,代码来源:__init__.py

示例9: html_for_led

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def html_for_led(led_number):
    i = str(led_number)
    result = " <input type='button' onClick='changed(" + i + ")' value='LED " + i + "'/>"
    return result 
开发者ID:simonmonk,项目名称:raspberrypi_cookbook_ed3,代码行数:6,代码来源:ch_16_web_control.py

示例10: startgreen

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def startgreen():
    print("Green light on")
    green.on()
    yellow.off()
    red.off()


# Turn the green off and the amber on for 3 seconds
# ('Pedestrian' red LED stays lit) 
开发者ID:CamJam-EduKit,项目名称:EduKit1,代码行数:11,代码来源:7-TrafficLights-solution.py

示例11: dontwalk

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def dontwalk():
    print("Don't walk")
    buzzer.off()


# Flash the amber on and off for 6 seconds
# (And the green 'pedestrian' LED too) 
开发者ID:CamJam-EduKit,项目名称:EduKit1,代码行数:9,代码来源:7-TrafficLights-solution.py

示例12: process_accept_effects

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def process_accept_effects(selfie_mode=False, image_path='', device_id=None):

    process_accept_effects_logger = logging.getLogger('cerebro_utils.process_accept_effects')

    if not test_environment:
        led = LED(config.__GREEN_LED__)
        led.on()

    audio_prompt = "Excellent! Seems that you like this effect. Now, lets upload this selfie ..."

    speech_file_path = generate_audio(speech_text=audio_prompt, filename="like_this_text.mp3")
    process_accept_effects_logger.info("Generated Audio now. Playing audio next ...")
    play_audio(file_path=speech_file_path)
    process_accept_effects_logger.info("Audio played. Done!")

    image_path = "%s/%s.jpg" % (config.__CEREBRO_MEDIA_DIR__, "filtered_image_effects")

    process_accept_effects_logger.info("Uploading the selfie now ...")
    upload_image(image_path=image_path)
    process_accept_effects_logger.info("Selfie was uploaded now!")

    profile_prompt = "Selfie was uploaded with image effects!"

    speech_file_path = generate_audio(speech_text=profile_prompt, filename="uploaded_with_effects.mp3")
    process_accept_effects_logger.info("Generated Audio now. Playing audio next ...")
    play_audio(file_path=speech_file_path)
    process_accept_effects_logger.info("Audio played. Done!")

    if not test_environment:
        led.off()

    process_accept_effects_logger.info("Completed the accept of the effects and uploaded. done!")
    
    return True 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:36,代码来源:cerebro_utils.py

示例13: __init__

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def __init__(self, pattern=GoogleHomeLedPattern):
        self.pattern = pattern(show=self.show)
        self.dev = apa102.APA102(num_led=self.PIXELS_N)
        self.power = LED(5)
        self.power.on()
        self.queue = Queue.Queue()
        self.t4 = threading.Thread(target=self._run)
        self.t4.daemon = True
        self.t4.start()
        self.last_direction = None 
开发者ID:shivasiddharth,项目名称:GassistPi,代码行数:12,代码来源:indicator.py

示例14: main

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def main():
    # parse the command line arguments
    args = ConfigArgumentParser(description=__doc__).parse_args()

    if _debug:
        _log.debug("initialization")
    if _debug:
        _log.debug("    - args: %r", args)

    # make a device object
    this_device = LocalDeviceObject(
        objectName=args.ini.objectname,
        objectIdentifier=("device", int(args.ini.objectidentifier)),
        maxApduLengthAccepted=int(args.ini.maxapdulengthaccepted),
        segmentationSupported=args.ini.segmentationsupported,
        vendorIdentifier=int(args.ini.vendoridentifier),
    )

    # make a sample application
    this_application = BIPSimpleApplication(this_device, args.ini.address)

    # make the buttons
    for button_id, bio_id in button_list:
        bio = RPiBinaryInput(
            button_id,
            objectIdentifier=("binaryInput", bio_id),
            objectName="Button-%d" % (button_id,),
        )
        _log.debug("    - bio: %r", bio)
        this_application.add_object(bio)

    # make the LEDs
    for led_id, boo_id in led_list:
        boo = RPiBinaryOutput(
            led_id,
            objectIdentifier=("binaryOutput", boo_id),
            objectName="LED-%d" % (led_id,),
        )
        _log.debug("    - boo: %r", boo)
        this_application.add_object(boo)

    _log.debug("running")

    run()

    _log.debug("fini") 
开发者ID:JoelBender,项目名称:bacpypes,代码行数:48,代码来源:binaryio.py

示例15: startgreen

# 需要导入模块: import gpiozero [as 别名]
# 或者: from gpiozero import LED [as 别名]
def startgreen():
    # Remember all code in the function is indented

# Turn the green off and the amber on for 3 seconds
# ('Pedestrian' red LED stays lit)
def steadyamber():
    # Remember all code in the function is indented

# Turn the amber off, and then the red on for 1 second
def steadyred():
    # Remember all code in the function is indented

# Sound the buzzer for 4 seconds
# (If you have the 'pedestrian' LEDs, turn the red off and green on)
def startwalking():
    # Make the buzzer buzz on and off, half a second of
    # sound followed by half a second of silence

# Turn the buzzer off and wait for 2 seconds
# (If you have a second green 'pedestrian' LED, make it flash on and
# off for the two seconds)
def dontwalk():
    # Remember all code in the function is indented

# Flash the amber on and off for 6 seconds
# (And the green 'pedestrian' LED too)
def flashingambergreen():
    # Remember all code in the function is indented

# Flash the amber for one more second
# (Turn the green 'pedestrian' LED off and the red on)
def flashingamber():
    # Remember all code in the function is indented

# Go through the traffic light sequence by calling each function
# one after the other.
def trafficlightqequence():
    # Remember all code in the function is indented

os.system('clear')  # Clears the terminal
print("Traffic Lights")
# Initialise the traffic lights
startgreen()

# Here is the loop that waits at lease 20 seconds before
# stopping the cars if the button has been pressed
while True:  # Loop around forever
    buttonnotpressed = True  # Button has not been pressed
    start = time.time()  # Records the current time
    while buttonnotpressed:  # While the button has not been pressed
        time.sleep(0.1)  # Wait for 0.1s
        if button.ispressed:  # If the button is pressed
            now = time.time()
            buttonnotpressed = False  # Button has been pressed
            if (now - start) <= 20:  # If under 20 seconds
                time.sleep(20 - (now - start))  # Wait until 20s is up
                trafficlightqequence()  # Run the traffic light sequence 
开发者ID:CamJam-EduKit,项目名称:EduKit1,代码行数:59,代码来源:7-TrafficLights.py


注:本文中的gpiozero.LED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。