Bladeren bron

Merge pull request #113 from SummerGGift/723

【完善】MicroPython 自动补全优化
朱天龙 (Armink) 6 jaren geleden
bovenliggende
commit
19d95c0b3d

+ 2 - 2
docs/code-completion/array.py

@@ -20,7 +20,7 @@ class array(object):
     """
     ...
 
-    def append(val) -> None:
+    def append(self, val) -> None:
         """
         将一个新元素追加到数组的末尾。
         示例:
@@ -34,7 +34,7 @@ class array(object):
         """
         ...
 
-    def extend(iterable) -> None:
+    def extend(self, iterable) -> None:
         """
         将一个新的数组追加到数组的末尾,注意追加的数组和原来数组的数据类型要保持一致。
         示例:

+ 30 - 19
docs/code-completion/machine.py

@@ -78,6 +78,8 @@ Usage Model::
     LOW_POWER = ...  # type: int
     MED_POWER = ...  # type: int
     HIGH_POWER = ...  # type: int
+    OUT_PP = ...  # type: int
+    OUT_OD = ...  # type: int
 
     def __init__(self, id: Any, mode: int = -1, pull: int = -1, *,
                  value: Optional[int] = None,
@@ -157,7 +159,7 @@ Usage Model::
         """
         ...
 
-    def value(self, x: Optional[int]) -> Optional[int]:
+    def value(self, x: Optional[int] = None) -> Optional[int]:
         """This method allows to set and get the value of the pin, depending on
         whether the argument **x** is supplied or not.
 
@@ -343,7 +345,7 @@ class UART(object):
         """
         ...
 
-    def read(self, nbytes: Optional[int]) -> bytes:
+    def read(self, nbytes: Optional[int] = None) -> bytes:
         """Read characters. If ``nbytes`` is specified then read at most that many
         bytes, otherwise read as much data as possible.
 
@@ -390,7 +392,9 @@ class SPI(object):
     LSB = ...  # type: int
     MSB = ...  # type: int
 
-    def __init__(self, id: int) -> None:
+    def __init__(self, id: int, baudrate: int = 1000000, polarity: int = 0, phase: int = 0,
+             bits: int = 8, firstbit: int = MSB, sck: Optional[Pin] = None,
+             mosi: Optional[Pin] = None, miso: Optional[Pin] = None) -> None:
         """
         Construct an SPI object on the given bus, ``id``. Values of id depend
         on a particular port and its hardware. Values 0, 1, etc. are commonly
@@ -463,7 +467,7 @@ class SPI(object):
 
 
 class I2C(object):
-    def __init__(self, id: int, *, scl: Pin, sda: Pin, freq: int = 400000) -> None:
+    def __init__(self, id: int, scl: Pin = None, sda: Pin = None, freq: int = 400000) -> None:
         """Construct and return a new I2C object.
 
         :param id: Particular I2C peripheral (-1 for software implementation).
@@ -580,7 +584,7 @@ class I2C(object):
         """
         ...
 
-    def writeto_mem(self, addr: int, memaddr: int, *, addrsize=8) -> None:
+    def writeto_mem(self, addr: int, memaddr: int, addrsize=8) -> None:
         """Write ``buf`` to the slave specified by ``addr`` starting from the
         memory address specified by ``memaddr``. The argument ``addrsize`` specifies
         the address size in bits (on ESP8266 this argument is not recognised
@@ -676,7 +680,7 @@ class Timer(object):
         :param id: Timer ID.
         """
 
-    def init(mode : Timer.PERIODIC, period : int, callback : func) -> None:
+    def init(self, mode : Timer.PERIODIC, period : int, callback : func) -> None:
         """
         Init the timer. Start the timer, and enable the timer peripheral.
         """
@@ -699,7 +703,7 @@ class ADC(object):
         """
         """
 
-    def init(channel) -> None:
+    def init(self, channel : int) -> None:
         """
         根据输入的层参数初始化 ADC 对象,入参为使用的 ADC 对象通道号;
         """
@@ -711,7 +715,7 @@ class ADC(object):
         """
         ...
 
-    def read() -> None:
+    def read(self) -> None:
         """
         用于获取并返回当前 ADC 对象的采样值。例如当前采样值为 2048,对应设备的分辨率为 12位,当前设备参考电压为 3.3V ,则该 ADC 对象通道上实际电压值的计算公式为:采样值 * 参考电压  /  (1 <<  分辨率位数),即 vol = 2048 / 4096 * 3.3 V = 1.15V。
         """
@@ -733,7 +737,7 @@ class PWM(object):
         """
         """
 
-    def init(channel, freq, duty) -> None:
+    def init(self, channel : int, freq : int, duty : int) -> None:
         """
         根据输入的参数初始化 PWM 对象。
         """
@@ -745,13 +749,13 @@ class PWM(object):
         """
         ...
 
-    def freq(freq)-> None:
+    def freq(self, freq : int = None)-> None:
         """
         用于获取或者设置 PWM 对象的频率,频率的范围为 [1, 156250]。如果参数为空,返回当前 PWM 对象的频率;如果参数非空,则使用该参数设置当前 PWM 对象的频率。
         """
         ...
 
-    def duty(duty) -> None:
+    def duty(self, duty : int = None) -> None:
         """
         用于获取或者设置 PWM 对象的占空比数值,占空比数值的范围为 [0, 255],例如 duty = 100,表示当前设备占空比为 100/255 = 39.22% 。如果参数为空,返回当前 PWM 对象的占空比数值;如果参数非空,则使用该参数设置当前 PWM 对象的占空比数值。
         """
@@ -784,13 +788,13 @@ class LCD(object):
         """
         """
 
-    def light(value) -> None:
+    def light(self, value : int) -> None:
         """
         控制是否开启 LCD 背光,入参为 True 则打开 LCD 背光,入参为 False 则关闭 LCD 背光。
         """
         ...
 
-    def fill(color) -> None:
+    def fill(self, color : int) -> None:
         """
         根据给定的颜色填充整个屏幕,支持多种颜色,可以传入的参数有:
 
@@ -798,32 +802,39 @@ class LCD(object):
         """
         ...
 
-    def pixel(x, y, color) -> None:
+    def pixel(self, x : int, y : int , color : int) -> None:
         """
         向指定的位置(x, y)画点,点的颜色为 color 指定的颜色,可指定的颜色和上一个功能相同。
         注意:(x, y)  坐标的范围是 0 - 239,使用下面的方法对坐标进行操作时同样需要遵循此限制。
         """
         ...
 
-    def text(str, x, y, size) -> None:
+    def set_color(self, back_color : int, fore_color : int) -> None:
+        """
+        设置 LCD 屏幕的前景色和背景色。
+        """
+        ...
+
+
+    def text(self, input_str : str, x : int, y : int, size : int) -> None:
         """
         在指定的位置(x,y)写入字符串,字符串由 str 指定,字体的大小由 size 指定,size 的大小可为 16,24,32。
         """
         ...
 
-    def line(x1, y1, x2, y2) -> None:
+    def line(self, x1 : int, y1 : int, x2 : int, y2 : int) -> None:
         """
         在 LCD 上画一条直线,起始地址为 (x1, y1),终点为(x2, y2)。
         """
         ...
 
-    def rectangle(x1, y1, x2, y2) -> None:
+    def rectangle(self, x1 : int, y1 : int, x2 : int, y2 : int) -> None:
         """
         在 LCD 上画一个矩形,左上角的位置为(x1, y1),右下角的位置为(x2, y2)。
         """
         ...
 
-    def circle(x1, y1, r) -> None:
+    def circle(self, x1 : int, y1 : int, r : int) -> None:
         """
         在 LCD 上画一个圆形,圆心的位置为(x1, y1),半径长度为 r。。
         """
@@ -832,7 +843,7 @@ class LCD(object):
 
 class WDT(object):
 
-    def __init__(self) -> None:
+    def __init__(self, timeout : int) -> None:
         """
         Construct a new watchdog object.
         """

+ 11 - 12
docs/code-completion/network.py

@@ -20,27 +20,26 @@ class WLAN(object):
     STAT_CONNECT_FAIL = ...  # type: int
     STAT_GOT_IP = ...  # type: int
 
-    def __init__(self, interface_id: int) -> None:
-    """
-    """
-    ...
+    def __init__(self, interface_id : int) -> None:
+        """初始化一个 wlan 对象"""
+        ...
 
-    def active(is_active : int) -> None:
+    def active(self, is_active : int) -> None:
         """
         - active([is_active])
         如果向该方法传入布尔数值,传入 True 则使能卡,传入 False 则禁止网卡。否则,如果不传入参数,则查询当前网卡的状态。
         """
         ...
 
-    def connect(ssid, password) -> None:
+    def connect(self, ssid: str, password : str) -> None:
         """使用指定的账号和密码链接指定的无线热点。"""
         ...
 
-    def disconnect() -> None:
+    def disconnect(self) -> None:
         """从当前链接的无线网络中断开。"""
         ...
 
-    def scan() -> None:
+    def scan(self) -> None:
         """
         扫描当前可以连接的无线网络。
         只能在 STA 模式下进行扫描,使用元组列表的形式返回 WiFi 接入点的相关信息。
@@ -48,7 +47,7 @@ class WLAN(object):
         """
         ...
 
-    def status(param) -> None:
+    def status(self, param : str) -> None:
         """
         - status([param])
         返回当前无线连接的状态。
@@ -59,13 +58,13 @@ class WLAN(object):
         """
         ...
 
-    def isconnected() -> None:
+    def isconnected(self) -> None:
         """
         在 STA 模式时,如果已经连接到 WiFi 网络,并且获得了 IP 地址,则返回 True。
         如果处在 AP 模式,此时已经与客户端建立连接,则返回 True。其他情况下都返回 False。"""
         ...
 
-    def ifconfig(config: tuple) -> None:
+    def ifconfig(self, config: tuple) -> None:
         """
         ifconfig([(ip, subnet, gateway, dns)])
         获取或者设置网络接口的参数,IP 地址,子网掩码,网关,DNS 服务器。
@@ -75,7 +74,7 @@ class WLAN(object):
         """
         ...
 
-    def config(param) -> None:
+    def config(self, mac : str = None, essid : str = None, password : str = None, hidden : int = 0, channel : int = 0) -> None:
         """
         - config(param=value, ...)
         获取或者设置一般网络接口参数,这些方法允许处理标准的 ip 配置之外的其他参数,如 WLAN.ifconfig() 函数处理的参数。

+ 4 - 4
docs/code-completion/select.py

@@ -40,7 +40,7 @@ class poll(string):
     def __init__(self) -> None:
     ...
 
-    def register(obj) -> None:
+    def register(self, obj) -> None:
         """
         - register(obj[, eventmask])
         注册一个用以监控的对象,并设置被监控对象的监控标志位 flag。
@@ -54,7 +54,7 @@ class poll(string):
         """
         ...
 
-    def unregister(obj) -> None:
+    def unregister(self, obj) -> None:
         """
         解除监控的对象的注册。
 
@@ -69,7 +69,7 @@ class poll(string):
         """
         ...
 
-    def modify(obj, eventmask) -> None:
+    def modify(self, obj, eventmask) -> None:
         """
         修改已注册的对象监控标志。
 
@@ -85,7 +85,7 @@ class poll(string):
         """
         ...
 
-    def poll(timeout) -> None:
+    def poll(self, timeout) -> None:
         """
         - poll([timeout])
         等待至少一个已注册的对象准备就绪。

+ 4 - 4
docs/code-completion/uctypes.py

@@ -31,7 +31,7 @@ class struct(addr, descriptor, type):
     def __init__(self) -> None:
     ...
 
-    def sizeof(struct) -> None:
+    def sizeof(self, struct) -> None:
         """
         按字节返回数据的大小。参数可以是类或者数据对象 (或集合)。 示例:
 
@@ -44,7 +44,7 @@ class struct(addr, descriptor, type):
         """
         ...
 
-    def addressof(obj) -> None:
+    def addressof(self, obj) -> None:
         """
         返回对象地址。参数需要是 bytes, bytearray 。 示例:
 
@@ -54,7 +54,7 @@ class struct(addr, descriptor, type):
         """
         ...
 
-    def bytes_at(addr, size)-> None:
+    def bytes_at(self, addr, size)-> None:
         """
         捕捉从 addr 开始到 size 个地址偏移量结束的内存数据为 bytearray 对象并返回。 示例:
 
@@ -64,7 +64,7 @@ class struct(addr, descriptor, type):
         """
         ...
 
-    def bytearray_at(addr, size) -> None:
+    def bytearray_at(self, addr, size) -> None:
         """
         捕捉给定大小和地址内存为 bytearray 对象。与 bytes_at() 函数不同的是,它可以被再次写入,可以访问给定地址的参数。 示例:
 

+ 9 - 9
docs/code-completion/uhashlib.py

@@ -15,15 +15,15 @@ class sha256(data):
     def __init__(self) -> None:
     ...
 
-    def update(data) -> None:
+    def update(self, data) -> None:
         """将更多二进制数据放入哈希表中。"""
         ...
 
-    def digest() -> None:
+    def digest(self) -> None:
         """返回字节对象哈希的所有数据。调用此方法后,将无法将更多数据送入哈希。"""
         ...
 
-    def hexdigest() -> None:
+    def hexdigest(self) -> None:
         """此方法没有实现, 使用 ubinascii.hexlify(hash.digest()) 达到类似效果。"""
         ...
 
@@ -36,15 +36,15 @@ class sha1(data):
     def __init__(self) -> None:
     ...
 
-    def update(data) -> None:
+    def update(self, data) -> None:
         """将更多二进制数据放入哈希表中。"""
         ...
 
-    def digest() -> None:
+    def digest(self) -> None:
         """返回字节对象哈希的所有数据。调用此方法后,将无法将更多数据送入哈希。"""
         ...
 
-    def hexdigest() -> None:
+    def hexdigest(self) -> None:
         """此方法没有实现, 使用 ubinascii.hexlify(hash.digest()) 达到类似效果。"""
         ...
 
@@ -58,14 +58,14 @@ class md5(data):
     def __init__(self) -> None:
     ...
 
-    def update(data) -> None:
+    def update(self, data) -> None:
         """将更多二进制数据放入哈希表中。"""
         ...
 
-    def digest() -> None:
+    def digest(self) -> None:
         """返回字节对象哈希的所有数据。调用此方法后,将无法将更多数据送入哈希。"""
         ...
 
-    def hexdigest() -> None:
+    def hexdigest(self) -> None:
         """此方法没有实现, 使用 ubinascii.hexlify(hash.digest()) 达到类似效果。"""
         ...

+ 1 - 1
docs/code-completion/uio.py

@@ -27,6 +27,6 @@ class BytesIO(string):
     def __init__(self) -> None:
     ...
 
-    def getvalue() -> None:
+    def getvalue(self) -> None:
         """获取缓存区内容。"""
         ...

+ 1 - 1
docs/code-completion/uos.py

@@ -10,7 +10,7 @@ def getcwd() -> None:
     """获取当前目录。"""
     ...
 
-def listdir(dir : str) -> None:
+def listdir(dir : str = None) -> None:
     """没有参数就列出当前目录,否则列出给定目录。"""
     ...
 

+ 14 - 14
docs/code-completion/ure.py

@@ -14,19 +14,19 @@ class compile(...):
     def __init__(self) -> None:
     ...
 
-    def match(string) -> None:
+    def match(self, string) -> None:
         """用 string 匹配 regex,匹配总是从字符串的开始匹配。"""
         ...
 
-    def search(string) -> None:
+    def search(self, string) -> None:
         """在 string 中搜索 regex。不同于匹配,它搜索第一个匹配位置的正则表达式字符串 (结果可能会是0)。"""
         ...
 
-    def sub(replace, string, count, flags) -> None:
+    def sub(self, replace, string, count, flags) -> None:
         """Compile regex_str and search for it in string, replacing all matches with replace, and returning the new string."""
         ...
 
-    def split() -> None:
+    def split(self) -> None:
         """获取缓存区内容。"""
         ...
 
@@ -39,25 +39,25 @@ class match(...):
     def __init__(self) -> None:
     ...
 
-    def group(index) -> None:
+    def group(self, index) -> None:
         """用 string 匹配 regex,匹配总是从字符串的开始匹配。"""
         ...
 
-    def groups() -> None:
+    def groups(self) -> None:
         """在 string 中搜索 regex。不同于匹配,它搜索第一个匹配位置的正则表达式字符串 (结果可能会是0)。"""
         ...
 
-    def start(index) -> None:
+    def start(self, index) -> None:
         """start([index])"""
         ...
 
-    def end(index) -> None:
+    def end(self, index) -> None:
         """end([index])
         Return the index in the original string of the start or end of the substring group that was matched. index defaults to the entire group, otherwise it will select a group.
         """
         ...
 
-    def span() -> None:
+    def span(self) -> None:
         """Returns the 2-tuple (match.start(index), match.end(index))."""
         ...
 
@@ -70,25 +70,25 @@ class search(...):
     def __init__(self) -> None:
     ...
 
-    def group(index) -> None:
+    def group(self, index) -> None:
         """用 string 匹配 regex,匹配总是从字符串的开始匹配。"""
         ...
 
-    def groups() -> None:
+    def groups(self) -> None:
         """在 string 中搜索 regex。不同于匹配,它搜索第一个匹配位置的正则表达式字符串 (结果可能会是0)。"""
         ...
 
-    def start(index) -> None:
+    def start(self, index) -> None:
         """start([index])"""
         ...
 
-    def end(index) -> None:
+    def end(self, index) -> None:
         """end([index])
         Return the index in the original string of the start or end of the substring group that was matched. index defaults to the entire group, otherwise it will select a group.
         """
         ...
 
-    def span() -> None:
+    def span(self) -> None:
         """Returns the 2-tuple (match.start(index), match.end(index))."""
         ...
 

+ 38 - 25
docs/code-completion/uscoket.py → docs/code-completion/usocket.py

@@ -13,17 +13,18 @@ SO_REUSEADDR = ...  # type: int
 IPPROTO_TCP  = ...  # type: int
 IPPROTO_UDP  = ...  # type: int
 
-class socket(family, type, protocol) -> None:
-    """
-    创建新的套接字,使用指定的地址、类型和协议号。
-    - usocket.socket(usocket.AF_INET,usocket.SOCK_STREAM)
-    """
-    ...
 
-    def __init__(self) -> None:
-    ...
+class socket(object):
 
-    def getaddrinfo(host, port) -> None:
+    def __init__(self, family, type, protocol = socket.IPPROTO_TCP) -> None:
+        """
+        创建新的套接字,使用指定的地址、类型和协议号。
+        - usocket.socket(usocket.AF_INET,usocket.SOCK_STREAM)
+        """
+        ...
+
+    def getaddrinfo(self, host, port) -> None:
+        return tuple
         """
         将主机域名(host)和端口(port)转换为用于创建套接字的5元组序列。元组列表的结构如下:
 
@@ -36,15 +37,15 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def close() -> None:
+    def close(self) -> None:
         """关闭套接字。一旦关闭后,套接字所有的功能都将失效。远端将接收不到任何数据 (清理队列数据后)。 虽然在垃圾回收时套接字会自动关闭,但还是推荐在必要时用 close() 去关闭。"""
         ...
 
-    def bind(address) -> None:
+    def bind(self, address) -> None:
         """将套接字绑定到地址,套接字不能是已经绑定的。"""
         ...
 
-    def listen(backlog) -> None:
+    def listen(self, backlog) -> None:
         """
         listen([backlog])
         监听套接字,使服务器能够接收连接。
@@ -52,7 +53,8 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def accept() -> None:
+    def accept(self) -> None:
+        return conn, address
         """
         接收连接请求。 注意: 只能在绑定地址端口号和监听后调用,返回 conn 和 address。
 
@@ -61,7 +63,7 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def connect(address) -> None:
+    def connect(self, address : tuple) -> None:
         """
         连接服务器。
 
@@ -69,7 +71,8 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def send(bytes) -> None:
+    def send(self, bytes) -> None:
+        return size
         """
         发送数据,并返回成功发送的字节数,返回字节数可能比发送的数据长度少。
 
@@ -77,7 +80,8 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def recv(bufsize) -> None:
+    def recv(self, bufsize) -> None:
+        return obj
         """
         接收数据,返回接收到的数据对象。
 
@@ -88,7 +92,8 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def sendto(bytes, address) -> None:
+    def sendto(self, bytes, address) -> None:
+        return size
         """
         送数据,目标由address决定,常用于UDP通信,返回发送的数据大小。
 
@@ -101,7 +106,8 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def recvfrom(bufsize) -> None:
+    def recvfrom(self, bufsize) -> None:
+        return size
         """
         接收数据,常用于UDP通信,并返回接收到的数据对象和对象的地址。
 
@@ -112,7 +118,8 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def setsockopt(level, optname, value) -> None:
+    def setsockopt(self, level, optname, value) -> None:
+        return status
         """
         根据选项值设置套接字。
 
@@ -125,7 +132,8 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def settimeout(value) -> None:
+    def settimeout(self, value) -> None:
+        return status
         """
         设置超时时间,单位:秒。 示例:
 
@@ -133,13 +141,15 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def setblocking(flag) -> None:
+    def setblocking(self, flag) -> None:
+        return status
         """
         设置阻塞或非阻塞模式: 如果 flag 是 false,设置非阻塞模式。
         """
         ...
 
-    def read(size) -> None:
+    def read(self, size) -> None:
+        return size
         """
         - read([size])
         Read up to size bytes from the socket. 
@@ -149,7 +159,8 @@ class socket(family, type, protocol) -> None:
         """
         ...
 
-    def readinto(buf) -> None:
+    def readinto(self, buf) -> None:
+        return size
         """
         readinto(buf[, nbytes])
         Read bytes into the buf. 
@@ -160,13 +171,15 @@ class socket(family, type, protocol) -> None:
         """
         ...
         
-    def readline() -> None:
+    def readline(self) -> None:
+        return obj
         """
         接收一行数据,遇换行符结束,并返回接收数据的对象 。
         """
         ...
 
-    def write(buf) -> None:
+    def write(self, buf) -> None:
+        return size
         """
         将字节类型数据写入套接字,并返回写入成功的数据大小。
         """

+ 16 - 7
docs/code-completion/utime.py

@@ -2,7 +2,10 @@
 utime 模块提供获取当前时间和日期、测量时间间隔和延迟的功能。
 """
 
-def localtime(secs : int) -> None:
+from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
+
+def localtime(secs : int) -> Tuple:
+    return Tuple
     """
     从初始时间的秒转换为元组: (年, 月, 日, 时, 分, 秒, 星期, yearday) 。如果 secs 是空或者 None,那么使用当前时间。
     year 年份包括世纪(例如2014)。
@@ -17,7 +20,8 @@ def localtime(secs : int) -> None:
     """
     ...
 
-def mktime(time : tuple) -> None:
+def mktime(time : tuple) -> int:
+    return time
     """时间的反函数,它的参数是完整8参数的元组,返回值一个整数自2000年1月1日以来的秒数。"""
     ...
 
@@ -33,7 +37,8 @@ def sleep_us(us) -> None:
     """延时指定微秒,参数不能小于0。"""
     ...
 
-def ticks_ms() -> None:
+def ticks_ms() -> int:
+    return time
     """
     返回不断递增的毫秒计数器,在某些值后会重新计数(未指定)。
     计数值本身无特定意义,只适合用在ticks_diff()。
@@ -42,7 +47,8 @@ def ticks_ms() -> None:
     """
     ...
 
-def ticks_us() -> None:
+def ticks_us() -> int:
+    return time
     """
     返回不断递增的微秒计数器,在某些值后会重新计数(未指定)。
     计数值本身无特定意义,只适合用在ticks_diff()。
@@ -55,7 +61,8 @@ def ticks_cpu() -> None:
     """与 ticks_ms() 和 ticks_us() 类似,具有更高精度 (使用 CPU 时钟),并非每个端口都实现此功能。"""
     ...
 
-def ticks_add(ticks, delta) -> None:
+def ticks_add(ticks, delta) -> int:
+    return time
     """
     给定一个数字作为节拍的偏移值 delta,这个数字的值是正数或者负数都可以。 
     给定一个 ticks 节拍值,本函数允许根据节拍值的模算数定义来计算给定节拍值之前或者之后 delta 个节拍的节拍值 。 
@@ -65,7 +72,8 @@ def ticks_add(ticks, delta) -> None:
     """
     ...
 
-def ticks_diff(ticks1, ticks2) -> None:
+def ticks_diff(ticks1, ticks2) -> int :
+    return time
     """
     计算两次调用 ticksms(), ticks_us(), 或 ticks_cpu()之间的时间。
     因为这些函数的计数值可能会回绕,所以不能直接相减,需要使用 ticks_diff() 函数。
@@ -82,7 +90,8 @@ def ticks_diff(ticks1, ticks2) -> None:
     """
     ...
 
-def time() -> None:
+def time() -> int:
+    return time
     """
     返回从开始时间的秒数(整数),假设 RTC 已经按照前面方法设置好。
     如果 RTC 没有设置,函数将返回参考点开始计算的秒数 (对于 RTC 没有后备电池的板子,上电或复位后的情况)。