MainCode/adalm1000_logger.py aktualisiert
plot ther but still errors D
This commit is contained in:
parent
acdc6bb8ee
commit
411528cdcd
@ -912,11 +912,17 @@ class BatteryTester(QMainWindow):
|
|||||||
|
|
||||||
# Button style
|
# Button style
|
||||||
button_style = f"""
|
button_style = f"""
|
||||||
|
QPushButton {{
|
||||||
{base_style}
|
{base_style}
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
min-height: 28px;
|
min-height: 28px;
|
||||||
|
background-color: {self.accent_color};
|
||||||
|
}}
|
||||||
|
QPushButton:checked {{
|
||||||
|
background-color: {self.warning_color};
|
||||||
|
}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Single toggle button (Start/Stop)
|
# Single toggle button (Start/Stop)
|
||||||
@ -939,10 +945,9 @@ class BatteryTester(QMainWindow):
|
|||||||
# Record button for Live mode
|
# Record button for Live mode
|
||||||
self.record_button = QPushButton("● Start Recording")
|
self.record_button = QPushButton("● Start Recording")
|
||||||
self.record_button.setCheckable(True)
|
self.record_button.setCheckable(True)
|
||||||
self.record_button.setStyleSheet(button_style + f"""
|
self.record_button.setStyleSheet(button_style.replace(
|
||||||
background-color: {self.success_color};
|
self.accent_color, self.success_color
|
||||||
min-width: 140px;
|
))
|
||||||
""")
|
|
||||||
self.record_button.clicked.connect(self.toggle_global_recording)
|
self.record_button.clicked.connect(self.toggle_global_recording)
|
||||||
button_layout.addWidget(self.record_button)
|
button_layout.addWidget(self.record_button)
|
||||||
self.record_button.hide()
|
self.record_button.hide()
|
||||||
@ -1154,7 +1159,7 @@ class BatteryTester(QMainWindow):
|
|||||||
self.ax.set_ylim(min_voltage, max_voltage)
|
self.ax.set_ylim(min_voltage, max_voltage)
|
||||||
|
|
||||||
# Voltage plot
|
# 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.set_ylabel("Voltage (V)", color='#00BFFF')
|
||||||
self.ax.tick_params(axis='y', labelcolor='#00BFFF')
|
self.ax.tick_params(axis='y', labelcolor='#00BFFF')
|
||||||
|
|
||||||
@ -1165,7 +1170,7 @@ class BatteryTester(QMainWindow):
|
|||||||
max_current = test_current * 1.5
|
max_current = test_current * 1.5
|
||||||
self.ax2.set_ylim(-max_current - current_padding, max_current + current_padding)
|
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.set_ylabel("Current (A)", color='r')
|
||||||
self.ax2.tick_params(axis='y', labelcolor='r')
|
self.ax2.tick_params(axis='y', labelcolor='r')
|
||||||
|
|
||||||
@ -1449,12 +1454,17 @@ class BatteryTester(QMainWindow):
|
|||||||
dev.current_data.append(current)
|
dev.current_data.append(current)
|
||||||
|
|
||||||
# Calculate metrics
|
# Calculate metrics
|
||||||
|
power = voltage * abs(current) # Always define power
|
||||||
if len(dev.time_data) > 1:
|
if len(dev.time_data) > 1:
|
||||||
delta_t = dev.time_data[-1] - dev.time_data[-2]
|
delta_t = dev.time_data[-1] - dev.time_data[-2]
|
||||||
power = voltage * abs(current)
|
|
||||||
dev.capacity_ah += abs(current) * delta_t / 3600 # Ah
|
dev.capacity_ah += abs(current) * delta_t / 3600 # Ah
|
||||||
dev.energy += power * delta_t / 3600 # Wh
|
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
|
# Update UI for active device
|
||||||
self.voltage_label.setText(f"{voltage:.4f}")
|
self.voltage_label.setText(f"{voltage:.4f}")
|
||||||
self.current_label.setText(f"{abs(current):.4f}")
|
self.current_label.setText(f"{abs(current):.4f}")
|
||||||
@ -2514,8 +2524,8 @@ class BatteryTester(QMainWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Create local copies of data safely
|
# Create local copies of data safely
|
||||||
with self.plot_mutex:
|
|
||||||
dev = self.active_device
|
dev = self.active_device
|
||||||
|
with self.plot_mutex:
|
||||||
if not dev.display_time_data:
|
if not dev.display_time_data:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user