PyThermostat: Add main function to plot.py

This commit is contained in:
atse 2024-11-18 11:47:11 +08:00
parent 9743dca775
commit 09300b5d44
1 changed files with 114 additions and 108 deletions

View File

@ -5,6 +5,8 @@ import matplotlib.animation as animation
from threading import Thread, Lock from threading import Thread, Lock
from pythermostat.client import Client from pythermostat.client import Client
def main():
TIME_WINDOW = 300.0 TIME_WINDOW = 300.0
tec = Client() tec = Client()
@ -119,7 +121,7 @@ def animate(i):
margin_y = 0.01 * (max_y - min_y) margin_y = 0.01 * (max_y - min_y)
ax.set_ylim(min_y - margin_y, max_y + margin_y) ax.set_ylim(min_y - margin_y, max_y + margin_y)
global legend nonlocal legend
legend.remove() legend.remove()
legend = ax.legend() legend = ax.legend()
@ -129,3 +131,7 @@ ani = animation.FuncAnimation(
plt.show() plt.show()
quit = True quit = True
thread.join() thread.join()
if __name__ == "__main__":
main()