當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。