From 986d887587c2c48cc4fdcf9d1edb1da23d0d001d Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Mon, 12 May 2025 16:28:28 +0200 Subject: [PATCH] UI Tweaks --- biogascontrollerapp/gui/about/about.py | 3 ++ biogascontrollerapp/gui/credits/credits.kv | 2 +- biogascontrollerapp/gui/home/home.kv | 3 +- biogascontrollerapp/gui/home/home.py | 36 +++++++++++++++++++--- biogascontrollerapp/gui/program/program.py | 2 ++ 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/biogascontrollerapp/gui/about/about.py b/biogascontrollerapp/gui/about/about.py index 180e7cf..b18970f 100644 --- a/biogascontrollerapp/gui/about/about.py +++ b/biogascontrollerapp/gui/about/about.py @@ -2,9 +2,12 @@ from kivy.uix.screenmanager import Screen from kivy.lang import Builder import webbrowser +from gui.popups.popups import SingleRowPopup + class AboutScreen(Screen): def report_issue(self): + SingleRowPopup().open("Opened your web-browser") webbrowser.open('https://github.com/janishutz/BiogasControllerApp/issues', new=2) Builder.load_file('./gui/about/about.kv') diff --git a/biogascontrollerapp/gui/credits/credits.kv b/biogascontrollerapp/gui/credits/credits.kv index 3c3a02f..fbe7b63 100644 --- a/biogascontrollerapp/gui/credits/credits.kv +++ b/biogascontrollerapp/gui/credits/credits.kv @@ -19,7 +19,7 @@ pos_hint:{"x":0.05, "y":0.35} size_hint: 0.9, 0.5 Label: - text: "This is a rework of the BiogasControllerApp V1, that was originally programmed by S. Reichmuth." + text: "This is a controller sofware that helps you reprogram and monitor the micro-controller used in ENATECH at KSWO" Label: text: "Written by: Janis Hutz\nDesigned by: Janis Hutz\nDesign language: Kivy" Label: diff --git a/biogascontrollerapp/gui/home/home.kv b/biogascontrollerapp/gui/home/home.kv index e9a052c..6a12cbf 100644 --- a/biogascontrollerapp/gui/home/home.kv +++ b/biogascontrollerapp/gui/home/home.kv @@ -32,8 +32,7 @@ on_release: root.quit() Label: - text: "App version" - id: app_version + text: "You are running version V3.0.0" font_size: 13 pos_hint: {"y": -0.45, "x":0.05} Button: diff --git a/biogascontrollerapp/gui/home/home.py b/biogascontrollerapp/gui/home/home.py index 86630e2..c412375 100644 --- a/biogascontrollerapp/gui/home/home.py +++ b/biogascontrollerapp/gui/home/home.py @@ -1,9 +1,23 @@ from kivy.uix.screenmanager import Screen from kivy.lang import Builder -from gui.popups.popups import QuitPopup, TwoActionPopup +from gui.popups.popups import DualRowPopup, QuitPopup, TwoActionPopup from lib.com import ComSuperClass +import platform -import configparser + +# Information for errors encountered when using pyserial +information = { + "Windows": { + "2": "Un- and replug the cable and ensure you have the required driver(s) installed", + "13": "You are probably missing a required driver or your cable doesn't work. Consult the wiki for more information", + "NO_COM": "Could not find a microcontroller. Please ensure you have one connected and the required driver(s) installed" + }, + "Linux": { + "2": "Un- and replug the cable, or if you haven't plugged a controller in yet, do that", + "13": "Incorrect permissions at /dev/ttyUSB0. Open a terminal and type: sudo chmod 777 /dev/ttyUSB0", + "NO_COM": "Could not find a microcontroller. Please ensure you have one connected" + } +} # This is the launch screen, i.e. what you see when you start up the app @@ -24,8 +38,22 @@ class HomeScreen(Screen): # Open popup for details as to why the connection failed def open_details_popup(self): - # TODO: Finish - print( 'Details' ) + DualRowPopup().open("Troubleshooting tips", self._generate_help()) + + def _generate_help(self) -> str: + operating_system = platform.system() + if operating_system == "Windows" or operating_system == "Linux": + port = self._com.get_comport(); + information["Linux"]["13"] = f"Incorrect permissions at {port}. Resolve by running 'sudo chmod 777 {port}'" + if port == "": + return information[operating_system]["NO_COM"] + err = self._com.get_error() + if err != None: + return information[operating_system][str(err.errno)] + else: + return "No error message available" + else: + return "You are running on an unsupported Operating System. No help available" # Helper to open a Popup to ask user whether to quit or not def quit(self): diff --git a/biogascontrollerapp/gui/program/program.py b/biogascontrollerapp/gui/program/program.py index 04d01ae..baa7d1b 100644 --- a/biogascontrollerapp/gui/program/program.py +++ b/biogascontrollerapp/gui/program/program.py @@ -25,6 +25,7 @@ class ProgramScreen(Screen): # Load the current configuration from the micro-controller def _load(self, dt: float): + # Hook to the microcontroller's data stream (i.e. sync up with it) if self._instructions.hook("RD", ["\n", "R", "D", "\n"]): config: List[List[str]] = [] @@ -35,6 +36,7 @@ class ProgramScreen(Screen): try: received = self._com.receive(28) except: + # Open error popup TwoActionPopup().open( "Failed to connect to micro-controller, retry?", "Cancel",