Skip to content

Commit

Permalink
Fix DGUS write variable endianness (MarlinFirmware#18689)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufanyufan authored and marknn3 committed Jul 20, 2020
1 parent 0fbd7b3 commit df6d405
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const void*>(&value), sizeof(uint16_t));
}

void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {
const char* myvalues = static_cast<const char*>(values);
bool strend = !myvalues;
Expand Down
5 changes: 1 addition & 4 deletions Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
static void WriteVariable(uint16_t adr, T value) {
WriteVariable(adr, static_cast<const void*>(&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)
Expand Down

0 comments on commit df6d405

Please sign in to comment.