From 9d8a7e74f7b5cd1e60a1b6feadd819cefa6064a9 Mon Sep 17 00:00:00 2001 From: uhi22 Date: Mon, 15 May 2023 20:06:11 +0200 Subject: [PATCH] fix: scope channel 3 offset. feature: scope: auto scaling for time axis --- scope.py | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/scope.py b/scope.py index 463000a..1d96bf2 100644 --- a/scope.py +++ b/scope.py @@ -1,4 +1,16 @@ +# Scope +# Shows data in the style of an oscilloscope. + +# +# Todos: +# - use correct time axis +# - allow the user to change the scaling +# - use functions intead of copy&paste code +# - support more channels +# - (and more) +# + from tkinter import * import time import sys # for argv @@ -39,7 +51,6 @@ c.create_line(x0Scope, y0Scope, x0Scope, y0Scope+ySizeScope, fill="#FFFFFF") c.create_line(x0Scope+xSizeScope, y0Scope+ySizeScope, x0Scope+xSizeScope, y0Scope, fill="#FFFFFF") c.create_line(x0Scope+xSizeScope, y0Scope+ySizeScope, x0Scope, y0Scope+ySizeScope, fill="#FFFFFF") - inputFileName = "local/pcaps_converted/2023-05-12_170340_tcpdump.pcap.values.txt" fileIn = open(inputFileName, 'r') Lines = fileIn.readlines() @@ -81,6 +92,17 @@ for line in Lines: #print("Line{}: {}".format(count, line.strip())) fileIn.close() +# Hack: look which channel has the most samples. +# Todo: This is not correct, because we have to use the time stamp instead of the sample number. +maxSamples = 1 +if maxSamplesvMax): @@ -195,12 +217,12 @@ print("Offset: " + str(offs3)) x = x0Scope for v in ch3values: - yPix = y0Scope+ySizeScope - (v - offs1)/perDiv3 * ySizeScope / divisionsPerScreen - x1, y1 = ( x - 1 ), ( yPix - 1 ) - x2, y2 = ( x + 1 ), ( yPix + 1 ) + yPix = y0Scope+ySizeScope - (v - offs3)/perDiv3 * ySizeScope / divisionsPerScreen + x1, y1 = ( x - 3 ), ( yPix - 3 ) + x2, y2 = ( x + 3 ), ( yPix + 3 ) c.create_line(x1, y1, x2, y2, fill=strCh3Color) c.create_line(x1, y2, x2, y1, fill=strCh3Color) - x+=0.035 + x+=dxPerSample