本文整理汇总了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
示例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,))
示例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
# ===========
示例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()
示例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
示例6: reboot
# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def reboot(pressed=True):
machine.reset()
示例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.
示例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
示例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()
示例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()
示例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
示例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
示例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
示例14: handle_command
# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def handle_command(self, _args):
import machine
machine.reset()
示例15: reboot
# 需要导入模块: import machine [as 别名]
# 或者: from machine import reset [as 别名]
def reboot():
import machine
machine.reset()