Improved BMS display
This commit is contained in:
@ -183,7 +183,7 @@ build_unflags = ${feedc0de.build_unflags}
|
|||||||
build_flags = ${feedc0de.build_flags}
|
build_flags = ${feedc0de.build_flags}
|
||||||
|
|
||||||
upload_protocol = espota
|
upload_protocol = espota
|
||||||
upload_port = 192.168.127.171
|
upload_port = 192.168.127.124
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,20 +23,23 @@ public:
|
|||||||
|
|
||||||
void rotate(int offset) override;
|
void rotate(int offset) override;
|
||||||
|
|
||||||
Label m_statusLabel{0, 0};
|
Label m_statusLabel{200, 0};
|
||||||
|
|
||||||
Label m_voltageLabel{105, 50};
|
Label m_voltageLabel{107, 0};
|
||||||
Label m_currentLabel{105, 75};
|
Label m_capacityLabel{107, 25};
|
||||||
Label m_capacityLabel{105, 100};
|
Label m_socLabel{107, 50};
|
||||||
Label m_socLabel{105, 125};
|
Label m_powerLabel{107, 75};
|
||||||
Label m_cycleLabel{105, 150};
|
Label m_currentLabel{107, 100};
|
||||||
Label m_powerLabel{105, 175};
|
Label m_speedLabel{107, 125};
|
||||||
|
Label m_powerPerSpeedLabel{107, 150};
|
||||||
|
|
||||||
std::array<Label, 12> m_battLabels{{
|
std::array<Label, 12> m_battLabels{{
|
||||||
Label{0, 225}, Label{60, 225}, Label{120, 225}, Label{180, 225},
|
Label{0, 225}, Label{60, 225}, Label{120, 225}, Label{180, 225},
|
||||||
Label{0, 250}, Label{60, 250}, Label{120, 250}, Label{180, 250},
|
Label{0, 250}, Label{60, 250}, Label{120, 250}, Label{180, 250},
|
||||||
Label{0, 275}, Label{60, 275}, Label{120, 275}, Label{180, 275}
|
Label{0, 275}, Label{60, 275}, Label{120, 275}, Label{180, 275}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
Label m_cycleLabel{105, 300};
|
||||||
};
|
};
|
||||||
|
|
||||||
void BmsDisplay::initScreen()
|
void BmsDisplay::initScreen()
|
||||||
@ -49,35 +52,75 @@ void BmsDisplay::initScreen()
|
|||||||
m_statusLabel.redraw("init");
|
m_statusLabel.redraw("init");
|
||||||
|
|
||||||
tft.setTextFont(4);
|
tft.setTextFont(4);
|
||||||
tft.drawString("Voltage:", 0, 50);
|
tft.drawString("Voltage:", 0, m_voltageLabel.y());
|
||||||
m_voltageLabel.start();
|
m_voltageLabel.start();
|
||||||
tft.drawString("Current:", 0, 75);
|
tft.drawString("Capacity:", 0, m_capacityLabel.y());
|
||||||
m_currentLabel.start();
|
|
||||||
tft.drawString("Capacity:", 0, 100);
|
|
||||||
m_capacityLabel.start();
|
m_capacityLabel.start();
|
||||||
tft.drawString("SOC:", 0, 125);
|
tft.drawString("SOC:", 0, m_socLabel.y());
|
||||||
m_socLabel.start();
|
m_socLabel.start();
|
||||||
tft.drawString("Cycle:", 0, 150);
|
tft.drawString("Power:", 0, m_powerLabel.y());
|
||||||
m_cycleLabel.start();
|
|
||||||
tft.drawString("Power:", 0, 175);
|
|
||||||
m_powerLabel.start();
|
m_powerLabel.start();
|
||||||
|
tft.drawString("Current:", 0, m_currentLabel.y());
|
||||||
|
m_currentLabel.start();
|
||||||
|
tft.drawString("Speed:", 0, m_speedLabel.y());
|
||||||
|
m_speedLabel.start();
|
||||||
|
tft.drawString("PpS:", 0, m_powerPerSpeedLabel.y());
|
||||||
|
m_powerPerSpeedLabel.start();
|
||||||
|
|
||||||
for (auto &label : m_battLabels)
|
for (auto &label : m_battLabels)
|
||||||
label.start();
|
label.start();
|
||||||
|
|
||||||
|
tft.drawString("Cycle:", 0, m_cycleLabel.y());
|
||||||
|
m_cycleLabel.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BmsDisplay::redraw()
|
void BmsDisplay::redraw()
|
||||||
{
|
{
|
||||||
m_statusLabel.redraw(bluetoothSerial.hasClient() ? "connected" : "not connected");
|
if (bluetoothSerial.hasClient())
|
||||||
|
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||||
|
tft.setTextFont(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_statusLabel.redraw(bluetoothSerial.hasClient() ? "OK" : "FAIL");
|
||||||
|
|
||||||
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
if (!bluetoothSerial.hasClient())
|
||||||
|
tft.setTextFont(4);
|
||||||
|
|
||||||
|
if (bluetoothSerial.hasClient())
|
||||||
|
{
|
||||||
m_voltageLabel.redraw(String{bms::voltage} + 'V');
|
m_voltageLabel.redraw(String{bms::voltage} + 'V');
|
||||||
m_currentLabel.redraw(String{bms::current} + 'A');
|
|
||||||
m_capacityLabel.redraw(String{int(bms::capacity)} + "mAh");
|
m_capacityLabel.redraw(String{int(bms::capacity)} + "mAh");
|
||||||
m_socLabel.redraw(String{bms::soc} + '%');
|
m_socLabel.redraw(String{bms::soc} + '%');
|
||||||
m_cycleLabel.redraw(String{bms::cycle} + "AH");
|
|
||||||
m_powerLabel.redraw(String{bms::power} + 'W');
|
m_powerLabel.redraw(String{bms::power} + 'W');
|
||||||
|
m_currentLabel.redraw(String{bms::current} + 'A');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_voltageLabel.clear();
|
||||||
|
m_capacityLabel.clear();
|
||||||
|
m_socLabel.clear();
|
||||||
|
m_powerLabel.clear();
|
||||||
|
m_currentLabel.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_speedLabel.redraw(String{avgSpeedKmh} + "kmh");
|
||||||
|
|
||||||
|
if (bluetoothSerial.hasClient())
|
||||||
|
m_powerPerSpeedLabel.redraw(String{avgSpeedKmh < 1 ? 0 : bms::power / avgSpeedKmh} + "W/kmh");
|
||||||
|
else
|
||||||
|
m_powerPerSpeedLabel.clear();
|
||||||
|
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < 12; i++)
|
||||||
m_battLabels[i].redraw(String{bms::batt[i]});
|
m_battLabels[i].redraw(String{bms::batt[i]});
|
||||||
|
|
||||||
|
if (bluetoothSerial.hasClient())
|
||||||
|
m_cycleLabel.redraw(String{bms::cycle} + "AH");
|
||||||
|
else
|
||||||
|
m_cycleLabel.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BmsDisplay::rotate(int offset)
|
void BmsDisplay::rotate(int offset)
|
||||||
|
Reference in New Issue
Block a user