[chronojump] Encoder: Linux: can stop capture before time ends



commit cb1adbffda99cf5969cdd71516ceba8ba027c81b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 8 12:40:23 2013 +0100

    Encoder: Linux: can stop capture before time ends

 encoder/graph.R           |    5 -----
 encoder/pyserial_pyper.py |   14 ++++++++++++--
 2 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/encoder/graph.R b/encoder/graph.R
index 43cc6d4..74a7b8b 100644
--- a/encoder/graph.R
+++ b/encoder/graph.R
@@ -680,10 +680,6 @@ paint1RMBadillo2010 <- function (paf, title) {
 		                          0.715, 0.635, 0.555, 0.475, 0.405, 0.325, 0.255, 0.185)
 	#variation <- c(0.08, 0.07, 0.06, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.04, 0.04, 0.04, 0.04, 0.03, 0.04)
 
-	#example of meanSpeedPropulsive of some curves:
-	#curvesSpeed <- c(0.60, 0.40, 1.5)
-	#curvesLoad <- c(80, 93, 25)
-
 	maxy=max(c(msp,curvesSpeed))
 	miny=min(c(msp,curvesSpeed))
 
@@ -705,7 +701,6 @@ paint1RMBadillo2010 <- function (paf, title) {
 	abline(h=msp, lty=2, col="gray")
 	mtext(side=4,at=msp, paste(" ",loadPercent), las=2)
 
-	#arrows(curvesLoad,curvesSpeed,loadCalc,0.185,code=2,col=heat.colors(100)[(100-loadPercentCalc)])
 	colors=c(rep(NA,29),rev(heat.colors(100)[0:71]))
 	arrows(curvesLoad,curvesSpeed,loadCalc,0.185,code=2,col=colors[loadPercentCalc])
 
diff --git a/encoder/pyserial_pyper.py b/encoder/pyserial_pyper.py
index 17061ad..3cefa09 100644
--- a/encoder/pyserial_pyper.py
+++ b/encoder/pyserial_pyper.py
@@ -32,7 +32,7 @@ from pyper import *
 #import pygame.image
 #import pygame.display
 import pygame
-#from pygame.locals import * #mouse and key definitions
+from pygame.locals import * #mouse and key definitions
 
 
 print(sys.argv)
@@ -472,7 +472,16 @@ if __name__ == '__main__':
 	secondsLeft = int(record_time / 1000)
 	msCount = 0
 
+	userStops = FALSE
 	for i in xrange(record_time):
+		for event in pygame.event.get():
+			if event.type == pygame.QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
+				userStops = TRUE
+		
+		if userStops:
+			print "USER BREAKS"
+			break
+
 		#if ser.readable(): #commented because don't work on linux
 		byte_data = ser.read()
 		# conver HEX to INT value
@@ -598,7 +607,8 @@ if __name__ == '__main__':
 	
 	while 1:
 		for event in pygame.event.get():
-			if event.type == pygame.QUIT: sys.exit()
+			if event.type == pygame.QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
+				sys.exit()
 
 		pygame.time.delay(30)
 		pygame.display.flip() #update the screen


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]