[tool] uart

This commit is contained in:
IrvingGao 2024-06-26 12:49:22 +08:00
parent 2a53c2d149
commit a8a069e543
1 changed files with 1 additions and 1 deletions

View File

@ -22,7 +22,7 @@ try:
num = int(data) # 尝试将读取的数据转换为整数
print(f"接收到的数字: {num}")
# print(f"接收到的字符串: {data}")
battery_level = num / 4096 * 4.5 /4.2 * 100 # 计算电池电量
battery_level = num / 4096 * 4.8 /4.2 * 100 # 计算电池电量
print(f"电池电量: {battery_level}%")
except ValueError: # 如果转换失败,说明不是有效的数字
print("接收到的数据无法转换为数字")