【发布时间】:2023-02-13 01:39:11
【问题描述】:
我正在使用通过 HAT 连接到 Pi Zero W 的 Waveshare 电子墨水显示器 (5x7)。我正在从上到下构建内容。
正如您从这张照片中看到的(对温室屋顶的反射表示歉意),到目前为止一切都很好:
但是,如果我继续在内容下方绘制一个或多个框,天气图标会从右向左淡出,如下所示:
我绘制的顺序无关紧要 - 无论我先绘制方框然后绘制天气数据,还是相反,都会发生这种情况。
相关代码如下:
# Draw one rectangle for top data
draw.rectangle([(0,0),(479,120)],outline = 0)
# And another for the tasks
draw.rectangle([(0,220),(239,700)],outline = 0)
# And a third for something else
draw.rectangle([(241,220),(479,700)],outline = 0)
# Draw the forecast (on a loop)
# If we have 400 pixels to play with, forecast covers next 5 hours, so 80 pixels per entry
i = 0
xoffset = 40
yoffset = 130
forecast = get_forecast()
while i < 5:
# Get the data
icon = get_icon(forecast[i]['icon'])
time = forecast[i]['time']
temperature = str(forecast[i]['temperature']) + u'\N{DEGREE SIGN}' + "C"
# Draw the forecast time
timewidth = forecastfont.getsize(time)[0]
textx = calculate_offset(xoffset, timewidth, xoffset)
texty = yoffset
draw.text((textx, texty), time, font = forecastfont, fill=0)
# Draw the forecast icon
iconwidth = weather24.getsize(icon)[0]
iconx = calculate_offset(xoffset, iconwidth, xoffset)
icony = yoffset + forecastfont.getsize(time)[1] + 5
draw.text((iconx, icony), icon, font = weather24, fill = 0)
# Draw the forecast temperature
tempwidth = temperaturefont.getsize(temperature)[0]
tempx = calculate_offset(xoffset, tempwidth, xoffset)
tempy = yoffset + forecastfont.getsize(time)[1] + weather24.getsize(icon)[1] + 5
draw.text((tempx, tempy), temperature, font = temperaturefont, fill=0)
# Advance the loop and move the offset
i += 1
xoffset += 60
我的研究似乎表明在写入后让显示器休眠应该会有所帮助,但我已经在这样做了:
epd.display(epd.getbuffer(image))
epd.sleep()
【问题讨论】:
-
你有没有找到解决这个问题的方法?
-
是的。原来是温室里的阳光!将屏幕移出阳光直射解决了这个问题。
标签: raspberry-pi e-ink