diff --git a/MainCode/adalm1000_logger.py b/MainCode/adalm1000_logger.py index b31f375..7094fd9 100644 --- a/MainCode/adalm1000_logger.py +++ b/MainCode/adalm1000_logger.py @@ -912,11 +912,17 @@ class BatteryTester(QMainWindow): # Button style button_style = f""" - {base_style} - font-weight: bold; - padding: 4px 8px; - border-radius: 4px; - min-height: 28px; + QPushButton {{ + {base_style} + font-weight: bold; + padding: 4px 8px; + border-radius: 4px; + min-height: 28px; + background-color: {self.accent_color}; + }} + QPushButton:checked {{ + background-color: {self.warning_color}; + }} """ # Single toggle button (Start/Stop) @@ -939,10 +945,9 @@ class BatteryTester(QMainWindow): # Record button for Live mode self.record_button = QPushButton("● Start Recording") self.record_button.setCheckable(True) - self.record_button.setStyleSheet(button_style + f""" - background-color: {self.success_color}; - min-width: 140px; - """) + self.record_button.setStyleSheet(button_style.replace( + self.accent_color, self.success_color + )) self.record_button.clicked.connect(self.toggle_global_recording) button_layout.addWidget(self.record_button) self.record_button.hide() @@ -1154,7 +1159,7 @@ class BatteryTester(QMainWindow): self.ax.set_ylim(min_voltage, max_voltage) # Voltage plot - self.line_voltage, = self.ax.plot([], [], color='#00BFFF', label='Voltage (V)', linewidth=2) + self.line_voltage, = self.ax.plot([0], [0], color='#00BFFF', label='Voltage (V)', linewidth=2) self.ax.set_ylabel("Voltage (V)", color='#00BFFF') self.ax.tick_params(axis='y', labelcolor='#00BFFF') @@ -1165,7 +1170,7 @@ class BatteryTester(QMainWindow): max_current = test_current * 1.5 self.ax2.set_ylim(-max_current - current_padding, max_current + current_padding) - self.line_current, = self.ax2.plot([], [], 'r-', label='Current (A)', linewidth=2) + self.line_current, = self.ax2.plot([0], [0], 'r-', label='Current (A)', linewidth=2) self.ax2.set_ylabel("Current (A)", color='r') self.ax2.tick_params(axis='y', labelcolor='r') @@ -1449,12 +1454,17 @@ class BatteryTester(QMainWindow): dev.current_data.append(current) # Calculate metrics + power = voltage * abs(current) # Always define power if len(dev.time_data) > 1: delta_t = dev.time_data[-1] - dev.time_data[-2] - power = voltage * abs(current) dev.capacity_ah += abs(current) * delta_t / 3600 # Ah dev.energy += power * delta_t / 3600 # Wh + # Update display buffers + dev.display_time_data.append(current_time) + dev.display_voltage_data.append(voltage) + dev.display_current_data.append(current) + # Update UI for active device self.voltage_label.setText(f"{voltage:.4f}") self.current_label.setText(f"{abs(current):.4f}") @@ -2514,8 +2524,8 @@ class BatteryTester(QMainWindow): return # Create local copies of data safely + dev = self.active_device with self.plot_mutex: - dev = self.active_device if not dev.display_time_data: return