Skip to content

Commit

Permalink
🐛 Fix JyersUI scrolling filename, etc. (#23082)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
dwzg and thinkyhead authored Nov 7, 2021
1 parent c07aa87 commit 30a69f7
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,31 +678,31 @@ void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) {
static uint8_t namescrl = 0;
if (reset) namescrl = 0;
if (process == Print) {
size_t len = strlen(filename);
int8_t pos = len;
if (pos > 30) {
pos -= namescrl;
len = _MIN(pos, 30);
char dispname[len + 1];
constexpr int8_t maxlen = 30;
char *outstr = filename;
size_t slen = strlen(filename);
int8_t outlen = slen;
if (slen > maxlen) {
char dispname[maxlen + 1];
int8_t pos = slen - namescrl, len = maxlen;
if (pos >= 0) {
NOMORE(len, pos);
LOOP_L_N(i, len) dispname[i] = filename[i + namescrl];
}
else {
LOOP_L_N(i, 30 + pos) dispname[i] = ' ';
LOOP_S_L_N(i, 30 + pos, 30) dispname[i] = filename[i - (30 + pos)];
const int8_t mp = maxlen + pos;
LOOP_L_N(i, mp) dispname[i] = ' ';
LOOP_S_L_N(i, mp, maxlen) dispname[i] = filename[i - mp];
if (mp <= 0) namescrl = 0;
}
dispname[len] = '\0';
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, dispname);
if (-pos >= 30) namescrl = 0;
outstr = dispname;
outlen = maxlen;
namescrl++;
}
else {
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2;
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, filename);
}
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
const int8_t npos = (DWIN_WIDTH - outlen * MENU_CHR_W) / 2;
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, outstr);
}
}

Expand Down Expand Up @@ -4702,7 +4702,7 @@ void CrealityDWINClass::Update_Status(const char * const text) {
char header[4];
LOOP_L_N(i, 3) header[i] = text[i];
header[3] = '\0';
if (strcmp_P(header,"<F>") == 0) {
if (strcmp_P(header, PSTR("<F>")) == 0) {
LOOP_L_N(i, _MIN((size_t)LONG_FILENAME_LENGTH, strlen(text))) filename[i] = text[i + 3];
filename[_MIN((size_t)LONG_FILENAME_LENGTH - 1, strlen(text))] = '\0';
Draw_Print_Filename(true);
Expand Down Expand Up @@ -4798,22 +4798,23 @@ void CrealityDWINClass::State_Update() {
}

void CrealityDWINClass::Screen_Update() {
const millis_t ms = millis();
static millis_t scrltime = 0;
if (ELAPSED(millis(), scrltime)) {
scrltime = millis() + 200;
if (ELAPSED(ms, scrltime)) {
scrltime = ms + 200;
Update_Status_Bar();
if (process == Print) Draw_Print_Filename();
}

static millis_t statustime = 0;
if (ELAPSED(millis(), statustime)) {
statustime = millis() + 500;
if (ELAPSED(ms, statustime)) {
statustime = ms + 500;
Draw_Status_Area();
}

static millis_t printtime = 0;
if (ELAPSED(millis(), printtime)) {
printtime = millis() + 1000;
if (ELAPSED(ms, printtime)) {
printtime = ms + 1000;
if (process == Print) {
Draw_Print_ProgressBar();
Draw_Print_ProgressElapsed();
Expand Down Expand Up @@ -5000,6 +5001,7 @@ void MarlinUI::init() {
void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) {
switch (message) {
case PAUSE_MESSAGE_INSERT: CrealityDWIN.Confirm_Handler(FilInsert); break;
case PAUSE_MESSAGE_PURGE:
case PAUSE_MESSAGE_OPTION: CrealityDWIN.Popup_Handler(PurgeMore); break;
case PAUSE_MESSAGE_HEAT: CrealityDWIN.Confirm_Handler(HeaterTime); break;
case PAUSE_MESSAGE_WAITING: CrealityDWIN.Draw_Print_Screen(); break;
Expand Down

0 comments on commit 30a69f7

Please sign in to comment.