Skip to content

Commit 914a049

Browse files
committed
Add basic infrastructure and navigation for axis settings #189
1 parent 2fe36ea commit 914a049

File tree

7 files changed

+113
-7
lines changed

7 files changed

+113
-7
lines changed

Marlin/src/lcd/extui/lib/dgus_creality/DGUSScreenHandler.h

-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ struct creality_dwin_settings_t {
3636
int16_t standby_screen_brightness;
3737
};
3838

39-
// endianness swap
40-
inline uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); }
41-
4239
class DGUSScreenHandler {
4340
public:
4441
DGUSScreenHandler() = default;

Marlin/src/lcd/extui/lib/dgus_creality/DGUSVPVariable.h

+5
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ struct DGUS_VP_Variable {
4747
return *this;
4848
}
4949
};
50+
51+
// endianness swap
52+
FORCE_INLINE uint16_t swap16(const uint16_t value) { return (value & 0xffU) << 8U | (value >> 8U); }
53+
54+
FORCE_INLINE uint16_t uInt16Value(void *val_ptr) { return swap16(*static_cast<uint16_t*>(val_ptr)); }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
#include "../../../../../inc/MarlinConfigPre.h"
3+
4+
#if ENABLED(DGUS_LCD_UI_CREALITY_TOUCH)
5+
6+
#include "../DGUSDisplayDef.h"
7+
#include "../DGUSDisplay.h"
8+
#include "../DGUSScreenHandler.h"
9+
10+
#include "AxisSettingsHandler.h"
11+
12+
#include "../../../ui_api.h"
13+
#include "../../../../marlinui.h"
14+
15+
#include "../../../../../module/temperature.h"
16+
#include "../../../../../module/settings.h"
17+
#include "../../../../../module/planner.h"
18+
#include "../../../../../gcode/gcode.h"
19+
20+
AxisEnum AxisSettingsHandler::current_axis;
21+
uint16_t AxisSettingsHandler::axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_X;
22+
23+
void AxisSettingsHandler::HandleNavigation(DGUS_VP_Variable &var, void *val_ptr) {
24+
switch (uInt16Value(val_ptr)) {
25+
case AXIS_SETTINGS_NAV_BUTTON_VAL_X:
26+
current_axis = X_AXIS;
27+
axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_X;
28+
break;
29+
30+
case AXIS_SETTINGS_NAV_BUTTON_VAL_Y:
31+
current_axis = Y_AXIS;
32+
axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_Y;
33+
break;
34+
35+
case AXIS_SETTINGS_NAV_BUTTON_VAL_Z:
36+
current_axis = Z_AXIS;
37+
axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_Z;
38+
break;
39+
40+
case AXIS_SETTINGS_NAV_BUTTON_VAL_E:
41+
current_axis = E_AXIS;
42+
axis_settings_title_icon = ICON_AXIS_SETTINGS_TITLE_E;
43+
break;
44+
}
45+
46+
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_AXIS_SETTINGS_AXIS);
47+
48+
// TODO: load settings for axis
49+
}
50+
51+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <cstdint>
2+
3+
class AxisSettingsHandler {
4+
private:
5+
static AxisEnum current_axis;
6+
7+
public:
8+
static uint16_t axis_settings_title_icon;
9+
10+
public:
11+
static void HandleNavigation(DGUS_VP_Variable &var, void *val_ptr);
12+
13+
14+
};
15+

Marlin/src/lcd/extui/lib/dgus_creality/creality_touch/DGUSDisplayDef.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "../DGUSDisplayDef.h"
3030
#include "../DGUSDisplay.h"
3131
#include "../DGUSScreenHandler.h"
32+
#include "../creality_touch/AxisSettingsHandler.h"
3233
#include "../creality_touch/EstepsHandler.h"
3334
#include "../creality_touch/PIDHandler.h"
3435

@@ -283,6 +284,21 @@ const uint16_t VPList_LevelingSettings[] PROGMEM = {
283284
0x0000
284285
};
285286

287+
const uint16_t VPList_AxisSettingsNav[] PROGMEM = {
288+
VPList_CommonWithHeatOnly,
289+
290+
0x0000
291+
};
292+
293+
const uint16_t VPList_AxisSettingsAxis[] PROGMEM = {
294+
VPList_CommonWithHeatOnly,
295+
296+
VP_AXIS_SETTINGS_TITLE_ICON,
297+
298+
0x0000
299+
};
300+
301+
286302
// -- Mapping from screen to variable list
287303
const struct VPMapping VPMap[] PROGMEM = {
288304
{ DGUSLCD_SCREEN_BOOT, VPList_None },
@@ -338,6 +354,9 @@ const struct VPMapping VPMap[] PROGMEM = {
338354
{ DGUSLCD_SCREEN_ESTEPS_CALIBRATION_RESULTS, VPList_EstepsCalibration },
339355
{ DGUSLCD_SCREEN_LEVELING_SETTINGS, VPList_LevelingSettings },
340356

357+
{ DGUSLCD_SCREEN_AXIS_SETTINGS_NAV, VPList_AxisSettingsNav },
358+
{ DGUSLCD_SCREEN_AXIS_SETTINGS_AXIS , VPList_AxisSettingsAxis },
359+
341360
{ 0 , nullptr } // List is terminated with an nullptr as table entry.
342361
};
343362

@@ -399,6 +418,10 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
399418

400419
VPHELPER(VP_GENERIC_BACK_BUTTON, nullptr, ScreenHandler.OnBackButton, nullptr),
401420

421+
// Axis settings
422+
VPHELPER(VP_AXIS_SETTINGS_NAV_BUTTON, nullptr, AxisSettingsHandler::HandleNavigation, nullptr),
423+
VPHELPER(VP_AXIS_SETTINGS_TITLE_ICON, &AxisSettingsHandler::axis_settings_title_icon, nullptr, ScreenHandler.DGUSLCD_SendWordValueToDisplay);
424+
402425
// Preheat settings
403426
#ifdef PREHEAT_1_LABEL
404427
VPHELPER(VP_PREHEAT_PLA_HOTEND_TEMP, &ui.material_preset[0].hotend_temp, ScreenHandler.DGUSLCD_SetValueDirectly<int16_t>, &ScreenHandler.DGUSLCD_SendWordValueToDisplay),

Marlin/src/lcd/extui/lib/dgus_creality/creality_touch/DGUSDisplayDef.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ enum DGUSLCD_Screens : uint8_t {
7676
DGUSLCD_SCREEN_TUNEFWRETRACT = 70,
7777

7878
DGUSLCD_SCREEN_ESTEPS_CALIBRATION_RESULTS = 71,
79-
DGUSLCD_SCREEN_LEVELING_SETTINGS = 72
79+
DGUSLCD_SCREEN_LEVELING_SETTINGS = 72,
80+
81+
DGUSLCD_SCREEN_AXIS_SETTINGS_NAV = 73,
82+
DGUSLCD_SCREEN_AXIS_SETTINGS_AXIS = 74
8083
};
8184

8285
// Version checks
@@ -290,6 +293,19 @@ constexpr uint16_t VP_LED_TOGGLE = 0x101F;
290293
constexpr uint16_t VP_FEED_AMOUNT = 0x1054;
291294
constexpr uint16_t VP_FEED_PROGRESS = 0x108e;
292295

296+
// Axis settings
297+
constexpr uint16_t VP_AXIS_SETTINGS_NAV_BUTTON = 0x22D9;
298+
constexpr uint16_t AXIS_SETTINGS_NAV_BUTTON_VAL_X = 1;
299+
constexpr uint16_t AXIS_SETTINGS_NAV_BUTTON_VAL_Y = 2;
300+
constexpr uint16_t AXIS_SETTINGS_NAV_BUTTON_VAL_Z = 3;
301+
constexpr uint16_t AXIS_SETTINGS_NAV_BUTTON_VAL_E = 4;
302+
303+
constexpr uint16_t VP_AXIS_SETTINGS_TITLE_ICON = 0x22DB;
304+
constexpr uint16_t ICON_AXIS_SETTINGS_TITLE_X = 20;
305+
constexpr uint16_t ICON_AXIS_SETTINGS_TITLE_Y = 21;
306+
constexpr uint16_t ICON_AXIS_SETTINGS_TITLE_Z = 22;
307+
constexpr uint16_t ICON_AXIS_SETTINGS_TITLE_E = 23;
308+
293309
// Mesh leveling
294310
constexpr uint16_t VP_MESH_SCREEN_MESSAGE_ICON = 0x22cb;
295311
constexpr uint16_t MESH_SCREEN_MESSAGE_ICON_LEVELING = 5;

Marlin/src/lcd/extui/lib/dgus_creality/creality_touch/PageHandlers.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,8 @@ void DGUSCrealityDisplay_HandleReturnKeyEvent(DGUS_VP_Variable &var, void *val_p
477477

478478
while ((ret = (uint16_t*) pgm_read_ptr(&(map->Handler)))) {
479479
if ((map->ScreenID) == current_screen) {
480-
unsigned short button_value = *static_cast<unsigned short*>(val_ptr);
481-
button_value = (button_value & 0xffU) << 8U | (button_value >> 8U);
482-
480+
uint16_t button_value = uInt16Value(val_ptr);
481+
483482
SERIAL_ECHOPAIR("Invoking handler for screen ", current_screen);
484483
SERIAL_ECHOLNPAIR("with VP=", var.VP, " value=", button_value);
485484

0 commit comments

Comments
 (0)