From 8f5a294a53ffd532297ef312b431e8b04aa89da8 Mon Sep 17 00:00:00 2001 From: linuswck Date: Tue, 22 Oct 2024 10:57:55 +0800 Subject: [PATCH] gui: Fix graphs' refresh rate to be 10Hz - Reduce unnecessary CPU usage --- pykirdy/kirdy_qt.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pykirdy/kirdy_qt.py b/pykirdy/kirdy_qt.py index 9000364..89272c2 100644 --- a/pykirdy/kirdy_qt.py +++ b/pykirdy/kirdy_qt.py @@ -196,14 +196,14 @@ class Graphs: ld_i_set_graph.setAxisItems({'left': ld_i_set_axis}) ld_i_set_graph.addItem(self._ld_i_set_plot) ld_i_set_graph.y_range_controller = LiveAxisRange(fixed_range=[0.0, 0.4]) - self.ld_i_set_connector = DataConnector(self._ld_i_set_plot, max_points=self.max_samples) + self.ld_i_set_connector = DataConnector(self._ld_i_set_plot, plot_rate=10.0, update_rate=10.0, max_points=self.max_samples) self.connectors += [self.ld_i_set_connector] pd_mon_pwr_axis = LiveAxis('left', text="Power", units="W") pd_mon_pwr_axis.showLabel() pd_mon_pwr_graph.setAxisItems({'left': pd_mon_pwr_axis}) pd_mon_pwr_graph.addItem(self._pd_mon_pwr_plot) - self.pd_mon_pwr_connector = DataConnector(self._pd_mon_pwr_plot, max_points=self.max_samples) + self.pd_mon_pwr_connector = DataConnector(self._pd_mon_pwr_plot, plot_rate=10.0, update_rate=10.0, max_points=self.max_samples) self.connectors += [self.pd_mon_pwr_connector] tec_temp_axis = LiveAxis('left', text="Temperature", units="℃") @@ -211,8 +211,8 @@ class Graphs: tec_temp_graph.setAxisItems({'left': tec_temp_axis}) tec_temp_graph.addItem(self._tec_setpoint_plot) tec_temp_graph.addItem(self._tec_temp_plot) - self.tec_setpoint_connector = DataConnector(self._tec_setpoint_plot, max_points=1) - self.tec_temp_connector = DataConnector(self._tec_temp_plot, max_points=self.max_samples) + self.tec_setpoint_connector = DataConnector(self._tec_setpoint_plot, plot_rate=10.0, update_rate=10.0, max_points=1) + self.tec_temp_connector = DataConnector(self._tec_temp_plot, plot_rate=10.0, update_rate=10.0, max_points=self.max_samples) self.connectors += [self.tec_temp_connector, self.tec_setpoint_connector] tec_i_axis = LiveAxis('left', text="Current", units="A") @@ -221,8 +221,8 @@ class Graphs: tec_i_graph.addLegend(brush=(50, 50, 200, 150)) tec_i_graph.addItem(self._tec_i_target_plot) tec_i_graph.addItem(self._tec_i_measure_plot) - self.tec_i_target_connector = DataConnector(self._tec_i_target_plot, max_points=self.max_samples) - self.tec_i_measure_connector = DataConnector(self._tec_i_measure_plot, max_points=self.max_samples) + self.tec_i_target_connector = DataConnector(self._tec_i_target_plot, plot_rate=10.0, update_rate=10.0, max_points=self.max_samples) + self.tec_i_measure_connector = DataConnector(self._tec_i_measure_plot, plot_rate=10.0, update_rate=10.0, max_points=self.max_samples) self.connectors += [self.tec_i_target_connector, self.tec_i_measure_connector] def set_max_samples(self, max_samples):