PowerPort added to store current independent from DC bus type
The DC bus type caused issues because current limits could not be defined individually for each connection to a junction, as described in issue #50. With this commit, also some structs were converted to C++ classes to improve readibility of the code and make sure that pointers (e.g. to PowerPort objects) are always assigned during initialization.
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
#ifndef UNIT_TEST
|
||||
|
||||
#include "main.h"
|
||||
extern DcBus *bat_terminal;
|
||||
extern DcBus *solar_terminal;
|
||||
extern PowerPort *bat_terminal;
|
||||
extern PowerPort *solar_terminal;
|
||||
|
||||
#ifdef OLED_ENABLED // otherwise don't compile code to reduce firmware size
|
||||
|
||||
@@ -61,8 +61,6 @@ void uext_process_asap() {;}
|
||||
|
||||
void uext_process_1s()
|
||||
{
|
||||
float tmp;
|
||||
|
||||
oled.clearDisplay();
|
||||
|
||||
oled.drawBitmap(6, 0, bmp_pv_panel, 16, 16, 1);
|
||||
@@ -96,27 +94,26 @@ void uext_process_1s()
|
||||
#else
|
||||
if (half_bridge_enabled()) {
|
||||
#endif
|
||||
tmp = -solar_terminal->voltage * solar_terminal->current;
|
||||
oled.setTextCursor(0, 18);
|
||||
oled.printf("%4.0fW", (abs(tmp) < 1) ? 0 : tmp); // remove negative zeros
|
||||
oled.printf("%4.0fW", (abs(solar_terminal->power) < 1) ? 0 : -solar_terminal->power); // remove negative zeros
|
||||
}
|
||||
else {
|
||||
oled.setTextCursor(8, 18);
|
||||
oled.printf("n/a");
|
||||
}
|
||||
#ifndef CHARGER_TYPE_PWM
|
||||
if (solar_terminal->voltage > bat_terminal->voltage)
|
||||
if (solar_terminal->bus->voltage > bat_terminal->bus->voltage)
|
||||
#endif
|
||||
{
|
||||
oled.setTextCursor(0, 26);
|
||||
oled.printf("%4.1fV", solar_terminal->voltage);
|
||||
oled.printf("%4.1fV", solar_terminal->bus->voltage);
|
||||
}
|
||||
|
||||
// battery data
|
||||
oled.setTextCursor(42, 18);
|
||||
oled.printf("%5.1fW", (abs(bat_terminal->power) < 0.1) ? 0 : bat_terminal->power); // remove negative zeros
|
||||
oled.setTextCursor(42, 26);
|
||||
oled.printf("%5.1fV", bat_terminal->voltage);
|
||||
oled.printf("%5.1fV", bat_terminal->bus->voltage);
|
||||
|
||||
// load data
|
||||
oled.setTextCursor(90, 18);
|
||||
|
||||
Reference in New Issue
Block a user