Skip to content

Commit

Permalink
🩹 Fix IA_CREALITY float, startup (#25493)
Browse files Browse the repository at this point in the history
Followup to #25440
  • Loading branch information
rmbq authored Mar 14, 2023
1 parent f90c499 commit 1cf8519
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
3 changes: 2 additions & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3061,7 +3061,8 @@
#if DGUS_UI_IS(MKS)
#define USE_MKS_GREEN_UI
#elif DGUS_UI_IS(IA_CREALITY)
//#define LCD_SCREEN_ROTATE 90 // Portrait Mode or 800x480 displays
//#define LCD_SCREEN_ROTATE 90 // Portrait Mode or 800x480 displays
//#define IA_CREALITY_BOOT_DELAY 1500 // (ms)
#endif

//
Expand Down
77 changes: 49 additions & 28 deletions Marlin/src/lcd/extui/ia_creality/creality_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,17 @@ namespace ExtUI {
#ifndef CUSTOM_MACHINE_NAME
#define CUSTOM_MACHINE_NAME MACHINE_NAME
#endif
#ifndef IA_CREALITY_BOOT_DELAY
#define IA_CREALITY_BOOT_DELAY 500
#endif

void onStartup() {
DWIN_SERIAL.begin(115200);
rtscheck.recdat.head[0] = rtscheck.snddat.head[0] = FHONE;
rtscheck.recdat.head[1] = rtscheck.snddat.head[1] = FHTWO;
ZERO(rtscheck.databuf);

delay_ms(TERN(DWINOS_4, 1500, 500)); // Delay to allow screen startup
delay_ms(IA_CREALITY_BOOT_DELAY); // Delay to allow screen startup
SetTouchScreenConfiguration();
rtscheck.RTS_SndData(StartSoundSet, SoundAddr);
delay_ms(400); // Delay to allow screen to configure
Expand Down Expand Up @@ -314,31 +317,31 @@ namespace ExtUI {
else
rtscheck.RTS_SndData(2, DisplayStandbyEnableIndicator);

rtscheck.RTS_SndData(uint16_t(getAxisSteps_per_mm(X)) * 10, StepMM_X);
rtscheck.RTS_SndData(uint16_t(getAxisSteps_per_mm(Y)) * 10, StepMM_Y);
rtscheck.RTS_SndData(uint16_t(getAxisSteps_per_mm(Z)) * 10, StepMM_Z);
rtscheck.RTS_SndData(uint16_t(getAxisSteps_per_mm(E0)) * 10, StepMM_E);
rtscheck.RTS_SndData(getAxisSteps_per_mm(X) * 10, StepMM_X);
rtscheck.RTS_SndData(getAxisSteps_per_mm(Y) * 10, StepMM_Y);
rtscheck.RTS_SndData(getAxisSteps_per_mm(Z) * 10, StepMM_Z);
rtscheck.RTS_SndData(getAxisSteps_per_mm(E0) * 10, StepMM_E);

rtscheck.RTS_SndData(uint16_t(getAxisMaxAcceleration_mm_s2(X)) / 100, Accel_X);
rtscheck.RTS_SndData(uint16_t(getAxisMaxAcceleration_mm_s2(Y)) / 100, Accel_Y);
rtscheck.RTS_SndData(uint16_t(getAxisMaxAcceleration_mm_s2(Z)) / 10, Accel_Z);
rtscheck.RTS_SndData(uint16_t(getAxisMaxAcceleration_mm_s2(E0)), Accel_E);
rtscheck.RTS_SndData(getAxisMaxAcceleration_mm_s2(X) / 100, Accel_X);
rtscheck.RTS_SndData(getAxisMaxAcceleration_mm_s2(Y) / 100, Accel_Y);
rtscheck.RTS_SndData(getAxisMaxAcceleration_mm_s2(Z) / 10, Accel_Z);
rtscheck.RTS_SndData(getAxisMaxAcceleration_mm_s2(E0), Accel_E);

rtscheck.RTS_SndData(uint16_t(getAxisMaxFeedrate_mm_s(X)), Feed_X);
rtscheck.RTS_SndData(uint16_t(getAxisMaxFeedrate_mm_s(Y)), Feed_Y);
rtscheck.RTS_SndData(uint16_t(getAxisMaxFeedrate_mm_s(Z)), Feed_Z);
rtscheck.RTS_SndData(uint16_t(getAxisMaxFeedrate_mm_s(E0)), Feed_E);
rtscheck.RTS_SndData(getAxisMaxFeedrate_mm_s(X), Feed_X);
rtscheck.RTS_SndData(getAxisMaxFeedrate_mm_s(Y), Feed_Y);
rtscheck.RTS_SndData(getAxisMaxFeedrate_mm_s(Z), Feed_Z);
rtscheck.RTS_SndData(getAxisMaxFeedrate_mm_s(E0), Feed_E);

rtscheck.RTS_SndData(uint16_t(getAxisMaxJerk_mm_s(X)) * 100, Jerk_X);
rtscheck.RTS_SndData(uint16_t(getAxisMaxJerk_mm_s(Y)) * 100, Jerk_Y);
rtscheck.RTS_SndData(uint16_t(getAxisMaxJerk_mm_s(Z)) * 100, Jerk_Z);
rtscheck.RTS_SndData(uint16_t(getAxisMaxJerk_mm_s(E0)) * 100, Jerk_E);
rtscheck.RTS_SndData(getAxisMaxJerk_mm_s(X) * 100, Jerk_X);
rtscheck.RTS_SndData(getAxisMaxJerk_mm_s(Y) * 100, Jerk_Y);
rtscheck.RTS_SndData(getAxisMaxJerk_mm_s(Z) * 100, Jerk_Z);
rtscheck.RTS_SndData(getAxisMaxJerk_mm_s(E0) * 100, Jerk_E);

#if HAS_HOTEND_OFFSET
rtscheck.RTS_SndData(uint16_t(getNozzleOffset_mm(X, E1)) * 10, T2Offset_X);
rtscheck.RTS_SndData(uint16_t(getNozzleOffset_mm(Y, E1)) * 10, T2Offset_Y);
rtscheck.RTS_SndData(uint16_t(getNozzleOffset_mm(Z, E1)) * 10, T2Offset_Z);
rtscheck.RTS_SndData(uint16_t(getAxisSteps_per_mm(E1)) * 10, T2StepMM_E);
rtscheck.RTS_SndData(getNozzleOffset_mm(X, E1) * 10, T2Offset_X);
rtscheck.RTS_SndData(getNozzleOffset_mm(Y, E1) * 10, T2Offset_Y);
rtscheck.RTS_SndData(getNozzleOffset_mm(Z, E1) * 10, T2Offset_Z);
rtscheck.RTS_SndData(getAxisSteps_per_mm(E1) * 10, T2StepMM_E);
#endif

#if HAS_BED_PROBE
Expand All @@ -349,13 +352,13 @@ namespace ExtUI {
#if HAS_PID_HEATING
rtscheck.RTS_SndData(pid_hotendAutoTemp, HotendPID_AutoTmp);
rtscheck.RTS_SndData(pid_bedAutoTemp, BedPID_AutoTmp);
rtscheck.RTS_SndData(uint16_t(getPID_Kp(E0)) * 10, HotendPID_P);
rtscheck.RTS_SndData(uint16_t(getPID_Ki(E0)) * 10, HotendPID_I);
rtscheck.RTS_SndData(uint16_t(getPID_Kd(E0)) * 10, HotendPID_D);
rtscheck.RTS_SndData(getPID_Kp(E0) * 10, HotendPID_P);
rtscheck.RTS_SndData(getPID_Ki(E0) * 10, HotendPID_I);
rtscheck.RTS_SndData(getPID_Kd(E0) * 10, HotendPID_D);
#if ENABLED(PIDTEMPBED)
rtscheck.RTS_SndData(uint16_t(getBedPID_Kp()) * 10, BedPID_P);
rtscheck.RTS_SndData(uint16_t(getBedPID_Ki()) * 10, BedPID_I);
rtscheck.RTS_SndData(uint16_t(getBedPID_Kd()) * 10, BedPID_D);
rtscheck.RTS_SndData(getBedPID_Kp() * 10, BedPID_P);
rtscheck.RTS_SndData(getBedPID_Ki() * 10, BedPID_I);
rtscheck.RTS_SndData(getBedPID_Kd() * 10, BedPID_D);
#endif
#endif
}
Expand Down Expand Up @@ -567,6 +570,25 @@ namespace ExtUI {
RTS_SndData();
}

void RTSSHOW::RTS_SndData(const_float_t f, const uint32_t addr, const uint8_t cmd/*=VarAddr_W*/) {
int16_t n = f;
if (cmd == VarAddr_W) {
snddat.data[0] = n;
snddat.len = 5;
}
else if (cmd == RegAddr_W) {
snddat.data[0] = n;
snddat.len = 3;
}
else if (cmd == VarAddr_R) {
snddat.bytelen = n;
snddat.len = 4;
}
snddat.command = cmd;
snddat.addr = addr;
RTS_SndData();
}

void RTSSHOW::RTS_SndData(const int n, const uint32_t addr, const uint8_t cmd/*=VarAddr_W*/) {
if (cmd == VarAddr_W) {
if ((unsigned int)n > 0xFFFF) {
Expand Down Expand Up @@ -789,7 +811,6 @@ namespace ExtUI {
}
else {
onStatusChanged(F("Requested Offset Beyond Limits"));
RTS_SndData(getZOffset_mm() * 100, ProbeOffset_Z);
}

rtscheck.RTS_SndData(getZOffset_mm() * 100, ProbeOffset_Z);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/ia_creality/creality_extui.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ namespace ExtUI {
void RTS_SndData(char, const uint32_t, const uint8_t=VarAddr_W);
void RTS_SndData(int, const uint32_t, const uint8_t=VarAddr_W);
void RTS_SndData(unsigned long, const uint32_t, const uint8_t=VarAddr_W);
void RTS_SndData(const_float_t, const uint32_t, const uint8_t=VarAddr_W);

void RTS_SndData(uint8_t * const str, const uint32_t addr, const uint8_t cmd=VarAddr_W) { RTS_SndData((char *)str, addr, cmd); }
void RTS_SndData(const unsigned int n, uint32_t addr, const uint8_t cmd=VarAddr_W) { RTS_SndData(int(n), addr, cmd); }
void RTS_SndData(const_float_t n, const uint32_t addr, const uint8_t cmd=VarAddr_W) { RTS_SndData(int(n), addr, cmd); }
void RTS_SndData(const long n, const uint32_t addr, const uint8_t cmd=VarAddr_W) { RTS_SndData((unsigned long)n, addr, cmd); }

void RTS_SDcard_Stop();
Expand Down

0 comments on commit 1cf8519

Please sign in to comment.