mirror of
https://github.com/janishutz/BiogasControllerApp.git
synced 2025-11-25 05:44:23 +00:00
Redesign app, prepare for 3.1.0 release
This commit is contained in:
@@ -1,19 +1,13 @@
|
||||
<HomeScreen>:
|
||||
name: "home"
|
||||
MDGridLayout:
|
||||
cols:1
|
||||
MDFloatLayout:
|
||||
MDCard:
|
||||
radius: 36
|
||||
pos_hint: {"center_x": .5, "center_y": .5}
|
||||
size_hint: .6, .8
|
||||
|
||||
Image:
|
||||
source: "BiogasControllerAppLogo.png"
|
||||
pos_hint: {"top": 1}
|
||||
radius: 36, 36, 0, 0
|
||||
allow_stretch: True
|
||||
keep_ratio: True
|
||||
MDFloatLayout:
|
||||
Image:
|
||||
source: "BiogasControllerAppLogo.png"
|
||||
pos_hint: {"top": 0.9}
|
||||
size_hint_y: .3
|
||||
radius: 36, 36, 0, 0
|
||||
allow_stretch: True
|
||||
keep_ratio: True
|
||||
|
||||
MDGridLayout:
|
||||
cols: 1
|
||||
@@ -28,32 +22,41 @@
|
||||
pos_hint: {'center_x': 0, 'center_y': 0}
|
||||
|
||||
|
||||
MDFloatLayout:
|
||||
MDGridLayout:
|
||||
cols: 2
|
||||
size_hint: 0.2, 0.2
|
||||
pos_hint: {"x": 0.4, "y": 0.3}
|
||||
MDGridLayout:
|
||||
spacing: 20
|
||||
size_hint: None, None
|
||||
size: self.minimum_size
|
||||
cols: 2
|
||||
pos_hint: {'center_x': 0.5, 'center_y': 0.3 }
|
||||
MDFillRoundFlatButton:
|
||||
font_size: 30
|
||||
text: "Start"
|
||||
on_release: root.start()
|
||||
|
||||
MDRaisedButton:
|
||||
on_release: root.start()
|
||||
font_size: 30
|
||||
text: "Start"
|
||||
radius: [25]
|
||||
MDRaisedButton:
|
||||
text: "Quit"
|
||||
font_size: 30
|
||||
on_release:
|
||||
root.quit()
|
||||
MDFillRoundFlatButton:
|
||||
text: "Quit"
|
||||
font_size: 30
|
||||
pos_hint: {"x": 0.7, "center_y": 0}
|
||||
on_release: root.quit()
|
||||
|
||||
MDLabel:
|
||||
text: "You are running version V3.0.1"
|
||||
font_size: 13
|
||||
pos_hint: {"y": -0.45, "x":0}
|
||||
halign: 'center'
|
||||
MDFlatButton:
|
||||
text: "About"
|
||||
font_size: 13
|
||||
size_hint: 0.07, 0.06
|
||||
pos_hint: {"x":0.01, "y":0.01}
|
||||
on_release:
|
||||
root.to_about()
|
||||
MDLabel:
|
||||
text: "You are running version V3.1.0"
|
||||
font_size: 13
|
||||
pos_hint: {"y": -0.45, "x":0}
|
||||
halign: 'center'
|
||||
|
||||
MDFlatButton:
|
||||
text: "About"
|
||||
font_size: 13
|
||||
size_hint: 0.07, 0.06
|
||||
pos_hint: {"x":0.01, "y":0.01}
|
||||
on_release:
|
||||
root.to_about()
|
||||
|
||||
# MDFlatButton:
|
||||
# text: "Change Theme"
|
||||
# font_size: 13
|
||||
# size_hint: 0.07, 0.06
|
||||
# pos_hint: {"right":0.99, "y":0.01}
|
||||
# on_release:
|
||||
# app.change_theme()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from kivymd.app import MDApp
|
||||
from kivymd.uix.button import MDFlatButton
|
||||
from kivymd.uix.dialog import MDDialog
|
||||
from kivymd.uix.screen import MDScreen
|
||||
from kivy.lang import Builder
|
||||
from gui.popups.popups import DualRowPopup, QuitPopup, TwoActionPopup
|
||||
from lib.com import ComSuperClass
|
||||
import platform
|
||||
|
||||
@@ -10,62 +12,113 @@ 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"
|
||||
"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"
|
||||
}
|
||||
"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
|
||||
class HomeScreen(MDScreen):
|
||||
def __init__(self, com: ComSuperClass, **kw):
|
||||
self._com = com;
|
||||
self._com = com
|
||||
self.connection_error_dialog = MDDialog(
|
||||
title="Connection",
|
||||
text="Failed to connect. See Details for more information and troubleshooting guide",
|
||||
buttons=[
|
||||
MDFlatButton(
|
||||
text="Cancel",
|
||||
on_release=lambda _: self.connection_error_dialog.dismiss(),
|
||||
),
|
||||
MDFlatButton(
|
||||
text="Details", on_release=lambda _: self.open_details_popup()
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
self.quit_dialog = MDDialog(
|
||||
title="Exit BiogasControllerApp",
|
||||
text="Do you really want to exit BiogasControllerApp?",
|
||||
buttons=[
|
||||
MDFlatButton(
|
||||
text="Cancel",
|
||||
on_release=lambda _: self.quit_dialog.dismiss(),
|
||||
),
|
||||
MDFlatButton(
|
||||
text="Quit", on_release=lambda _: self._quit()
|
||||
),
|
||||
],
|
||||
)
|
||||
super().__init__(**kw)
|
||||
|
||||
# Go to the main screen if we can establish connection or the check was disabled
|
||||
def _quit(self):
|
||||
self._com.close()
|
||||
MDApp.get_running_app().stop()
|
||||
|
||||
# Go to the main screen if we can establish connection or the check was disabled
|
||||
# in the configs
|
||||
def start(self):
|
||||
if self._com.connect():
|
||||
self.manager.current = 'main'
|
||||
self.manager.transition.direction = 'right'
|
||||
self.manager.current = "main"
|
||||
self.manager.transition.direction = "right"
|
||||
else:
|
||||
TwoActionPopup().open('Failed to connect', 'Details', self.open_details_popup)
|
||||
print('ERROR connecting')
|
||||
self.connection_error_dialog.open()
|
||||
print("[ COM ] Connection failed!")
|
||||
|
||||
# Open popup for details as to why the connection failed
|
||||
def open_details_popup(self):
|
||||
DualRowPopup().open("Troubleshooting tips", self._generate_help())
|
||||
self.connection_error_dialog.dismiss()
|
||||
self.details_dialog = MDDialog(
|
||||
title="Troubleshooting",
|
||||
text=self._generate_help(),
|
||||
buttons=[
|
||||
MDFlatButton(
|
||||
text="Ok", on_release=lambda _: self.details_dialog.dismiss()
|
||||
)
|
||||
],
|
||||
)
|
||||
self.details_dialog.open()
|
||||
|
||||
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}'"
|
||||
port = self._com.get_comport()
|
||||
if port == "Sim":
|
||||
return "Running in simulator, so this error is just simulated"
|
||||
|
||||
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"
|
||||
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):
|
||||
QuitPopup(self._com).open()
|
||||
self.quit_dialog.open()
|
||||
|
||||
# Switch to about screen
|
||||
def to_about(self):
|
||||
self.manager.current = 'about'
|
||||
self.manager.transition.direction = 'down'
|
||||
self.manager.current = "about"
|
||||
self.manager.transition.direction = "down"
|
||||
|
||||
|
||||
# Load the design file for this screen (.kv files)
|
||||
# The path has to be relative to root of the app, i.e. where the biogascontrollerapp.py
|
||||
# The path has to be relative to root of the app, i.e. where the biogascontrollerapp.py
|
||||
# file is located
|
||||
Builder.load_file('./gui/home/home.kv')
|
||||
Builder.load_file("./gui/home/home.kv")
|
||||
|
||||
Reference in New Issue
Block a user