コード例 #1
0
 def tickStrings(self, values, scale, spacing):
     strns = []
     rng = max(values) - min(values)
     #if rng < 120:
     #    return pg.AxisItem.tickStrings(self, values, scale, spacing)
     if rng < 3600 * 24:
         string = '%H:%M:%S'
         label1 = '%b %d -'
         label2 = ' %b %d, %Y'
     elif rng >= 3600 * 24 and rng < 3600 * 24 * 30:
         string = '%d'
         label1 = '%b - '
         label2 = '%b, %Y'
     elif rng >= 3600 * 24 * 30 and rng < 3600 * 24 * 30 * 24:
         string = '%b'
         label1 = '%Y -'
         label2 = ' %Y'
     elif rng >= 3600 * 24 * 30 * 24:
         string = '%Y'
         label1 = ''
         label2 = ''
     for x in values:
         try:
             strns.append(time.strftime(string, time.localtime(x)))
         except ValueError:  ## Windows can't handle dates before 1970
             strns.append('')
     try:
         label = time.strftime(label1, time.localtime(
             min(values))) + time.strftime(label2,
                                           time.localtime(max(values)))
     except ValueError:
         label = ''
     #self.setLabel(text=label)
     return strns
コード例 #2
0
ファイル: 4Time.py プロジェクト: em-gray/FixedChallenge
import numpy as np
from numpy import fft
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph.ptime import time
import time
import serial

# Create serial port and file for writing data
port_name = "COM4"
baudrate = 9600
ser = serial.Serial(port_name, baudrate)

# Creates file with current time to store data in csv format
# "raw-" indicates all four values are the raw data as opposed to fourier transformed
timestr = time.strftime("%Y%m%d-%H%M%S")
datafile = open("raw-" + timestr + ".txt", "w+")
datafile.write("port1,port2,port3,port4\n")

# Initializing all the windows/plots
app = QtGui.QApplication([])
view = pg.GraphicsView()
view.resize(800, 500)
win = pg.GraphicsLayout()
view.setCentralItem(win)
view.show()
view.setWindowTitle('Live plots of EEG from 4 channels')

# Top label
win.addLabel('Raw signal from Arduino', colspan=4)