From df6d40578583c6bdd9d8815051c180bd37b957a2 Mon Sep 17 00:00:00 2001 From: yufanyufan Date: Sat, 18 Jul 2020 15:26:00 -0700 Subject: [PATCH] Fix DGUS write variable endianness (#18689) --- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 4 ++++ Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index b3325703dc210..1cef323926bef 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -1180,6 +1180,10 @@ void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t values } } +void DGUSDisplay::WriteVariable(uint16_t adr, uint16_t value) { + WriteVariable(adr, static_cast(&value), sizeof(uint16_t)); +} + void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) { const char* myvalues = static_cast(values); bool strend = !myvalues; diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h index 9eddfcf3b5b88..fea33c73d4fb0 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h @@ -54,10 +54,7 @@ class DGUSDisplay { // Variable access. static void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false); static void WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false); - template - static void WriteVariable(uint16_t adr, T value) { - WriteVariable(adr, static_cast(&value), sizeof(T)); - } + static void WriteVariable(uint16_t adr, uint16_t value); // Until now I did not need to actively read from the display. That's why there is no ReadVariable // (I extensively use the auto upload of the display)