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


Python machine.reset方法代码示例

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


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

示例1: setup

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def setup(name, password, reset=True):
    if name != _cfg.config.wifi_name or \
            password != _cfg.config.wifi_pw:
        _cfg.wifi(name, password)
        print("Updated wifi config.")
        if reset:
            print("Resetting system in 3 seconds.")
            time.sleep(1)
            nr.stop()
            time.sleep(2)
            machine.reset()
        else:
            activate()

# when module loaded the first time start blocking to also bring up netrepl at
# right time 
开发者ID:ulno,项目名称:ulnoiot-upy,代码行数:18,代码来源:_wifi.py

示例2: __init__

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def __init__(self):
        super().__init__(
            id="relay", name="Wifi Power Socket", type="OW8266-02Q"
        )
        self.led = Pin(4, Pin.OUT, value=1)
        self.r_on = Pin(12, Pin.OUT)
        self.r_off = Pin(5, Pin.OUT)

        self.power_property = HomieNodeProperty(
            id="power",
            name="Relay",
            settable=True,
            retained=True,
            datatype=BOOLEAN,
            default=FALSE,
            restore=True,
        )
        self.add_property(self.power_property, self.on_power_msg)

        self.button = Pushbutton(Pin(14, Pin.IN, Pin.PULL_UP))
        self.button.release_func(self.toggle, ())
        self.button.long_func(reset, (self.led,)) 
开发者ID:microhomie,项目名称:microhomie,代码行数:24,代码来源:main.py

示例3: restart

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def restart(microWebSrv2: MicroWebSrv2, request: HttpRequest):

        TerkinHttpApi.respond_text(request, 'ACK')

        def do_reset():
            """ """
            log.info('Resetting device')
            microWebSrv2.Stop()
            machine.reset()

        try:
            import _thread
            _thread.start_new_thread(do_reset, ())
        except:
            do_reset()

    # ===========
    # Application
    # =========== 
开发者ID:hiveeyes,项目名称:terkin-datalogger,代码行数:21,代码来源:http.py

示例4: _httpHanderConfig

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def _httpHanderConfig(httpClient, httpResponse) :
	formData  = httpClient.GetRequestQueryParams()
	ssid      = formData.get("ssid")
	password  = formData.get("password")
	other_flg = formData.get("other")
	print(formData)
	content = ''
	is_connected = False

	if other_flg == 'true' or doConnect(ssid, password, False):
		is_connected = True
		saveWiFi(ssid, password)
		content = """<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><style>h1{text-align:center;margin-top:120px;font-size:1.4rem;color:#0064a0}p{text-align:center;font-size:1.1rem}div{width:200px;margin:0 auto;padding-left:60px}</style><title></title></head><body><h1>^_^ WiFi connection success</h1><div><span>Reset device now </span><span id="wating">...</span></div></body><script>var wating=document.getElementById("wating");setInterval(function(){if(wating.innerText==="..."){return wating.innerText="."}wating.innerText+="."},500);</script></html>"""
	else:
		content = """<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><style>h1{text-align:center;margin-top:120px;font-size:1.4rem;color:red}p{text-align:center;font-size:1.1rem}</style><title></title></head><body><h1>×_× WiFi connection failed</h1><p>Click <a href="/">here</a> return configure page.</p></body></html>"""

	httpResponse.WriteResponseOk( headers		 = None,
								  contentType	 = "text/html",
								  contentCharset = "UTF-8",
								  content 		 = content )

	if is_connected:
		lcd.image(0, 0, '/flash/img/1-3.jpg', type=lcd.JPG)
		time.sleep(3)
		wlan_ap.active(False)
		machine.reset() 
开发者ID:m5stack,项目名称:UIFlow-Code,代码行数:28,代码来源:wifiWebCfg.py

示例5: reboot

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def reboot(delay = 5):
    print('rebooting ...')
    time.sleep(delay)
    machine.reset()

# start a wi-fi access point 
开发者ID:artem-smotrakov,项目名称:esp32-weather-google-sheets,代码行数:8,代码来源:util.py

示例6: reboot

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def reboot(pressed=True):
    machine.reset() 
开发者ID:IBM-Developer-Korea,项目名称:developer-badge-2018-apps,代码行数:4,代码来源:util.py

示例7: _keepalive

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def _keepalive(self):
        while True:
            due = self._tim_ka - utime.ticks_diff(utime.ticks_ms(), self._last_wr)
            if due <= 0:
                # error sets ._evfail, .run cancels this coro
                await self._send(b'\n')
            else:
                await asyncio.sleep_ms(due)

    # Read a line from nonblocking socket: reads can return partial data which
    # are joined into a line. Blank lines are keepalive packets which reset
    # the timeout: _readline() pauses until a complete line has been received. 
开发者ID:peterhinch,项目名称:micropython-iot,代码行数:14,代码来源:client.py

示例8: _readline

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def _readline(self, to):
        led = self._led
        line = b''
        start = utime.ticks_ms()
        while True:
            if line.endswith(b'\n'):
                self._ok = True  # Got at least 1 packet after an outage.
                if len(line) > 1:
                    return line
                # Got a keepalive: discard, reset timers, toggle LED.
                self._feed(0)
                line = b''
                if led is not None:
                    if isinstance(led, machine.Pin):
                        led(not led())
                    else:  # On Pyboard D
                        led.toggle()
            try:
                d = self._sock.readline()
            except Exception as e:
                self._verbose and print('_readline exception', d)
                raise
            if d == b'':
                self._verbose and print('_readline peer disconnect')
                raise OSError
            if d is None:  # Nothing received: wait on server
                if utime.ticks_diff(utime.ticks_ms(), start) > to:
                    self._verbose and print('_readline timeout')
                    raise OSError
                await asyncio.sleep_ms(0)
            else:  # Something received: reset timer
                start = utime.ticks_ms()
                line = b''.join((line, d)) if line else d 
开发者ID:peterhinch,项目名称:micropython-iot,代码行数:35,代码来源:client.py

示例9: reset

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def reset(*args, **kwargs):
    try:
        import machine

        machine.reset()

    except ImportError:
        import microcontroller

        microcontroller.reset() 
开发者ID:KMKfw,项目名称:kmk_firmware,代码行数:12,代码来源:stock.py

示例10: bootloader

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def bootloader(*args, **kwargs):
    try:
        import machine

        machine.bootloader()

    except ImportError:
        import microcontroller

        microcontroller.on_next_reset(microcontroller.RunMode.BOOTLOADER)
        microcontroller.reset() 
开发者ID:KMKfw,项目名称:kmk_firmware,代码行数:13,代码来源:stock.py

示例11: reset

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def reset(self, **kwargs):
        """
        Perform a device reset, similar to the user pushing the RESET button.
        :param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.execute`.
        """
        code = '''
import machine
machine.reset()
'''
        return self.execute(code, wait_response=False, **kwargs).output 
开发者ID:BlackLight,项目名称:platypush,代码行数:12,代码来源:__init__.py

示例12: soft_reset

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def soft_reset(self, **kwargs):
        """
        Performs a soft reset of the interpreter, deleting all Python objects and resetting the Python heap.
        :param kwargs: Parameters to pass to :meth:`platypush.plugins.esp.EspPlugin.execute`.
        """
        code = '''
import machine
machine.soft_reset()
'''
        return self.execute(code, wait_response=False, **kwargs).output 
开发者ID:BlackLight,项目名称:platypush,代码行数:12,代码来源:__init__.py

示例13: deep_sleep

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [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

示例14: handle_command

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def handle_command(self, _args):
        import machine
        machine.reset() 
开发者ID:fadushin,项目名称:esp8266,代码行数:5,代码来源:ush.py

示例15: reboot

# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def reboot():
    import machine
    machine.reset() 
开发者ID:fadushin,项目名称:esp8266,代码行数:5,代码来源:cmd.py


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