diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui
index 9598f3a..1bd4d7b 100644
--- a/gui/mainwindow.ui
+++ b/gui/mainwindow.ui
@@ -6,8 +6,8 @@
0
0
- 503
- 530
+ 493
+ 466
@@ -32,29 +32,62 @@
-
-
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
-
+
+
+
+ 75
+ true
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+ Qt::LeftToRight
+
+
+ QTabWidget::South
+
0
-
-
-
- 0
- -25
- 471
- 399
-
-
+
-
+
0
0
-
- Programming
+
+ Flashing
-
+
-
@@ -62,6 +95,66 @@
+ -
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ true
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Upload
+
+
+
+ -
+
+
+ Expert mode
+
+
+ true
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Board:
+
+
+
-
@@ -101,98 +194,143 @@
- -
-
+
+
+
+
+ Discovery
+
+
+ -
+
- -
-
+
-
+
+
+
+ true
+
+
+
+ Double-click to open configuration page.
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+ -
+
-
+
0
0
-
+
+ Sensors detected in local network:
+
+
+
+ -
+
+
+ Refresh
+
+
+
+
+
+
+
+ Serial Monitor
+
+
+ -
+
+
+ -
+
+
+ In case of sensor issues, Serial Monitor can be used to review logs sent by the sensor over USB cable.
+
+
true
- -
-
-
- Board:
-
-
-
- -
-
-
-
-
-
-
- 0
- 0
-
-
-
- Upload
-
-
-
- -
-
-
- Expert mode
-
-
- true
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
-
-
-
-
- 0
- 0
- 491
- 374
-
-
-
- Discovery
-
-
-
-
-
- -
-
+
- Scan
+ Connect
+
+
+ true
-
-
+
+
About
-
+
+
+ 12
+
+ -
+
+
+
+ 64
+ 64
+
+
+
+
+
+
+ ../assets/logo.png
+
+
+ true
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ Luftdaten.info Flashing Tool
+
+
+
+ -
+
+
+ <html><head/><body><p>Developed by <a href="https://inf.re/"><span style=" text-decoration: underline; color:#0000ff;">Piotr Dobrowolski</span></a>.</p><p>This software is released under the terms of MIT license. No warranty is provided.</p><p>For newest release see: <a href="https://d.inf.re/luftdaten/"><span style=" text-decoration: underline; color:#0000ff;">https://d.inf.re/luftdaten/</span></a></p></body></html>
+
+
+ Qt::RichText
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
+
+ true
+
+
+ true
+
+
+
+
@@ -203,8 +341,8 @@
0
0
- 503
- 29
+ 493
+ 20
diff --git a/i18n/Polish.ts b/i18n/Polish.ts
index b6fbb16..a13f545 100644
--- a/i18n/Polish.ts
+++ b/i18n/Polish.ts
@@ -4,94 +4,149 @@
MainWindow
-
+
No boards found
Nie znaleziono płytki
-
+
Others...
Inne...
-
+
No device selected.
Nie wybrano urządzenia.
-
+
No version selected.
Nie wybrano wersji.
-
+
Board:
Płytka:
-
+
Firmware version:
Wersja oprogramowania:
-
+
Upload
Wgraj
-
+
Expert mode
Tryb eksperta
-
+
Baudrate:
Prędkość portu:
-
+
Invalid version / file does not exist
Błędna wersja / plik nie istnieje
-
+
Work in progess...
Praca w toku...
-
+
Downloading...
Pobieranie...
-
+
Connecting...
Łączenie...
-
+
Connected. Chip type: {chip_type}
Połączono. Typ układu: {chip_type}
-
+
Writing at 0x{address:08x}...
Zapisywanie pod adresem 0x{address:08x}...
-
+
Finished in {time:.2f} seconds. Sensor ID: {sensor_id}
Zakończono w {time:.2f} sekundy. ID sensora: {sensor_id}
-
+
Luftdaten.info Flashing Tool
Luftdaten.info Flashing Tool
-
+
Loading firmware list...
Ładowanie wersji oprogramowania...
+
+
+ Have you installed <a href="{drivers_url}">the drivers</a>?
+ Czy zainstalowałeś <a href="{drivers_url}">sterowniki</a>?
+
+
+
+ Flashing
+ Programowanie
+
+
+
+ Double-click to open configuration page.
+ Naciśnij dwukrotnie aby otworzyć stronę konfiguracji.
+
+
+
+ Sensors detected in local network:
+ Sensory wykryte w sieci lokalnej:
+
+
+
+ Refresh
+ Odśwież
+
+
+
+ Discovery
+ Wykrywanie
+
+
+
+ In case of sensor issues, Serial Monitor can be used to review logs sent by the sensor over USB cable.
+ W przypadku problemów z sensorem, Serial Monitor pozwala na przejrzenie stanu urządzenia przez kabel USB.
+
+
+
+ Connect
+ Połącz
+
+
+
+ Serial Monitor
+ Serial Monitor
+
+
+
+ <html><head/><body><p>Developed by <a href="https://inf.re/"><span style=" text-decoration: underline; color:#0000ff;">Piotr Dobrowolski</span></a>.</p><p>This software is released under the terms of MIT license. No warranty is provided.</p><p>For newest release see: <a href="https://d.inf.re/luftdaten/"><span style=" text-decoration: underline; color:#0000ff;">https://d.inf.re/luftdaten/</span></a></p></body></html>
+ <html><head/><body><p>Wykonane przez <a href="https://inf.re/"><span style=" text-decoration: underline; color:#0000ff;">Piotr Dobrowolski</span></a>.</p><p>Ten program wypuszczony jest na warunkach licencji MIT. Brak gwarancji.</p><p>Najnowszą wersję znajdziesz na: <a href="https://d.inf.re/luftdaten/"><span style=" text-decoration: underline; color:#0000ff;">https://d.inf.re/luftdaten/</span></a></p></body></html>
+
+
+
+ About
+ O programie
+
diff --git a/luftdaten-tool.py b/luftdaten-tool.py
index 311440f..a1c8fbe 100644
--- a/luftdaten-tool.py
+++ b/luftdaten-tool.py
@@ -19,7 +19,7 @@ from luftdatentool.workers import PortDetectThread, FirmwareListThread, \
from gui import mainwindow
from luftdatentool.consts import UPDATE_REPOSITORY, ALLOWED_PROTO, \
- PREFERED_PORTS, ROLE_DEVICE
+ PREFERED_PORTS, ROLE_DEVICE, DRIVERS_URL
if getattr(sys, 'frozen', False):
RESOURCES_PATH = sys._MEIPASS
@@ -31,6 +31,8 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
uploadProgress = QtCore.Signal([str, int])
errorSignal = QtCore.Signal([str])
uploadThread = None
+ zeroconf_discovery = None
+ boards_detected = False
def __init__(self, parent=None, app=None):
super(MainWindow, self).__init__(parent)
@@ -43,8 +45,8 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
os.chdir(oldcwd)
self.app = app
- self.translator = QtCore.QTranslator()
+ self.translator = QtCore.QTranslator()
self.i18n_init(QtCore.QLocale.system())
self.statusbar.showMessage(self.tr("Loading firmware list..."))
@@ -59,18 +61,25 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.port_detect.error.connect(self.on_work_error)
self.port_detect.start()
- self.zeroconf_discovery = ZeroconfDiscoveryThread()
- self.zeroconf_discovery.deviceDiscovered.connect(
- self.on_zeroconf_discovered)
- self.zeroconf_discovery.start()
+ self.discovery_start()
+ self.globalMessage.hide()
+
+ # Hide WIP GUI parts...
self.on_expertModeBox_clicked()
+ self.expertModeBox.hide()
+ self.tabWidget.removeTab(self.tabWidget.indexOf(self.serialTab))
self.uploadProgress.connect(self.on_work_update)
self.errorSignal.connect(self.on_work_error)
self.cachedir = tempfile.TemporaryDirectory()
+ def show_global_message(self, title, message):
+ self.globalMessage.show()
+ self.globalMessageTitle.setText(title)
+ self.globalMessageText.setText(message)
+
def on_work_update(self, status, progress):
self.statusbar.showMessage(status)
self.progressBar.setValue(progress)
@@ -78,17 +87,6 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def on_work_error(self, message):
self.statusbar.showMessage(message)
- def on_zeroconf_discovered(self, name, address, info):
- """Called on every zeroconf discovered device"""
- if name.startswith('Feinstaubsensor'):
- item = QtWidgets.QListWidgetItem('{}: {}'.format(address, name.split('.')[0]))
- item.setData(ROLE_DEVICE, 'http://{}:{}'.format(address, info.port))
- self.listWidget.addItem(item)
-
- @QtCore.Slot(QtWidgets.QListWidgetItem)
- def on_listWidget_itemDoubleClicked(self, index):
- QtGui.QDesktopServices.openUrl(QtCore.QUrl(index.data(ROLE_DEVICE)))
-
def i18n_init(self, locale):
"""Initializes i18n to specified QLocale"""
@@ -131,6 +129,17 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
sep.setEnabled(False)
self.boardBox.model().appendRow(sep)
+ # No prefered boards has been found so far and there is a
+ # suggested driver download URL available
+ if not self.boards_detected and DRIVERS_URL:
+ self.show_global_message(
+ self.tr('No boards found'),
+ self.tr('Have you installed '
+ 'the drivers?').format(drivers_url=DRIVERS_URL))
+ else:
+ self.globalMessage.hide()
+ self.boards_detected = True
+
if others:
sep = QtGui.QStandardItem(self.tr('Others...'))
sep.setEnabled(False)
@@ -263,9 +272,36 @@ class MainWindow(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
@QtCore.Slot()
def on_expertModeBox_clicked(self):
self.expertForm.setVisible(self.expertModeBox.checkState())
- self.centralwidget.setFixedHeight(
- self.centralwidget.sizeHint().height())
- self.setFixedHeight(self.sizeHint().height())
+ #self.centralwidget.setFixedHeight(
+ # self.centralwidget.sizeHint().height())
+ #self.setFixedHeight(self.sizeHint().height())
+
+ # Zeroconf page
+ def discovery_start(self):
+ if self.zeroconf_discovery:
+ self.zeroconf_discovery.stop()
+
+ self.zeroconf_discovery = ZeroconfDiscoveryThread()
+ self.zeroconf_discovery.deviceDiscovered.connect(
+ self.on_zeroconf_discovered)
+ self.zeroconf_discovery.start()
+
+
+ def on_zeroconf_discovered(self, name, address, info):
+ """Called on every zeroconf discovered device"""
+ if name.startswith('Feinstaubsensor'):
+ item = QtWidgets.QListWidgetItem('{}: {}'.format(address, name.split('.')[0]))
+ item.setData(ROLE_DEVICE, 'http://{}:{}'.format(address, info.port))
+ self.discoveryList.addItem(item)
+
+ @QtCore.Slot(QtWidgets.QListWidgetItem)
+ def on_discoveryList_itemDoubleClicked(self, index):
+ QtGui.QDesktopServices.openUrl(QtCore.QUrl(index.data(ROLE_DEVICE)))
+
+ @QtCore.Slot()
+ def on_discoveryRefreshButton_clicked(self):
+ self.discoveryList.clear()
+ self.discovery_start()
if __name__ == "__main__":
diff --git a/luftdatentool/consts.py b/luftdatentool/consts.py
index ab53ae5..9522cd6 100644
--- a/luftdatentool/consts.py
+++ b/luftdatentool/consts.py
@@ -1,5 +1,8 @@
+import sys
+
from .qtvariant import QtCore
+
# Firmware update repository
UPDATE_REPOSITORY = 'https://www.madavi.de/sensor/update/data/'
@@ -16,3 +19,10 @@ PREFERED_PORTS = [
]
ROLE_DEVICE = QtCore.Qt.UserRole + 1
+
+if sys.platform.startswith('darwin'):
+ DRIVERS_URL = 'http://www.wch.cn/downloads/CH341SER_MAC_ZIP.html'
+elif sys.platform.startswith(('cygwin', 'win32')):
+ DRIVERS_URL = 'http://www.wch.cn/downloads/CH341SER_ZIP.html'
+else:
+ DRIVERS_URL = None
diff --git a/luftdatentool/workers.py b/luftdatentool/workers.py
index d2aed47..8298814 100644
--- a/luftdatentool/workers.py
+++ b/luftdatentool/workers.py
@@ -39,10 +39,13 @@ class FirmwareListThread(QuickThread):
class ZeroconfDiscoveryThread(QuickThread):
deviceDiscovered = QtCore.Signal(str, str, object)
+ browser = None
def target(self):
- zc = zeroconf.Zeroconf()
- browser = zeroconf.ServiceBrowser(zc, "_http._tcp.local.",
+ """This thread scans for Bonjour/mDNS devices and emits
+ deviceDiscovered signal with its name, address and info object"""
+ self.zc = zeroconf.Zeroconf()
+ self.browser = zeroconf.ServiceBrowser(self.zc, "_http._tcp.local.",
handlers=[self.on_state_change])
while True:
time.sleep(0.5)
@@ -51,3 +54,7 @@ class ZeroconfDiscoveryThread(QuickThread):
info = zeroconf.get_service_info(service_type, name)
if info:
self.deviceDiscovered.emit(name, socket.inet_ntoa(info.address), info)
+
+ def stop(self):
+ if self.browser:
+ self.browser.cancel()