From 28cc9798e7d3909dd8f72d39763b0d6d3e79e0f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Fri, 2 May 2014 13:53:42 +0200 Subject: [PATCH] small changes to texter and ekgplotter --- ekgplotter/ekgplotter/main.py | 66 +++++++++++++++++++++++++++++++++-- texter/texter/main.py | 2 +- texter/texter/texter3.ui | 10 +++--- texter/texter/texter_ui.py | 8 ++--- 4 files changed, 74 insertions(+), 12 deletions(-) diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index af99120..9c04d3a 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -52,6 +52,69 @@ except ImportError as e: from chaosc.osc_lib import OSCMessage, decode_osc +class Generator(object): + def __init__(self): + self.count = 0 + self.max_count = 200 + self.min_puls = 75 + self.max_pulse = 160 + self.pulse = 83 + + def run(self): + data_points = 0 + + min_puls = 70 + max_pulse = 130 + pulse = random.randint(min_puls, max_pulse) + + steps, sleep_time = get_steps(pulse, sleep_time) + count = 0 + delta = 1 + + result = list() + + print "pulse", pulse + print "sleep_time", sleep_time + print "steps", steps + + while 1: + value = random.randint(0, steps) + if count < int(steps / 100. * 20): + value = random.randint(0,20) + elif count < int(steps / 100. * 30): + value = random.randint(20, 30) + elif count < int(steps / 100. * 40): + value = random.randint(30,100) + elif count < int(steps / 2.): + value = random.randint(100,200) + elif count == int(steps / 2.): + value = 255 + elif count < int(steps / 100. * 60): + value = random.randint(100, 200) + elif count < int(steps / 100. * 70): + value = random.randint(50, 100) + elif count < int(steps / 100. * 80): + value = random.randint(20, 50) + elif count <= steps: + value = random.randint(0,20) + elif count >= steps: + count = 0 + + #if data_points % (5 * steps) == 0: + #print "new steps", steps, delta + #steps += delta + + #if steps <= min_steps: + #delta = 1 + #elif steps >= max_steps: + #print "change step sign", steps, delta + #delta = -1 + + time.sleep(sleep_time) + count += 1 + #data_points += 1 + serial_sock.write(struct.pack("B", value)) + class OSCThread(threading.Thread): def __init__(self, args): super(OSCThread, self).__init__() @@ -266,7 +329,7 @@ class MyHandler(BaseHTTPRequestHandler): self.thread = thread = OSCThread(self.server.args) thread.daemon = True thread.start() - actor_names = ["bjoern", "uwe", "merle"] + actor_names = ["merle", "uwe", "bjoern" ] num_data = 100 colors = ["r", "g", "b"] qtapp = QtGui.QApplication([]) @@ -339,7 +402,6 @@ def main(): arg_parser.add_subscriber_group() args = arg_parser.finalize() - http_host, http_port = resolve_host(args.http_host, args.http_port, args.address_family) server = JustAHTTPServer((http_host, http_port), MyHandler) diff --git a/texter/texter/main.py b/texter/texter/main.py index 8a1a265..a17c363 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -559,7 +559,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): public_rect = self.live_text.geometry() global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) self.ffserver = subprocess.Popen("ffserver -f /etc/ffserver.conf", shell=True, close_fds=True) - self.ffmpeg = subprocess.Popen("ffmpeg -f x11grab -s 768x576 -r 30 -i :0.0+%d,%d -vcodec mjpeg -pix_fmt yuvj444p -r 30 -aspect 4:3 http://localhost:8090/webcam.ffm" % (global_rect.x()+5, global_rect.y()+5), shell=True, close_fds=True) + self.ffmpeg = subprocess.Popen("ffmpeg -f x11grab -show_region 1 -s 768x576 -r 30 -i :0.0+%d,%d -vcodec mjpeg -pix_fmt yuvj444p -r 30 -aspect 4:3 http://localhost:8090/webcam.ffm" % (global_rect.x()+3, global_rect.y()+3), shell=True, close_fds=True) self.is_streaming = True def focusChanged(self, old, new): diff --git a/texter/texter/texter3.ui b/texter/texter/texter3.ui index d9255da..90aeb6e 100644 --- a/texter/texter/texter3.ui +++ b/texter/texter/texter3.ui @@ -90,13 +90,13 @@ 775 - 578 + 582 775 - 578 + 582 @@ -248,13 +248,13 @@ 300 - 577 + 582 - 769 - 577 + 775 + 582 diff --git a/texter/texter/texter_ui.py b/texter/texter/texter_ui.py index 88a4b04..cb7f74b 100644 --- a/texter/texter/texter_ui.py +++ b/texter/texter/texter_ui.py @@ -57,8 +57,8 @@ class Ui_MainWindow(object): self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.live_text = KRichTextWidget(self.centralwidget) - self.live_text.setMinimumSize(QtCore.QSize(775, 578)) - self.live_text.setMaximumSize(QtCore.QSize(775, 578)) + self.live_text.setMinimumSize(QtCore.QSize(775, 582)) + self.live_text.setMaximumSize(QtCore.QSize(775, 582)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) @@ -111,8 +111,8 @@ class Ui_MainWindow(object): sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.preview_text.sizePolicy().hasHeightForWidth()) self.preview_text.setSizePolicy(sizePolicy) - self.preview_text.setMinimumSize(QtCore.QSize(300, 577)) - self.preview_text.setMaximumSize(QtCore.QSize(769, 577)) + self.preview_text.setMinimumSize(QtCore.QSize(300, 582)) + self.preview_text.setMaximumSize(QtCore.QSize(769, 582)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern)