@@ -78,6 +78,8 @@ class Pin(object):
7878 LOW_POWER = ... # type: int
7979 MED_POWER = ... # type: int
8080 HIGH_POWER = ... # type: int
81+ OUT_PP = ... # type: int
82+ OUT_OD = ... # type: int
8183
8284 def __init__ (self , id : Any , mode : int = - 1 , pull : int = - 1 , * ,
8385 value : Optional [int ] = None ,
@@ -157,7 +159,7 @@ def init(self, value: int, drive: int, alt: int, mode: int = -1, pull: int = -1)
157159 """
158160 ...
159161
160- def value (self , x : Optional [int ]) -> Optional [int ]:
162+ def value (self , x : Optional [int ] = None ) -> Optional [int ]:
161163 """This method allows to set and get the value of the pin, depending on
162164 whether the argument **x** is supplied or not.
163165
@@ -343,7 +345,7 @@ def any(self) -> int:
343345 """
344346 ...
345347
346- def read (self , nbytes : Optional [int ]) -> bytes :
348+ def read (self , nbytes : Optional [int ] = None ) -> bytes :
347349 """Read characters. If ``nbytes`` is specified then read at most that many
348350 bytes, otherwise read as much data as possible.
349351
@@ -390,7 +392,9 @@ class SPI(object):
390392 LSB = ... # type: int
391393 MSB = ... # type: int
392394
393- def __init__ (self , id : int ) -> None :
395+ def __init__ (self , id : int , baudrate : int = 1000000 , polarity : int = 0 , phase : int = 0 ,
396+ bits : int = 8 , firstbit : int = MSB , sck : Optional [Pin ] = None ,
397+ mosi : Optional [Pin ] = None , miso : Optional [Pin ] = None ) -> None :
394398 """
395399 Construct an SPI object on the given bus, ``id``. Values of id depend
396400 on a particular port and its hardware. Values 0, 1, etc. are commonly
@@ -463,7 +467,7 @@ def write_readinto(self, write_buf: bytearray, read_buf: bytearray) -> None:
463467
464468
465469class I2C (object ):
466- def __init__ (self , id : int , * , scl : Pin , sda : Pin , freq : int = 400000 ) -> None :
470+ def __init__ (self , id : int , scl : Pin = None , sda : Pin = None , freq : int = 400000 ) -> None :
467471 """Construct and return a new I2C object.
468472
469473 :param id: Particular I2C peripheral (-1 for software implementation).
@@ -580,7 +584,7 @@ def readfrom_mem_into(self, addr: int, memaddr: int, buf, *, addrsize=8) -> None
580584 """
581585 ...
582586
583- def writeto_mem (self , addr : int , memaddr : int , * , addrsize = 8 ) -> None :
587+ def writeto_mem (self , addr : int , memaddr : int , addrsize = 8 ) -> None :
584588 """Write ``buf`` to the slave specified by ``addr`` starting from the
585589 memory address specified by ``memaddr``. The argument ``addrsize`` specifies
586590 the address size in bits (on ESP8266 this argument is not recognised
@@ -676,7 +680,7 @@ def __init__(self, id: int) -> None:
676680 :param id: Timer ID.
677681 """
678682
679- def init (mode : Timer .PERIODIC , period : int , callback : func ) -> None :
683+ def init (self , mode : Timer .PERIODIC , period : int , callback : func ) -> None :
680684 """
681685 Init the timer. Start the timer, and enable the timer peripheral.
682686 """
@@ -699,7 +703,7 @@ def __init__(self, id: int, channel: int) -> None:
699703 """
700704 """
701705
702- def init (channel ) -> None :
706+ def init (self , channel : int ) -> None :
703707 """
704708 根据输入的层参数初始化 ADC 对象,入参为使用的 ADC 对象通道号;
705709 """
@@ -711,7 +715,7 @@ def deinit(self) -> None:
711715 """
712716 ...
713717
714- def read () -> None :
718+ def read (self ) -> None :
715719 """
716720 用于获取并返回当前 ADC 对象的采样值。例如当前采样值为 2048,对应设备的分辨率为 12位,当前设备参考电压为 3.3V ,则该 ADC 对象通道上实际电压值的计算公式为:采样值 * 参考电压 / (1 << 分辨率位数),即 vol = 2048 / 4096 * 3.3 V = 1.15V。
717721 """
@@ -733,7 +737,7 @@ def __init__(self, id: int, channel: int, freq: int, duty: int) -> None:
733737 """
734738 """
735739
736- def init (channel , freq , duty ) -> None :
740+ def init (self , channel : int , freq : int , duty : int ) -> None :
737741 """
738742 根据输入的参数初始化 PWM 对象。
739743 """
@@ -745,13 +749,13 @@ def deinit(self) -> None:
745749 """
746750 ...
747751
748- def freq (freq )-> None :
752+ def freq (self , freq : int = None )-> None :
749753 """
750754 用于获取或者设置 PWM 对象的频率,频率的范围为 [1, 156250]。如果参数为空,返回当前 PWM 对象的频率;如果参数非空,则使用该参数设置当前 PWM 对象的频率。
751755 """
752756 ...
753757
754- def duty (duty ) -> None :
758+ def duty (self , duty : int = None ) -> None :
755759 """
756760 用于获取或者设置 PWM 对象的占空比数值,占空比数值的范围为 [0, 255],例如 duty = 100,表示当前设备占空比为 100/255 = 39.22% 。如果参数为空,返回当前 PWM 对象的占空比数值;如果参数非空,则使用该参数设置当前 PWM 对象的占空比数值。
757761 """
@@ -784,46 +788,53 @@ def __init__(self) -> None:
784788 """
785789 """
786790
787- def light (value ) -> None :
791+ def light (self , value : int ) -> None :
788792 """
789793 控制是否开启 LCD 背光,入参为 True 则打开 LCD 背光,入参为 False 则关闭 LCD 背光。
790794 """
791795 ...
792796
793- def fill (color ) -> None :
797+ def fill (self , color : int ) -> None :
794798 """
795799 根据给定的颜色填充整个屏幕,支持多种颜色,可以传入的参数有:
796800
797801 - WHITE BLACK BLUE BRED GRED GBLUE RED MAGENTA GREEN CYAN YELLOW BROWN BRRED GRAY GRAY175 GRAY151 GRAY240
798802 """
799803 ...
800804
801- def pixel (x , y , color ) -> None :
805+ def pixel (self , x : int , y : int , color : int ) -> None :
802806 """
803807 向指定的位置(x, y)画点,点的颜色为 color 指定的颜色,可指定的颜色和上一个功能相同。
804808 注意:(x, y) 坐标的范围是 0 - 239,使用下面的方法对坐标进行操作时同样需要遵循此限制。
805809 """
806810 ...
807811
808- def text (str , x , y , size ) -> None :
812+ def set_color (self , back_color : int , fore_color : int ) -> None :
813+ """
814+ 设置 LCD 屏幕的前景色和背景色。
815+ """
816+ ...
817+
818+
819+ def text (self , input_str : str , x : int , y : int , size : int ) -> None :
809820 """
810821 在指定的位置(x,y)写入字符串,字符串由 str 指定,字体的大小由 size 指定,size 的大小可为 16,24,32。
811822 """
812823 ...
813824
814- def line (x1 , y1 , x2 , y2 ) -> None :
825+ def line (self , x1 : int , y1 : int , x2 : int , y2 : int ) -> None :
815826 """
816827 在 LCD 上画一条直线,起始地址为 (x1, y1),终点为(x2, y2)。
817828 """
818829 ...
819830
820- def rectangle (x1 , y1 , x2 , y2 ) -> None :
831+ def rectangle (self , x1 : int , y1 : int , x2 : int , y2 : int ) -> None :
821832 """
822833 在 LCD 上画一个矩形,左上角的位置为(x1, y1),右下角的位置为(x2, y2)。
823834 """
824835 ...
825836
826- def circle (x1 , y1 , r ) -> None :
837+ def circle (self , x1 : int , y1 : int , r : int ) -> None :
827838 """
828839 在 LCD 上画一个圆形,圆心的位置为(x1, y1),半径长度为 r。。
829840 """
@@ -832,7 +843,7 @@ def circle(x1, y1, r) -> None:
832843
833844class WDT (object ):
834845
835- def __init__ (self ) -> None :
846+ def __init__ (self , timeout : int ) -> None :
836847 """
837848 Construct a new watchdog object.
838849 """
0 commit comments