當前位置: 首頁>>代碼示例>>Python>>正文


Python machine.deepsleep方法代碼示例

本文整理匯總了Python中machine.deepsleep方法的典型用法代碼示例。如果您正苦於以下問題:Python machine.deepsleep方法的具體用法?Python machine.deepsleep怎麽用?Python machine.deepsleep使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在machine的用法示例。


在下文中一共展示了machine.deepsleep方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: restart

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def restart():
    machine.deepsleep(1) 
開發者ID:IBM-Developer-Korea,項目名稱:developer-badge-2018-apps,代碼行數:4,代碼來源:util.py

示例2: deep_sleep

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def deep_sleep(self, seconds: Optional[float] = None, **kwargs):
        """
        Stops execution in an attempt to enter a low power state.
        A deepsleep may not retain RAM or any other state of the system (for example peripherals or network interfaces).
        Upon wake execution is resumed from the main script, similar to a hard or power-on reset.

        :param seconds: Sleep seconds (default: sleep until there are some PIN/RTC events to process)
        :param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.execute`.
        """
        code = '''
import machine
machine.deepsleep({msec})
'''.format(msec=int(seconds * 1000) if seconds else '')

        return self.execute(code, wait_response=False, **kwargs).output 
開發者ID:BlackLight,項目名稱:platypush,代碼行數:17,代碼來源:__init__.py

示例3: tear_down

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def tear_down(timer, initial_time_remaining):
    timer.stop()
    elapsed_ms = int(timer.read()*1000)
    timer.reset()
    time_remaining = initial_time_remaining - elapsed_ms
    print('sleeping for {}ms ({})'.format(time_remaining, ertc.get_time()))

    # deepsleep_pin = Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP)
    # machine.pin_deepsleep_wakeup(pins=[deepsleep_pin], mode=machine.WAKEUP_ALL_LOW, enable_pull=True)
    machine.deepsleep(time_remaining)


######################
#  External RTC
###################### 
開發者ID:ayoy,項目名稱:upython-aq-monitor,代碼行數:17,代碼來源:main.py

示例4: go_deepsleep

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def go_deepsleep(t):
    """Deep sleep helper that also powers down the on-board Dotstar."""
    set_dotstar_power(False)
    machine.deepsleep(t) 
開發者ID:tinypico,項目名稱:tinypico-micropython,代碼行數:6,代碼來源:tinypico.py

示例5: deep_sleep

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def deep_sleep(secs) :
    import machine

    # configure RTC.ALARM0 to be able to wake the device
    rtc = machine.RTC()
    rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)

    # set RTC.ALARM0 to fire after 10 seconds (waking the device)
    rtc.alarm(rtc.ALARM0, secs)

    # put the device to sleep
    machine.deepsleep() 
開發者ID:fadushin,項目名稱:esp8266,代碼行數:14,代碼來源:util_old.py

示例6: deepsleep

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def deepsleep(sleeping_time, wait_before_sleep=None, event=None):
    if wait_before_sleep is not None:
        await asyncio.sleep(wait_before_sleep)
    if event is not None:
        await event
    if platform == "esp32_LoBo":
        machine.deepsleep(int(sleeping_time * 1000))
    else:
        rtc = machine.RTC()
        rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
        rtc.alarm(rtc.ALARM0, int(sleeping_time * 1000))
        machine.deepsleep() 
開發者ID:kevinkk525,項目名稱:pysmartnode,代碼行數:14,代碼來源:deepsleep.py

示例7: sleep

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def sleep(self, milliseconds):
        # To be able to use this fea
        import machine

        # configure RTC.ALARM0 to be able to wake the device
        rtc = machine.RTC()
        rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)

        # set RTC.ALARM0 to fire after some milliseconds
        rtc.alarm(rtc.ALARM0, milliseconds)

        # put the device to sleep
        machine.deepsleep() 
開發者ID:idimitrakopoulos,項目名稱:illuminOS,代碼行數:15,代碼來源:Board.py

示例8: set_wakeup_mode

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def set_wakeup_mode(self):
        """ """

        # Set wake up parameters.
        """
        The arguments are:

        - pins: a list or tuple containing the GPIO to setup for deepsleep wakeup.

        - mode: selects the way the configured GPIOs can wake up the module.
          The possible values are: machine.WAKEUP_ALL_LOW and machine.WAKEUP_ANY_HIGH.

        - enable_pull: if set to True keeps the pull up or pull down resistors enabled
          during deep sleep. If this variable is set to True, then ULP or capacitive touch
          wakeup cannot be used in combination with GPIO wakeup.

        -- https://community.hiveeyes.org/t/deep-sleep-with-fipy-esp32-on-micropython/1792/12

        This will yield a wake up reason like::

            'wakeup_reason': {'code': 1, 'message': 'PIN'}

        """

        # Todo: ``enable_pull`` or not?

        # From documentation.
        # machine.pin_sleep_wakeup(pins=['P8'], mode=machine.WAKEUP_ALL_LOW, enable_pull=True)

        # Let's try.
        #log.info('Configuring Pin 4 for wakeup from deep sleep')
        #machine.pin_sleep_wakeup(pins=['P4'], mode=machine.WAKEUP_ALL_LOW, enable_pull=True)
        #machine.pin_sleep_wakeup(pins=['P4'], mode=machine.WAKEUP_ANY_HIGH, enable_pull=True)
        pass 
開發者ID:hiveeyes,項目名稱:terkin-datalogger,代碼行數:36,代碼來源:device.py

示例9: power_off_lte_modem

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def power_off_lte_modem(self):
        """
        We don't use LTE yet.

        Important
        =========
        Once the LTE radio is initialized, it must be de-initialized
        before going to deepsleep in order to ensure minimum power consumption.
        This is required due to the LTE radio being powered independently and
        allowing use cases which require the system to be taken out from
        deepsleep by an event from the LTE network (data or SMS received for
        instance).

        Note
        ====
        When using the expansion board and the FiPy together, the RTS/CTS
        jumpers MUST be removed as those pins are being used by the LTE radio.
        Keeping those jumpers in place will lead to erratic operation and
        higher current consumption specially while in deepsleep.

        -- https://forum.pycom.io/topic/3090/fipy-current-consumption-analysis/17

        See also
        ========
        - https://community.hiveeyes.org/t/lte-modem-des-pycom-fipy-komplett-stilllegen/2161
        - https://forum.pycom.io/topic/4877/deepsleep-on-batteries/10
        """

        log.info('Turning off LTE modem')
        try:
            import pycom
            from network import LTE

            log.info('Turning off LTE modem on boot')
            pycom.lte_modem_en_on_boot(False)

            # Disables LTE modem completely. This presumably reduces the power
            # consumption to the minimum. Call this before entering deepsleep.
            log.info('Invoking LTE.deinit()')
            lte = LTE()
            lte.deinit(detach=False, reset=True)

        except Exception as ex:
            log.exc(ex, 'Shutting down LTE modem failed') 
開發者ID:hiveeyes,項目名稱:terkin-datalogger,代碼行數:46,代碼來源:device.py

示例10: hibernate

# 需要導入模塊: import machine [as 別名]
# 或者: from machine import deepsleep [as 別名]
def hibernate(self, interval, lightsleep=False, deepsleep=False):
        """

        :param interval:
        :param lightsleep:  (Default value = False)
        :param deepsleep:  (Default value = False)

        """

        #logging.enable_logging()

        if deepsleep:

            # Prepare and invoke deep sleep.
            # https://docs.micropython.org/en/latest/library/machine.html#machine.deepsleep

            log.info('Preparing deep sleep')

            # Set wake up mode.
            self.set_wakeup_mode()

            # Invoke deep sleep.
            log.info('Entering deep sleep for {} seconds'.format(interval))
            #self.terminal.stop()
            machine.deepsleep(int(interval * 1000))

        else:

            # Adjust watchdog for interval.
            self.watchdog.adjust_for_interval(interval)

            # Invoke light sleep.
            # https://docs.micropython.org/en/latest/library/machine.html#machine.sleep
            # https://docs.micropython.org/en/latest/library/machine.html#machine.lightsleep
            #
            # As "machine.sleep" seems to be a noop on Pycom MicroPython,
            # we will just use the regular "time.sleep" here.
            # machine.sleep(int(interval * 1000))
            machine.idle()

            if lightsleep:
                log.info('Entering light sleep for {} seconds'.format(interval))
                machine.sleep(int(interval * 1000))

            else:
                # Normal wait.
                log.info('Waiting for {} seconds'.format(interval))
                time.sleep(interval) 
開發者ID:hiveeyes,項目名稱:terkin-datalogger,代碼行數:50,代碼來源:device.py


注:本文中的machine.deepsleep方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。