Skip to content

Commit 5fd042e

Browse files
committed
all: Replace all uses of umodule in Python code.
Applies to drivers/examples/extmod/port-modules/tools. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent 9d7eac0 commit 5fd042e

File tree

29 files changed

+99
-121
lines changed

29 files changed

+99
-121
lines changed

examples/hwapi/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ application of this idea would look like:
4040
`app.py`:
4141

4242
from hwconfig import *
43-
import utime
43+
import time
4444

4545
while True:
4646
LED.value(1)
47-
utime.sleep_ms(500)
47+
time.sleep_ms(500)
4848
LED.value(0)
49-
utime.sleep_ms(500)
49+
time.sleep_ms(500)
5050

5151

5252
To deploy this application to a particular board, a user will need:

examples/hwapi/button_led.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import utime
1+
import time
22
from hwconfig import LED, BUTTON
33

44
# Light LED when (and while) a BUTTON is pressed
55

66
while 1:
77
LED.value(BUTTON.value())
88
# Don't burn CPU
9-
utime.sleep_ms(10)
9+
time.sleep_ms(10)

examples/hwapi/button_reaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import utime
1+
import time
22
import machine
33
from hwconfig import LED, BUTTON
44

@@ -18,4 +18,4 @@
1818
print("Well, you're *really* slow")
1919
else:
2020
print("You are as slow as %d microseconds!" % delay)
21-
utime.sleep_ms(10)
21+
time.sleep_ms(10)

examples/hwapi/soft_pwm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import utime
1+
import time
22
from hwconfig import LED
33

44

@@ -15,10 +15,10 @@ def pwm_cycle(led, duty, cycles):
1515
for i in range(cycles):
1616
if duty:
1717
led.on()
18-
utime.sleep_ms(duty)
18+
time.sleep_ms(duty)
1919
if duty_off:
2020
led.off()
21-
utime.sleep_ms(duty_off)
21+
time.sleep_ms(duty_off)
2222

2323

2424
# At the duty setting of 1, an LED is still pretty bright, then

examples/network/http_client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
try:
2-
import usocket as socket
3-
except:
4-
import socket
1+
import socket
52

63

74
def main(use_stream=False):

examples/network/http_client_ssl.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
try:
2-
import usocket as _socket
3-
except:
4-
import _socket
5-
try:
6-
import ussl as ssl
7-
except:
8-
import ssl
1+
import socket
2+
import ssl
93

104

115
def main(use_stream=True):
12-
s = _socket.socket()
6+
s = socket.socket()
137

14-
ai = _socket.getaddrinfo("google.com", 443)
8+
ai = socket.getaddrinfo("google.com", 443)
159
print("Address infos:", ai)
1610
addr = ai[0][-1]
1711

examples/network/http_server.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
try:
2-
import usocket as socket
3-
except:
4-
import socket
1+
import socket
52

63

74
CONTENT = b"""\

examples/network/http_server_simplistic.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Do not use this code in real projects! Read
22
# http_server_simplistic_commented.py for details.
3-
try:
4-
import usocket as socket
5-
except:
6-
import socket
3+
import socket
74

85

96
CONTENT = b"""\

examples/network/http_server_simplistic_commented.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
# details, and use this code only for quick hacks, preferring
99
# http_server.py for "real thing".
1010
#
11-
try:
12-
import usocket as socket
13-
except:
14-
import socket
11+
import socket
1512

1613

1714
CONTENT = b"""\

examples/network/http_server_ssl.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import ubinascii as binascii
2-
3-
try:
4-
import usocket as socket
5-
except:
6-
import socket
7-
import ussl as ssl
1+
import binascii
2+
import socket
3+
import ssl
84

95

106
# This self-signed key/cert pair is randomly generated and to be used for

0 commit comments

Comments
 (0)