Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 05d61a3

Browse files
committedJan 3, 2023
more cleanup
1 parent 762aaff commit 05d61a3

File tree

1 file changed

+26
-41
lines changed

1 file changed

+26
-41
lines changed
 

‎Marlin/src/lcd/extui/ia_creality/creality_extui.cpp

+26-41
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,7 @@ namespace ExtUI {
9191
rtscheck.recdat.head[1] = rtscheck.snddat.head[1] = FHTWO;
9292
memset(rtscheck.databuf, 0, sizeof(rtscheck.databuf));
9393

94-
#if ENABLED(DWINOS_4)
95-
#define DWIN_BOOTUP_DELAY 1500
96-
#else
97-
#define DWIN_BOOTUP_DELAY 500
98-
#endif
99-
delay_ms(DWIN_BOOTUP_DELAY); // Delay to allow screen startup
94+
delay_ms(TERN(DWINOS_4, 1500, 500)); // Delay to allow screen startup
10095
SetTouchScreenConfiguration();
10196
rtscheck.RTS_SndData(StartSoundSet, SoundAddr);
10297
delay_ms(400); // Delay to allow screen to configure
@@ -1684,14 +1679,15 @@ namespace ExtUI {
16841679
}
16851680
break;
16861681

1687-
#if ENABLED(POWER_LOSS_RECOVERY)
1688-
case PwrOffNoF:
1689-
if (recdat.data[0] == 1) // Yes:continue to print the 3Dmode during power-off.
1690-
injectCommands(F("M1000"));
1691-
else if (recdat.data[0] == 2) // No
1692-
injectCommands(F("M1000C"));
1693-
break;
1694-
#endif
1682+
#if ENABLED(POWER_LOSS_RECOVERY)
1683+
case PwrOffNoF:
1684+
if (recdat.data[0] == 1) // Yes: continue to print the 3Dmode during power-off.
1685+
injectCommands(F("M1000"));
1686+
else if (recdat.data[0] == 2) // No
1687+
injectCommands(F("M1000C"));
1688+
break;
1689+
#endif
1690+
16951691
case Volume:
16961692
if (recdat.data[0] < 0)
16971693
Settings.display_volume = 0;
@@ -1855,8 +1851,7 @@ namespace ExtUI {
18551851
break;
18561852
}
18571853

1858-
case AutolevelVal:
1859-
{
1854+
case AutolevelVal: {
18601855
uint8_t meshPoint = (recdat.addr - AutolevelVal) / 2;
18611856
uint8_t yPnt = floor(meshPoint / GRID_MAX_POINTS_X);
18621857
uint8_t xPnt;
@@ -1895,7 +1890,7 @@ namespace ExtUI {
18951890

18961891
void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false, char fillChar=' ') {
18971892
const char* myvalues = static_cast<const char*>(values);
1898-
bool strend = !myvalues;
1893+
bool strend = !myvalues;
18991894
DWIN_SERIAL.write(FHONE);
19001895
DWIN_SERIAL.write(FHTWO);
19011896
DWIN_SERIAL.write(valueslen + 3);
@@ -1907,7 +1902,7 @@ namespace ExtUI {
19071902
if (!strend) x = *myvalues++;
19081903
if ((isstr && !x) || strend) {
19091904
strend = true;
1910-
x = fillChar;
1905+
x = fillChar;
19111906
}
19121907
DWIN_SERIAL.write(x);
19131908
}
@@ -1918,29 +1913,19 @@ namespace ExtUI {
19181913
LIMIT(Settings.screen_brightness, 10, 100); // Prevent a possible all-dark screen
19191914
LIMIT(Settings.standby_time_seconds, 10, 655); // Prevent a possible all-dark screen for standby, yet also don't go higher than the DWIN limitation
19201915

1921-
1922-
unsigned char cfg_bits = 0x0;
1923-
// #if ENABLED(DWINOS_4)
1924-
cfg_bits |= 1UL << 7; // 7: Enable Control
1925-
// #endif
1926-
cfg_bits |= 1UL << 5; // 5: load 22 touch file
1927-
cfg_bits |= 1UL << 4; // 4: auto-upload should always be enabled
1928-
if (Settings.display_sound) cfg_bits |= 1UL << 3; // 3: audio
1929-
if (Settings.display_standby) cfg_bits |= 1UL << 2; // 2: backlight on standby
1930-
if (Settings.screen_rotation == 10) cfg_bits |= 1UL << 1; // 1 & 0: Inversion
1931-
#if ANY(MachineCR10Smart, MachineCR10SmartPro )
1932-
cfg_bits |= 1UL << 0; // Portrait Mode or 800x480 display has 0 point rotated 90deg from 480x272 display
1933-
#endif
1934-
1935-
1936-
1937-
const unsigned char config_set[] = {
1938-
#if ENABLED(DWINOS_4)
1939-
0x5A, 0x00, (unsigned char)(cfg_bits >> 8U), (unsigned char)(cfg_bits & 0xFFU)
1940-
#else
1941-
0x5A, 0x00, 0xFF, cfg_bits
1942-
#endif
1943-
};
1916+
unsigned char cfg_bits = 0x0
1917+
| _BV(7) // 7: Enable Control ... TERN0(DWINOS_4, _BV(7))
1918+
| _BV(5) // 5: load 22 touch file
1919+
| _BV(4) // 4: auto-upload should always be enabled
1920+
| (Settings.display_sound ? _BV(3) : 0) // 3: audio
1921+
| (Settings.display_standby ? _BV(2) : 0) // 2: backlight on standby
1922+
| (Settings.screen_rotation == 10 ? _BV(1) : 0) // 1 & 0: Inversion
1923+
#if EITHER(MachineCR10Smart, MachineCR10SmartPro)
1924+
| _BV(0) // Portrait Mode or 800x480 display has 0 point rotated 90deg from 480x272 display
1925+
#endif
1926+
;
1927+
1928+
const unsigned char config_set[] = { 0x5A, 0x00, TERN(DWINOS_4, 0x00, 0xFF), cfg_bits };
19441929
WriteVariable(0x80 /*System_Config*/, config_set, sizeof(config_set));
19451930

19461931
// Standby brightness (LED_Config)

0 commit comments

Comments
 (0)
Please sign in to comment.