Skip to content

Commit

Permalink
Added BMS pressure sensor support
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Jan 12, 2024
1 parent 6533b34 commit 10f36a1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,10 @@ void Commands::processPacket(QByteArray data)
val.wh_cnt_dis_total = vb.vbPopFrontDouble32Auto();
}

if (vb.size() >= 2) {
val.pressure = vb.vbPopFrontDouble16(1e-1);
}

val.updateTimeStamp();

emit bmsValuesRx(val);
Expand Down
3 changes: 3 additions & 0 deletions datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ struct BMS_VALUES {
Q_PROPERTY(QVector<bool> is_balancing MEMBER is_balancing)
Q_PROPERTY(double temp_ic MEMBER temp_ic)
Q_PROPERTY(double humidity MEMBER humidity)
Q_PROPERTY(double pressure MEMBER pressure)
Q_PROPERTY(double temp_hum_sensor MEMBER temp_hum_sensor)
Q_PROPERTY(double temp_cells_highest MEMBER temp_cells_highest)
Q_PROPERTY(double soc MEMBER soc)
Expand All @@ -746,6 +747,7 @@ struct BMS_VALUES {
ah_cnt = 0.0;
wh_cnt = 0.0;
humidity = 0.0;
pressure = 0.0;
temp_hum_sensor = 0.0;
temp_cells_highest = 0.0;
soc = 0.0;
Expand Down Expand Up @@ -784,6 +786,7 @@ struct BMS_VALUES {
QVector<bool> is_balancing;
double temp_ic;
double humidity;
double pressure;
double temp_hum_sensor;
double temp_cells_highest;
double soc;
Expand Down
2 changes: 1 addition & 1 deletion mobile/BMS.qml
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ Item {
"Wh Cnt : " + parseFloat(val.wh_cnt).toFixed(2) + " Wh\n" +
"Power : " + parseFloat(val.v_tot * val.i_in_ic).toFixed(2) + " W\n" +
"Humidity : " + parseFloat(val.humidity).toFixed(1) + " %\n" +
"Pressure : " + parseFloat(val.pressure).toFixed(0) + " Pa\n" +
"Temp Hum : " + parseFloat(val.temp_hum_sensor).toFixed(1) + " \u00B0C\n" +
"Temp Max : " + parseFloat(val.temp_cells_highest).toFixed(1) + " \u00B0C\n" +
"SoC : " + parseFloat(val.soc * 100).toFixed(1) + " %\n" +
"SoH : " + parseFloat(val.soh * 100).toFixed(1) + " %\n" +
"Ah Chg Tot : " + parseFloat(val.ah_cnt_chg_total).toFixed(3) + " Ah"

cellCanvas.requestPaint()
Expand Down
11 changes: 6 additions & 5 deletions pages/pagebms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ void PageBms::bmsValuesRx(BMS_VALUES val)
ui->valTable->item(8, 0)->setText(QString("%1 %").arg(val.soh * 100.0, 0, 'f', 0));
ui->valTable->item(9, 0)->setText(QString("%1 °C").arg(val.temp_cells_highest, 0, 'f', 2));
ui->valTable->item(10, 0)->setText(QString("%1 %").arg(val.humidity, 0, 'f', 2));
ui->valTable->item(11, 0)->setText(QString("%1 °C").arg(val.temp_hum_sensor, 0, 'f', 2));
ui->valTable->item(12, 0)->setText(QString("%1 Ah").arg(val.ah_cnt_chg_total, 0, 'f', 3));
ui->valTable->item(13, 0)->setText(QString("%1 Wh").arg(val.wh_cnt_chg_total, 0, 'f', 3));
ui->valTable->item(14, 0)->setText(QString("%1 Ah").arg(val.ah_cnt_dis_total, 0, 'f', 3));
ui->valTable->item(15, 0)->setText(QString("%1 Wh").arg(val.wh_cnt_dis_total, 0, 'f', 3));
ui->valTable->item(11, 0)->setText(QString("%1 Pa").arg(val.pressure, 0, 'f', 0));
ui->valTable->item(12, 0)->setText(QString("%1 °C").arg(val.temp_hum_sensor, 0, 'f', 2));
ui->valTable->item(13, 0)->setText(QString("%1 Ah").arg(val.ah_cnt_chg_total, 0, 'f', 3));
ui->valTable->item(14, 0)->setText(QString("%1 Wh").arg(val.wh_cnt_chg_total, 0, 'f', 3));
ui->valTable->item(15, 0)->setText(QString("%1 Ah").arg(val.ah_cnt_dis_total, 0, 'f', 3));
ui->valTable->item(16, 0)->setText(QString("%1 Wh").arg(val.wh_cnt_dis_total, 0, 'f', 3));
}

void PageBms::reloadCellBars(int cells)
Expand Down
10 changes: 10 additions & 0 deletions pages/pagebms.ui
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@
<string>Humidity</string>
</property>
</row>
<row>
<property name="text">
<string>Pressure</string>
</property>
</row>
<row>
<property name="text">
<string>Temp Hum Sensor</string>
Expand Down Expand Up @@ -247,6 +252,11 @@
<string/>
</property>
</item>
<item row="16" column="0">
<property name="text">
<string/>
</property>
</item>
</widget>
</item>
<item>
Expand Down

0 comments on commit 10f36a1

Please sign in to comment.