Skip to content

Commit

Permalink
Show unknown axis in homing screen as red #73
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebazzz committed Dec 24, 2020
1 parent 4939c81 commit 7370107
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Marlin/src/lcd/extui/lib/dgus_creality/DGUSDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@ void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t val
}
}

void DGUSDisplay::SetVariableDisplayColor(uint16_t sp, uint16_t color) {
WriteVariable(sp + 0x03, color);
}

void DGUSDisplay::SetVariableAppendText(uint16_t sp, PGM_P appendText) {
// High byte is length, low byte is first char
if (!appendText) {
WriteVariable(sp + 0x07, static_cast<uint8_t>(0));
return;
}

uint8_t lengthFirstChar = strlen_P(appendText);// << 8;
WriteVariable(sp + 0x07, lengthFirstChar);
WriteVariablePGM(sp + 0x08, appendText, strlen_P(appendText));
}

void DGUSDisplay::ProcessRx() {

#if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS)
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/lcd/extui/lib/dgus_creality/DGUSDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class DGUSDisplay {
static void WriteVariable(uint16_t adr, int8_t value);
static void WriteVariable(uint16_t adr, long value);

static void SetVariableDisplayColor(uint16_t sp, uint16_t color);
static void SetVariableAppendText(uint16_t sp, PGM_P appendText);

static void ReadVariable(uint16_t adr);

// Utility functions for bridging ui_api and dgus
Expand Down
13 changes: 12 additions & 1 deletion Marlin/src/lcd/extui/lib/dgus_creality/DGUSScreenHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class DGUSScreenHandler {
static void HandleSettings(DGUS_VP_Variable &var, void *val_ptr);
static void HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr);
static void HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr);

static void HandleFeedAmountChanged(DGUS_VP_Variable &var, void *val_ptr);

// Hook for move to position
Expand Down Expand Up @@ -250,6 +249,18 @@ class DGUSScreenHandler {
}
}

template<AxisEnum Axis>
static void SendAxisTrustValue(DGUS_VP_Variable &var) {
bool trust = axis_is_trusted(Axis);

uint16_t color = trust ? 0xFFFF /*White*/ : 0XF800 /*Red*/;
dgusdisplay.SetVariableDisplayColor(var.VP, color);

//PGM_P suffix = trust ? nullptr : "???";
//dgusdisplay.SetVariableAppendText(var.VP, suffix);
}


/// Force an update of all VP on the current screen.
static inline void ForceCompleteUpdate() { update_ptr = 0; ScreenComplete = false; }
/// Has all VPs sent to the screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ const uint16_t VPList_PrintScreen[] PROGMEM = {
#endif

VP_X_POSITION, VP_Y_POSITION, VP_Z_POSITION,
VP_X_POSITION_SP, VP_Y_POSITION_SP, VP_Z_POSITION_SP,

VP_Z_OFFSET,
//VP_Fan0_Percentage,
VP_Feedrate_Percentage,
Expand Down Expand Up @@ -437,6 +439,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
VPHELPER(VP_Y_POSITION, &current_position.y, ScreenHandler.HandlePositionChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),
VPHELPER(VP_Z_POSITION, &current_position.z, ScreenHandler.HandlePositionChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<1>),

VPHELPER(VP_X_POSITION_SP, nullptr, nullptr, ScreenHandler.SendAxisTrustValue<X_AXIS>),
VPHELPER(VP_Y_POSITION_SP, nullptr, nullptr, ScreenHandler.SendAxisTrustValue<Y_AXIS>),
VPHELPER(VP_Z_POSITION_SP, nullptr, nullptr, ScreenHandler.SendAxisTrustValue<Z_AXIS>),

VPHELPER(VP_Z_OFFSET, &probe.offset.z, ScreenHandler.HandleZoffsetChange, ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),

VPHELPER(VP_FAN_TOGGLE, &thermalManager.fan_speed[0], nullptr, ScreenHandler.DGUSLCD_SendFanStatusToDisplay),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,11 @@ constexpr uint16_t VP_FEED_PROGRESS = 0x108e;

// Movement screen
constexpr uint16_t VP_X_POSITION = 0x1048;
constexpr uint16_t VP_X_POSITION_SP = 0x4000;
constexpr uint16_t VP_Y_POSITION = 0x104A;
constexpr uint16_t VP_Y_POSITION_SP = 0x4030;
constexpr uint16_t VP_Z_POSITION = 0x104C;
constexpr uint16_t VP_Z_POSITION_SP = 0x4060;
constexpr uint16_t VP_BUTTON_MOVEKEY = 0x1046;

// Icons
Expand Down

0 comments on commit 7370107

Please sign in to comment.