Skip to content

all: remove u-module naming where possible #880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions micropython/aioespnow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A supplementary module which extends the micropython `espnow` module to provide
`asyncio` support.

- Asyncio support is available on all ESP32 targets as well as those ESP8266
boards which include the `uasyncio` module (ie. ESP8266 devices with at least
boards which include the `asyncio` module (ie. ESP8266 devices with at least
2MB flash storage).

## API reference
Expand Down Expand Up @@ -52,7 +52,7 @@ A small async server example::
```python
import network
import aioespnow
import uasyncio as asyncio
import asyncio

# A WLAN interface must be active to send()/recv()
network.WLAN(network.STA_IF).active(True)
Expand Down
6 changes: 3 additions & 3 deletions micropython/aioespnow/aioespnow.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# aioespnow module for MicroPython on ESP32 and ESP8266
# MIT license; Copyright (c) 2022 Glenn Moloney @glenn20

import uasyncio as asyncio
import asyncio
import espnow


# Modelled on the uasyncio.Stream class (extmod/stream/stream.py)
# NOTE: Relies on internal implementation of uasyncio.core (_io_queue)
# Modelled on the asyncio.Stream class (extmod/asyncio/stream.py)
# NOTE: Relies on internal implementation of asyncio.core (_io_queue)
class AIOESPNow(espnow.ESPNow):
# Read one ESPNow message
async def arecv(self):
Expand Down
2 changes: 1 addition & 1 deletion micropython/aiorepl/aiorepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def execute(code, g, s):
code = "return {}".format(code)

code = """
import uasyncio as asyncio
import asyncio
async def __code():
{}

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/aioble/central.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import bluetooth
import struct

import uasyncio as asyncio
import asyncio

from .core import (
ensure_active,
Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/aioble/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from micropython import const
from collections import deque
import uasyncio as asyncio
import asyncio
import struct

import bluetooth
Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/aioble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from micropython import const

import uasyncio as asyncio
import asyncio
import binascii

from .core import ble, register_irq_handler, log_error
Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/aioble/l2cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from micropython import const

import uasyncio as asyncio
import asyncio

from .core import ble, log_error, register_irq_handler
from .device import DeviceConnection
Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/aioble/peripheral.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import bluetooth
import struct

import uasyncio as asyncio
import asyncio

from .core import (
ensure_active,
Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/aioble/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# MIT license; Copyright (c) 2021 Jim Mussared

from micropython import const, schedule
import uasyncio as asyncio
import asyncio
import binascii
import json

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/aioble/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from micropython import const
from collections import deque
import bluetooth
import uasyncio as asyncio
import asyncio

from .core import (
ensure_active,
Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/examples/l2cap_file_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from micropython import const

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/examples/l2cap_file_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from micropython import const

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/examples/temp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from micropython import const

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/examples/temp_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from micropython import const

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/multitests/ble_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/multitests/ble_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/multitests/ble_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
12 changes: 8 additions & 4 deletions micropython/bluetooth/aioble/multitests/ble_write_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down Expand Up @@ -44,12 +44,12 @@ async def instance0_task():

# Register characteristic.written() handlers as asyncio background tasks.
# The order of these is important!
asyncio.create_task(task_written(characteristic_second, "second"))
asyncio.create_task(task_written(characteristic_first, "first"))
task_second = asyncio.create_task(task_written(characteristic_second, "second"))
task_first = asyncio.create_task(task_written(characteristic_first, "first"))

# This dummy task simulates background processing on a real system that
# can block the asyncio loop for brief periods of time
asyncio.create_task(task_dummy())
task_dummy_ = asyncio.create_task(task_dummy())

multitest.globals(BDADDR=aioble.config("mac"))
multitest.next()
Expand All @@ -63,6 +63,10 @@ async def instance0_task():

await connection.disconnected()

task_second.cancel()
task_first.cancel()
task_dummy_.cancel()


async def task_written(chr, label):
while True:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth

Expand Down
2 changes: 1 addition & 1 deletion micropython/bluetooth/aioble/multitests/perf_l2cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import machine
import time

import uasyncio as asyncio
import asyncio
import aioble
import bluetooth
import random
Expand Down
12 changes: 6 additions & 6 deletions micropython/drivers/display/lcd160cr/lcd160cr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import machine
from utime import sleep_ms
from ustruct import calcsize, pack_into
import uerrno
import errno

# for set_orient
PORTRAIT = const(0)
Expand Down Expand Up @@ -110,7 +110,7 @@ def _waitfor(self, n, buf):
return
t -= 1
sleep_ms(1)
raise OSError(uerrno.ETIMEDOUT)
raise OSError(errno.ETIMEDOUT)

def oflush(self, n=255):
t = 5000
Expand All @@ -121,7 +121,7 @@ def oflush(self, n=255):
return
t -= 1
machine.idle()
raise OSError(uerrno.ETIMEDOUT)
raise OSError(errno.ETIMEDOUT)

def iflush(self):
t = 5000
Expand All @@ -131,7 +131,7 @@ def iflush(self):
return
t -= 1
sleep_ms(1)
raise OSError(uerrno.ETIMEDOUT)
raise OSError(errno.ETIMEDOUT)

#### MISC METHODS ####

Expand Down Expand Up @@ -254,7 +254,7 @@ def get_pixel(self, x, y):
return self.buf[3][1] | self.buf[3][2] << 8
t -= 1
sleep_ms(1)
raise OSError(uerrno.ETIMEDOUT)
raise OSError(errno.ETIMEDOUT)

def get_line(self, x, y, buf):
l = len(buf) // 2
Expand All @@ -268,7 +268,7 @@ def get_line(self, x, y, buf):
return
t -= 1
sleep_ms(1)
raise OSError(uerrno.ETIMEDOUT)
raise OSError(errno.ETIMEDOUT)

def screen_dump(self, buf, x=0, y=0, w=None, h=None):
if w is None:
Expand Down
14 changes: 7 additions & 7 deletions micropython/drivers/radio/nrf24l01/nrf24l01test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test for nrf24l01 module. Portable between MicroPython targets."""

import usys
import ustruct as struct
import sys
import struct
import utime
from machine import Pin, SPI, SoftSPI
from nrf24l01 import NRF24L01
Expand All @@ -14,20 +14,20 @@
# initiator may be a slow device. Value tested with Pyboard, ESP32 and ESP8266.
_RESPONDER_SEND_DELAY = const(10)

if usys.platform == "pyboard":
if sys.platform == "pyboard":
spi = SPI(2) # miso : Y7, mosi : Y8, sck : Y6
cfg = {"spi": spi, "csn": "Y5", "ce": "Y4"}
elif usys.platform == "esp8266": # Hardware SPI
elif sys.platform == "esp8266": # Hardware SPI
spi = SPI(1) # miso : 12, mosi : 13, sck : 14
cfg = {"spi": spi, "csn": 4, "ce": 5}
elif usys.platform == "esp32": # Software SPI
elif sys.platform == "esp32": # Software SPI
spi = SoftSPI(sck=Pin(25), mosi=Pin(33), miso=Pin(32))
cfg = {"spi": spi, "csn": 26, "ce": 27}
elif usys.platform == "rp2": # Hardware SPI with explicit pin definitions
elif sys.platform == "rp2": # Hardware SPI with explicit pin definitions
spi = SPI(0, sck=Pin(2), mosi=Pin(3), miso=Pin(4))
cfg = {"spi": spi, "csn": 5, "ce": 6}
else:
raise ValueError("Unsupported platform {}".format(usys.platform))
raise ValueError("Unsupported platform {}".format(sys.platform))

# Addresses are in little-endian format. They correspond to big-endian
# 0xf0f0f0f0e1, 0xf0f0f0f0d2
Expand Down
17 changes: 5 additions & 12 deletions micropython/net/ntptime/ntptime.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import utime

try:
import usocket as socket
except:
import socket
try:
import ustruct as struct
except:
import struct
from time import gmtime
import socket
import struct

# The NTP host can be configured at runtime by doing: ntptime.host = 'myhost.org'
host = "pool.ntp.org"
Expand Down Expand Up @@ -53,7 +46,7 @@ def time():

# Convert timestamp from NTP format to our internal format

EPOCH_YEAR = utime.gmtime(0)[0]
EPOCH_YEAR = gmtime(0)[0]
if EPOCH_YEAR == 2000:
# (date(2000, 1, 1) - date(1900, 1, 1)).days * 24*60*60
NTP_DELTA = 3155673600
Expand All @@ -71,5 +64,5 @@ def settime():
t = time()
import machine

tm = utime.gmtime(t)
tm = gmtime(t)
machine.RTC().datetime((tm[0], tm[1], tm[2], tm[6] + 1, tm[3], tm[4], tm[5], 0))
2 changes: 1 addition & 1 deletion micropython/uaiohttpclient/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
uaiohttpclient is an HTTP client module for MicroPython uasyncio module,
uaiohttpclient is an HTTP client module for MicroPython asyncio module,
with API roughly compatible with aiohttp (https://github.com/KeepSafe/aiohttp)
module. Note that only client is implemented, for server see picoweb
microframework.
2 changes: 1 addition & 1 deletion micropython/uaiohttpclient/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# uaiohttpclient - fetch URL passed as command line argument.
#
import sys
import uasyncio as asyncio
import asyncio
import uaiohttpclient as aiohttp


Expand Down
2 changes: 1 addition & 1 deletion micropython/uaiohttpclient/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadata(description="HTTP client module for MicroPython uasyncio module", version="0.5.2")
metadata(description="HTTP client module for MicroPython asyncio module", version="0.5.2")

# Originally written by Paul Sokolovsky.

Expand Down
2 changes: 1 addition & 1 deletion micropython/uaiohttpclient/uaiohttpclient.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import uasyncio as asyncio
import asyncio


class ClientResponse:
Expand Down
Loading
Loading