MainCode/adalm1000_logger.py aktualisiert
improves the measurement display padding the graph (C)
This commit is contained in:
parent
adc7edd501
commit
e9799c17de
@ -388,50 +388,57 @@ class BatteryTester(QMainWindow):
|
||||
display_frame = QFrame()
|
||||
display_frame.setFrameShape(QFrame.StyledPanel)
|
||||
display_layout = QGridLayout(display_frame)
|
||||
display_layout.setHorizontalSpacing(15)
|
||||
display_layout.setVerticalSpacing(8)
|
||||
|
||||
measurement_labels = [
|
||||
("Voltage (V)", "V"),
|
||||
("Current (A)", "A"),
|
||||
("Voltage", "V"),
|
||||
("Current", "A"),
|
||||
("Test Phase", ""),
|
||||
("Elapsed Time", "s"),
|
||||
("Discharge Capacity", "Ah"),
|
||||
("Charge Capacity", "Ah"),
|
||||
("Coulomb Eff.", "%"),
|
||||
("Coulomb Efficiency", "%"),
|
||||
("Cycle Count", ""),
|
||||
]
|
||||
|
||||
self.value_labels = {} # Optional: Store labels for easy update
|
||||
|
||||
for i, (label, unit) in enumerate(measurement_labels):
|
||||
row = i // 2
|
||||
col = (i % 2) * 2
|
||||
col = (i % 2) * 3 # Each block is 3 columns: label | value | unit
|
||||
|
||||
lbl = QLabel(f"{label}:")
|
||||
lbl.setStyleSheet("font-size: 11px;")
|
||||
display_layout.addWidget(lbl, row, col)
|
||||
name_label = QLabel(label + ":")
|
||||
name_label.setStyleSheet("font-size: 11px;")
|
||||
display_layout.addWidget(name_label, row, col)
|
||||
|
||||
value_label = QLabel("0.000")
|
||||
value_label.setStyleSheet("font-size: 12px; font-weight: bold;")
|
||||
value_label.setStyleSheet("font-size: 12px; font-weight: bold; min-width: 60px;")
|
||||
display_layout.addWidget(value_label, row, col + 1)
|
||||
|
||||
if unit:
|
||||
unit_label = QLabel(unit)
|
||||
display_layout.addWidget(unit_label, row, col + 2)
|
||||
unit_label = QLabel(unit)
|
||||
unit_label.setStyleSheet("font-size: 11px; color: gray;")
|
||||
display_layout.addWidget(unit_label, row, col + 2)
|
||||
|
||||
if i == 0:
|
||||
# Save reference for updating later
|
||||
self.value_labels[label] = value_label
|
||||
|
||||
# Assign to instance attributes for specific fields
|
||||
if label == "Voltage":
|
||||
self.voltage_label = value_label
|
||||
elif i == 1:
|
||||
elif label == "Current":
|
||||
self.current_label = value_label
|
||||
elif i == 2:
|
||||
elif label == "Test Phase":
|
||||
self.phase_label = value_label
|
||||
self.phase_label.setText(self.test_phase)
|
||||
elif i == 3:
|
||||
elif label == "Elapsed Time":
|
||||
self.time_label = value_label
|
||||
elif i == 4:
|
||||
elif label == "Discharge Capacity":
|
||||
self.capacity_label = value_label
|
||||
elif i == 5:
|
||||
elif label == "Charge Capacity":
|
||||
self.charge_capacity_label = value_label
|
||||
elif i == 6:
|
||||
elif label == "Coulomb Efficiency":
|
||||
self.efficiency_label = value_label
|
||||
elif i == 7:
|
||||
elif label == "Cycle Count":
|
||||
self.cycle_label = value_label
|
||||
|
||||
self.main_layout.addWidget(display_frame)
|
||||
@ -944,7 +951,7 @@ class BatteryTester(QMainWindow):
|
||||
max_time = list(self.time_data)[-1]
|
||||
current_xlim = self.ax.get_xlim()
|
||||
if max_time > current_xlim[1] * 0.95:
|
||||
new_xmax = current_xlim[1] + (max_time * 1.05 - current_xlim[1]) * 0.1
|
||||
new_xmax = max_time * 1.10 # 10% padding
|
||||
self.ax.set_xlim(0, new_xmax)
|
||||
self.ax2.set_xlim(0, new_xmax)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user