我之前是想通过获取图片的灰度和宽高,转化成16进制去发送,但是代码有错误,而且这样的话在接收端也需要重新组合,有没有更方便的方法
请在这里粘贴代码
import time, image
from pyb import UART
file_abs = None
uart = UART(3, 19200)
oled = []
s = [100]
n=0
classmates = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
while (True):
lu = ('singtown/first.png')
file_abs = image.Image(lu,copy_to_fb=True)
va1 = 64
width = int(file_abs.width()/va1)
high = int(file_abs.height()/va1)
#gray_lwpCV = file_abs.get_pixel(i,j)
for i in range(high):
for j in range(width):
gray_lwpCV = file_abs.get_pixel(i,j)
oled.append('gray_lwpCV')
sss = len(oled)
for i in range(sss):
while oled[i]>0:
s[n] = oled[i]%16
oled[i]=oled[i]/16
n+=1
for m in n:
hhex = classmates[s[m]]
uart.write(hhex)
print(hhex)