Skip to content

Commit

Permalink
Color presets added - new gcode in M250
Browse files Browse the repository at this point in the history
  • Loading branch information
inib committed Oct 10, 2019
1 parent 7a1a38f commit 44cee4f
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 83 deletions.
17 changes: 16 additions & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,22 @@
// FSMC_UPSCALE 2 2x upscaler for 320x240 displays (default)
// FSMC_UPSCALE 3 3x upscaler for 480x320 displays
//
#define FSMC_UPSCALE 2
#define FSMC_UPSCALE 3

//
// Change colors
// some colors are predefined, see /src/lcd/dogm/u8g_dev_tft_480~.cpp Line 160
// or use 16bit color (e.g. 0x0000 = black, 0xFFE0 = yellow)
// see https://ee-programming-notepad.blogspot.com/2016/10/16-bit-color-generator-picker.html
//

#define TFT_MARLINUI_COLOR COLOR_WHITE // main foreground color
#define TFT_MARLINBG_COLOR COLOR_NAVY // background color
#define TFT_BTCANCEL_COLOR 0xA9A6 // cancel button
#define TFT_BTARROWS_COLOR COLOR_WHITE // arrows up/down
#define TFT_BTOKMENU_COLOR COLOR_WHITE // enter button
//#define TFT_DISABLED_COLOR COLOR_DARK // currently not used

#endif

//=============================================================================
Expand Down
41 changes: 28 additions & 13 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2507,27 +2507,42 @@
/**
* User-defined menu items that execute custom GCode
*/
//#define CUSTOM_USER_MENUS
#define CUSTOM_USER_MENUS
#if ENABLED(CUSTOM_USER_MENUS)
//#define CUSTOM_USER_MENU_TITLE "Custom Commands"
#define USER_SCRIPT_DONE "M117 User Script Done"
#define CUSTOM_USER_MENU_TITLE "TFT Color Profiles"
#define USER_SCRIPT_DONE "M117 Color profile changed"
#define USER_SCRIPT_AUDIBLE_FEEDBACK
//#define USER_SCRIPT_RETURN // Return to status screen after a script

#define USER_DESC_1 "Home & UBL Info"
#define USER_GCODE_1 "G28\nG29 W"
#define USER_DESC_1 "Black & White"
#define USER_GCODE_1 "M250 P0"

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

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

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

#define USER_DESC_5 "Home & Info"
#define USER_GCODE_5 "G28\nM503"
#define USER_DESC_3 "Inverted B&W"
#define USER_GCODE_3 "M250 P2"

// #define USER_DESC_3 "Preheat for " PREHEAT_2_LABEL
// #define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)

#define USER_DESC_4 "Olive LED"
#define USER_GCODE_4 "M250 P3"

// #define USER_DESC_4 "Heat Bed/Home/Level"
// #define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"

#define USER_DESC_5 "Grey Matters"
#define USER_GCODE_5 "M250 P4"

// #define USER_DESC_5 "Home & Info"
// #define USER_GCODE_5 "G28\nM503"
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 240: M240(); break; // M240: Trigger a camera
#endif

#if HAS_LCD_CONTRAST
#if HAS_LCD_CONTRAST || TFT_HAS_COLOR
case 250: M250(); break; // M250: Set LCD contrast
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ class GcodeSuite {
static void M240();
#endif

#if HAS_LCD_CONTRAST
#if HAS_LCD_CONTRAST || TFT_HAS_COLOR
static void M250();
#endif

Expand Down
37 changes: 33 additions & 4 deletions Marlin/src/gcode/lcd/M250.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,46 @@

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

#if HAS_LCD_CONTRAST
#if HAS_LCD_CONTRAST || TFT_HAS_COLOR

#include "../gcode.h"
#include "../../lcd/ultralcd.h"
#include "../../lcd/dogm/ultralcd_DOGM.h"

/**
* M250: Read and optionally set the LCD contrast
*/
void GcodeSuite::M250() {
if (parser.seen('C')) ui.set_contrast(parser.value_int());
SERIAL_ECHOLNPAIR("LCD Contrast: ", ui.contrast);

#if HAS_LCD_CONTRAST
if (parser.seen('C')) ui.set_contrast(parser.value_int());
SERIAL_ECHOLNPAIR("LCD Contrast: ", ui.contrast);
#endif // HAS_LCD_CONTRAST

//
// Warning this component is still pretty stupid
//

#if TFT_HAS_COLOR
if (parser.seen('B'))
{
bg_color = parser.value_ushort();
SERIAL_ECHOLNPAIR("TFT Background Color: ", bg_color);
}

if (parser.seen('F'))
{
ui_color = parser.value_ushort();
SERIAL_ECHOLNPAIR("TFT Foreground Color: ", ui_color);
}

if (parser.seen('P'))
{
switchColorPreset(parser.value_byte());
SERIAL_ECHOLN("Switched Color Preset: ");
}
#endif // TFT_HAS_COLOR

}

#endif // HAS_LCD_CONTRAST
#endif // HAS_LCD_CONTRAST || TFT_HAS_COLOR
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,12 @@
#define DOGLCD
#define IS_ULTIPANEL
#define DELAYED_BACKLIGHT_INIT
#define TFT_HAS_COLOR defined(FSMC_GRAPHICAL_TFT)
#endif

// don't know if this is the right way to do it
#define TFT_HAS_COLOR defined(FSMC_GRAPHICAL_TFT)

/**
* I2C Panels
*/
Expand Down
Loading

0 comments on commit 44cee4f

Please sign in to comment.