forked from M-Labs/thermostat
Compare commits
9 Commits
9763225b45
...
68e6de7215
Author | SHA1 | Date |
---|---|---|
atse | 68e6de7215 | |
atse | e2bb6f4cfa | |
Egor Savkin | 6e91373af4 | |
atse | 8c9d0ffc94 | |
atse | 9e3d63c377 | |
atse | ecf89f45bf | |
atse | 940e83dd17 | |
atse | 69566cc3fc | |
atse | 6c08a7fb07 |
14
README.md
14
README.md
|
@ -67,7 +67,19 @@ On a Windows machine install [st.com](https://st.com) DfuSe USB device firmware
|
|||
openocd -f interface/stlink.cfg -f target/stm32f4x.cfg -c "program target/thumbv7em-none-eabihf/release/thermostat verify reset;exit"
|
||||
```
|
||||
|
||||
## Network
|
||||
## GUI Usage
|
||||
|
||||
A GUI has been developed for easy configuration and plotting of key parameters.
|
||||
|
||||
The Python GUI program is located at pytec/tec_qt.py.
|
||||
|
||||
The GUI is developed based on the Python library pyqtgraph. The GUI can be configured and launched automatically by running:
|
||||
|
||||
```
|
||||
nix run .#thermostat_gui
|
||||
```
|
||||
|
||||
## Command Line Usage
|
||||
|
||||
### Connecting
|
||||
|
||||
|
|
65
flake.nix
65
flake.nix
|
@ -58,42 +58,61 @@
|
|||
|
||||
qasync = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "qasync";
|
||||
version = "0.24.0";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "CabbageDevelopment";
|
||||
repo = "qasync";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-ls5F+VntXXa3n+dULaYWK9sAmwly1nk/5+RGWLrcf2Y=";
|
||||
version = "0.27.1";
|
||||
format = "pyproject";
|
||||
src = pkgs.fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "sha256-jcdo/R7l3hBEx8MF7M8tOdJNh4A+pxGJ1AJPtHX0mF8=";
|
||||
};
|
||||
buildInputs = [ pkgs.python3Packages.poetry-core ];
|
||||
propagatedBuildInputs = [ pkgs.python3Packages.pyqt6 ];
|
||||
nativeCheckInputs = [ pkgs.python3Packages.pytest ];
|
||||
checkPhase = ''
|
||||
pytest -k 'test_qthreadexec.py' # the others cause the test execution to be aborted, I think because of asyncio
|
||||
'';
|
||||
};
|
||||
thermostat_gui = pkgs.python3Packages.buildPythonPackage rec {
|
||||
|
||||
pyqtgraph = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "pyqtgraph";
|
||||
version = "0.13.3";
|
||||
format = "pyproject";
|
||||
src = pkgs.fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "sha256-WBCNhBHHBU4IQdi3ke6F4QH8KWubNZwOAd3jipj/Ks4=";
|
||||
};
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [ numpy pyqt6 ];
|
||||
};
|
||||
|
||||
pglive = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "pglive";
|
||||
version = "0.7.2";
|
||||
format = "pyproject";
|
||||
src = pkgs.fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "sha256-jqj8X6H1N5mJQ4OrY5ANqRB0YJByqg/bNneEALWmH1A=";
|
||||
};
|
||||
buildInputs = [ pkgs.python3Packages.poetry-core ];
|
||||
propagatedBuildInputs = [ pyqtgraph pkgs.python3Packages.numpy ];
|
||||
};
|
||||
|
||||
thermostat_gui = pkgs.python3Packages.buildPythonPackage {
|
||||
pname = "thermostat_gui";
|
||||
version = "0.0.0";
|
||||
src = self;
|
||||
|
||||
preBuild =
|
||||
''
|
||||
export VERSIONEER_OVERRIDE=${version}
|
||||
export VERSIONEER_REV=v0.0.0
|
||||
'';
|
||||
format = "pyproject";
|
||||
src = "${self}/pytec";
|
||||
|
||||
nativeBuildInputs = [ pkgs.qt6.wrapQtAppsHook ];
|
||||
propagatedBuildInputs = (with pkgs.python3Packages; [ pyqtgraph pyqt6 qasync]);
|
||||
propagatedBuildInputs = [ pkgs.qt6.qtbase ] ++ (with pkgs.python3Packages; [ pyqtgraph pyqt6 qasync pglive ]);
|
||||
|
||||
dontWrapQtApps = true;
|
||||
postFixup = ''
|
||||
ls -al $out/
|
||||
wrapQtApp "$out/pytec/tec_qt"
|
||||
wrapQtApp "$out/bin/tec_qt"
|
||||
'';
|
||||
};
|
||||
in {
|
||||
packages.x86_64-linux = {
|
||||
inherit thermostat qasync thermostat_gui;
|
||||
inherit thermostat thermostat_gui;
|
||||
};
|
||||
|
||||
apps.x86_64-linux.thermostat_gui = {
|
||||
type = "app";
|
||||
program = "${self.packages.x86_64-linux.thermostat_gui}/bin/tec_qt";
|
||||
};
|
||||
|
||||
hydraJobs = {
|
||||
|
@ -105,7 +124,7 @@
|
|||
buildInputs = with pkgs; [
|
||||
rust openocd dfu-util
|
||||
] ++ (with python3Packages; [
|
||||
numpy matplotlib pyqtgraph setuptools pyqt6 qasync
|
||||
numpy matplotlib pyqtgraph setuptools pyqt6 qasync pglive
|
||||
]);
|
||||
};
|
||||
defaultPackage.x86_64-linux = thermostat;
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import asyncio
|
||||
from pytec.aioclient import Client
|
||||
|
||||
async def main():
|
||||
tec = Client()
|
||||
await tec.start_session() #(host="192.168.1.26", port=23)
|
||||
await tec.set_param("s-h", 1, "t0", 20)
|
||||
print(await tec.get_pwm())
|
||||
print(await tec.get_pid())
|
||||
print(await tec.get_pwm())
|
||||
print(await tec.get_postfilter())
|
||||
print(await tec.get_steinhart_hart())
|
||||
async for data in tec.report_mode():
|
||||
print(data)
|
||||
|
||||
asyncio.run(main())
|
|
@ -199,20 +199,20 @@ class PIDAutotune:
|
|||
# calculate ultimate gain
|
||||
self._Ku = 4.0 * self._outputstep / \
|
||||
(self._induced_amplitude * math.pi)
|
||||
print('Ku: {0}'.format(self._Ku))
|
||||
logging.debug('Ku: {0}'.format(self._Ku))
|
||||
|
||||
# calculate ultimate period in seconds
|
||||
period1 = self._peak_timestamps[3] - self._peak_timestamps[1]
|
||||
period2 = self._peak_timestamps[4] - self._peak_timestamps[2]
|
||||
self._Pu = 0.5 * (period1 + period2) / 1000.0
|
||||
print('Pu: {0}'.format(self._Pu))
|
||||
logging.debug('Pu: {0}'.format(self._Pu))
|
||||
|
||||
for rule in self._tuning_rules:
|
||||
params = self.get_pid_parameters(rule)
|
||||
print('rule: {0}'.format(rule))
|
||||
print('Kp: {0}'.format(params.Kp))
|
||||
print('Ki: {0}'.format(params.Ki))
|
||||
print('Kd: {0}'.format(params.Kd))
|
||||
logging.debug('rule: {0}'.format(rule))
|
||||
logging.debug('Kp: {0}'.format(params.Kp))
|
||||
logging.debug('Ki: {0}'.format(params.Ki))
|
||||
logging.debug('Kd: {0}'.format(params.Kd))
|
||||
|
||||
return True
|
||||
return False
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "pytec"
|
||||
version = "0.0"
|
||||
authors = [{name = "M-Labs"}]
|
||||
description = "Control TEC"
|
||||
urls.Repository = "https://git.m-labs.hk/M-Labs/thermostat"
|
||||
license = {text = "GPLv3"}
|
||||
|
||||
[project.gui-scripts]
|
||||
tec_qt = "tec_qt:main"
|
||||
|
||||
[tool.setuptools]
|
||||
packages.find = {}
|
||||
py-modules = ["aioexample", "autotune", "example", "plot", "tec_qt", "ui_tec_qt", "waitingspinnerwidget"]
|
|
@ -0,0 +1,279 @@
|
|||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
|
||||
class CommandError(Exception):
|
||||
pass
|
||||
|
||||
class StoppedConnecting(Exception):
|
||||
pass
|
||||
|
||||
class Client:
|
||||
def __init__(self):
|
||||
self._reader = None
|
||||
self._writer = None
|
||||
self._connecting_task = None
|
||||
self._command_lock = asyncio.Lock()
|
||||
self._report_mode_on = False
|
||||
self.timeout = None
|
||||
|
||||
async def start_session(self, host='192.168.1.26', port=23, timeout=None):
|
||||
"""Start session to Thermostat at specified host and port.
|
||||
Throws StoppedConnecting if disconnect was called while connecting.
|
||||
Throws asyncio.TimeoutError if timeout was exceeded.
|
||||
|
||||
Example::
|
||||
client = Client()
|
||||
try:
|
||||
await client.start_session()
|
||||
except StoppedConnecting:
|
||||
print("Stopped connecting")
|
||||
"""
|
||||
self._connecting_task = asyncio.create_task(
|
||||
asyncio.wait_for(asyncio.open_connection(host, port), timeout)
|
||||
)
|
||||
self.timeout = timeout
|
||||
try:
|
||||
self._reader, self._writer = await self._connecting_task
|
||||
except asyncio.CancelledError:
|
||||
raise StoppedConnecting
|
||||
finally:
|
||||
self._connecting_task = None
|
||||
|
||||
await self._check_zero_limits()
|
||||
|
||||
def connecting(self):
|
||||
"""Returns True if client is connecting"""
|
||||
return self._connecting_task is not None
|
||||
|
||||
def connected(self):
|
||||
"""Returns True if client is connected"""
|
||||
return self._writer is not None
|
||||
|
||||
async def end_session(self):
|
||||
"""End session to Thermostat if connected, cancel connection if connecting"""
|
||||
if self._connecting_task is not None:
|
||||
self._connecting_task.cancel()
|
||||
|
||||
if self._writer is None:
|
||||
return
|
||||
|
||||
# Reader needn't be closed
|
||||
self._writer.close()
|
||||
await self._writer.wait_closed()
|
||||
self._reader = None
|
||||
self._writer = None
|
||||
|
||||
async def _check_zero_limits(self):
|
||||
pwm_report = await self.get_pwm()
|
||||
for pwm_channel in pwm_report:
|
||||
for limit in ["max_i_neg", "max_i_pos", "max_v"]:
|
||||
if pwm_channel[limit]["value"] == 0.0:
|
||||
logging.warning("`{}` limit is set to zero on channel {}".format(limit, pwm_channel["channel"]))
|
||||
|
||||
async def _read_line(self):
|
||||
# read 1 line
|
||||
chunk = await asyncio.wait_for(self._reader.readline(), self.timeout) # Only wait for response until timeout
|
||||
return chunk.decode('utf-8', errors='ignore')
|
||||
|
||||
async def _read_write(self, command):
|
||||
self._writer.write(((" ".join(command)).strip() + "\n").encode('utf-8'))
|
||||
await self._writer.drain()
|
||||
|
||||
return await self._read_line()
|
||||
|
||||
async def _command(self, *command):
|
||||
async with self._command_lock:
|
||||
# protect the read-write process from being cancelled midway
|
||||
line = await asyncio.shield(self._read_write(command))
|
||||
|
||||
response = json.loads(line)
|
||||
logging.debug(f"{command}: {response}")
|
||||
if "error" in response:
|
||||
raise CommandError(response["error"])
|
||||
return response
|
||||
|
||||
async def _get_conf(self, topic):
|
||||
result = [None, None]
|
||||
for item in await self._command(topic):
|
||||
result[int(item["channel"])] = item
|
||||
return result
|
||||
|
||||
async def get_pwm(self):
|
||||
"""Retrieve PWM limits for the TEC
|
||||
|
||||
Example::
|
||||
[{'channel': 0,
|
||||
'center': 'vref',
|
||||
'i_set': {'max': 2.9802790335151985, 'value': -0.02002179650216762},
|
||||
'max_i_neg': {'max': 3.0, 'value': 3.0},
|
||||
'max_v': {'max': 5.988, 'value': 5.988},
|
||||
'max_i_pos': {'max': 3.0, 'value': 3.0}},
|
||||
{'channel': 1,
|
||||
'center': 'vref',
|
||||
'i_set': {'max': 2.9802790335151985, 'value': -0.02002179650216762},
|
||||
'max_i_neg': {'max': 3.0, 'value': 3.0},
|
||||
'max_v': {'max': 5.988, 'value': 5.988},
|
||||
'max_i_pos': {'max': 3.0, 'value': 3.0}}
|
||||
]
|
||||
"""
|
||||
return await self._get_conf("pwm")
|
||||
|
||||
async def get_pid(self):
|
||||
"""Retrieve PID control state
|
||||
|
||||
Example::
|
||||
[{'channel': 0,
|
||||
'parameters': {
|
||||
'kp': 10.0,
|
||||
'ki': 0.02,
|
||||
'kd': 0.0,
|
||||
'output_min': 0.0,
|
||||
'output_max': 3.0},
|
||||
'target': 37.0},
|
||||
{'channel': 1,
|
||||
'parameters': {
|
||||
'kp': 10.0,
|
||||
'ki': 0.02,
|
||||
'kd': 0.0,
|
||||
'output_min': 0.0,
|
||||
'output_max': 3.0},
|
||||
'target': 36.5}]
|
||||
"""
|
||||
return await self._get_conf("pid")
|
||||
|
||||
async def get_steinhart_hart(self):
|
||||
"""Retrieve Steinhart-Hart parameters for resistance to temperature conversion
|
||||
|
||||
Example::
|
||||
[{'params': {'b': 3800.0, 'r0': 10000.0, 't0': 298.15}, 'channel': 0},
|
||||
{'params': {'b': 3800.0, 'r0': 10000.0, 't0': 298.15}, 'channel': 1}]
|
||||
"""
|
||||
return await self._get_conf("s-h")
|
||||
|
||||
async def get_postfilter(self):
|
||||
"""Retrieve DAC postfilter configuration
|
||||
|
||||
Example::
|
||||
[{'rate': None, 'channel': 0},
|
||||
{'rate': 21.25, 'channel': 1}]
|
||||
"""
|
||||
return await self._get_conf("postfilter")
|
||||
|
||||
async def get_fan(self):
|
||||
"""Get Thermostat current fan settings"""
|
||||
return await self._command("fan")
|
||||
|
||||
async def report(self):
|
||||
"""Obtain one-time report on measurement values"""
|
||||
return await self._command("report")
|
||||
|
||||
async def report_mode(self):
|
||||
"""Start reporting measurement values
|
||||
|
||||
Example of yielded data::
|
||||
{'channel': 0,
|
||||
'time': 2302524,
|
||||
'adc': 0.6199188965423515,
|
||||
'sens': 6138.519310282602,
|
||||
'temperature': 36.87032392655527,
|
||||
'pid_engaged': True,
|
||||
'i_set': 2.0635816680889123,
|
||||
'vref': 1.494,
|
||||
'dac_value': 2.527790834044456,
|
||||
'dac_feedback': 2.523,
|
||||
'i_tec': 2.331,
|
||||
'tec_i': 2.0925,
|
||||
'tec_u_meas': 2.5340000000000003,
|
||||
'pid_output': 2.067581958092247}
|
||||
"""
|
||||
await self._command("report mode", "on")
|
||||
self._report_mode_on = True
|
||||
|
||||
while self._report_mode_on:
|
||||
async with self._command_lock:
|
||||
line = await self._read_line()
|
||||
if not line:
|
||||
break
|
||||
try:
|
||||
yield json.loads(line)
|
||||
except json.decoder.JSONDecodeError:
|
||||
pass
|
||||
|
||||
await self._command("report mode", "off")
|
||||
|
||||
def stop_report_mode(self):
|
||||
self._report_mode_on = False
|
||||
|
||||
async def set_param(self, topic, channel, field="", value=""):
|
||||
"""Set configuration parameters
|
||||
|
||||
Examples::
|
||||
await tec.set_param("pwm", 0, "max_v", 2.0)
|
||||
await tec.set_param("pid", 1, "output_max", 2.5)
|
||||
await tec.set_param("s-h", 0, "t0", 20.0)
|
||||
await tec.set_param("center", 0, "vref")
|
||||
await tec.set_param("postfilter", 1, 21)
|
||||
|
||||
See the firmware's README.md for a full list.
|
||||
"""
|
||||
if type(value) is float:
|
||||
value = "{:f}".format(value)
|
||||
if type(value) is not str:
|
||||
value = str(value)
|
||||
await self._command(topic, str(channel), field, value)
|
||||
|
||||
async def set_fan(self, power="auto"):
|
||||
"""Set fan power"""
|
||||
await self._command("fan", str(power))
|
||||
|
||||
async def set_fcurve(self, a=1.0, b=0.0, c=0.0):
|
||||
"""Set fan curve"""
|
||||
await self._command("fcurve", str(a), str(b), str(c))
|
||||
|
||||
async def power_up(self, channel, target):
|
||||
"""Start closed-loop mode"""
|
||||
await self.set_param("pid", channel, "target", value=target)
|
||||
await self.set_param("pwm", channel, "pid")
|
||||
|
||||
async def save_config(self, channel=""):
|
||||
"""Save current configuration to EEPROM"""
|
||||
await self._command("save", str(channel))
|
||||
|
||||
async def load_config(self, channel=""):
|
||||
"""Load current configuration from EEPROM"""
|
||||
await self._command("load", str(channel))
|
||||
if channel == "":
|
||||
await self._read_line() # Read the extra {}
|
||||
|
||||
async def hw_rev(self):
|
||||
"""Get Thermostat hardware revision"""
|
||||
return await self._command("hwrev")
|
||||
|
||||
async def reset(self):
|
||||
"""Reset the Thermostat
|
||||
|
||||
The client is disconnected as the TCP session is terminated.
|
||||
"""
|
||||
async with self._command_lock:
|
||||
self._writer.write("reset\n".encode('utf-8'))
|
||||
await self._writer.drain()
|
||||
|
||||
await self.end_session()
|
||||
|
||||
async def dfu(self):
|
||||
"""Put the Thermostat in DFU update mode
|
||||
|
||||
The client is disconnected as the Thermostat stops responding to
|
||||
TCP commands in DFU update mode. The only way to exit it is by
|
||||
power-cycling.
|
||||
"""
|
||||
async with self._command_lock:
|
||||
self._writer.write("dfu\n".encode('utf-8'))
|
||||
await self._writer.drain()
|
||||
|
||||
await self.end_session()
|
||||
|
||||
async def ipv4(self):
|
||||
"""Get the IPv4 settings of the Thermostat"""
|
||||
return await self._command('ipv4')
|
|
@ -9,4 +9,10 @@ setup(
|
|||
license="GPLv3",
|
||||
install_requires=["setuptools"],
|
||||
packages=find_packages(),
|
||||
entry_points={
|
||||
"gui_scripts": [
|
||||
"tec_qt = tec_qt:main",
|
||||
]
|
||||
},
|
||||
py_modules=['tec_qt', 'ui_tec_qt', 'autotune', 'waitingspinnerwidget'],
|
||||
)
|
||||
|
|
1036
pytec/tec_qt.py
1036
pytec/tec_qt.py
File diff suppressed because it is too large
Load Diff
447
pytec/tec_qt.ui
447
pytec/tec_qt.ui
|
@ -23,7 +23,11 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Control TEC</string>
|
||||
<string>Thermostat Control Panel</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>thermostat-icon-640x640.png</normaloff>thermostat-icon-640x640.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="main_widget">
|
||||
<property name="sizePolicy">
|
||||
|
@ -96,32 +100,16 @@
|
|||
<widget class="ParameterTree" name="ch0_tree" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="PlotWidget" name="ch1_t_graph" native="true">
|
||||
<property name="title">
|
||||
<string>Channel 1 Temperature</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LivePlotWidget" name="ch1_t_graph" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="PlotWidget" name="ch0_t_graph" native="true">
|
||||
<property name="title">
|
||||
<string>Channel 0 Temperature</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LivePlotWidget" name="ch0_t_graph" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="PlotWidget" name="ch0_i_graph" native="true">
|
||||
<property name="title">
|
||||
<string>Channel 0 Current</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LivePlotWidget" name="ch0_i_graph" native="true"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="PlotWidget" name="ch1_i_graph" native="true">
|
||||
<property name="title">
|
||||
<string>Channel 1 Current</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="LivePlotWidget" name="ch1_i_graph" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -171,69 +159,7 @@
|
|||
<item>
|
||||
<layout class="QHBoxLayout" name="settings_layout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="ip_set_line">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>192.168.1.26</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>IP:port for the Thermostat</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="port_set_spin">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>23</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="connect_btn">
|
||||
<widget class="QToolButton" name="connect_btn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -261,6 +187,12 @@
|
|||
<property name="text">
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::MenuButtonPopup</enum>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonFollowStyle</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -273,7 +205,7 @@
|
|||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>120</width>
|
||||
<width>240</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -295,18 +227,61 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_0">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="QToolButton" name="thermostat_settings">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<property name="text">
|
||||
<string notr="true">⚙</string>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="plot_settings">
|
||||
<property name="toolTip">
|
||||
<string>Plot Settings</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>📉</string>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="limits_warning">
|
||||
<property name="toolTipDuration">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="background_task_lbl">
|
||||
<property name="text">
|
||||
<string>Ready.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QtWaitingSpinner" name="loading_spinner" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="report_group" native="true">
|
||||
<property name="enabled">
|
||||
|
@ -341,7 +316,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="report_layout" stretch="1,1,1">
|
||||
<layout class="QHBoxLayout" name="report_layout" stretch="0,1,1,1">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
|
@ -351,6 +326,16 @@
|
|||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="report_lbl">
|
||||
<property name="text">
|
||||
<string>Poll every: </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="report_refresh_spin">
|
||||
<property name="sizePolicy">
|
||||
|
@ -377,6 +362,9 @@
|
|||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> s</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
|
@ -455,193 +443,6 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="fan_group" native="true">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="gan_layout">
|
||||
<property name="spacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="fan_lbl">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fan:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="fan_power_slider">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="fan_auto_box">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="hw_rev_lbl">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Thermostat vX.Y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -651,20 +452,92 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<action name="actionReset">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset the Thermostat</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnter_DFU_Mode">
|
||||
<property name="text">
|
||||
<string>Enter DFU Mode</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset thermostat and enter USB device firmware update (DFU) mode</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNetwork_Settings">
|
||||
<property name="text">
|
||||
<string>Network Settings</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Configure IPv4 address, netmask length, and optional default gateway</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout_Thermostat">
|
||||
<property name="text">
|
||||
<string>About Thermostat</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show Thermostat hardware revision, and settings related to i</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoad_all_configs">
|
||||
<property name="text">
|
||||
<string>Load all channel configs from flash</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Restore configuration for all channels from flash</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_all_configs">
|
||||
<property name="text">
|
||||
<string>Save all channel configs to flash</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save configuration for all channels to flash</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>PlotWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>pyqtgraph</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ParameterTree</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>pyqtgraph.parametertree</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LivePlotWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>pglive.sources.live_plot_widget</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QtWaitingSpinner</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>waitingspinnerwidget</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 244 KiB |
|
@ -1,6 +1,6 @@
|
|||
# Form implementation generated from reading ui file 'tec_qt.ui'
|
||||
#
|
||||
# Created by: PyQt6 UI code generator 6.4.2
|
||||
# Created by: PyQt6 UI code generator 6.5.2
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
@ -15,6 +15,9 @@ class Ui_MainWindow(object):
|
|||
MainWindow.resize(1280, 720)
|
||||
MainWindow.setMinimumSize(QtCore.QSize(1280, 720))
|
||||
MainWindow.setMaximumSize(QtCore.QSize(3840, 2160))
|
||||
icon = QtGui.QIcon()
|
||||
icon.addPixmap(QtGui.QPixmap("thermostat-icon-640x640.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
|
||||
MainWindow.setWindowIcon(icon)
|
||||
self.main_widget = QtWidgets.QWidget(parent=MainWindow)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(1)
|
||||
|
@ -50,16 +53,16 @@ class Ui_MainWindow(object):
|
|||
self.ch0_tree = ParameterTree(parent=self.graph_group)
|
||||
self.ch0_tree.setObjectName("ch0_tree")
|
||||
self.graphs_layout.addWidget(self.ch0_tree, 0, 0, 1, 1)
|
||||
self.ch1_t_graph = PlotWidget(parent=self.graph_group)
|
||||
self.ch1_t_graph = LivePlotWidget(parent=self.graph_group)
|
||||
self.ch1_t_graph.setObjectName("ch1_t_graph")
|
||||
self.graphs_layout.addWidget(self.ch1_t_graph, 1, 1, 1, 1)
|
||||
self.ch0_t_graph = PlotWidget(parent=self.graph_group)
|
||||
self.ch0_t_graph = LivePlotWidget(parent=self.graph_group)
|
||||
self.ch0_t_graph.setObjectName("ch0_t_graph")
|
||||
self.graphs_layout.addWidget(self.ch0_t_graph, 0, 1, 1, 1)
|
||||
self.ch0_i_graph = PlotWidget(parent=self.graph_group)
|
||||
self.ch0_i_graph = LivePlotWidget(parent=self.graph_group)
|
||||
self.ch0_i_graph.setObjectName("ch0_i_graph")
|
||||
self.graphs_layout.addWidget(self.ch0_i_graph, 0, 2, 1, 1)
|
||||
self.ch1_i_graph = PlotWidget(parent=self.graph_group)
|
||||
self.ch1_i_graph = LivePlotWidget(parent=self.graph_group)
|
||||
self.ch1_i_graph.setObjectName("ch1_i_graph")
|
||||
self.graphs_layout.addWidget(self.ch1_i_graph, 1, 2, 1, 1)
|
||||
self.graphs_layout.setColumnMinimumWidth(0, 100)
|
||||
|
@ -90,31 +93,7 @@ class Ui_MainWindow(object):
|
|||
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
|
||||
self.settings_layout = QtWidgets.QHBoxLayout()
|
||||
self.settings_layout.setObjectName("settings_layout")
|
||||
self.ip_set_line = QtWidgets.QLineEdit(parent=self.bottom_settings_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.ip_set_line.sizePolicy().hasHeightForWidth())
|
||||
self.ip_set_line.setSizePolicy(sizePolicy)
|
||||
self.ip_set_line.setMinimumSize(QtCore.QSize(160, 0))
|
||||
self.ip_set_line.setMaximumSize(QtCore.QSize(160, 16777215))
|
||||
self.ip_set_line.setMaxLength(15)
|
||||
self.ip_set_line.setClearButtonEnabled(True)
|
||||
self.ip_set_line.setObjectName("ip_set_line")
|
||||
self.settings_layout.addWidget(self.ip_set_line)
|
||||
self.port_set_spin = QtWidgets.QSpinBox(parent=self.bottom_settings_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.port_set_spin.sizePolicy().hasHeightForWidth())
|
||||
self.port_set_spin.setSizePolicy(sizePolicy)
|
||||
self.port_set_spin.setMinimumSize(QtCore.QSize(70, 0))
|
||||
self.port_set_spin.setMaximumSize(QtCore.QSize(70, 16777215))
|
||||
self.port_set_spin.setMaximum(65535)
|
||||
self.port_set_spin.setProperty("value", 23)
|
||||
self.port_set_spin.setObjectName("port_set_spin")
|
||||
self.settings_layout.addWidget(self.port_set_spin)
|
||||
self.connect_btn = QtWidgets.QPushButton(parent=self.bottom_settings_group)
|
||||
self.connect_btn = QtWidgets.QToolButton(parent=self.bottom_settings_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
|
@ -123,6 +102,8 @@ class Ui_MainWindow(object):
|
|||
self.connect_btn.setMinimumSize(QtCore.QSize(100, 0))
|
||||
self.connect_btn.setMaximumSize(QtCore.QSize(100, 16777215))
|
||||
self.connect_btn.setBaseSize(QtCore.QSize(100, 0))
|
||||
self.connect_btn.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.MenuButtonPopup)
|
||||
self.connect_btn.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonFollowStyle)
|
||||
self.connect_btn.setObjectName("connect_btn")
|
||||
self.settings_layout.addWidget(self.connect_btn)
|
||||
self.status_lbl = QtWidgets.QLabel(parent=self.bottom_settings_group)
|
||||
|
@ -131,21 +112,33 @@ class Ui_MainWindow(object):
|
|||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.status_lbl.sizePolicy().hasHeightForWidth())
|
||||
self.status_lbl.setSizePolicy(sizePolicy)
|
||||
self.status_lbl.setMinimumSize(QtCore.QSize(120, 0))
|
||||
self.status_lbl.setMinimumSize(QtCore.QSize(240, 0))
|
||||
self.status_lbl.setMaximumSize(QtCore.QSize(120, 16777215))
|
||||
self.status_lbl.setBaseSize(QtCore.QSize(120, 50))
|
||||
self.status_lbl.setObjectName("status_lbl")
|
||||
self.settings_layout.addWidget(self.status_lbl)
|
||||
self.line_0 = QtWidgets.QFrame(parent=self.bottom_settings_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.line_0.sizePolicy().hasHeightForWidth())
|
||||
self.line_0.setSizePolicy(sizePolicy)
|
||||
self.line_0.setFrameShape(QtWidgets.QFrame.Shape.VLine)
|
||||
self.line_0.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
|
||||
self.line_0.setObjectName("line_0")
|
||||
self.settings_layout.addWidget(self.line_0)
|
||||
self.thermostat_settings = QtWidgets.QToolButton(parent=self.bottom_settings_group)
|
||||
self.thermostat_settings.setEnabled(False)
|
||||
self.thermostat_settings.setText("⚙")
|
||||
self.thermostat_settings.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||
self.thermostat_settings.setObjectName("thermostat_settings")
|
||||
self.settings_layout.addWidget(self.thermostat_settings)
|
||||
self.plot_settings = QtWidgets.QToolButton(parent=self.bottom_settings_group)
|
||||
self.plot_settings.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||
self.plot_settings.setObjectName("plot_settings")
|
||||
self.settings_layout.addWidget(self.plot_settings)
|
||||
self.limits_warning = QtWidgets.QLabel(parent=self.bottom_settings_group)
|
||||
self.limits_warning.setToolTipDuration(1000000000)
|
||||
self.limits_warning.setObjectName("limits_warning")
|
||||
self.settings_layout.addWidget(self.limits_warning)
|
||||
self.background_task_lbl = QtWidgets.QLabel(parent=self.bottom_settings_group)
|
||||
self.background_task_lbl.setObjectName("background_task_lbl")
|
||||
self.settings_layout.addWidget(self.background_task_lbl)
|
||||
self.loading_spinner = QtWaitingSpinner(parent=self.bottom_settings_group)
|
||||
self.loading_spinner.setObjectName("loading_spinner")
|
||||
self.settings_layout.addWidget(self.loading_spinner)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.settings_layout.addItem(spacerItem)
|
||||
self.report_group = QtWidgets.QWidget(parent=self.bottom_settings_group)
|
||||
self.report_group.setEnabled(False)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
|
@ -164,6 +157,10 @@ class Ui_MainWindow(object):
|
|||
self.report_layout.setContentsMargins(0, -1, -1, -1)
|
||||
self.report_layout.setSpacing(6)
|
||||
self.report_layout.setObjectName("report_layout")
|
||||
self.report_lbl = QtWidgets.QLabel(parent=self.report_group)
|
||||
self.report_lbl.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
|
||||
self.report_lbl.setObjectName("report_lbl")
|
||||
self.report_layout.addWidget(self.report_lbl)
|
||||
self.report_refresh_spin = QtWidgets.QDoubleSpinBox(parent=self.report_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
|
@ -201,116 +198,64 @@ class Ui_MainWindow(object):
|
|||
self.report_apply_btn.setBaseSize(QtCore.QSize(80, 0))
|
||||
self.report_apply_btn.setObjectName("report_apply_btn")
|
||||
self.report_layout.addWidget(self.report_apply_btn)
|
||||
self.report_layout.setStretch(0, 1)
|
||||
self.report_layout.setStretch(1, 1)
|
||||
self.report_layout.setStretch(2, 1)
|
||||
self.report_layout.setStretch(3, 1)
|
||||
self.horizontalLayout_4.addLayout(self.report_layout)
|
||||
self.settings_layout.addWidget(self.report_group)
|
||||
self.line_1 = QtWidgets.QFrame(parent=self.bottom_settings_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.line_1.sizePolicy().hasHeightForWidth())
|
||||
self.line_1.setSizePolicy(sizePolicy)
|
||||
self.line_1.setFrameShape(QtWidgets.QFrame.Shape.VLine)
|
||||
self.line_1.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
|
||||
self.line_1.setObjectName("line_1")
|
||||
self.settings_layout.addWidget(self.line_1)
|
||||
self.fan_group = QtWidgets.QWidget(parent=self.bottom_settings_group)
|
||||
self.fan_group.setEnabled(False)
|
||||
self.fan_group.setMinimumSize(QtCore.QSize(40, 0))
|
||||
self.fan_group.setObjectName("fan_group")
|
||||
self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.fan_group)
|
||||
self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0)
|
||||
self.horizontalLayout_6.setSpacing(0)
|
||||
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
|
||||
self.gan_layout = QtWidgets.QHBoxLayout()
|
||||
self.gan_layout.setSpacing(9)
|
||||
self.gan_layout.setObjectName("gan_layout")
|
||||
self.fan_lbl = QtWidgets.QLabel(parent=self.fan_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.fan_lbl.sizePolicy().hasHeightForWidth())
|
||||
self.fan_lbl.setSizePolicy(sizePolicy)
|
||||
self.fan_lbl.setMinimumSize(QtCore.QSize(40, 0))
|
||||
self.fan_lbl.setMaximumSize(QtCore.QSize(40, 16777215))
|
||||
self.fan_lbl.setBaseSize(QtCore.QSize(40, 0))
|
||||
self.fan_lbl.setObjectName("fan_lbl")
|
||||
self.gan_layout.addWidget(self.fan_lbl)
|
||||
self.fan_power_slider = QtWidgets.QSlider(parent=self.fan_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.fan_power_slider.sizePolicy().hasHeightForWidth())
|
||||
self.fan_power_slider.setSizePolicy(sizePolicy)
|
||||
self.fan_power_slider.setMinimumSize(QtCore.QSize(200, 0))
|
||||
self.fan_power_slider.setMaximumSize(QtCore.QSize(200, 16777215))
|
||||
self.fan_power_slider.setBaseSize(QtCore.QSize(200, 0))
|
||||
self.fan_power_slider.setMaximum(100)
|
||||
self.fan_power_slider.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.fan_power_slider.setObjectName("fan_power_slider")
|
||||
self.gan_layout.addWidget(self.fan_power_slider)
|
||||
self.fan_auto_box = QtWidgets.QCheckBox(parent=self.fan_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.fan_auto_box.sizePolicy().hasHeightForWidth())
|
||||
self.fan_auto_box.setSizePolicy(sizePolicy)
|
||||
self.fan_auto_box.setMinimumSize(QtCore.QSize(70, 0))
|
||||
self.fan_auto_box.setMaximumSize(QtCore.QSize(70, 16777215))
|
||||
self.fan_auto_box.setObjectName("fan_auto_box")
|
||||
self.gan_layout.addWidget(self.fan_auto_box)
|
||||
self.horizontalLayout_6.addLayout(self.gan_layout)
|
||||
self.settings_layout.addWidget(self.fan_group)
|
||||
self.line_3 = QtWidgets.QFrame(parent=self.bottom_settings_group)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.line_3.sizePolicy().hasHeightForWidth())
|
||||
self.line_3.setSizePolicy(sizePolicy)
|
||||
self.line_3.setFrameShape(QtWidgets.QFrame.Shape.VLine)
|
||||
self.line_3.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
|
||||
self.line_3.setObjectName("line_3")
|
||||
self.settings_layout.addWidget(self.line_3)
|
||||
self.hw_rev_lbl = QtWidgets.QLabel(parent=self.bottom_settings_group)
|
||||
self.hw_rev_lbl.setEnabled(False)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.hw_rev_lbl.sizePolicy().hasHeightForWidth())
|
||||
self.hw_rev_lbl.setSizePolicy(sizePolicy)
|
||||
self.hw_rev_lbl.setMinimumSize(QtCore.QSize(150, 0))
|
||||
self.hw_rev_lbl.setMaximumSize(QtCore.QSize(150, 16777215))
|
||||
self.hw_rev_lbl.setBaseSize(QtCore.QSize(150, 0))
|
||||
self.hw_rev_lbl.setObjectName("hw_rev_lbl")
|
||||
self.settings_layout.addWidget(self.hw_rev_lbl)
|
||||
self.horizontalLayout_2.addLayout(self.settings_layout)
|
||||
self.main_layout.addWidget(self.bottom_settings_group)
|
||||
self.gridLayout_2.addLayout(self.main_layout, 0, 1, 1, 1)
|
||||
MainWindow.setCentralWidget(self.main_widget)
|
||||
self.actionReset = QtGui.QAction(parent=MainWindow)
|
||||
self.actionReset.setMenuRole(QtGui.QAction.MenuRole.NoRole)
|
||||
self.actionReset.setObjectName("actionReset")
|
||||
self.actionEnter_DFU_Mode = QtGui.QAction(parent=MainWindow)
|
||||
self.actionEnter_DFU_Mode.setMenuRole(QtGui.QAction.MenuRole.NoRole)
|
||||
self.actionEnter_DFU_Mode.setObjectName("actionEnter_DFU_Mode")
|
||||
self.actionNetwork_Settings = QtGui.QAction(parent=MainWindow)
|
||||
self.actionNetwork_Settings.setMenuRole(QtGui.QAction.MenuRole.NoRole)
|
||||
self.actionNetwork_Settings.setObjectName("actionNetwork_Settings")
|
||||
self.actionAbout_Thermostat = QtGui.QAction(parent=MainWindow)
|
||||
self.actionAbout_Thermostat.setMenuRole(QtGui.QAction.MenuRole.NoRole)
|
||||
self.actionAbout_Thermostat.setObjectName("actionAbout_Thermostat")
|
||||
self.actionLoad_all_configs = QtGui.QAction(parent=MainWindow)
|
||||
self.actionLoad_all_configs.setMenuRole(QtGui.QAction.MenuRole.NoRole)
|
||||
self.actionLoad_all_configs.setObjectName("actionLoad_all_configs")
|
||||
self.actionSave_all_configs = QtGui.QAction(parent=MainWindow)
|
||||
self.actionSave_all_configs.setMenuRole(QtGui.QAction.MenuRole.NoRole)
|
||||
self.actionSave_all_configs.setObjectName("actionSave_all_configs")
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
MainWindow.setWindowTitle(_translate("MainWindow", "Control TEC"))
|
||||
self.ch1_t_graph.setTitle(_translate("MainWindow", "Channel 1 Temperature"))
|
||||
self.ch0_t_graph.setTitle(_translate("MainWindow", "Channel 0 Temperature"))
|
||||
self.ch0_i_graph.setTitle(_translate("MainWindow", "Channel 0 Current"))
|
||||
self.ch1_i_graph.setTitle(_translate("MainWindow", "Channel 1 Current"))
|
||||
self.ip_set_line.setText(_translate("MainWindow", "192.168.1.26"))
|
||||
self.ip_set_line.setPlaceholderText(_translate("MainWindow", "IP:port for the Thermostat"))
|
||||
MainWindow.setWindowTitle(_translate("MainWindow", "Thermostat Control Panel"))
|
||||
self.connect_btn.setText(_translate("MainWindow", "Connect"))
|
||||
self.status_lbl.setText(_translate("MainWindow", "Disconnected"))
|
||||
self.plot_settings.setToolTip(_translate("MainWindow", "Plot Settings"))
|
||||
self.plot_settings.setText(_translate("MainWindow", "📉"))
|
||||
self.background_task_lbl.setText(_translate("MainWindow", "Ready."))
|
||||
self.report_lbl.setText(_translate("MainWindow", "Poll every: "))
|
||||
self.report_refresh_spin.setSuffix(_translate("MainWindow", " s"))
|
||||
self.report_box.setText(_translate("MainWindow", "Report"))
|
||||
self.report_apply_btn.setText(_translate("MainWindow", "Apply"))
|
||||
self.fan_lbl.setText(_translate("MainWindow", "Fan:"))
|
||||
self.fan_auto_box.setText(_translate("MainWindow", "Auto"))
|
||||
self.hw_rev_lbl.setText(_translate("MainWindow", "Thermostat vX.Y"))
|
||||
from pyqtgraph import PlotWidget
|
||||
self.actionReset.setText(_translate("MainWindow", "Reset"))
|
||||
self.actionReset.setToolTip(_translate("MainWindow", "Reset the Thermostat"))
|
||||
self.actionEnter_DFU_Mode.setText(_translate("MainWindow", "Enter DFU Mode"))
|
||||
self.actionEnter_DFU_Mode.setToolTip(_translate("MainWindow", "Reset thermostat and enter USB device firmware update (DFU) mode"))
|
||||
self.actionNetwork_Settings.setText(_translate("MainWindow", "Network Settings"))
|
||||
self.actionNetwork_Settings.setToolTip(_translate("MainWindow", "Configure IPv4 address, netmask length, and optional default gateway"))
|
||||
self.actionAbout_Thermostat.setText(_translate("MainWindow", "About Thermostat"))
|
||||
self.actionAbout_Thermostat.setToolTip(_translate("MainWindow", "Show Thermostat hardware revision, and settings related to i"))
|
||||
self.actionLoad_all_configs.setText(_translate("MainWindow", "Load all channel configs from flash"))
|
||||
self.actionLoad_all_configs.setToolTip(_translate("MainWindow", "Restore configuration for all channels from flash"))
|
||||
self.actionSave_all_configs.setText(_translate("MainWindow", "Save all channel configs to flash"))
|
||||
self.actionSave_all_configs.setToolTip(_translate("MainWindow", "Save configuration for all channels to flash"))
|
||||
from pglive.sources.live_plot_widget import LivePlotWidget
|
||||
from pyqtgraph.parametertree import ParameterTree
|
||||
from waitingspinnerwidget import QtWaitingSpinner
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
"""
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012-2014 Alexander Turkin
|
||||
Copyright (c) 2014 William Hallatt
|
||||
Copyright (c) 2015 Jacob Dawid
|
||||
Copyright (c) 2016 Luca Weiss
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
"""
|
||||
|
||||
import math
|
||||
|
||||
from PyQt6.QtCore import *
|
||||
from PyQt6.QtGui import *
|
||||
from PyQt6.QtWidgets import *
|
||||
|
||||
|
||||
class QtWaitingSpinner(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
# WAS IN initialize()
|
||||
self._color = QColor(Qt.GlobalColor.black)
|
||||
self._roundness = 100.0
|
||||
self._minimumTrailOpacity = 3.14159265358979323846
|
||||
self._trailFadePercentage = 80.0
|
||||
self._revolutionsPerSecond = 1.57079632679489661923
|
||||
self._numberOfLines = 20
|
||||
self._lineLength = 5
|
||||
self._lineWidth = 2
|
||||
self._innerRadius = 5
|
||||
self._currentCounter = 0
|
||||
|
||||
self._timer = QTimer(self)
|
||||
self._timer.timeout.connect(self.rotate)
|
||||
self.updateSize()
|
||||
self.updateTimer()
|
||||
# END initialize()
|
||||
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
def paintEvent(self, QPaintEvent):
|
||||
painter = QPainter(self)
|
||||
painter.fillRect(self.rect(), Qt.GlobalColor.transparent)
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, True)
|
||||
|
||||
if self._currentCounter >= self._numberOfLines:
|
||||
self._currentCounter = 0
|
||||
|
||||
painter.setPen(Qt.PenStyle.NoPen)
|
||||
for i in range(0, self._numberOfLines):
|
||||
painter.save()
|
||||
painter.translate(self._innerRadius + self._lineLength, self._innerRadius + self._lineLength)
|
||||
rotateAngle = float(360 * i) / float(self._numberOfLines)
|
||||
painter.rotate(rotateAngle)
|
||||
painter.translate(self._innerRadius, 0)
|
||||
distance = self.lineCountDistanceFromPrimary(i, self._currentCounter, self._numberOfLines)
|
||||
color = self.currentLineColor(distance, self._numberOfLines, self._trailFadePercentage,
|
||||
self._minimumTrailOpacity, self._color)
|
||||
painter.setBrush(color)
|
||||
painter.drawRoundedRect(QRect(0, int(-self._lineWidth / 2), self._lineLength, self._lineWidth), self._roundness,
|
||||
self._roundness, Qt.SizeMode.RelativeSize)
|
||||
painter.restore()
|
||||
|
||||
def start(self):
|
||||
if not self._timer.isActive():
|
||||
self._timer.start()
|
||||
self._currentCounter = 0
|
||||
|
||||
def stop(self):
|
||||
if self._timer.isActive():
|
||||
self._timer.stop()
|
||||
self._currentCounter = 0
|
||||
|
||||
def setNumberOfLines(self, lines):
|
||||
self._numberOfLines = lines
|
||||
self._currentCounter = 0
|
||||
self.updateTimer()
|
||||
|
||||
def setLineLength(self, length):
|
||||
self._lineLength = length
|
||||
self.updateSize()
|
||||
|
||||
def setLineWidth(self, width):
|
||||
self._lineWidth = width
|
||||
self.updateSize()
|
||||
|
||||
def setInnerRadius(self, radius):
|
||||
self._innerRadius = radius
|
||||
self.updateSize()
|
||||
|
||||
def color(self):
|
||||
return self._color
|
||||
|
||||
def roundness(self):
|
||||
return self._roundness
|
||||
|
||||
def minimumTrailOpacity(self):
|
||||
return self._minimumTrailOpacity
|
||||
|
||||
def trailFadePercentage(self):
|
||||
return self._trailFadePercentage
|
||||
|
||||
def revolutionsPersSecond(self):
|
||||
return self._revolutionsPerSecond
|
||||
|
||||
def numberOfLines(self):
|
||||
return self._numberOfLines
|
||||
|
||||
def lineLength(self):
|
||||
return self._lineLength
|
||||
|
||||
def lineWidth(self):
|
||||
return self._lineWidth
|
||||
|
||||
def innerRadius(self):
|
||||
return self._innerRadius
|
||||
|
||||
def setRoundness(self, roundness):
|
||||
self._roundness = max(0.0, min(100.0, roundness))
|
||||
|
||||
def setColor(self, color=Qt.GlobalColor.black):
|
||||
self._color = QColor(color)
|
||||
|
||||
def setRevolutionsPerSecond(self, revolutionsPerSecond):
|
||||
self._revolutionsPerSecond = revolutionsPerSecond
|
||||
self.updateTimer()
|
||||
|
||||
def setTrailFadePercentage(self, trail):
|
||||
self._trailFadePercentage = trail
|
||||
|
||||
def setMinimumTrailOpacity(self, minimumTrailOpacity):
|
||||
self._minimumTrailOpacity = minimumTrailOpacity
|
||||
|
||||
def rotate(self):
|
||||
self._currentCounter += 1
|
||||
if self._currentCounter >= self._numberOfLines:
|
||||
self._currentCounter = 0
|
||||
self.update()
|
||||
|
||||
def updateSize(self):
|
||||
self.size = (self._innerRadius + self._lineLength) * 2
|
||||
self.setFixedSize(self.size, self.size)
|
||||
|
||||
def updateTimer(self):
|
||||
self._timer.setInterval(int(1000 / (self._numberOfLines * self._revolutionsPerSecond)))
|
||||
|
||||
def lineCountDistanceFromPrimary(self, current, primary, totalNrOfLines):
|
||||
distance = primary - current
|
||||
if distance < 0:
|
||||
distance += totalNrOfLines
|
||||
return distance
|
||||
|
||||
def currentLineColor(self, countDistance, totalNrOfLines, trailFadePerc, minOpacity, colorinput):
|
||||
color = QColor(colorinput)
|
||||
if countDistance == 0:
|
||||
return color
|
||||
minAlphaF = minOpacity / 100.0
|
||||
distanceThreshold = int(math.ceil((totalNrOfLines - 1) * trailFadePerc / 100.0))
|
||||
if countDistance > distanceThreshold:
|
||||
color.setAlphaF(minAlphaF)
|
||||
else:
|
||||
alphaDiff = color.alphaF() - minAlphaF
|
||||
gradient = alphaDiff / float(distanceThreshold + 1)
|
||||
resultAlpha = color.alphaF() - gradient * countDistance
|
||||
# If alpha is out of bounds, clip it.
|
||||
resultAlpha = min(1.0, max(0.0, resultAlpha))
|
||||
color.setAlphaF(resultAlpha)
|
||||
return color
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication([])
|
||||
waiting_spinner = QtWaitingSpinner()
|
||||
waiting_spinner.show()
|
||||
waiting_spinner.start()
|
||||
app.exec()
|
Loading…
Reference in New Issue