Commits

iorodeo  committed a9e104d Draft

Modified firmware and GUI so that the use can specify how many frames to drop [1,9].

  • Participants
  • Parent commits 03aa562

Comments (0)

Files changed (5)

File firmware/firmware.pde

 
 // Global variables
 bool pulseHigh = false;
-bool skipPulse = false;
+unsigned int skipPulse = 0;
 unsigned long pulseCount = 0;
 unsigned long pulseTime = 0;
 unsigned long pulseTimeLast = 0;
         cmd = Serial.read();
         switch (cmd) {
 
-            case 's':
-                // Skip a pulse
+            // Skip a upto 9 pulses - this is super cheesey
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7':
+            case '8':
+            case '9':
                 ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
-                    skipPulse = true;
+                    skipPulse = ((unsigned int)cmd) - 48;
                 }
                 break;
 
     else {
         for (int i=0; i<NUM_COUNTER_BITS; i++) {
             if ( i < count%(NUM_COUNTER_BITS+1) ) {
-                //Serial << COUNTER_OUTPUT_PINS[i] << " hi" << endl;
                 digitalWrite(COUNTER_OUTPUT_PINS[i], HIGH);
             }
             else {
-                //Serial << COUNTER_OUTPUT_PINS[i] << " lo" << endl;
                 digitalWrite(COUNTER_OUTPUT_PINS[i], LOW); 
             } 
         }
 }
 
 void onPulseInterrupt() {
-    if (skipPulse) {
-        skipPulse = false;
+    if (skipPulse>0) {
+        skipPulse -= 1;
     }
     else {
         digitalWrite(PULSE_OUTPUT_PIN, HIGH);

File python/pulse_skipper.py

 
 
     def skipClicked(self):
-        self.dev.skipPulse()
+        skipValue = self.skipSpinBox.value()
+        self.dev.skipPulse(skipValue)
 
     def resetClicked(self):
         self.dev.resetCount()

File python/pulse_skipper.ui

    <rect>
     <x>0</x>
     <y>0</y>
-    <width>345</width>
-    <height>263</height>
+    <width>411</width>
+    <height>331</height>
    </rect>
   </property>
+  <property name="minimumSize">
+   <size>
+    <width>0</width>
+    <height>0</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>16777215</height>
+   </size>
+  </property>
   <property name="windowTitle">
    <string>Pulse Skipper</string>
   </property>
      </widget>
     </item>
     <item>
-     <widget class="QWidget" name="widget" native="true">
-      <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <widget class="QGroupBox" name="pulseGroupBox">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="minimumSize">
+       <size>
+        <width>0</width>
+        <height>0</height>
+       </size>
+      </property>
+      <property name="title">
+       <string>Pulse</string>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout">
        <item>
-        <widget class="QGroupBox" name="pulseGroupBox">
+        <widget class="QWidget" name="widget_2" native="true">
          <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
-         <property name="title">
-          <string>Pulse</string>
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>0</height>
+          </size>
          </property>
-         <layout class="QVBoxLayout" name="verticalLayout_2">
+         <property name="maximumSize">
+          <size>
+           <width>16777215</width>
+           <height>16777215</height>
+          </size>
+         </property>
+         <layout class="QHBoxLayout" name="horizontalLayout_3">
+          <item>
+           <widget class="QPushButton" name="resetPushButton">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="minimumSize">
+             <size>
+              <width>120</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>120</width>
+              <height>16777215</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>Reset Counter</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_4">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeType">
+             <enum>QSizePolicy::Fixed</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>10</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
           <item>
            <widget class="QPushButton" name="skipPushButton">
             <property name="sizePolicy">
             </property>
             <property name="minimumSize">
              <size>
-              <width>100</width>
+              <width>120</width>
               <height>0</height>
              </size>
             </property>
             <property name="maximumSize">
              <size>
-              <width>100</width>
+              <width>120</width>
               <height>16777215</height>
              </size>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="QPushButton" name="resetPushButton">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
+           <spacer name="horizontalSpacer_6">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
             </property>
-            <property name="minimumSize">
+            <property name="sizeType">
+             <enum>QSizePolicy::Fixed</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
              <size>
-              <width>100</width>
-              <height>0</height>
+              <width>10</width>
+              <height>20</height>
              </size>
             </property>
-            <property name="maximumSize">
-             <size>
-              <width>100</width>
-              <height>16777215</height>
-             </size>
+           </spacer>
+          </item>
+          <item>
+           <widget class="QSpinBox" name="skipSpinBox">
+            <property name="minimum">
+             <number>1</number>
             </property>
-            <property name="text">
-             <string>Reset Count</string>
+            <property name="maximum">
+             <number>9</number>
             </property>
            </widget>
           </item>
           <item>
-           <spacer name="verticalSpacer_2">
+           <spacer name="horizontalSpacer_3">
             <property name="orientation">
-             <enum>Qt::Vertical</enum>
+             <enum>Qt::Horizontal</enum>
             </property>
             <property name="sizeHint" stdset="0">
              <size>
-              <width>20</width>
-              <height>0</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-         </layout>
-        </widget>
-       </item>
-       <item>
-        <widget class="Line" name="line">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QGroupBox" name="displayGroupBox">
-         <property name="title">
-          <string>Display</string>
-         </property>
-         <layout class="QVBoxLayout" name="verticalLayout">
-          <item>
-           <widget class="QRadioButton" name="numberRadioButton">
-            <property name="text">
-             <string>Number</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QRadioButton" name="binaryRadioButton">
-            <property name="text">
-             <string>Binary</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <spacer name="verticalSpacer">
-            <property name="orientation">
-             <enum>Qt::Vertical</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>20</width>
-              <height>7</height>
+              <width>40</width>
+              <height>20</height>
              </size>
             </property>
            </spacer>
       </layout>
      </widget>
     </item>
+    <item>
+     <widget class="Line" name="line">
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QGroupBox" name="displayGroupBox">
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="minimumSize">
+       <size>
+        <width>150</width>
+        <height>0</height>
+       </size>
+      </property>
+      <property name="title">
+       <string>Display</string>
+      </property>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <item>
+        <widget class="QRadioButton" name="numberRadioButton">
+         <property name="text">
+          <string>Number</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QRadioButton" name="binaryRadioButton">
+         <property name="text">
+          <string>Binary</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+    </item>
+    <item>
+     <spacer name="verticalSpacer">
+      <property name="orientation">
+       <enum>Qt::Vertical</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>20</width>
+        <height>54</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
    </layout>
   </widget>
   <widget class="QMenuBar" name="menubar">
     <rect>
      <x>0</x>
      <y>0</y>
-     <width>345</width>
+     <width>411</width>
      <height>25</height>
     </rect>
    </property>

File python/pulse_skipper_serial.py

         super(PulseSkipperSerial,self).__init__(port=port,baudrate=9600,timeout=5.0)
         time.sleep(2.0)
 
-    def skipPulse(self):
-        self.write('s')
+    def skipPulse(self,n):
+        assert (n>=1 and n<=9), 'pulse number must be in range [1,9]'
+        self.write('{0}'.format(n))
 
     def resetCount(self):
         self.write('r')

File python/pulse_skipper_ui.py

 
 # Form implementation generated from reading ui file 'pulse_skipper.ui'
 #
-# Created: Mon Oct  1 15:43:04 2012
+# Created: Tue Oct  2 16:48:16 2012
 #      by: PyQt4 UI code generator 4.8.3
 #
 # WARNING! All changes made in this file will be lost!
 class Ui_MainWindow(object):
     def setupUi(self, MainWindow):
         MainWindow.setObjectName(_fromUtf8("MainWindow"))
-        MainWindow.resize(345, 263)
+        MainWindow.resize(411, 331)
+        MainWindow.setMinimumSize(QtCore.QSize(0, 0))
+        MainWindow.setMaximumSize(QtCore.QSize(16777215, 16777215))
         self.centralwidget = QtGui.QWidget(MainWindow)
         self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
         self.verticalLayout_3 = QtGui.QVBoxLayout(self.centralwidget)
         self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
         self.line_2.setObjectName(_fromUtf8("line_2"))
         self.verticalLayout_3.addWidget(self.line_2)
-        self.widget = QtGui.QWidget(self.centralwidget)
-        self.widget.setObjectName(_fromUtf8("widget"))
-        self.horizontalLayout_2 = QtGui.QHBoxLayout(self.widget)
-        self.horizontalLayout_2.setMargin(0)
-        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
-        self.pulseGroupBox = QtGui.QGroupBox(self.widget)
+        self.pulseGroupBox = QtGui.QGroupBox(self.centralwidget)
         sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
         sizePolicy.setHorizontalStretch(0)
         sizePolicy.setVerticalStretch(0)
         sizePolicy.setHeightForWidth(self.pulseGroupBox.sizePolicy().hasHeightForWidth())
         self.pulseGroupBox.setSizePolicy(sizePolicy)
+        self.pulseGroupBox.setMinimumSize(QtCore.QSize(0, 0))
         self.pulseGroupBox.setObjectName(_fromUtf8("pulseGroupBox"))
-        self.verticalLayout_2 = QtGui.QVBoxLayout(self.pulseGroupBox)
-        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
-        self.skipPushButton = QtGui.QPushButton(self.pulseGroupBox)
+        self.verticalLayout = QtGui.QVBoxLayout(self.pulseGroupBox)
+        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
+        self.widget_2 = QtGui.QWidget(self.pulseGroupBox)
+        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
+        sizePolicy.setHorizontalStretch(0)
+        sizePolicy.setVerticalStretch(0)
+        sizePolicy.setHeightForWidth(self.widget_2.sizePolicy().hasHeightForWidth())
+        self.widget_2.setSizePolicy(sizePolicy)
+        self.widget_2.setMinimumSize(QtCore.QSize(0, 0))
+        self.widget_2.setMaximumSize(QtCore.QSize(16777215, 16777215))
+        self.widget_2.setObjectName(_fromUtf8("widget_2"))
+        self.horizontalLayout_3 = QtGui.QHBoxLayout(self.widget_2)
+        self.horizontalLayout_3.setMargin(0)
+        self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
+        self.resetPushButton = QtGui.QPushButton(self.widget_2)
+        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+        sizePolicy.setHorizontalStretch(0)
+        sizePolicy.setVerticalStretch(0)
+        sizePolicy.setHeightForWidth(self.resetPushButton.sizePolicy().hasHeightForWidth())
+        self.resetPushButton.setSizePolicy(sizePolicy)
+        self.resetPushButton.setMinimumSize(QtCore.QSize(120, 0))
+        self.resetPushButton.setMaximumSize(QtCore.QSize(120, 16777215))
+        self.resetPushButton.setObjectName(_fromUtf8("resetPushButton"))
+        self.horizontalLayout_3.addWidget(self.resetPushButton)
+        spacerItem2 = QtGui.QSpacerItem(10, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
+        self.horizontalLayout_3.addItem(spacerItem2)
+        self.skipPushButton = QtGui.QPushButton(self.widget_2)
         sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
         sizePolicy.setHorizontalStretch(0)
         sizePolicy.setVerticalStretch(0)
         sizePolicy.setHeightForWidth(self.skipPushButton.sizePolicy().hasHeightForWidth())
         self.skipPushButton.setSizePolicy(sizePolicy)
-        self.skipPushButton.setMinimumSize(QtCore.QSize(100, 0))
-        self.skipPushButton.setMaximumSize(QtCore.QSize(100, 16777215))
+        self.skipPushButton.setMinimumSize(QtCore.QSize(120, 0))
+        self.skipPushButton.setMaximumSize(QtCore.QSize(120, 16777215))
         self.skipPushButton.setObjectName(_fromUtf8("skipPushButton"))
-        self.verticalLayout_2.addWidget(self.skipPushButton)
-        self.resetPushButton = QtGui.QPushButton(self.pulseGroupBox)
-        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
+        self.horizontalLayout_3.addWidget(self.skipPushButton)
+        spacerItem3 = QtGui.QSpacerItem(10, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
+        self.horizontalLayout_3.addItem(spacerItem3)
+        self.skipSpinBox = QtGui.QSpinBox(self.widget_2)
+        self.skipSpinBox.setMinimum(1)
+        self.skipSpinBox.setMaximum(9)
+        self.skipSpinBox.setObjectName(_fromUtf8("skipSpinBox"))
+        self.horizontalLayout_3.addWidget(self.skipSpinBox)
+        spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
+        self.horizontalLayout_3.addItem(spacerItem4)
+        self.verticalLayout.addWidget(self.widget_2)
+        self.verticalLayout_3.addWidget(self.pulseGroupBox)
+        self.line = QtGui.QFrame(self.centralwidget)
+        self.line.setFrameShape(QtGui.QFrame.HLine)
+        self.line.setFrameShadow(QtGui.QFrame.Sunken)
+        self.line.setObjectName(_fromUtf8("line"))
+        self.verticalLayout_3.addWidget(self.line)
+        self.displayGroupBox = QtGui.QGroupBox(self.centralwidget)
+        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Preferred)
         sizePolicy.setHorizontalStretch(0)
         sizePolicy.setVerticalStretch(0)
-        sizePolicy.setHeightForWidth(self.resetPushButton.sizePolicy().hasHeightForWidth())
-        self.resetPushButton.setSizePolicy(sizePolicy)
-        self.resetPushButton.setMinimumSize(QtCore.QSize(100, 0))
-        self.resetPushButton.setMaximumSize(QtCore.QSize(100, 16777215))
-        self.resetPushButton.setObjectName(_fromUtf8("resetPushButton"))
-        self.verticalLayout_2.addWidget(self.resetPushButton)
-        spacerItem2 = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
-        self.verticalLayout_2.addItem(spacerItem2)
-        self.horizontalLayout_2.addWidget(self.pulseGroupBox)
-        self.line = QtGui.QFrame(self.widget)
-        self.line.setFrameShape(QtGui.QFrame.VLine)
-        self.line.setFrameShadow(QtGui.QFrame.Sunken)
-        self.line.setObjectName(_fromUtf8("line"))
-        self.horizontalLayout_2.addWidget(self.line)
-        self.displayGroupBox = QtGui.QGroupBox(self.widget)
+        sizePolicy.setHeightForWidth(self.displayGroupBox.sizePolicy().hasHeightForWidth())
+        self.displayGroupBox.setSizePolicy(sizePolicy)
+        self.displayGroupBox.setMinimumSize(QtCore.QSize(150, 0))
         self.displayGroupBox.setObjectName(_fromUtf8("displayGroupBox"))
-        self.verticalLayout = QtGui.QVBoxLayout(self.displayGroupBox)
-        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
+        self.verticalLayout_2 = QtGui.QVBoxLayout(self.displayGroupBox)
+        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
         self.numberRadioButton = QtGui.QRadioButton(self.displayGroupBox)
         self.numberRadioButton.setObjectName(_fromUtf8("numberRadioButton"))
-        self.verticalLayout.addWidget(self.numberRadioButton)
+        self.verticalLayout_2.addWidget(self.numberRadioButton)
         self.binaryRadioButton = QtGui.QRadioButton(self.displayGroupBox)
         self.binaryRadioButton.setObjectName(_fromUtf8("binaryRadioButton"))
-        self.verticalLayout.addWidget(self.binaryRadioButton)
-        spacerItem3 = QtGui.QSpacerItem(20, 7, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
-        self.verticalLayout.addItem(spacerItem3)
-        self.horizontalLayout_2.addWidget(self.displayGroupBox)
-        self.verticalLayout_3.addWidget(self.widget)
+        self.verticalLayout_2.addWidget(self.binaryRadioButton)
+        self.verticalLayout_3.addWidget(self.displayGroupBox)
+        spacerItem5 = QtGui.QSpacerItem(20, 54, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
+        self.verticalLayout_3.addItem(spacerItem5)
         MainWindow.setCentralWidget(self.centralwidget)
         self.menubar = QtGui.QMenuBar(MainWindow)
-        self.menubar.setGeometry(QtCore.QRect(0, 0, 345, 25))
+        self.menubar.setGeometry(QtCore.QRect(0, 0, 411, 25))
         self.menubar.setObjectName(_fromUtf8("menubar"))
         MainWindow.setMenuBar(self.menubar)
         self.statusbar = QtGui.QStatusBar(MainWindow)
         self.label.setText(QtGui.QApplication.translate("MainWindow", "Port", None, QtGui.QApplication.UnicodeUTF8))
         self.connectPushButton.setText(QtGui.QApplication.translate("MainWindow", "Connect", None, QtGui.QApplication.UnicodeUTF8))
         self.pulseGroupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Pulse", None, QtGui.QApplication.UnicodeUTF8))
+        self.resetPushButton.setText(QtGui.QApplication.translate("MainWindow", "Reset Counter", None, QtGui.QApplication.UnicodeUTF8))
         self.skipPushButton.setText(QtGui.QApplication.translate("MainWindow", "Skip", None, QtGui.QApplication.UnicodeUTF8))
-        self.resetPushButton.setText(QtGui.QApplication.translate("MainWindow", "Reset Count", None, QtGui.QApplication.UnicodeUTF8))
         self.displayGroupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Display", None, QtGui.QApplication.UnicodeUTF8))
         self.numberRadioButton.setText(QtGui.QApplication.translate("MainWindow", "Number", None, QtGui.QApplication.UnicodeUTF8))
         self.binaryRadioButton.setText(QtGui.QApplication.translate("MainWindow", "Binary", None, QtGui.QApplication.UnicodeUTF8))