当前位置: 首页>>代码示例>>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;未经允许,请勿转载。