-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
72 lines (60 loc) · 2.35 KB
/
app.py
File metadata and controls
72 lines (60 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#---------------------------------------------------------------------#
# File: /home/will/OneDrive/PiSpace/ByProject/Power Supply/Python-Controller/app.py
# Project: Power Supply/Python-Controller
# Created Date: Tuesday, February 15th 2022, 10:23:36 am
# Description: A custom-written program that interacts with a DPS3005 power supply module over bluetooth
# Author: Will Hall
# Copyright (c) 2022 Lime Parallelogram
# -----
# Last Modified: Tue Feb 15 2022
# Modified By: Will Hall
# -----
# HISTORY:
# Date By Comments
# ---------- --- ---------------------------------------------------------
#---------------------------------------------------------------------#
# ------------------------------ Imports Modules ----------------------------- #
from tkinter import Widget
from DPS3005 import DPS3005
from time import sleep
import PyQt5.QtCore as qtCore
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow
from PyQt5 import uic
from PyQt5.QtGui import QPalette, QColor
from darktheme.widget_template import DarkPalette
import sys
# ----------------------------- Program constants ---------------------------- #
DEVICE_MAC = "98:DA:20:01:13:09"
supply = DPS3005()
# -------------------------- Main Application Window ------------------------- #
class DashboardWindow(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi("dashboard.ui", self)
self.voltsSubmit.clicked.connect(self.updateVolts)
self.ampsSubmit.clicked.connect(self.updateAmps)
self.actionConnect.triggered.connect(self.connect)
# -- Update the displayed set volts -- #
def updateVolts(self):
volts = self.voltsSpinBox.value()
self.voltsSetting.display(volts)
supply.setVoltage(volts)
# -- Update the displayed amps value -- #
def updateAmps(self):
amps = self.ampsSpinBox.value()
self.ampsSetting.display(amps)
supply.setCurrent(amps)
# -- Connect to device -- #
def connect(self):
print("Connecting To Device")
supply.connect(DEVICE_MAC)
# -- Disconnect device -- #
def disconnect(self):
print("Disconnecting Device")
supply.close()
# ------------------------ Initiate Window and loading ----------------------- #
app = QApplication(sys.argv)
app.setPalette(DarkPalette())
window = DashboardWindow()
window.show()
app.exec()