Update to the backend and new Screen.

Features:
- Added a new settings page
- Laid out some backend stuff to integrate some new features
- prepared backend to include an option to have the previous values also displayed when updating them both screens where you may change configuration of the microcontroller
This commit is contained in:
simplePCBuilding
2022-02-21 18:26:03 +01:00
parent 3c8f814e5f
commit e24f501bf5
15 changed files with 270 additions and 51 deletions

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -5,6 +5,7 @@ RootScreen:
ProgramTemp: ProgramTemp:
Program: Program:
Credits: Credits:
Modify:
<QuitPU>: <QuitPU>:
title: "BiogasControllerApp" title: "BiogasControllerApp"
@@ -214,18 +215,18 @@ RootScreen:
on_release: on_release:
root.exitapp() root.exitapp()
Label: Label:
text: "You are currently running Version 2.1.0 - If you encounter a bug, please report it!" text: "You are currently running Version 2.2.0 - If you encounter a bug, please report it!"
font_size: 13 font_size: 13
pos_hint: {"y": -0.45, "x":0.05} pos_hint: {"y": -0.45, "x":0.05}
Button: Button:
text: "credits" text: "Settings"
font_size: 13 font_size: 13
size_hint: 0.07, 0.06 size_hint: 0.07, 0.06
pos_hint: {"x":0.01, "y":0.01} pos_hint: {"x":0.01, "y":0.01}
background_color: (50, 0, 0, 0.2) background_color: (50, 0, 0, 0.2)
on_release: on_release:
app.root.current = "Credits" app.root.current = "Settings"
root.manager.transition.direction = "left" root.manager.transition.direction = "down"
<ReadoutScreen>: <ReadoutScreen>:
on_pre_enter: self.reset_screen = root.resscreen() on_pre_enter: self.reset_screen = root.resscreen()
@@ -249,25 +250,25 @@ RootScreen:
size_hint: 0.8, 0.3 size_hint: 0.8, 0.3
pos_hint: {"x":0.1, "y":0.4} pos_hint: {"x":0.1, "y":0.4}
Label: Label:
text: "SONDE 1: " text: "SENSOR 1: "
font_size: 20 font_size: 20
Label: Label:
id: sonde1 id: sonde1
text: "" text: ""
Label: Label:
text: "SONDE 2: " text: "SENSOR 2: "
font_size: 20 font_size: 20
Label: Label:
id: sonde2 id: sonde2
text: "" text: ""
Label: Label:
text: "SONDE 3: " text: "SENSOR 3: "
font_size: 20 font_size: 20
Label: Label:
id: sonde3 id: sonde3
text: "" text: ""
Label: Label:
text: "SONDE 4: " text: "SENSOR 4: "
font_size: 20 font_size: 20
Label: Label:
id: sonde4 id: sonde4
@@ -415,25 +416,25 @@ RootScreen:
pos_hint: {"x": 0.1, "y":0.3} pos_hint: {"x": 0.1, "y":0.3}
cols:2 cols:2
Label: Label:
text: "Temperatur Sonde 1: " text: "Temperature Sensor 1: "
TextInput: TextInput:
id: temp_s1 id: temp_s1
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Temperatur Sonde 2: " text: "Temperature Sensor 2: "
TextInput: TextInput:
id: temp_s2 id: temp_s2
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Temperatur Sonde 3: " text: "Temperature Sensor 3: "
TextInput: TextInput:
id: temp_s3 id: temp_s3
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Temperatur Sonde 4: " text: "Temperature Sensor 4: "
TextInput: TextInput:
id: temp_s4 id: temp_s4
multiline: False multiline: False
@@ -474,97 +475,97 @@ RootScreen:
pos_hint: {"x":0.1, "y":0.2} pos_hint: {"x":0.1, "y":0.2}
cols: 4 cols: 4
Label: Label:
text: "Sonde 1, a:" text: "Sensor 1, a:"
TextInput: TextInput:
id: s1_a id: s1_a
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 1, b:" text: "Sensor 1, b:"
TextInput: TextInput:
id: s1_b id: s1_b
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 1, c:" text: "Sensor 1, c:"
TextInput: TextInput:
id: s1_c id: s1_c
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 1, Temp:" text: "Sensor 1, Temp:"
TextInput: TextInput:
id: s1_t id: s1_t
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 2, a:" text: "Sensor 2, a:"
TextInput: TextInput:
id: s2_a id: s2_a
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 2, b:" text: "Sensor 2, b:"
TextInput: TextInput:
id: s2_b id: s2_b
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 2, c:" text: "Sensor 2, c:"
TextInput: TextInput:
id: s2_c id: s2_c
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 2, Temp:" text: "Sensor 2, Temp:"
TextInput: TextInput:
id: s2_t id: s2_t
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 3, a:" text: "Sensor 3, a:"
TextInput: TextInput:
id: s3_a id: s3_a
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 3, b:" text: "Sensor 3, b:"
TextInput: TextInput:
id: s3_b id: s3_b
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 3, c:" text: "Sensor 3, c:"
TextInput: TextInput:
id: s3_c id: s3_c
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 3, Temp:" text: "Sensor 3, Temp:"
TextInput: TextInput:
id: s3_t id: s3_t
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 4, a:" text: "Sensor 4, a:"
TextInput: TextInput:
id: s4_a id: s4_a
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 4, b:" text: "Sensor 4, b:"
TextInput: TextInput:
id: s4_b id: s4_b
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 4, c:" text: "Sensor 4, c:"
TextInput: TextInput:
id: s4_c id: s4_c
multiline: False multiline: False
input_filter: "float" input_filter: "float"
Label: Label:
text: "Sonde 4, Temp:" text: "Sensor 4, Temp:"
TextInput: TextInput:
id: s4_t id: s4_t
multiline: False multiline: False
@@ -599,7 +600,7 @@ RootScreen:
size_hint: 0.4, 0.2 size_hint: 0.4, 0.2
pos_hint: {"x":0.3, "y":0.1} pos_hint: {"x":0.3, "y":0.1}
on_release: on_release:
app.root.current = "Home" app.root.current = "Settings"
root.manager.transition.direction = "right" root.manager.transition.direction = "right"
GridLayout: GridLayout:
cols:1 cols:1
@@ -609,3 +610,47 @@ RootScreen:
text: "This is a rework of the BiogasControllerApp V1, that was originally programmed by S. Reichmuth." text: "This is a rework of the BiogasControllerApp V1, that was originally programmed by S. Reichmuth."
Label: Label:
text: "Written by: Janis Hutz\nDesigned by: Janis Hutz\nDesign language: Kivy" text: "Written by: Janis Hutz\nDesigned by: Janis Hutz\nDesign language: Kivy"
<Modify>:
on_pre_enter: self.config = root.read_config()
name: "Settings"
canvas.before:
Color:
rgba: (50,50,50,0.2)
Rectangle:
size: self.size
pos: self.pos
GridLayout:
cols: 1
Label:
text: "Settings"
font_size: 40
color: (0, 113, 0, 1)
bold: True
FloatLayout:
GridLayout:
pos_hint: {"x":0.05, "y":0.05}
size_hint: 0.9, 0.9
cols: 4
Button:
text: "Back"
background_color: (255,0,0,0.6)
on_release:
app.root.current = "Home"
root.manager.transition.direction = "up"
Button:
text: "Report a\nBug"
background_color: (255,0,0,0.6)
on_release:
root.issue_reporting()
ToggleButton:
id: prsel
text: "Easy\nreprogramming" if self.state == "normal" else "Advanced\nreprogramming"
on_text: root.change_programming()
background_color: (255,0,0,0.6) if self.state == "normal" else (0,0,255,0.6)
Button:
text: "Credits"
background_color: (255,0,0,0.6)
on_release:
app.root.current = "Credits"
root.manager.transition.direction = "left"

View File

@@ -0,0 +1,122 @@
"""@package docstring
This is a simplification of the csv module"""
import csv
class CsvRead:
"""This is a class that reads csv files and depending on the module selected does do different things with it"""
def __init__(self):
self.__imp = ""
self.__raw = ""
self.__raw_list = ""
def importing(self, path):
"""Returns a list of the imported csv-file, requires path, either direct system path or relative path"""
self.__imp = open(path)
self.__raw = csv.reader(self.__imp, delimiter=',')
self.__raw_list = list(self.__raw)
self.__imp.close()
return self.__raw_list
class CsvWrite:
"""This is a class that modifies csv files"""
def __init__(self):
self.__impl = []
self.__strpop = []
self.__removed = []
self.__removing = 0
self.__change = 0
self.__appending = 0
self.__imp = []
self.__raw = []
def rem_str(self, path, row):
"""Opens the csv-file in write mode which is specified as an argument either as direct or relative path"""
self.__imp = open(path)
self.__raw = csv.reader(self.__imp, delimiter=',')
self.__impl = list(self.__raw)
self.__removed = self.__impl.pop(row + 1)
with open(path, "w") as removedata:
self.__removing = csv.writer(removedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__removing.writerow(self.__impl.pop(0))
while len(self.__impl) > 0:
with open(path, "a") as removedata:
self.__removing = csv.writer(removedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__removing.writerow(self.__impl.pop(0))
self.__imp.close()
removedata.close()
def chg_str(self, path, row, pos, new_value):
"""Opens the csv-file in write mode to change a value, e.g. if a recipes is changed."""
self.__imp = open(path)
self.__raw = csv.reader(self.__imp, delimiter=',')
self.__impl = list(self.__raw)
self.__strpop = self.__impl.pop(row)
self.__strpop.pop(pos)
self.__strpop.insert(pos, new_value)
self.__impl.insert(row, self.__strpop)
with open(path, "w") as changedata:
self.__change = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__change.writerow(self.__impl.pop(0))
while len(self.__impl) > 0:
with open(path, "a") as changedata:
self.__removing = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__removing.writerow(self.__impl.pop(0))
self.__imp.close()
changedata.close()
def chg_str_rem(self, path, row, pos):
"""Opens the csv-file in write mode to change a value, e.g. if a recipes is changed."""
self.__imp = open(path)
self.__raw = csv.reader(self.__imp, delimiter=',')
self.__impl = list(self.__raw)
self.__strpop = self.__impl.pop(row)
self.__strpop.pop(pos)
self.__strpop.pop(pos)
self.__impl.insert(row, self.__strpop)
with open(path, "w") as changedata:
self.__change = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__change.writerow(self.__impl.pop(0))
while len(self.__impl) > 0:
with open(path, "a") as changedata:
self.__removing = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__removing.writerow(self.__impl.pop(0))
self.__imp.close()
changedata.close()
def chg_str_add(self, path, row, new_value1, new_value2):
"""Opens the csv-file in write mode to change a value, e.g. if a recipes is changed."""
self.__imp = open(path)
self.__raw = csv.reader(self.__imp, delimiter=',')
self.__impl = list(self.__raw)
self.__strpop = self.__impl.pop(row)
self.__strpop.append(new_value1)
self.__strpop.append(new_value2)
self.__impl.insert(row, self.__strpop)
with open(path, "w") as changedata:
self.__change = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__change.writerow(self.__impl.pop(0))
while len(self.__impl) > 0:
with open(path, "a") as changedata:
self.__removing = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__removing.writerow(self.__impl.pop(0))
self.__imp.close()
changedata.close()
def app_str(self, path, value):
"""Opens the csv-file in append mode and writes given input. CsvWrite.app_str(path, value).
Path can be specified both as direct or relative. value is a list. Will return an error if type of value is
not a list."""
with open(path, "a") as appenddata:
self.__appending = csv.writer(appenddata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__appending.writerow(value)
appenddata.close()
def write_str(self, path, value):
with open(path, "w") as writedata:
self.__change = csv.writer(writedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
self.__change.writerow(value)
writedata.close()

View File

@@ -5,12 +5,13 @@ print("""
BIOGASCONTROLLERAPP BIOGASCONTROLLERAPP
---------- ----------
Version 2.1 Version 2.2
Copyright 2022 J.Hutz""") Copyright 2022 J.Hutz""")
import time import time
import threading import threading
import platform import platform
import os import os
import webbrowser
os.environ["KIVY_NO_CONSOLELOG"] = "1" os.environ["KIVY_NO_CONSOLELOG"] = "1"
from kivy.uix.screenmanager import Screen, ScreenManager from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.uix.popup import Popup from kivy.uix.popup import Popup
@@ -20,10 +21,10 @@ from kivy.clock import mainthread
import bin.lib.lib import bin.lib.lib
import bin.lib.communication import bin.lib.communication
import bin.lib.comport_search import bin.lib.comport_search
import bin.lib.csv_parsers
cvr = bin.lib.csv_parsers.CsvRead()
cvw = bin.lib.csv_parsers.CsvWrite()
com = bin.lib.lib.Com() com = bin.lib.lib.Com()
################################################################## ##################################################################
@@ -339,24 +340,27 @@ class Program(Screen):
self.__transmit.append(self.ids.s4_b.text) self.__transmit.append(self.ids.s4_b.text)
self.__transmit.append(self.ids.s4_c.text) self.__transmit.append(self.ids.s4_c.text)
self.__transmit.append(self.ids.s4_t.text) self.__transmit.append(self.ids.s4_t.text)
self.coms.change_all(self.__transmit,"") try:
self.ids.s1_a.text = "" self.coms.change_all(self.__transmit, "")
self.ids.s1_b.text = "" self.ids.s1_a.text = ""
self.ids.s1_c.text = "" self.ids.s1_b.text = ""
self.ids.s1_t.text = "" self.ids.s1_c.text = ""
self.ids.s2_a.text = "" self.ids.s1_t.text = ""
self.ids.s2_b.text = "" self.ids.s2_a.text = ""
self.ids.s2_c.text = "" self.ids.s2_b.text = ""
self.ids.s2_t.text = "" self.ids.s2_c.text = ""
self.ids.s3_a.text = "" self.ids.s2_t.text = ""
self.ids.s3_b.text = "" self.ids.s3_a.text = ""
self.ids.s3_c.text = "" self.ids.s3_b.text = ""
self.ids.s3_t.text = "" self.ids.s3_c.text = ""
self.ids.s4_a.text = "" self.ids.s3_t.text = ""
self.ids.s4_b.text = "" self.ids.s4_a.text = ""
self.ids.s4_c.text = "" self.ids.s4_b.text = ""
self.ids.s4_t.text = "" self.ids.s4_c.text = ""
self.openconfpu() self.ids.s4_t.text = ""
self.openconfpu()
except:
self.open_confail_pu()
else: else:
self.openerrorpu() self.openerrorpu()
else: else:
@@ -376,9 +380,30 @@ class Program(Screen):
class ProgramTemp(Screen): class ProgramTemp(Screen):
def read_config(self):
self.config_imp = []
self.__export = []
self.config_imp = cvr.importing("./config/config.csv")
self.__export = self.config_imp.pop(0)
self.__extracted = self.__export.pop(0)
if self.__extracted == "1":
self.ids.prsel.state = "normal"
self.__mode = 1
else:
self.ids.prsel.state = "down"
self.__mode = 2
def create_com(self): def create_com(self):
self.coms = bin.lib.communication.Communication() self.coms = bin.lib.communication.Communication()
def change_mode(self):
if self.__mode == "1":
self.ids.prsel.state = "down"
self.__mode = 2
else:
self.ids.prsel.state = "normal"
self.__mode = 1
def send_data(self): def send_data(self):
try: try:
self.create_com() self.create_com()
@@ -485,6 +510,32 @@ class Credits(Screen):
pass pass
class Modify(Screen):
def read_config(self):
self.config_imp = []
self.__export = []
self.config_imp = cvr.importing("./config/config.csv")
self.__export = self.config_imp.pop(0)
self.__extracted = self.__export.pop(0)
if self.__extracted == "1":
self.ids.prsel.state = "normal"
else:
self.ids.prsel.state = "down"
def issue_reporting(self):
webbrowser.open("https://github.com/simplePCBuilding/BiogasControllerApp/issues", new=2)
def change_programming(self):
self.csv_import = []
self.csv_import = cvr.importing("./config/config.csv")
self.csv_import.pop(0)
if self.ids.prsel.text == "Easy\nreprogramming":
self.csv_import.insert(0, 1)
else:
self.csv_import.insert(0, 2)
cvw.write_str("./config/config.csv", self.csv_import)
######################################################## ########################################################
# Screenmanager # Screenmanager
######################################################## ########################################################

View File

@@ -0,0 +1 @@
1
1 1