Preferences: added config option for the MicroPython serial communication timeout. micropython

Sat, 27 Jul 2019 15:41:52 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Jul 2019 15:41:52 +0200
branch
micropython
changeset 7086
b757db426076
parent 7085
328f0f44aa95
child 7087
2ca7fb61a82f

Preferences: added config option for the MicroPython serial communication timeout.

eric6/Preferences/ConfigurationPages/MicroPythonPage.py file | annotate | diff | comparison | revisions
eric6/Preferences/ConfigurationPages/MicroPythonPage.ui file | annotate | diff | comparison | revisions
eric6/Preferences/__init__.py file | annotate | diff | comparison | revisions
--- a/eric6/Preferences/ConfigurationPages/MicroPythonPage.py	Sat Jul 27 15:40:51 2019 +0200
+++ b/eric6/Preferences/ConfigurationPages/MicroPythonPage.py	Sat Jul 27 15:41:52 2019 +0200
@@ -38,6 +38,9 @@
         self.colorSchemeComboBox.setCurrentIndex(
             self.colorSchemeComboBox.findText(
                 Preferences.getMicroPython("ColorScheme")))
+        self.timeoutSpinBox.setValue(
+            Preferences.getMicroPython("SerialTimeout") / 1000)
+        # converted to seconds
     
     def save(self):
         """
@@ -45,6 +48,9 @@
         """
         Preferences.setMicroPython(
             "ColorScheme", self.colorSchemeComboBox.currentText())
+        Preferences.setMicroPython(
+            "SerialTimeout", self.timeoutSpinBox.value() * 1000)
+        # converted to milliseconds
     
 
 def create(dlg):
--- a/eric6/Preferences/ConfigurationPages/MicroPythonPage.ui	Sat Jul 27 15:40:51 2019 +0200
+++ b/eric6/Preferences/ConfigurationPages/MicroPythonPage.ui	Sat Jul 27 15:41:52 2019 +0200
@@ -32,18 +32,71 @@
     </widget>
    </item>
    <item>
-    <widget class="QLabel" name="label">
-     <property name="text">
-      <string>Color Scheme for ANSI Escape Codes:</string>
-     </property>
-    </widget>
-   </item>
-   <item>
-    <widget class="QComboBox" name="colorSchemeComboBox">
-     <property name="toolTip">
-      <string>Select the color scheme to be applied for ANSI color escape codes</string>
-     </property>
-    </widget>
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="0">
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Color Scheme for ANSI Escape Codes:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QComboBox" name="colorSchemeComboBox">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="toolTip">
+        <string>Select the color scheme to be applied for ANSI color escape codes</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Timeout for Serial Link Communication:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <widget class="QSpinBox" name="timeoutSpinBox">
+         <property name="toolTip">
+          <string>Enter the timout value</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+         </property>
+         <property name="suffix">
+          <string> s</string>
+         </property>
+         <property name="minimum">
+          <number>1</number>
+         </property>
+         <property name="maximum">
+          <number>30</number>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>108</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </item>
+    </layout>
    </item>
    <item>
     <spacer name="verticalSpacer">
--- a/eric6/Preferences/__init__.py	Sat Jul 27 15:40:51 2019 +0200
+++ b/eric6/Preferences/__init__.py	Sat Jul 27 15:41:52 2019 +0200
@@ -1592,6 +1592,7 @@
     
     # defaults for MicroPython
     microPythonDefaults = {
+        "SerialTimeout": 10000,         # timeout in milliseconds
     }
     if Globals.isWindowsPlatform():
         microPythonDefaults["ColorScheme"] = "Windows 10"
@@ -3821,9 +3822,14 @@
     @param prefClass preferences class used as the storage area
     @return the requested MicroPython value
     """
-    return prefClass.settings.value(
-        "MicroPython/" + key,
-        prefClass.microPythonDefaults[key])
+    if key in ("SerialTimeout"):
+        return int(prefClass.settings.value(
+            "MicroPython/" + key,
+            prefClass.microPythonDefaults[key]))
+    else:
+        return prefClass.settings.value(
+            "MicroPython/" + key,
+            prefClass.microPythonDefaults[key])
 
 
 def setMicroPython(key, value, prefClass=Prefs):

eric ide

mercurial