1
count = 0
while True:
        if count > 20:
                count = 0
                current_track = spotify.current_user_playing_track()
                if current_track is None:
                        display_string = ""
                else:
                        display_string = current_track['item']['name']+" - "+current_track['item']['artists'][0]['name']+" | "
                if display_string != previous_track:
                        sphd.clear()
                        sphd.write_string(display_string,brightness=0.1)
                        previous_track = display_string[:]
        time.sleep(0.05)
        sphd.show()
        sphd.scroll(1)
        count += 1

上面的代码在 Pi Zero 上运行,每秒获取当前播放的曲目并将其显示在滚动显示上。问题是获取轨道的过程会导致显示冻结约 0.25 秒。有没有什么方法可以运行循环来单独获取曲目以刷新显示的滚动或任何方法来加快获取曲目?感谢您提前提供任何帮助。

4

1 回答 1

1

冻结的原因可能是 Raspberry Pi Zero 的低性能。

于 2018-03-25T11:40:19.417 回答