Commit 65595c86 authored by Stefan Steinmüller's avatar Stefan Steinmüller
Browse files

Liveplot erster versuch

parent 8cf51ba3
import serial
import matplotlib.pyplot as plt
import numpy as np
from collections import deque
fig, ax_1 = plt.subplots(1,1)
ax_2 = ax_1.twinx()
ax_3 = ax_1.twinx()
x_range = deque([])
max_range = 0
ax_1.set_ylim([-100, 100])
ax_2.set_ylim([-100, 100])
ax_3.set_ylim([-100, 100])
try:
board = serial.Serial("/dev/ttyACM1")
except Exception as e:
print("an error occured while opening the serial device\n{}".format(e))
plt.show()
while(board):
_txt = board.readline()
txt = _txt.split(";").strip()
x_range.append(max_range+1)
max_range += 1
ax_1.set_xlim([max_range-200, max_range+1])
ax_1.plot([max_range], [txt[0]])
ax_2.plot([max_range], [txt[1]])
ax_2.plot([max_range], [txt[2]])
csv_cont = []
try:
with open('log_plot.csv', 'r') as csv:
csv_cont = csv.readlines()
except:
pass
with open('log_plot.csv', 'w') as csv:
csv_cont.append(_txt)
csv.writelines(csv_cont)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment