Kaynağa Gözat

[change] Modify code comments to English to avoid errors when executing code snippets

SummerGift 6 yıl önce
ebeveyn
işleme
11a2df9c75

+ 2 - 2
examples/basic/random.py

@@ -11,7 +11,7 @@
 import random
 
 for j in range(0, 2):
-    random.seed(13)  # 指定随机数种子
-    for i in range(0, 10):  # 生成0到10范围内的随机序列
+    random.seed(13)                   # Specify random number seed
+    for i in range(0, 10):            # Generate random sequences in the range of 0 to 10
         print(random.randint(1, 10))
     print("end")

+ 10 - 10
examples/basic/uos.py

@@ -10,32 +10,32 @@
 
 import uos
 
-print("获得当前所在目录:")
+print("Get the current directory:")
 print(uos.getcwd())
 
-print("创建文件夹 :rtthread")
+print("Create folder: rtthread")
 uos.mkdir("rtthread")
 
-print("列出当前目录下的文件列表:")
+print("List the files in the current directory:")
 print(uos.listdir())
 
-print("移动当前目录到 rtthread 文件夹下:")
+print("Move the current directory to the rtthread folder:")
 uos.chdir("rtthread")
 
-print("获得当前所在目录:")
+print("Get the current directory:")
 print(uos.getcwd())
 
-print("切换到上一级目录:")
+print("Switch to the previous directory:")
 uos.chdir("..")
 
-print("获得当前所在目录:")
+print("Get the current directory:")
 print(uos.getcwd())
 
-print("列出当前目录下的文件列表:")
+print("List the files in the current directory:")
 print(uos.listdir())
 
-print("删除 rtthread 文件夹:")
+print("Delete the rtthread folder:")
 uos.rmdir("rtthread")
 
-print("列出当前目录下的文件列表:")
+print("List the files in the current directory:")
 print(uos.listdir())

+ 4 - 4
examples/basic/utime.py

@@ -10,11 +10,11 @@
 
 import utime
 
-utime.sleep(1)                                    # sleep for 1 second
-utime.sleep_ms(500)                               # sleep for 500 milliseconds
-utime.sleep_us(10)                                # sleep for 10 microseconds
+utime.sleep(1)                                     # sleep for 1 second
+utime.sleep_ms(500)                                # sleep for 500 milliseconds
+utime.sleep_us(10)                                 # sleep for 10 microseconds
 
-start = utime.ticks_ms()                          # get value of millisecond counter
+start = utime.ticks_ms()                           # get value of millisecond counter
 delta = utime.ticks_diff(utime.ticks_ms(), start)  # compute time difference
 print(utime.ticks_add(utime.ticks_ms(), -100))
 print(utime.ticks_add(0, -1))

+ 1 - 1
examples/network/tcp_server.py

@@ -17,7 +17,7 @@ server.listen(5)
 server.setblocking(True)
 
 while True:
-    # 等待客户端连接
+    # Wait for client connection
     clientsocket, addr = server.accept()
     print("connect address: %s" % str(addr))
     clientsocket.send('welcome to rt-thread micropython!')

+ 5 - 5
examples/stm32l4_pandora/adc.py

@@ -8,9 +8,9 @@
 # 2019-06-13     SummerGift   first version
 #
 
-from machine import ADC     # 从 machine 导入 ADC 类
+from machine import ADC     # Import the ADC class from machine
 
-adc = ADC(2, 5)             # 创建 ADC 对象,当前使用编号为 2 的 ADC 设备的 5 通道
-adc.read()                  # 获取 ADC 对象采样值
-adc.deinit()                # 关闭 ADC 对象
-adc.init(5)                 # 开启并重新配置 ADC 对象
+adc = ADC(2, 5)             # Creates an ADC object that currently uses the 5 channels of an ADC device numbered 2
+adc.read()                  # Gets the ADC object sampling value
+adc.deinit()                # Close ADC object
+adc.init(5)                 # Open and reconfigure the ADC object

+ 16 - 16
examples/stm32l4_pandora/lcd.py

@@ -8,20 +8,20 @@
 # 2019-06-13     SummerGift   first version
 #
 
-from machine import LCD     # 从 machine 导入 LCD 类
+from machine import LCD     # Import the LCD class from machine
 
-lcd = LCD()                             # 创建一个 lcd 对象
-lcd.light(False)                        # 关闭背光
-lcd.light(True)                         # 打开背光
-lcd.fill(lcd.BLACK)                     # 将整个 LCD 填充为黑色
-lcd.fill(lcd.RED)                       # 将整个 LCD 填充为红色
-lcd.fill(lcd.GRAY)                      # 将整个 LCD 填充为灰色
-lcd.fill(lcd.WHITE)                     # 将整个 LCD 填充为白色
-lcd.pixel(50, 50, lcd.BLUE)             # 将(50,50)位置的像素填充为蓝色
-lcd.text("hello RT-Thread", 0, 0, 16)   # 在(0, 0) 位置以 16 字号打印字符串
-lcd.text("hello RT-Thread", 0, 16, 24)  # 在(0, 16)位置以 24 字号打印字符串
-lcd.text("hello RT-Thread", 0, 48, 32)  # 在(0, 48)位置以 32 字号打印字符串
-lcd.line(0, 50, 239, 50)                # 以起点(0,50),终点(239,50)画一条线
-lcd.line(0, 50, 239, 50)                # 以起点(0,50),终点(239,50)画一条线
-lcd.rectangle(100, 100, 200, 200)       # 以左上角为(100,100),右下角(200,200)画矩形
-lcd.circle(150, 150, 80)                # 以圆心位置(150,150),半径为 80 画圆
+lcd = LCD()                             # Create a LCD object
+lcd.light(False)                        # Close the backlight
+lcd.light(True)                         # Open the backlight
+lcd.fill(lcd.BLACK)                     # Fill the entire LCD with black
+lcd.fill(lcd.RED)                       # Fill the entire LCD with red
+lcd.fill(lcd.GRAY)                      # Fill the entire LCD with gray
+lcd.fill(lcd.WHITE)                     # Fill the entire LCD with white
+lcd.pixel(50, 50, lcd.BLUE)             # fills the pixels in the (50,50) position with blue
+lcd.text("hello RT-Thread", 0, 0, 16)   # prints the string at 16 font size at position (0, 0)
+lcd.text("hello RT-Thread", 0, 16, 24)  # prints the string at 24 font size at position (0, 16)
+lcd.text("hello RT-Thread", 0, 48, 32)  # prints the string at 32 font size at position (0, 48)
+lcd.line(0, 50, 239, 50)                # Draw a line starting at (0,50) and ending at (239,50)
+lcd.line(0, 50, 239, 50)                # Draw a line starting at (0,50) and ending at (239,50)
+lcd.rectangle(100, 100, 200, 200)       # Draw a rectangle with the top left corner (100,100) and the bottom right corner (200,200)
+lcd.circle(150, 150, 80)                # Draw a circle with a radius of 80 at the center (150,150)

+ 9 - 8
examples/stm32l4_pandora/pwm.py

@@ -8,12 +8,13 @@
 # 2019-06-13     SummerGift   first version
 #
 
-from machine import PWM     # 从 machine 导入 PWM 类
+from machine import PWM     # Import PWM class from machine
 
-pwm = PWM(1, 4, 1000, 100)  # 创建 PWM 对象,当前使用编号为 1 的 PWM 设备的 4 通道,初始化的频率为 1000Hz,占空比数值为 100(占空比为 100/255 = 39.22%)
-pwm.freq(2000)              # 设置 PWM 对象频率
-pwm.freq()                  # 获取 PWM 对象频率
-pwm.duty(200)               # 设置 PWM 对象占空比数值
-pwm.duty()                  # 获取 PWM 对象占空比数值
-pwm.deinit()                # 关闭 PWM 对象
-pwm.init(4, 1000, 100)      # 开启并重新配置 PWM 对象
+pwm = PWM(1, 4, 1000, 100)  # Create PWM object. Currently, 4 channels of PWM device numbered 1 are used. 
+                            # The initialization frequency is 1000Hz and the duty ratio value is 100 (duty ratio is 100/255 = 39.22%).
+pwm.freq(2000)              # Set the frequency of PWM object
+pwm.freq()                  # Get the frequency of PWM object
+pwm.duty(200)               # sets the duty ratio value of PWM object
+pwm.duty()                  # Get the duty ratio value of PWM object
+pwm.deinit()                # close PWM object
+pwm.init(4, 1000, 100)      # open and reconfigure the PWM object

+ 5 - 5
examples/stm32l4_pandora/rtc.py

@@ -10,8 +10,8 @@
 
 from machine import RTC
 
-rtc = RTC()                        # 创建 RTC 设备对象
-rtc.init((2019,6,5,2,10,22,30,0))  # 设置初始化时间
-rtc.now()                          # 获取当前时间
-rtc.deinit()                       # 重置时间到2015年1月1日
-rtc.now()                          # 获取当前时间
+rtc = RTC()                        # Create an RTC device object
+rtc.init((2019,6,5,2,10,22,30,0))  # Set initialization time
+rtc.now()                          # Get the current time
+rtc.deinit()                       # Reset time to January 1, 2015
+rtc.now()                          # Get the current time

+ 7 - 7
examples/stm32l4_pandora/uart.py

@@ -10,10 +10,10 @@
 
 from machine import UART
 
-uart = UART(1, 9600)                         # init with given baudrate
-uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters
-uart.read(10)                                # read 10 characters, returns a bytes object
-uart.read()                                  # read all available characters
-uart.readline()                              # read a line
-uart.readinto(buf)                           # read and store into the given buffer
-uart.write('abc')                            # write the 3 characters
+uart = UART(1, 9600)                          # init with given baudrate
+uart.init(9600, bits=8, parity=None, stop=1)  # init with given parameters
+uart.read(10)                                 # read 10 characters, returns a bytes object
+uart.read()                                   # read all available characters
+uart.readline()                               # read a line
+uart.readinto(buf)                            # read and store into the given buffer
+uart.write('abc')                             # write the 3 characters