Skip to content

Commit 39a0ee2

Browse files
committed
Show BMS min-max-diff voltage
1 parent 22f21dd commit 39a0ee2

File tree

5 files changed

+101
-38
lines changed

5 files changed

+101
-38
lines changed

mobile/BMS.qml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,16 @@ Item {
230230
}
231231

232232
ColumnLayout {
233+
property int textRows: 12
234+
233235
Layout.fillWidth: true
234236
Layout.fillHeight: true
235237
Layout.preferredWidth: isHorizontal ? parent.width/2 : parent.width
236238
Layout.column:0
237239
Layout.row: isHorizontal ? 0 : 1
238-
Layout.preferredHeight: valMetrics.height * 12 + 20 + menuButton.implicitHeight
240+
Layout.preferredHeight: valMetrics.height * textRows + 20 + menuButton.implicitHeight
239241
spacing: 0
242+
240243
Rectangle {
241244
id: textRect
242245
color: Utility.getAppHexColor("darkBackground")
@@ -249,7 +252,7 @@ Item {
249252
}
250253

251254
Layout.fillWidth: true
252-
Layout.preferredHeight: valMetrics.height * 12 + 20
255+
Layout.preferredHeight: valMetrics.height * parent.textRows + 20
253256
Layout.alignment: Qt.AlignBottom
254257

255258
Text {
@@ -351,19 +354,25 @@ Item {
351354
mVal = val
352355
mValSet = true
353356

357+
var cvMin = Math.min(...mVal.v_cells)
358+
var cvMax = Math.max(...mVal.v_cells)
359+
354360
valText.text =
355-
"V Tot : " + parseFloat(val.v_tot).toFixed(2) + " V\n" +
356-
"V Charge : " + parseFloat(val.v_charge).toFixed(2) + " V\n" +
357-
"I In : " + parseFloat(val.i_in_ic).toFixed(2) + " A\n" +
358-
"Ah Cnt : " + parseFloat(val.ah_cnt).toFixed(3) + " Ah\n" +
359-
"Wh Cnt : " + parseFloat(val.wh_cnt).toFixed(2) + " Wh\n" +
360-
"Power : " + parseFloat(val.v_tot * val.i_in_ic).toFixed(2) + " W\n" +
361-
"Humidity : " + parseFloat(val.humidity).toFixed(1) + " %\n" +
362-
"Pressure : " + parseFloat(val.pressure).toFixed(0) + " Pa\n" +
363-
"Temp Hum : " + parseFloat(val.temp_hum_sensor).toFixed(1) + " \u00B0C\n" +
364-
"SoC : " + parseFloat(val.soc * 100).toFixed(1) + " %\n" +
365-
"Ah Chg Tot : " + parseFloat(val.ah_cnt_chg_total).toFixed(3) + " Ah\n" +
366-
"Ah Dis Tot : " + parseFloat(val.ah_cnt_dis_total).toFixed(3) + " Ah"
361+
"Min-Max-Diff : " + parseFloat(cvMin).toFixed(3) + " - " +
362+
parseFloat(cvMax).toFixed(3) + " - " +
363+
parseFloat(cvMax - cvMin).toFixed(3) + " V\n" +
364+
"V Tot : " + parseFloat(val.v_tot).toFixed(2) + " V\n" +
365+
"V Charge : " + parseFloat(val.v_charge).toFixed(2) + " V\n" +
366+
"I In : " + parseFloat(val.i_in_ic).toFixed(2) + " A\n" +
367+
"Ah Cnt : " + parseFloat(val.ah_cnt).toFixed(3) + " Ah\n" +
368+
"Wh Cnt : " + parseFloat(val.wh_cnt).toFixed(2) + " Wh\n" +
369+
"Power : " + parseFloat(val.v_tot * val.i_in_ic).toFixed(2) + " W\n" +
370+
"Hum (temp) : " + parseFloat(val.humidity).toFixed(1) + " %" +
371+
" (" + parseFloat(val.temp_hum_sensor).toFixed(1) + " \u00B0C)\n" +
372+
"Pressure : " + parseFloat(val.pressure).toFixed(0) + " Pa\n" +
373+
"SoC : " + parseFloat(val.soc * 100).toFixed(1) + " %\n" +
374+
"Ah Chg Tot : " + parseFloat(val.ah_cnt_chg_total).toFixed(3) + " Ah\n" +
375+
"Ah Dis Tot : " + parseFloat(val.ah_cnt_dis_total).toFixed(3) + " Ah"
367376

368377
cellCanvas.requestPaint()
369378
tempCanvas.requestPaint()

mobile/Settings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Item {
120120
id: fwUpdateAvailableBox
121121
Layout.fillWidth: true
122122
text: "Show firmware update message"
123-
checked: VescIf.showFwUpdateAvailable()()
123+
checked: VescIf.showFwUpdateAvailable()
124124
}
125125

126126
CheckBox {

pages/pagebms.cpp

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,24 @@ void PageBms::bmsValuesRx(BMS_VALUES val)
6868
reloadCellBars(val.v_cells.size());
6969
}
7070

71+
double vcMin = 0.0;
72+
double vcMax = 0.0;
73+
74+
if (val.v_cells.size() > 0) {
75+
vcMin = val.v_cells.first();
76+
vcMax = vcMin;
77+
}
78+
7179
QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
7280
for (int i = 0;i < val.v_cells.size();i++) {
81+
if (val.v_cells.at(i) > vcMax) {
82+
vcMax = val.v_cells.at(i);
83+
}
84+
85+
if (val.v_cells.at(i) < vcMin) {
86+
vcMin = val.v_cells.at(i);
87+
}
88+
7389
QVector<double> cell, voltage;
7490
cell.append(i + 1);
7591
voltage.append(val.v_cells.at(i));
@@ -129,23 +145,27 @@ void PageBms::bmsValuesRx(BMS_VALUES val)
129145
ui->plotTemp->replotWhenVisible();
130146

131147
// Value table
132-
ui->valTable->item(0, 0)->setText(QString("%1 V").arg(val.v_tot, 0, 'f', 2));
133-
ui->valTable->item(1, 0)->setText(QString("%1 V").arg(val.v_charge, 0, 'f', 2));
134-
ui->valTable->item(2, 0)->setText(QString("%1 A").arg(val.i_in, 0, 'f', 2));
135-
ui->valTable->item(3, 0)->setText(QString("%1 A").arg(val.i_in_ic, 0, 'f', 2));
136-
ui->valTable->item(4, 0)->setText(QString("%1 Ah").arg(val.ah_cnt, 0, 'f', 3));
137-
ui->valTable->item(5, 0)->setText(QString("%1 Wh").arg(val.wh_cnt, 0, 'f', 3));
138-
ui->valTable->item(6, 0)->setText(QString("%1 W").arg(val.i_in_ic * val.v_tot, 0, 'f', 3));
139-
ui->valTable->item(7, 0)->setText(QString("%1 %").arg(val.soc * 100.0, 0, 'f', 0));
140-
ui->valTable->item(8, 0)->setText(QString("%1 %").arg(val.soh * 100.0, 0, 'f', 0));
141-
ui->valTable->item(9, 0)->setText(QString("%1 °C").arg(val.temp_cells_highest, 0, 'f', 2));
142-
ui->valTable->item(10, 0)->setText(QString("%1 %").arg(val.humidity, 0, 'f', 2));
143-
ui->valTable->item(11, 0)->setText(QString("%1 Pa").arg(val.pressure, 0, 'f', 0));
144-
ui->valTable->item(12, 0)->setText(QString("%1 °C").arg(val.temp_hum_sensor, 0, 'f', 2));
145-
ui->valTable->item(13, 0)->setText(QString("%1 Ah").arg(val.ah_cnt_chg_total, 0, 'f', 3));
146-
ui->valTable->item(14, 0)->setText(QString("%1 Wh").arg(val.wh_cnt_chg_total, 0, 'f', 3));
147-
ui->valTable->item(15, 0)->setText(QString("%1 Ah").arg(val.ah_cnt_dis_total, 0, 'f', 3));
148-
ui->valTable->item(16, 0)->setText(QString("%1 Wh").arg(val.wh_cnt_dis_total, 0, 'f', 3));
148+
int ind = 0;
149+
ui->valTable->item(ind++, 0)->setText(QString("%1 V").arg(val.v_tot, 0, 'f', 2));
150+
ui->valTable->item(ind++, 0)->setText(QString("%1 V").arg(vcMin, 0, 'f', 3));
151+
ui->valTable->item(ind++, 0)->setText(QString("%1 V").arg(vcMax, 0, 'f', 3));
152+
ui->valTable->item(ind++, 0)->setText(QString("%1 V").arg(vcMax - vcMin, 0, 'f', 3));
153+
ui->valTable->item(ind++, 0)->setText(QString("%1 V").arg(val.v_charge, 0, 'f', 2));
154+
ui->valTable->item(ind++, 0)->setText(QString("%1 A").arg(val.i_in, 0, 'f', 2));
155+
ui->valTable->item(ind++, 0)->setText(QString("%1 A").arg(val.i_in_ic, 0, 'f', 2));
156+
ui->valTable->item(ind++, 0)->setText(QString("%1 Ah").arg(val.ah_cnt, 0, 'f', 3));
157+
ui->valTable->item(ind++, 0)->setText(QString("%1 Wh").arg(val.wh_cnt, 0, 'f', 3));
158+
ui->valTable->item(ind++, 0)->setText(QString("%1 W").arg(val.i_in_ic * val.v_tot, 0, 'f', 3));
159+
ui->valTable->item(ind++, 0)->setText(QString("%1 %").arg(val.soc * 100.0, 0, 'f', 0));
160+
ui->valTable->item(ind++, 0)->setText(QString("%1 %").arg(val.soh * 100.0, 0, 'f', 0));
161+
ui->valTable->item(ind++, 0)->setText(QString("%1 °C").arg(val.temp_cells_highest, 0, 'f', 2));
162+
ui->valTable->item(ind++, 0)->setText(QString("%1 %").arg(val.humidity, 0, 'f', 2));
163+
ui->valTable->item(ind++, 0)->setText(QString("%1 Pa").arg(val.pressure, 0, 'f', 0));
164+
ui->valTable->item(ind++, 0)->setText(QString("%1 °C").arg(val.temp_hum_sensor, 0, 'f', 2));
165+
ui->valTable->item(ind++, 0)->setText(QString("%1 Ah").arg(val.ah_cnt_chg_total, 0, 'f', 3));
166+
ui->valTable->item(ind++, 0)->setText(QString("%1 Wh").arg(val.wh_cnt_chg_total, 0, 'f', 3));
167+
ui->valTable->item(ind++, 0)->setText(QString("%1 Ah").arg(val.ah_cnt_dis_total, 0, 'f', 3));
168+
ui->valTable->item(ind++, 0)->setText(QString("%1 Wh").arg(val.wh_cnt_dis_total, 0, 'f', 3));
149169
}
150170

151171
void PageBms::reloadCellBars(int cells)

pages/pagebms.ui

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<item>
1818
<widget class="QSplitter" name="splitter">
1919
<property name="orientation">
20-
<enum>Qt::Vertical</enum>
20+
<enum>Qt::Orientation::Vertical</enum>
2121
</property>
2222
<property name="handleWidth">
2323
<number>8</number>
@@ -27,7 +27,7 @@
2727
</property>
2828
<widget class="QTabWidget" name="tabWidget">
2929
<property name="tabShape">
30-
<enum>QTabWidget::Triangular</enum>
30+
<enum>QTabWidget::TabShape::Triangular</enum>
3131
</property>
3232
<property name="currentIndex">
3333
<number>0</number>
@@ -64,11 +64,11 @@
6464
</widget>
6565
</widget>
6666
<widget class="QWidget" name="layoutWidget">
67-
<layout class="QHBoxLayout" name="horizontalLayout_3">
67+
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,0">
6868
<item>
6969
<widget class="QTableWidget" name="valTable">
7070
<property name="editTriggers">
71-
<set>QAbstractItemView::NoEditTriggers</set>
71+
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
7272
</property>
7373
<attribute name="horizontalHeaderVisible">
7474
<bool>false</bool>
@@ -87,6 +87,21 @@
8787
<string>Total Voltage</string>
8888
</property>
8989
</row>
90+
<row>
91+
<property name="text">
92+
<string>Cell Min</string>
93+
</property>
94+
</row>
95+
<row>
96+
<property name="text">
97+
<string>Cell Max</string>
98+
</property>
99+
</row>
100+
<row>
101+
<property name="text">
102+
<string>Cell Diff</string>
103+
</property>
104+
</row>
90105
<row>
91106
<property name="text">
92107
<string>Charge Input Voltage</string>
@@ -257,10 +272,25 @@
257272
<string/>
258273
</property>
259274
</item>
275+
<item row="17" column="0">
276+
<property name="text">
277+
<string/>
278+
</property>
279+
</item>
280+
<item row="18" column="0">
281+
<property name="text">
282+
<string/>
283+
</property>
284+
</item>
285+
<item row="19" column="0">
286+
<property name="text">
287+
<string/>
288+
</property>
289+
</item>
260290
</widget>
261291
</item>
262292
<item>
263-
<layout class="QVBoxLayout" name="verticalLayout">
293+
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,1">
264294
<property name="spacing">
265295
<number>2</number>
266296
</property>
@@ -358,7 +388,7 @@
358388
<item>
359389
<spacer name="verticalSpacer">
360390
<property name="orientation">
361-
<enum>Qt::Vertical</enum>
391+
<enum>Qt::Orientation::Vertical</enum>
362392
</property>
363393
<property name="sizeHint" stdset="0">
364394
<size>

res/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* Movable lisp-tabs and better tab behavior in general.
55
* Detect file system changes in script editor.
66
* Duplicate line shortcut in script editor.
7+
* Use temperature convention on BMS page.
8+
* Show Min, Max and Diff voltage on BMS page.
9+
10+
---
711

812
### 6.05
913
#### Released 2024-08-19

0 commit comments

Comments
 (0)