Skip to content

Commit c3bfafc

Browse files
authored
Merge pull request #80 from SummerGGift/plug_readme
【修改】 添加初步 readme,并修改代码注释为英文以避免代码片段执行错误
2 parents e3548c4 + 11a2df9 commit c3bfafc

File tree

9 files changed

+59
-58
lines changed

9 files changed

+59
-58
lines changed

examples/basic/random.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import random
1212

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

examples/basic/uos.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,32 @@
1010

1111
import uos
1212

13-
print("获得当前所在目录:")
13+
print("Get the current directory:")
1414
print(uos.getcwd())
1515

16-
print("创建文件夹 :rtthread")
16+
print("Create folder: rtthread")
1717
uos.mkdir("rtthread")
1818

19-
print("列出当前目录下的文件列表:")
19+
print("List the files in the current directory:")
2020
print(uos.listdir())
2121

22-
print("移动当前目录到 rtthread 文件夹下:")
22+
print("Move the current directory to the rtthread folder:")
2323
uos.chdir("rtthread")
2424

25-
print("获得当前所在目录:")
25+
print("Get the current directory:")
2626
print(uos.getcwd())
2727

28-
print("切换到上一级目录:")
28+
print("Switch to the previous directory:")
2929
uos.chdir("..")
3030

31-
print("获得当前所在目录:")
31+
print("Get the current directory:")
3232
print(uos.getcwd())
3333

34-
print("列出当前目录下的文件列表:")
34+
print("List the files in the current directory:")
3535
print(uos.listdir())
3636

37-
print("删除 rtthread 文件夹:")
37+
print("Delete the rtthread folder:")
3838
uos.rmdir("rtthread")
3939

40-
print("列出当前目录下的文件列表:")
40+
print("List the files in the current directory:")
4141
print(uos.listdir())

examples/basic/utime.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
import utime
1212

13-
utime.sleep(1) # sleep for 1 second
14-
utime.sleep_ms(500) # sleep for 500 milliseconds
15-
utime.sleep_us(10) # sleep for 10 microseconds
13+
utime.sleep(1) # sleep for 1 second
14+
utime.sleep_ms(500) # sleep for 500 milliseconds
15+
utime.sleep_us(10) # sleep for 10 microseconds
1616

17-
start = utime.ticks_ms() # get value of millisecond counter
17+
start = utime.ticks_ms() # get value of millisecond counter
1818
delta = utime.ticks_diff(utime.ticks_ms(), start) # compute time difference
1919
print(utime.ticks_add(utime.ticks_ms(), -100))
2020
print(utime.ticks_add(0, -1))

examples/network/tcp_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
server.setblocking(True)
1818

1919
while True:
20-
# 等待客户端连接
20+
# Wait for client connection
2121
clientsocket, addr = server.accept()
2222
print("connect address: %s" % str(addr))
2323
clientsocket.send('welcome to rt-thread micropython!')

examples/stm32l4_pandora/adc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
# 2019-06-13 SummerGift first version
99
#
1010

11-
from machine import ADC # 从 machine 导入 ADC
11+
from machine import ADC # Import the ADC class from machine
1212

13-
adc = ADC(2, 5) # 创建 ADC 对象,当前使用编号为 2 的 ADC 设备的 5 通道
14-
adc.read() # 获取 ADC 对象采样值
15-
adc.deinit() # 关闭 ADC 对象
16-
adc.init(5) # 开启并重新配置 ADC 对象
13+
adc = ADC(2, 5) # Creates an ADC object that currently uses the 5 channels of an ADC device numbered 2
14+
adc.read() # Gets the ADC object sampling value
15+
adc.deinit() # Close ADC object
16+
adc.init(5) # Open and reconfigure the ADC object

examples/stm32l4_pandora/lcd.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
# 2019-06-13 SummerGift first version
99
#
1010

11-
from machine import LCD # 从 machine 导入 LCD
11+
from machine import LCD # Import the LCD class from machine
1212

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

examples/stm32l4_pandora/pwm.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
# 2019-06-13 SummerGift first version
99
#
1010

11-
from machine import PWM # 从 machine 导入 PWM 类
11+
from machine import PWM # Import PWM class from machine
1212

13-
pwm = PWM(1, 4, 1000, 100) # 创建 PWM 对象,当前使用编号为 1 的 PWM 设备的 4 通道,初始化的频率为 1000Hz,占空比数值为 100(占空比为 100/255 = 39.22%)
14-
pwm.freq(2000) # 设置 PWM 对象频率
15-
pwm.freq() # 获取 PWM 对象频率
16-
pwm.duty(200) # 设置 PWM 对象占空比数值
17-
pwm.duty() # 获取 PWM 对象占空比数值
18-
pwm.deinit() # 关闭 PWM 对象
19-
pwm.init(4, 1000, 100) # 开启并重新配置 PWM 对象
13+
pwm = PWM(1, 4, 1000, 100) # Create PWM object. Currently, 4 channels of PWM device numbered 1 are used.
14+
# The initialization frequency is 1000Hz and the duty ratio value is 100 (duty ratio is 100/255 = 39.22%).
15+
pwm.freq(2000) # Set the frequency of PWM object
16+
pwm.freq() # Get the frequency of PWM object
17+
pwm.duty(200) # sets the duty ratio value of PWM object
18+
pwm.duty() # Get the duty ratio value of PWM object
19+
pwm.deinit() # close PWM object
20+
pwm.init(4, 1000, 100) # open and reconfigure the PWM object

examples/stm32l4_pandora/rtc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
from machine import RTC
1212

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

examples/stm32l4_pandora/uart.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
from machine import UART
1212

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

0 commit comments

Comments
 (0)