Skip to content

Commit

Permalink
Merge remote-tracking branch 'tbnobody/OpenDTU/master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Dec 29, 2023
2 parents d769cdd + 9250487 commit f89f9da
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 58 deletions.
72 changes: 51 additions & 21 deletions lib/Hoymiles/src/parser/GridProfileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
#include <frozen/string.h>

const std::array<const ProfileType_t, PROFILE_TYPE_COUNT> GridProfileParser::_profileTypes = { {
{ 0x02, 0x00, "no data (yet)" },
{ 0x03, 0x00, "Germany - DE_VDE4105_2018" },
{ 0x0a, 0x00, "European - EN 50549-1:2019" },
{ 0x0c, 0x00, "AT Tor - EU_EN50438" },
{ 0x0d, 0x04, "France" },
{ 0x12, 0x00, "Poland - EU_EN50438" },
{ 0x37, 0x00, "Swiss - CH_NA EEA-NE7-CH2020" },
{ 0x02, 0x00, "US - NA_IEEE1547_240V" },
{ 0x03, 0x00, "DE - DE_VDE4105_2018" },
{ 0x03, 0x01, "XX - unknown" },
{ 0x0a, 0x00, "XX - EN 50549-1:2019" },
{ 0x0c, 0x00, "AT - AT_TOR_Erzeuger_default" },
{ 0x0d, 0x04, "FR -" },
{ 0x10, 0x00, "ES - ES_RD1699" },
{ 0x12, 0x00, "PL - EU_EN50438" },
{ 0x29, 0x00, "NL - NL_NEN-EN50549-1_2019" },
{ 0x37, 0x00, "CH - CH_NA EEA-NE7-CH2020" },
} };

constexpr frozen::map<uint8_t, frozen::string, 12> profileSection = {
Expand Down Expand Up @@ -45,19 +48,19 @@ constexpr GridProfileItemDefinition_t make_value(frozen::string Name, frozen::st
return v;
}

constexpr frozen::map<uint8_t, GridProfileItemDefinition_t, 0x39> itemDefinitions = {
constexpr frozen::map<uint8_t, GridProfileItemDefinition_t, 0x42> itemDefinitions = {
{ 0x01, make_value("Nominale Voltage (NV)", "V", 10) },
{ 0x02, make_value("Low Voltage 1 (LV1)", "V", 10) },
{ 0x03, make_value("LV1 Maximum Trip Time (MTT)", "s", 10) },
{ 0x04, make_value("High Voltage 1 (HV1)", "V", 10) },
{ 0x05, make_value("HV1 Maximum Trip Time (MTT)", "s", 10) },
{ 0x06, make_value("Low Voltage 2 (LV2)", "V", 10) },
{ 0x07, make_value("LV2 Maximum Trip Time (MTT)", "s", 10) },
{ 0x07, make_value("LV2 Maximum Trip Time (MTT)", "s", 100) },
{ 0x08, make_value("High Voltage 2 (HV2)", "V", 10) },
{ 0x09, make_value("HV2 Maximum Trip Time (MTT)", "s", 10) },
{ 0x09, make_value("HV2 Maximum Trip Time (MTT)", "s", 100) },
{ 0x0a, make_value("10mins Average High Voltage (AHV)", "V", 10) },
{ 0x0b, make_value("High Voltage 3 (HV3)", "V", 10) },
{ 0x0c, make_value("HV3 Maximum Trip Time (MTT)", "s", 10) },
{ 0x0c, make_value("HV3 Maximum Trip Time (MTT)", "s", 100) },
{ 0x0d, make_value("Nominal Frequency", "Hz", 100) },
{ 0x0e, make_value("Low Frequency 1 (LF1)", "Hz", 100) },
{ 0x0f, make_value("LF1 Maximum Trip Time (MTT)", "s", 10) },
Expand Down Expand Up @@ -94,14 +97,23 @@ constexpr frozen::map<uint8_t, GridProfileItemDefinition_t, 0x39> itemDefinition
{ 0x2e, make_value("Voltage Set Point V3", "V", 10) },
{ 0x2f, make_value("Voltage Set Point V4", "V", 10) },
{ 0x30, make_value("Reactive Set Point Q4", "%Pn", 10) },
{ 0x31, make_value("Setting Time (Tr)", "s", 10) },
{ 0x31, make_value("VV Setting Time (Tr)", "s", 10) },
{ 0x32, make_value("SPF Function Activated", "bool", 1) },
{ 0x33, make_value("Power Factor (PF)", "", 100) },
{ 0x34, make_value("RPC Function Activated", "bool", 1) },
{ 0x35, make_value("Reactive Power (VAR)", "%Sn", 1) },
{ 0x36, make_value("WPF Function Activated", "bool", 1) },
{ 0x37, make_value("Start of Power of WPF (Pstart)", "%Pn", 10) },
{ 0x38, make_value("Power Factor ar Rated Power (PFRP)", "", 100) },
{ 0x39, make_value("Low Voltage 3 (LV3)", "V", 10) },
{ 0x3a, make_value("LV3 Maximum Trip Time (MTT)", "s", 100) },
{ 0x3b, make_value("Momentary Cessition Low Voltage", "V", 10) },
{ 0x3c, make_value("Momentary Cessition High Voltage", "V", 10) },
{ 0x3d, make_value("FW Settling Time (Tr)", "s", 10) },
{ 0x3e, make_value("LF2 Maximum Trip Time (MTT)", "s", 100) },
{ 0x3f, make_value("HF2 Maximum Trip time (MTT)", "s", 100) },
{ 0x40, make_value("Short Interruption Reconnect Time (SRT)", "s", 10) },
{ 0x41, make_value("Short Interruption Time (SIT)", "s", 10) },
{ 0xff, make_value("Unkown Value", "", 1) },
};

Expand All @@ -114,6 +126,24 @@ const std::array<const GridProfileValue_t, SECTION_VALUE_COUNT> GridProfileParse
{ 0x00, 0x00, 0x04 },
{ 0x00, 0x00, 0x05 },

// Version 0x01
{ 0x00, 0x01, 0x01 },
{ 0x00, 0x01, 0x02 },
{ 0x00, 0x01, 0x03 },
{ 0x00, 0x01, 0x04 },
{ 0x00, 0x01, 0x05 },
{ 0x00, 0x01, 0x08 },
{ 0x00, 0x01, 0x09 },

// Version 0x02
{ 0x00, 0x02, 0x01 },
{ 0x00, 0x02, 0x02 },
{ 0x00, 0x02, 0x03 },
{ 0x00, 0x02, 0x04 },
{ 0x00, 0x02, 0x05 },
{ 0x00, 0x02, 0x06 },
{ 0x00, 0x02, 0x07 },

// Version 0x03
{ 0x00, 0x03, 0x01 },
{ 0x00, 0x03, 0x02 },
Expand Down Expand Up @@ -178,10 +208,10 @@ const std::array<const GridProfileValue_t, SECTION_VALUE_COUNT> GridProfileParse
{ 0x00, 0x35, 0x07 },
{ 0x00, 0x35, 0x08 },
{ 0x00, 0x35, 0x09 },
{ 0x00, 0x35, 0xff },
{ 0x00, 0x35, 0xff },
{ 0x00, 0x35, 0xff },
{ 0x00, 0x35, 0xff },
{ 0x00, 0x35, 0x39 },
{ 0x00, 0x35, 0x3a },
{ 0x00, 0x35, 0x3b },
{ 0x00, 0x35, 0x3c },

// Frequency (H/LFRT)
// Version 0x00
Expand All @@ -198,9 +228,9 @@ const std::array<const GridProfileValue_t, SECTION_VALUE_COUNT> GridProfileParse
{ 0x10, 0x03, 0x10 },
{ 0x10, 0x03, 0x11 },
{ 0x10, 0x03, 0x12 },
{ 0x10, 0x03, 0x13 },
{ 0x10, 0x03, 0x3e },
{ 0x10, 0x03, 0x14 },
{ 0x10, 0x03, 0x15 },
{ 0x10, 0x03, 0x3f },

// Island Detection (ID)
// Version 0x00
Expand All @@ -220,8 +250,8 @@ const std::array<const GridProfileValue_t, SECTION_VALUE_COUNT> GridProfileParse
{ 0x30, 0x07, 0x19 },
{ 0x30, 0x07, 0x1a },
{ 0x30, 0x07, 0x1b },
{ 0x30, 0x07, 0xff },
{ 0x30, 0x07, 0xff },
{ 0x30, 0x07, 0x40 },
{ 0x30, 0x07, 0x41 },

// Ramp Rates (RR)
// Version 0x00
Expand Down Expand Up @@ -255,7 +285,7 @@ const std::array<const GridProfileValue_t, SECTION_VALUE_COUNT> GridProfileParse
{ 0x50, 0x11, 0x1f },
{ 0x50, 0x11, 0x20 },
{ 0x50, 0x11, 0x21 },
{ 0x50, 0x11, 0x22 },
{ 0x50, 0x11, 0x3d },

// Volt Watt (VW)
// Version 0x00
Expand Down
4 changes: 2 additions & 2 deletions lib/Hoymiles/src/parser/GridProfileParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <list>

#define GRID_PROFILE_SIZE 141
#define PROFILE_TYPE_COUNT 7
#define SECTION_VALUE_COUNT 144
#define PROFILE_TYPE_COUNT 10
#define SECTION_VALUE_COUNT 158

typedef struct {
uint8_t lIdx;
Expand Down
8 changes: 6 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ extra_configs =
custom_ci_action = generic,generic_esp32,generic_esp32s3,generic_esp32s3_usb

framework = arduino
platform = espressif32@6.3.2
platform = espressif32@6.5.0

build_flags =
-DPIOENV=\"$PIOENV\"
-D_TASK_STD_FUNCTION=1
-Wall -Wextra -Werror -Wunused -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wnull-dereference
-Wall -Wextra -Wunused -Wmisleading-indentation -Wduplicated-cond -Wlogical-op -Wnull-dereference
; Have to remove -Werror because of
; https://github.com/espressif/arduino-esp32/issues/9044 and
; https://github.com/espressif/arduino-esp32/issues/9045
; -Werror
-std=c++17
-std=gnu++17
build_unflags =
Expand Down
43 changes: 25 additions & 18 deletions src/Display_Graphic_Diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,28 @@ void DisplayGraphicDiagramClass::updatePeriod()

void DisplayGraphicDiagramClass::redraw(uint8_t screenSaverOffsetX)
{
const uint8_t graphPosX = DIAG_POSX + ((screenSaverOffsetX > 3) ? 1 : 0); // screenSaverOffsetX expected to be in range 0..6
// screenSaverOffsetX expected to be in range 0..6
const uint8_t graphPosX = DIAG_POSX + ((screenSaverOffsetX > 3) ? 1 : 0);
const uint8_t graphPosY = DIAG_POSY + ((screenSaverOffsetX > 3) ? 1 : 0);

const uint8_t horizontal_line_y = graphPosY + CHART_HEIGHT - 1;
const uint8_t arrow_size = 2;

// draw diagram axis
_display->drawVLine(graphPosX, graphPosY, CHART_HEIGHT);
_display->drawHLine(graphPosX, graphPosY + CHART_HEIGHT - 1, CHART_WIDTH);
_display->drawHLine(graphPosX, horizontal_line_y, CHART_WIDTH);

// UP-arrow
_display->drawLine(graphPosX, graphPosY, graphPosX + arrow_size, graphPosY + arrow_size);
_display->drawLine(graphPosX, graphPosY, graphPosX - arrow_size, graphPosY + arrow_size);

_display->drawLine(graphPosX + 1, graphPosY + 1, graphPosX + 2, graphPosY + 2); // UP-arrow
_display->drawLine(graphPosX - 2, graphPosY + 2, graphPosX - 1, graphPosY + 1); // UP-arrow
_display->drawLine(graphPosX + CHART_WIDTH - 3, graphPosY + CHART_HEIGHT - 3, graphPosX + CHART_WIDTH - 2, graphPosY + CHART_HEIGHT - 2); // LEFT-arrow
_display->drawLine(graphPosX + CHART_WIDTH - 3, graphPosY + CHART_HEIGHT + 1, graphPosX + CHART_WIDTH - 2, graphPosY + CHART_HEIGHT); // LEFT-arrow
// LEFT-arrow
_display->drawLine(graphPosX + CHART_WIDTH - 1, horizontal_line_y, graphPosX + CHART_WIDTH - 1 - arrow_size, horizontal_line_y - arrow_size);
_display->drawLine(graphPosX + CHART_WIDTH - 1, horizontal_line_y, graphPosX + CHART_WIDTH - 1 - arrow_size, horizontal_line_y + arrow_size);

// draw AC value
_display->setFont(u8g2_font_tom_thumb_4x6_mr); // 4 pixels per char
// 4 pixels per char
_display->setFont(u8g2_font_tom_thumb_4x6_mr);
char fmtText[7];
const float maxWatts = *std::max_element(_graphValues.begin(), _graphValues.end());
if (maxWatts > 999) {
Expand All @@ -84,25 +92,24 @@ void DisplayGraphicDiagramClass::redraw(uint8_t screenSaverOffsetX)
snprintf(fmtText, sizeof(fmtText), "%dW", static_cast<uint16_t>(maxWatts));
}
const uint8_t textLength = strlen(fmtText);
const uint8_t space_and_arrow_pixels = 2;
_display->drawStr(graphPosX - space_and_arrow_pixels - (textLength * 4), graphPosY + 5, fmtText);
_display->drawStr(graphPosX - arrow_size - textLength * 4, graphPosY + 5, fmtText);

// draw chart
const float scaleFactor = maxWatts / CHART_HEIGHT;
uint8_t axisTick = 1;
for (int i = 0; i < _graphValuesCount; i++) {
if (scaleFactor > 0) {
if (i == 0) {
_display->drawPixel(graphPosX + 1 + i, graphPosY + CHART_HEIGHT - ((_graphValues[i] / scaleFactor) + 0.5)); // + 0.5 to round mathematical
} else {
_display->drawLine(graphPosX + i, graphPosY + CHART_HEIGHT - ((_graphValues[i - 1] / scaleFactor) + 0.5), graphPosX + 1 + i, graphPosY + CHART_HEIGHT - ((_graphValues[i] / scaleFactor) + 0.5));
}
}

for (uint8_t i = 1; i < _graphValuesCount; i++) {
// draw one tick per hour to the x-axis
if (i * getSecondsPerDot() > (3600u * axisTick)) {
_display->drawPixel(graphPosX + 1 + i, graphPosY + CHART_HEIGHT);
axisTick++;
}

if (scaleFactor == 0) {
continue;
}

_display->drawLine(
graphPosX + i - 1, horizontal_line_y - std::max<int16_t>(0, _graphValues[i - 1] / scaleFactor - 0.5),
graphPosX + i, horizontal_line_y - std::max<int16_t>(0, _graphValues[i] / scaleFactor - 0.5));
}
}
4 changes: 2 additions & 2 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/node": "^20.10.5",
"@types/sortablejs": "^1.15.7",
"@types/spark-md5": "^3.0.4",
"@vitejs/plugin-vue": "^4.5.2",
"@vitejs/plugin-vue": "^5.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/tsconfig": "^0.5.1",
"eslint": "^8.56.0",
Expand All @@ -42,6 +42,6 @@
"vite": "^5.0.10",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-css-injected-by-js": "^3.3.1",
"vue-tsc": "^1.8.26"
"vue-tsc": "^1.8.27"
}
}
26 changes: 13 additions & 13 deletions webapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,10 @@
resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.2.0.tgz#756641adb587851b5ccb3e095daf27ae581c8406"
integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==

"@vitejs/plugin-vue@^4.5.2":
version "4.5.2"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-4.5.2.tgz#1212d81bc83680e14448fefe55abd9fe1ed49ed1"
integrity sha512-UGR3DlzLi/SaVBPX0cnSyE37vqxU3O6chn8l0HJNzQzDia6/Au2A4xKv+iIJW8w2daf80G7TYHhi1pAUjdZ0bQ==
"@vitejs/plugin-vue@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-5.0.0.tgz#8e8946548e6dfd9eb0391bbc282ec8e52103e0dd"
integrity sha512-7x5e8X4J1Wi4NxudGjJBd2OFerAi/0nzF80ojCzvfj347WVr0YSn82C8BSsgwSHzlk9Kw5xnZfj0/7RLnNwP5w==

"@volar/language-core@1.11.1", "@volar/language-core@~1.11.1":
version "1.11.1"
Expand Down Expand Up @@ -690,10 +690,10 @@
"@typescript-eslint/parser" "^6.7.0"
vue-eslint-parser "^9.3.1"

"@vue/language-core@1.8.26":
version "1.8.26"
resolved "https://registry.yarnpkg.com/@vue/language-core/-/language-core-1.8.26.tgz#7edb6b51a6ed57b618928500c3cbda9757a9f5f0"
integrity sha512-9cmza/Y2YTiOnKZ0Mi9zsNn7Irw+aKirP+5LLWVSNaL3fjKJjW1cD3HGBckasY2RuVh4YycvdA9/Q6EBpVd/7Q==
"@vue/language-core@1.8.27":
version "1.8.27"
resolved "https://registry.yarnpkg.com/@vue/language-core/-/language-core-1.8.27.tgz#2ca6892cb524e024a44e554e4c55d7a23e72263f"
integrity sha512-L8Kc27VdQserNaCUNiSFdDl9LWT24ly8Hpwf1ECy3aFb9m6bDhBGQYOujDm21N7EW3moKIOKEanQwe1q5BK+mA==
dependencies:
"@volar/language-core" "~1.11.1"
"@volar/source-map" "~1.11.1"
Expand Down Expand Up @@ -2605,13 +2605,13 @@ vue-template-compiler@^2.7.14:
de-indent "^1.0.2"
he "^1.2.0"

vue-tsc@^1.8.26:
version "1.8.26"
resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-1.8.26.tgz#f66abd1dab4e4593590b2b7d4ede0a696882feec"
integrity sha512-jMEJ4aqU/l1hdgmeExH5h1TFoN+hbho0A2ZAhHy53/947DGm7Qj/bpB85VpECOCwV00h7JYNVnvoD2ceOorB4Q==
vue-tsc@^1.8.27:
version "1.8.27"
resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-1.8.27.tgz#feb2bb1eef9be28017bb9e95e2bbd1ebdd48481c"
integrity sha512-WesKCAZCRAbmmhuGl3+VrdWItEvfoFIPXOvUJkjULi+x+6G/Dy69yO3TBRJDr9eUlmsNAwVmxsNZxvHKzbkKdg==
dependencies:
"@volar/typescript" "~1.11.1"
"@vue/language-core" "1.8.26"
"@vue/language-core" "1.8.27"
semver "^7.5.4"

vue@^3.3.13:
Expand Down

0 comments on commit f89f9da

Please sign in to comment.