Skip to content

Commit 44cee4f

Browse files
committed
Color presets added - new gcode in M250
1 parent 7a1a38f commit 44cee4f

8 files changed

+220
-83
lines changed

Marlin/Configuration.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,22 @@
20892089
// FSMC_UPSCALE 2 2x upscaler for 320x240 displays (default)
20902090
// FSMC_UPSCALE 3 3x upscaler for 480x320 displays
20912091
//
2092-
#define FSMC_UPSCALE 2
2092+
#define FSMC_UPSCALE 3
2093+
2094+
//
2095+
// Change colors
2096+
// some colors are predefined, see /src/lcd/dogm/u8g_dev_tft_480~.cpp Line 160
2097+
// or use 16bit color (e.g. 0x0000 = black, 0xFFE0 = yellow)
2098+
// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
2099+
//
2100+
2101+
#define TFT_MARLINUI_COLOR COLOR_WHITE // main foreground color
2102+
#define TFT_MARLINBG_COLOR COLOR_NAVY // background color
2103+
#define TFT_BTCANCEL_COLOR 0xA9A6 // cancel button
2104+
#define TFT_BTARROWS_COLOR COLOR_WHITE // arrows up/down
2105+
#define TFT_BTOKMENU_COLOR COLOR_WHITE // enter button
2106+
//#define TFT_DISABLED_COLOR COLOR_DARK // currently not used
2107+
20932108
#endif
20942109

20952110
//=============================================================================

Marlin/Configuration_adv.h

+28-13
Original file line numberDiff line numberDiff line change
@@ -2507,27 +2507,42 @@
25072507
/**
25082508
* User-defined menu items that execute custom GCode
25092509
*/
2510-
//#define CUSTOM_USER_MENUS
2510+
#define CUSTOM_USER_MENUS
25112511
#if ENABLED(CUSTOM_USER_MENUS)
2512-
//#define CUSTOM_USER_MENU_TITLE "Custom Commands"
2513-
#define USER_SCRIPT_DONE "M117 User Script Done"
2512+
#define CUSTOM_USER_MENU_TITLE "TFT Color Profiles"
2513+
#define USER_SCRIPT_DONE "M117 Color profile changed"
25142514
#define USER_SCRIPT_AUDIBLE_FEEDBACK
25152515
//#define USER_SCRIPT_RETURN // Return to status screen after a script
25162516

2517-
#define USER_DESC_1 "Home & UBL Info"
2518-
#define USER_GCODE_1 "G28\nG29 W"
2517+
#define USER_DESC_1 "Black & White"
2518+
#define USER_GCODE_1 "M250 P0"
25192519

2520-
#define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL
2521-
#define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
2520+
// #define USER_DESC_1 "Home & UBL Info"
2521+
// #define USER_GCODE_1 "G28\nG29 W"
25222522

2523-
#define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL
2524-
#define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
2523+
#define USER_DESC_2 "Classic Blue"
2524+
#define USER_GCODE_2 "M250 P1"
25252525

2526-
#define USER_DESC_4 "Heat Bed/Home/Level"
2527-
#define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"
2526+
// #define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL
2527+
// #define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
25282528

2529-
#define USER_DESC_5 "Home & Info"
2530-
#define USER_GCODE_5 "G28\nM503"
2529+
#define USER_DESC_3 "Inverted B&W"
2530+
#define USER_GCODE_3 "M250 P2"
2531+
2532+
// #define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL
2533+
// #define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
2534+
2535+
#define USER_DESC_4 "Olive LED"
2536+
#define USER_GCODE_4 "M250 P3"
2537+
2538+
// #define USER_DESC_4 "Heat Bed/Home/Level"
2539+
// #define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"
2540+
2541+
#define USER_DESC_5 "Grey Matters"
2542+
#define USER_GCODE_5 "M250 P4"
2543+
2544+
// #define USER_DESC_5 "Home & Info"
2545+
// #define USER_GCODE_5 "G28\nM503"
25312546
#endif
25322547

25332548
/**

Marlin/src/gcode/gcode.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
595595
case 240: M240(); break; // M240: Trigger a camera
596596
#endif
597597

598-
#if HAS_LCD_CONTRAST
598+
#if HAS_LCD_CONTRAST || TFT_HAS_COLOR
599599
case 250: M250(); break; // M250: Set LCD contrast
600600
#endif
601601

Marlin/src/gcode/gcode.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ class GcodeSuite {
695695
static void M240();
696696
#endif
697697

698-
#if HAS_LCD_CONTRAST
698+
#if HAS_LCD_CONTRAST || TFT_HAS_COLOR
699699
static void M250();
700700
#endif
701701

Marlin/src/gcode/lcd/M250.cpp

+33-4
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,46 @@
2222

2323
#include "../../inc/MarlinConfig.h"
2424

25-
#if HAS_LCD_CONTRAST
25+
#if HAS_LCD_CONTRAST || TFT_HAS_COLOR
2626

2727
#include "../gcode.h"
2828
#include "../../lcd/ultralcd.h"
29+
#include "../../lcd/dogm/ultralcd_DOGM.h"
2930

3031
/**
3132
* M250: Read and optionally set the LCD contrast
3233
*/
3334
void GcodeSuite::M250() {
34-
if (parser.seen('C')) ui.set_contrast(parser.value_int());
35-
SERIAL_ECHOLNPAIR("LCD Contrast: ", ui.contrast);
35+
36+
#if HAS_LCD_CONTRAST
37+
if (parser.seen('C')) ui.set_contrast(parser.value_int());
38+
SERIAL_ECHOLNPAIR("LCD Contrast: ", ui.contrast);
39+
#endif // HAS_LCD_CONTRAST
40+
41+
//
42+
// Warning this component is still pretty stupid
43+
//
44+
45+
#if TFT_HAS_COLOR
46+
if (parser.seen('B'))
47+
{
48+
bg_color = parser.value_ushort();
49+
SERIAL_ECHOLNPAIR("TFT Background Color: ", bg_color);
50+
}
51+
52+
if (parser.seen('F'))
53+
{
54+
ui_color = parser.value_ushort();
55+
SERIAL_ECHOLNPAIR("TFT Foreground Color: ", ui_color);
56+
}
57+
58+
if (parser.seen('P'))
59+
{
60+
switchColorPreset(parser.value_byte());
61+
SERIAL_ECHOLN("Switched Color Preset: ");
62+
}
63+
#endif // TFT_HAS_COLOR
64+
3665
}
3766

38-
#endif // HAS_LCD_CONTRAST
67+
#endif // HAS_LCD_CONTRAST || TFT_HAS_COLOR

Marlin/src/inc/Conditionals_LCD.h

+4
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,12 @@
231231
#define DOGLCD
232232
#define IS_ULTIPANEL
233233
#define DELAYED_BACKLIGHT_INIT
234+
#define TFT_HAS_COLOR defined(FSMC_GRAPHICAL_TFT)
234235
#endif
235236

237+
// don't know if this is the right way to do it
238+
#define TFT_HAS_COLOR defined(FSMC_GRAPHICAL_TFT)
239+
236240
/**
237241
* I2C Panels
238242
*/

0 commit comments

Comments
 (0)