Skip to content

Commit 4a0daa3

Browse files
committed
release: 1.4.13
1 parent d86a2de commit 4a0daa3

4 files changed

Lines changed: 162 additions & 97 deletions

File tree

SerialUI.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def _numba_probe(x):
202202
DEFAULT_TEXT_LINES, MAX_TEXT_LINES, MAX_ROWS,
203203
DEBUGKEYINPUT, DEBUG_LEVEL, DEBUGRECEIVER, DEBUGCHART,
204204
ENCODING, BACKGROUNDCOLOR, BACKGROUNDCOLOR_LOG, BACKGROUNDCOLOR_TABS,
205+
BLESCAN_SHORT,
205206
EOL_DICT, EOL_DICT_INV, EOL_DEFAULT_LABEL, EOL_DEFAULT_BYTES, DEFAULT_LINETERMINATOR,
206207
PARSE_OPTIONS, PARSE_OPTIONS_INV, PARSE_DEFAULT_LABEL, PARSE_DEFAULT_NAME,
207208
LOG_OPTIONS, LOG_OPTIONS_INV, LOG_DEFAULT_LABEL, LOG_DEFAULT_NAME,
@@ -252,7 +253,7 @@ def _numba_probe(x):
252253
QTextEdit, QTabWidget, QWidget,
253254
QPlainTextEdit, QApplication,
254255
)
255-
from PyQt6.QtGui import QIcon, QShortcut, QTextCursor, QTextOption, QKeySequence, QGuiApplication, QPixmap
256+
from PyQt6.QtGui import QIcon, QShortcut, QTextCursor, QTextOption, QKeySequence, QGuiApplication, QPixmap, QFontDatabase
256257
WindowType = Qt.WindowType
257258
ConnectionType= Qt.ConnectionType
258259
NO_WRAP = QPlainTextEdit.LineWrapMode.NoWrap
@@ -274,7 +275,7 @@ def _numba_probe(x):
274275
QPlainTextEdit, QApplication,
275276
)
276277
from PyQt5.QtGui import (
277-
QIcon, QTextCursor, QTextOption, QKeySequence, QGuiApplication, QPixmap
278+
QIcon, QTextCursor, QTextOption, QKeySequence, QGuiApplication, QPixmap, QFontDatabase
278279
)
279280
WindowType = Qt
280281
ConnectionType= Qt
@@ -414,6 +415,7 @@ def __init__(self, parent=None, logger=None):
414415

415416
self.isMonitoring = False
416417
self.isPlotting = False # chart receiver status request
418+
self.startup_work_scheduled = False
417419
self.lineSendHistory = [] # previously sent text (e.g. commands)
418420
self.lineSendHistoryIndx = -1
419421
self.textLineTerminator = DEFAULT_LINETERMINATOR
@@ -430,6 +432,11 @@ def __init__(self, parent=None, logger=None):
430432

431433
self.log_widget = self.ui.plainTextEdit_Log
432434
self.log_widget.setStyleSheet(f"background-color: {BACKGROUNDCOLOR_LOG};")
435+
if hasQt6:
436+
log_font = QFontDatabase.systemFont(QFontDatabase.SystemFont.FixedFont)
437+
else:
438+
log_font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
439+
self.log_widget.setFont(log_font)
433440

434441
# Modify LOG display window on serial text display
435442
self.log_widget.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOn)
@@ -1096,8 +1103,16 @@ def on_tab_change(self, index: int) -> None:
10961103
self.text_scroll_bar.setValue(self.text_scroll_bar.maximum())
10971104
self.log_scroll_bar.setValue(self.log_scroll_bar.maximum())
10981105

1106+
elif tab_name == "Log":
1107+
self.log_scroll_bar.setValue(self.log_scroll_bar.maximum())
1108+
10991109
elif tab_name == "Plotter":
1100-
pass
1110+
if USE_FASTPLOTLIB:
1111+
if not self.chart.chartFPLInitialized:
1112+
QTimer.singleShot(0, self.chart.fpl_figure_init)
1113+
else:
1114+
if not self.chart.chartPGInitialized:
1115+
QTimer.singleShot(0, self.chart.pg_figure_init)
11011116

11021117
elif tab_name == "Indicator":
11031118
pass
@@ -1131,6 +1146,14 @@ def on_pushButton_toBLE(self) -> None:
11311146
return
11321147

11331148
self.ui.stackedWidget_BLE_Serial.setCurrentIndex(1)
1149+
if not self.ble.device_scan_requested:
1150+
self.ble.device_scan_requested = True
1151+
self.ble.scanDevicesRequest.emit(float(BLESCAN_SHORT))
1152+
self.ble.ui.pushButton_BLEScan.setEnabled(False)
1153+
self.ble.ui.pushButton_BLEConnect.setEnabled(False)
1154+
self.handle_log(logging.INFO,
1155+
f"[{self.instance_name[:15]:<15}]: BLE device auto-scan requested ({BLESCAN_SHORT:.1f}s)."
1156+
)
11341157
self.handle_log(logging.INFO,
11351158
f"[{self.instance_name[:15]:<15}]: BLE."
11361159
)
@@ -1140,13 +1163,13 @@ def on_pushButton_toBLE(self) -> None:
11401163
def showEvent(self, event):
11411164
"""Qt calls this when the User Interface window is shown."""
11421165
super().showEvent(event)
1143-
if USE_FASTPLOTLIB:
1144-
QTimer.singleShot(200, self.chart.fpl_figure_init)
1145-
else:
1146-
QTimer.singleShot(200, self.chart.pg_figure_init)
1147-
1148-
# Start the Monitoring by default
1149-
QTimer.singleShot(0, lambda: self.runMonitoringRequest.emit(True))
1166+
if self.startup_work_scheduled:
1167+
return
1168+
1169+
self.startup_work_scheduled = True
1170+
1171+
# Give the UI time to paint and accept input before auto-start work begins.
1172+
QTimer.singleShot(750, lambda: self.runMonitoringRequest.emit(True))
11501173

11511174
@pyqtSlot()
11521175
def closeEvent(self, event):

assets/serialUI.ui

Lines changed: 113 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>1290</width>
9+
<width>1299</width>
1010
<height>800</height>
1111
</rect>
1212
</property>
@@ -192,41 +192,13 @@
192192
</property>
193193
</widget>
194194
</item>
195-
<item>
196-
<widget class="QPlainTextEdit" name="plainTextEdit_Log">
197-
<property name="sizePolicy">
198-
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
199-
<horstretch>1</horstretch>
200-
<verstretch>0</verstretch>
201-
</sizepolicy>
202-
</property>
203-
<property name="minimumSize">
204-
<size>
205-
<width>0</width>
206-
<height>100</height>
207-
</size>
208-
</property>
209-
<property name="maximumSize">
210-
<size>
211-
<width>16777215</width>
212-
<height>100</height>
213-
</size>
214-
</property>
215-
<property name="font">
216-
<font>
217-
<family>Fira Mono</family>
218-
<pointsize>9</pointsize>
219-
</font>
220-
</property>
221-
</widget>
222-
</item>
223195
<item>
224196
<layout class="QHBoxLayout" name="horizontalLayout_bottom_Monitor" stretch="0">
225197
<property name="spacing">
226198
<number>3</number>
227199
</property>
228200
<item>
229-
<layout class="QHBoxLayout" name="horizontalLayout_bottom_Monitor_left" stretch="0,0,0,0,0,0,0,1,0,0,0">
201+
<layout class="QHBoxLayout" name="horizontalLayout_bottom_Monitor_left" stretch="0,0,0,0,0,0,0,1,0">
230202
<property name="spacing">
231203
<number>3</number>
232204
</property>
@@ -403,51 +375,6 @@
403375
</property>
404376
</spacer>
405377
</item>
406-
<item>
407-
<widget class="QLabel" name="label_LogLevel">
408-
<property name="text">
409-
<string>Log Level</string>
410-
</property>
411-
</widget>
412-
</item>
413-
<item>
414-
<widget class="QComboBox" name="comboBoxDropDown_LogLevel">
415-
<property name="minimumSize">
416-
<size>
417-
<width>0</width>
418-
<height>30</height>
419-
</size>
420-
</property>
421-
<property name="sizeAdjustPolicy">
422-
<enum>QComboBox::AdjustToContents</enum>
423-
</property>
424-
<item>
425-
<property name="text">
426-
<string>DEBUG</string>
427-
</property>
428-
</item>
429-
<item>
430-
<property name="text">
431-
<string>INFO</string>
432-
</property>
433-
</item>
434-
<item>
435-
<property name="text">
436-
<string>WARNING</string>
437-
</property>
438-
</item>
439-
<item>
440-
<property name="text">
441-
<string>ERROR</string>
442-
</property>
443-
</item>
444-
<item>
445-
<property name="text">
446-
<string>CRITICAL</string>
447-
</property>
448-
</item>
449-
</widget>
450-
</item>
451378
<item>
452379
<widget class="QGroupBox" name="groupBox_History">
453380
<property name="sizePolicy">
@@ -2133,6 +2060,116 @@
21332060
</item>
21342061
</layout>
21352062
</widget>
2063+
<widget class="QWidget" name="Log">
2064+
<property name="sizePolicy">
2065+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
2066+
<horstretch>1</horstretch>
2067+
<verstretch>1</verstretch>
2068+
</sizepolicy>
2069+
</property>
2070+
<attribute name="title">
2071+
<string>Log</string>
2072+
</attribute>
2073+
<layout class="QVBoxLayout" name="verticalLayout_Log">
2074+
<property name="spacing">
2075+
<number>3</number>
2076+
</property>
2077+
<property name="leftMargin">
2078+
<number>3</number>
2079+
</property>
2080+
<property name="topMargin">
2081+
<number>3</number>
2082+
</property>
2083+
<property name="rightMargin">
2084+
<number>3</number>
2085+
</property>
2086+
<property name="bottomMargin">
2087+
<number>3</number>
2088+
</property>
2089+
<item>
2090+
<layout class="QHBoxLayout" name="horizontalLayout_Log">
2091+
<property name="spacing">
2092+
<number>3</number>
2093+
</property>
2094+
<item>
2095+
<widget class="QPlainTextEdit" name="plainTextEdit_Log">
2096+
<property name="sizePolicy">
2097+
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
2098+
<horstretch>1</horstretch>
2099+
<verstretch>1</verstretch>
2100+
</sizepolicy>
2101+
</property>
2102+
</widget>
2103+
</item>
2104+
</layout>
2105+
</item>
2106+
<item>
2107+
<layout class="QHBoxLayout" name="horizontalLayout_bottom_Log">
2108+
<property name="spacing">
2109+
<number>3</number>
2110+
</property>
2111+
<item>
2112+
<spacer name="horizontalSpacer_bottom_Log_spacer">
2113+
<property name="orientation">
2114+
<enum>Qt::Horizontal</enum>
2115+
</property>
2116+
<property name="sizeHint" stdset="0">
2117+
<size>
2118+
<width>40</width>
2119+
<height>20</height>
2120+
</size>
2121+
</property>
2122+
</spacer>
2123+
</item>
2124+
<item>
2125+
<widget class="QLabel" name="label_LogLevel">
2126+
<property name="text">
2127+
<string>Log Level</string>
2128+
</property>
2129+
</widget>
2130+
</item>
2131+
<item>
2132+
<widget class="QComboBox" name="comboBoxDropDown_LogLevel">
2133+
<property name="minimumSize">
2134+
<size>
2135+
<width>0</width>
2136+
<height>30</height>
2137+
</size>
2138+
</property>
2139+
<property name="sizeAdjustPolicy">
2140+
<enum>QComboBox::AdjustToContents</enum>
2141+
</property>
2142+
<item>
2143+
<property name="text">
2144+
<string>DEBUG</string>
2145+
</property>
2146+
</item>
2147+
<item>
2148+
<property name="text">
2149+
<string>INFO</string>
2150+
</property>
2151+
</item>
2152+
<item>
2153+
<property name="text">
2154+
<string>WARNING</string>
2155+
</property>
2156+
</item>
2157+
<item>
2158+
<property name="text">
2159+
<string>ERROR</string>
2160+
</property>
2161+
</item>
2162+
<item>
2163+
<property name="text">
2164+
<string>CRITICAL</string>
2165+
</property>
2166+
</item>
2167+
</widget>
2168+
</item>
2169+
</layout>
2170+
</item>
2171+
</layout>
2172+
</widget>
21362173
</widget>
21372174
</item>
21382175
<item>
@@ -3115,7 +3152,7 @@
31153152
<rect>
31163153
<x>0</x>
31173154
<y>0</y>
3118-
<width>1290</width>
3155+
<width>1299</width>
31193156
<height>22</height>
31203157
</rect>
31213158
</property>

config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from helpers.colors import color_names_sweet16 as COLORS
77
################################################################################################################################
88
# Constants General
9-
VERSION = "1.4.11" # this version
9+
VERSION = "1.4.13" # this version
1010
AUTHOR = "Urs Utzinger" # me
1111
DATE = "2026" # year of last update
1212
################################################################################################################################
@@ -61,6 +61,8 @@
6161
TX_CHARACTERISTIC_UUID = "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"
6262
# BLE Constants
6363
BLETIMEOUT = 30 # Timeout for BLE operations
64+
BLESCAN_SHORT = 2 # [s] short BLE discovery when switching to BLE view
65+
BLESCAN_LONG = 5 # [s] full BLE discovery when user clicks Scan
6466
ATT_HDR = 3 # Attribute header length
6567
BLEMTUMAX = 517 # Maximum MTU size
6668
BLEMTUNORMAL = 247 # Normal MTU size

0 commit comments

Comments
 (0)