diff --git a/Copy to SD Card root directory to update/BIGTREE_TFT24_V1.1.27.bin b/Copy to SD Card root directory to update/BIGTREE_TFT24_V1.1.27.bin index 695025fb02..dfd2a18885 100755 Binary files a/Copy to SD Card root directory to update/BIGTREE_TFT24_V1.1.27.bin and b/Copy to SD Card root directory to update/BIGTREE_TFT24_V1.1.27.bin differ diff --git a/Copy to SD Card root directory to update/BIGTREE_TFT28_V3.0.27.bin b/Copy to SD Card root directory to update/BIGTREE_TFT28_V3.0.27.bin index f375156819..d4ee38a3fb 100755 Binary files a/Copy to SD Card root directory to update/BIGTREE_TFT28_V3.0.27.bin and b/Copy to SD Card root directory to update/BIGTREE_TFT28_V3.0.27.bin differ diff --git a/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0.27.bin b/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0.27.bin index c6f8aa5b72..196c7e5c51 100755 Binary files a/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0.27.bin and b/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0.27.bin differ diff --git a/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0_B1.27.bin b/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0_B1.27.bin index 75b3b2954c..bef1f6caad 100755 Binary files a/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0_B1.27.bin and b/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0_B1.27.bin differ diff --git a/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0_E3.27.bin b/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0_E3.27.bin index 5be26a9b4b..62a02c4011 100755 Binary files a/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0_E3.27.bin and b/Copy to SD Card root directory to update/BIGTREE_TFT35_V3.0_E3.27.bin differ diff --git a/Copy to SD Card root directory to update/BIGTREE_TFT43_V3.0.27.bin b/Copy to SD Card root directory to update/BIGTREE_TFT43_V3.0.27.bin index a144779e2b..0878d8a288 100755 Binary files a/Copy to SD Card root directory to update/BIGTREE_TFT43_V3.0.27.bin and b/Copy to SD Card root directory to update/BIGTREE_TFT43_V3.0.27.bin differ diff --git a/Copy to SD Card root directory to update/BIGTREE_TFT50_V3.0.27.bin b/Copy to SD Card root directory to update/BIGTREE_TFT50_V3.0.27.bin index 4f96a606ea..52bf2ad11a 100755 Binary files a/Copy to SD Card root directory to update/BIGTREE_TFT50_V3.0.27.bin and b/Copy to SD Card root directory to update/BIGTREE_TFT50_V3.0.27.bin differ diff --git a/Copy to SD Card root directory to update/BIGTREE_TFT70_V3.0.27.bin b/Copy to SD Card root directory to update/BIGTREE_TFT70_V3.0.27.bin index b5239e3afc..55b145f222 100755 Binary files a/Copy to SD Card root directory to update/BIGTREE_TFT70_V3.0.27.bin and b/Copy to SD Card root directory to update/BIGTREE_TFT70_V3.0.27.bin differ diff --git a/Copy to SD Card root directory to update/BIQU_TFT28_V1.0.27.bin b/Copy to SD Card root directory to update/BIQU_TFT28_V1.0.27.bin index e8215036f5..d8058032f7 100755 Binary files a/Copy to SD Card root directory to update/BIQU_TFT28_V1.0.27.bin and b/Copy to SD Card root directory to update/BIQU_TFT28_V1.0.27.bin differ diff --git a/Copy to SD Card root directory to update/BIQU_TFT35_APP1_V2.0.27.bin b/Copy to SD Card root directory to update/BIQU_TFT35_APP1_V2.0.27.bin index 0677517989..78f1cc31af 100755 Binary files a/Copy to SD Card root directory to update/BIQU_TFT35_APP1_V2.0.27.bin and b/Copy to SD Card root directory to update/BIQU_TFT35_APP1_V2.0.27.bin differ diff --git a/Copy to SD Card root directory to update/BIQU_TFT35_V1.0.27.bin b/Copy to SD Card root directory to update/BIQU_TFT35_V1.0.27.bin index 1392cf2d79..225d4ebb71 100755 Binary files a/Copy to SD Card root directory to update/BIQU_TFT35_V1.0.27.bin and b/Copy to SD Card root directory to update/BIQU_TFT35_V1.0.27.bin differ diff --git a/Copy to SD Card root directory to update/BIQU_TFT35_V1.1.27.bin b/Copy to SD Card root directory to update/BIQU_TFT35_V1.1.27.bin index df72812f7c..041e33c699 100755 Binary files a/Copy to SD Card root directory to update/BIQU_TFT35_V1.1.27.bin and b/Copy to SD Card root directory to update/BIQU_TFT35_V1.1.27.bin differ diff --git a/Copy to SD Card root directory to update/BIQU_TFT35_V1.2.27.bin b/Copy to SD Card root directory to update/BIQU_TFT35_V1.2.27.bin index cbfc46a625..02163b07cd 100755 Binary files a/Copy to SD Card root directory to update/BIQU_TFT35_V1.2.27.bin and b/Copy to SD Card root directory to update/BIQU_TFT35_V1.2.27.bin differ diff --git a/Copy to SD Card root directory to update/MKS_TFT28_V3.0.27.bin b/Copy to SD Card root directory to update/MKS_TFT28_V3.0.27.bin index e8e37f201a..6acb2ee12f 100755 Binary files a/Copy to SD Card root directory to update/MKS_TFT28_V3.0.27.bin and b/Copy to SD Card root directory to update/MKS_TFT28_V3.0.27.bin differ diff --git a/Copy to SD Card root directory to update/MKS_TFT28_V4.0.27.bin b/Copy to SD Card root directory to update/MKS_TFT28_V4.0.27.bin index cc11fe9ebc..0d7dd482e9 100755 Binary files a/Copy to SD Card root directory to update/MKS_TFT28_V4.0.27.bin and b/Copy to SD Card root directory to update/MKS_TFT28_V4.0.27.bin differ diff --git a/Copy to SD Card root directory to update/MKS_TFT32_V1.3.27.bin b/Copy to SD Card root directory to update/MKS_TFT32_V1.3.27.bin index 39b56f57a3..3efeefcfff 100755 Binary files a/Copy to SD Card root directory to update/MKS_TFT32_V1.3.27.bin and b/Copy to SD Card root directory to update/MKS_TFT32_V1.3.27.bin differ diff --git a/Copy to SD Card root directory to update/MKS_TFT32_V1.4.27.bin b/Copy to SD Card root directory to update/MKS_TFT32_V1.4.27.bin index fa8388f8eb..3f16490f33 100755 Binary files a/Copy to SD Card root directory to update/MKS_TFT32_V1.4.27.bin and b/Copy to SD Card root directory to update/MKS_TFT32_V1.4.27.bin differ diff --git a/Copy to SD Card root directory to update/config.ini b/Copy to SD Card root directory to update/config.ini index f7fd735d51..41de0617e4 100644 --- a/Copy to SD Card root directory to update/config.ini +++ b/Copy to SD Card root directory to update/config.ini @@ -122,7 +122,7 @@ mesh_min_color:7 ## Color used by the Mesh Editor menu for drawing the mesh with the maximum value in the grid mesh_max_color:2 -#### Terminal text Color Scheme +#### Terminal Text Color Scheme # Select as color scheme for displaying text in Teminal menu. # Options: [Material Dark: 0, Material Light: 1, High Contrast: 2] # Material Dark: Dark background with light font color and orange command font color. @@ -135,7 +135,7 @@ terminal_color_scheme:0 # Options: [enable: 1, disable: 0] rotate_ui:0 -#### Temperature ACK in Terminal +#### Temperature ACK In Terminal # Show or hide temperature ACK in Terminal menu. # Options: [show: 1, hide: 0] terminal_ack:0 @@ -301,21 +301,21 @@ fan_max:F0:255 F1:255 F2:255 F3:255 F4:255 F5:255 CtL:255 CtI:255 size_min:X0 Y0 Z0 size_max:X235 Y235 Z250 -#### Default X & Y Move Speeds/feedrates +#### Default X & Y Move Speeds/Feedrates # Move speeds used in move menu to move X and Y axes. # Format: [move_speed: S N F] # Unit: [feedrate in mm/min] # Value range: [min: 10, max: 12000] xy_speed:S1000 N3000 F5000 -#### Default Z Speeds/feedrates +#### Default Z Speeds/Feedrates # Move speeds used in move menu to move Z axis. # Format: [move_speed: S N F] # Unit: [feedrate in mm/min] # Value range: [min: 10, max: 12000] z_speed:S500 N1000 F2000 -#### Default Extruder Speeds/feedrates +#### Default Extruder Speeds/Feedrates # Speed settings used to extrude/retract. # Format: [ext_speed: S N F] # Unit: [feedrate in mm/min] @@ -588,7 +588,7 @@ knob_led_color:0 # Options: [true: 1, false: 0] knob_led_idle:1 -#### Knob LED pixels (only for TFT43 V3.0, TFT50 V3.0 & TFT70 V3.0) +#### Knob LED Pixels (only for TFT43 V3.0, TFT50 V3.0 & TFT70 V3.0) # Set the number of LEDs in the strip connected the "Neopixel" port of TFT. # It shares the same signal line as "knob_led". 0 means the default number in TFT hardware, # Greater than 0 means the number of LEDs in the strip. diff --git a/Copy to SD Card root directory to update/config_rrf.ini b/Copy to SD Card root directory to update/config_rrf.ini index c2d9dc2fed..3d8d1add52 100644 --- a/Copy to SD Card root directory to update/config_rrf.ini +++ b/Copy to SD Card root directory to update/config_rrf.ini @@ -122,7 +122,7 @@ mesh_min_color:7 ## Color used by the Mesh Editor menu for drawing the mesh with the maximum value in the grid mesh_max_color:2 -#### Terminal text Color Scheme +#### Terminal Text Color Scheme # Select as color scheme for displaying text in Teminal menu. # Options: [Material Dark: 0, Material Light: 1, High Contrast: 2] # Material Dark: Dark background with light font color and orange command font color. @@ -135,7 +135,7 @@ terminal_color_scheme:0 # Options: [enable: 1, disable: 0] rotate_ui:0 -#### Temperature ACK in Terminal +#### Temperature ACK In Terminal # Show or hide temperature ACK in Terminal menu. # Options: [show: 1, hide: 0] terminal_ack:0 @@ -301,21 +301,21 @@ fan_max:F0:255 F1:255 F2:255 F3:255 F4:255 F5:255 CtL:255 CtI:255 size_min:X0 Y0 Z0 size_max:X235 Y235 Z250 -#### Default X & Y Move Speeds/feedrates +#### Default X & Y Move Speeds/Feedrates # Move speeds used in move menu to move X and Y axes. # Format: [move_speed: S N F] # Unit: [feedrate in mm/min] # Value range: [min: 10, max: 12000] xy_speed:S1000 N3000 F5000 -#### Default Z Speeds/feedrates +#### Default Z Speeds/Feedrates # Move speeds used in move menu to move Z axis. # Format: [move_speed: S N F] # Unit: [feedrate in mm/min] # Value range: [min: 10, max: 12000] z_speed:S500 N1000 F2000 -#### Default Extruder Speeds/feedrates +#### Default Extruder Speeds/Feedrates # Speed settings used to extrude/retract. # Format: [ext_speed: S N F] # Unit: [feedrate in mm/min] @@ -588,7 +588,7 @@ knob_led_color:0 # Options: [true: 1, false: 0] knob_led_idle:1 -#### Knob LED pixels (only for TFT43 V3.0, TFT50 V3.0 & TFT70 V3.0) +#### Knob LED Pixels (only for TFT43 V3.0, TFT50 V3.0 & TFT70 V3.0) # Set the number of LEDs in the strip connected the "Neopixel" port of TFT. # It shares the same signal line as "knob_led". 0 means the default number in TFT hardware, # Greater than 0 means the number of LEDs in the strip. diff --git a/TFT/src/User/API/ledcolor.c b/TFT/src/User/API/LCD_LEDColor.c similarity index 98% rename from TFT/src/User/API/ledcolor.c rename to TFT/src/User/API/LCD_LEDColor.c index 0074a1b9e9..88476423d6 100644 --- a/TFT/src/User/API/ledcolor.c +++ b/TFT/src/User/API/LCD_LEDColor.c @@ -1,4 +1,4 @@ -#include "ledcolor.h" +#include "LCD_LEDColor.h" #include "GPIO_Init.h" #include "includes.h" diff --git a/TFT/src/User/API/ledcolor.h b/TFT/src/User/API/LCD_LEDColor.h similarity index 99% rename from TFT/src/User/API/ledcolor.h rename to TFT/src/User/API/LCD_LEDColor.h index 9e73129efc..6b8a75be10 100644 --- a/TFT/src/User/API/ledcolor.h +++ b/TFT/src/User/API/LCD_LEDColor.h @@ -1,5 +1,5 @@ -#ifndef _LEDCOLOR_H_ -#define _LEDCOLOR_H_ +#ifndef _LCD_LED_COLOR_H_ +#define _LCD_LED_COLOR_H_ #ifdef __cplusplus extern "C" { diff --git a/TFT/src/User/API/UI/Numpad.c b/TFT/src/User/API/UI/Numpad.c index a27d04faab..ff58849db4 100644 --- a/TFT/src/User/API/UI/Numpad.c +++ b/TFT/src/User/API/UI/Numpad.c @@ -1,4 +1,51 @@ #include "Numpad.h" +#include "list_item.h" + +#define SKEYHEIGHT (LCD_HEIGHT-ICON_START_Y)/4 +#define SKEYWIDTH LCD_WIDTH/4 + +#define KEY_NUM 16 +#define FLOAT_BUFLONG 9 +#define INT_BUFLONG 6 + +typedef enum +{ + SKEY_0 = 0, + SKEY_1, + SKEY_2, + SKEY_3, + SKEY_4, + SKEY_5, + SKEY_6, + SKEY_7, + SKEY_8, + SKEY_9, + SKEY_10, + SKEY_11, + SKEY_IDLE = IDLE_TOUCH, +}SKEY_VALUES; + +typedef enum +{ + NUM_KEY_1 = 0, + NUM_KEY_2, + NUM_KEY_3, + NUM_KEY_OK, + NUM_KEY_4, + NUM_KEY_5, + NUM_KEY_6, + NUM_KEY_DEL, + NUM_KEY_7, + NUM_KEY_8, + NUM_KEY_9, + NUM_KEY_EXIT, + NUM_KEY_DEC, + NUM_KEY_0, + NUM_KEY_MINUS, + NUM_KEY_RESET, + + NUM_KEY_IDLE = IDLE_TOUCH, +}NUM_KEY_VALUES; const GUI_RECT rect_of_numkey[KEY_NUM]={ {0*SKEYWIDTH, ICON_START_Y+0*SKEYHEIGHT, 1*SKEYWIDTH, ICON_START_Y+1*SKEYHEIGHT},//1 diff --git a/TFT/src/User/API/UI/Numpad.h b/TFT/src/User/API/UI/Numpad.h index 5c6aa66563..1d0cc3db2d 100644 --- a/TFT/src/User/API/UI/Numpad.h +++ b/TFT/src/User/API/UI/Numpad.h @@ -6,54 +6,6 @@ extern "C" { #endif #include "includes.h" -#include "list_item.h" - -#define SKEYHEIGHT (LCD_HEIGHT-ICON_START_Y)/4 -#define SKEYWIDTH LCD_WIDTH/4 - -#define KEY_NUM 16 -#define FLOAT_BUFLONG 9 -#define INT_BUFLONG 6 - -typedef enum -{ - SKEY_0 = 0, - SKEY_1, - SKEY_2, - SKEY_3, - SKEY_4, - SKEY_5, - SKEY_6, - SKEY_7, - SKEY_8, - SKEY_9, - SKEY_10, - SKEY_11, - SKEY_IDLE = IDLE_TOUCH, -}SKEY_VALUES; - -typedef enum -{ - NUM_KEY_1 = 0, - NUM_KEY_2, - NUM_KEY_3, - NUM_KEY_OK, - NUM_KEY_4, - NUM_KEY_5, - NUM_KEY_6, - NUM_KEY_DEL, - NUM_KEY_7, - NUM_KEY_8, - NUM_KEY_9, - NUM_KEY_EXIT, - NUM_KEY_DEC, - NUM_KEY_0, - NUM_KEY_MINUS, - NUM_KEY_RESET, - - NUM_KEY_IDLE = IDLE_TOUCH, -}NUM_KEY_VALUES; - double numPadFloat(u8* title, double old_val, double reset_val, bool negative); diff --git a/TFT/src/User/Configuration.h b/TFT/src/User/Configuration.h index a5c50f3587..945a691068 100644 --- a/TFT/src/User/Configuration.h +++ b/TFT/src/User/Configuration.h @@ -428,11 +428,11 @@ #define SHOW_FAN_PERCENTAGE true // To enabled: true | To disabled: false (Default: true) /** - * Mesh Editor Keyboard on left side - * By default the Mesh Editor Keyboard is drawn on right side of the screen. - * Enable MESH_LEFT_KEYBOARD to draw the mesh editor keyboard on left side of the screen. + * Keyboard on left side (Mesh Editor, RGB Settings Custom) + * By default the keyboard is drawn on right side of the screen. + * Enable KEYBOARD_ON_LEFT to draw the keyboard on left side of the screen. */ -//#define MESH_LEFT_KEYBOARD +//#define KEYBOARD_ON_LEFT // // Terminal Keyboard / Numpad settings @@ -440,7 +440,7 @@ // Terminal Keyboard / Numpad theme // Uncomment to enable Material theme for keyboard and Numpad -#define KEYBOARD_MATERIAL_THEME // Default: disabled +#define KEYBOARD_MATERIAL_THEME // Default: disabled /** * Color scheme for the Terminal Keyboard / Numpad diff --git a/TFT/src/User/Menu/LEDColor.c b/TFT/src/User/Menu/LEDColor.c new file mode 100644 index 0000000000..409904f61d --- /dev/null +++ b/TFT/src/User/Menu/LEDColor.c @@ -0,0 +1,581 @@ +#include "LEDColor.h" +#include "includes.h" + +// value ranges +#define LED_UPDATE_TIME 1000 // 1 seconds is 1000 +#define LED_MIN_VALUE 0 +#define LED_MAX_VALUE 255 + +// data structures +#define LED_VECT_SIZE 6 + +// LED color components vector: +// R: red +// G: green +// B: blue +// W: white; NEOPIXEL or RGB(W) +// P: intensity; NEOPIXEL +// I: index; NEOPIXEL +typedef uint8_t LED_VECT[LED_VECT_SIZE]; + +// key button enumeration +typedef enum +{ + LED_KEY_PREV = 0, + LED_KEY_NEXT, + // after NEXT, all the other keys + LED_KEY_RESET, + LED_KEY_CANCEL, + LED_KEY_OK, + // no need to declare key numbers if no special task is performed by the key + LED_KEY_IDLE = IDLE_TOUCH, +} LED_KEY_VALUES; + +// colors +#define KB_FONT_COLOR infoSettings.font_color +#undef KB_BG_COLOR +#define KB_BG_COLOR infoSettings.bg_color +#define KB_BORDER_COLOR infoSettings.list_border_color +#define KB_BORDER_COLOR_2 0x4b0d + +#define CTRL_FONT_COLOR WHITE +#define CTRL_BG_COLOR 0x2174 +#define CTRL_BORDER_COLOR 0x4b0d + +// layout sizes +#define KB_ROW_NUM 4 +#define KB_COL_NUM 4 +#define CTRL_COL_NUM 3 +#define KEY_NUM ((KB_COL_NUM * KB_ROW_NUM - 1) + (CTRL_COL_NUM - 1)) // keyboard keys + control bar keys +#define ROW_NUM (KB_ROW_NUM + 1) // keyboard rows + control bar +#define ROW_HEIGHT (LCD_HEIGHT / ROW_NUM) // button height +#define PAGE_ITEMS 3 +#define PAGE_NUM (LED_VECT_SIZE / PAGE_ITEMS) + +// keyboard key sizes +#define KB_WIDTH (LCD_WIDTH / KB_COL_NUM) +#define KB_HEIGHT ROW_HEIGHT + +// control bar keys sizes +#define CTRL_WIDTH (LCD_WIDTH / CTRL_COL_NUM) +#define CTRL_HEIGHT ROW_HEIGHT + +// key button rectangles +const GUI_RECT ledKeyRect[KEY_NUM] = { +#ifdef KEYBOARD_ON_LEFT + // control bar + {0 * CTRL_WIDTH, 4 * CTRL_HEIGHT, 1 * CTRL_WIDTH, 5 * CTRL_HEIGHT}, // PREV + {1 * CTRL_WIDTH, 4 * CTRL_HEIGHT, 2 * CTRL_WIDTH, 5 * CTRL_HEIGHT}, // NEXT + + // menu buttons + {2 * KB_WIDTH, 0 * KB_HEIGHT, 3 * KB_WIDTH, 1 * KB_HEIGHT}, // RESET + {1 * KB_WIDTH, 0 * KB_HEIGHT, 2 * KB_WIDTH, 1 * KB_HEIGHT}, // CANCEL + {0 * KB_WIDTH, 0 * KB_HEIGHT, 1 * KB_WIDTH, 1 * KB_HEIGHT}, // OK + + // R component + {3 * KB_WIDTH, 1 * KB_HEIGHT, 4 * KB_WIDTH, 2 * KB_HEIGHT}, // COLOR + {2 * KB_WIDTH, 1 * KB_HEIGHT, 3 * KB_WIDTH, 2 * KB_HEIGHT}, // EDIT + {0 * KB_WIDTH, 1 * KB_HEIGHT, 1 * KB_WIDTH, 2 * KB_HEIGHT}, // DEC + {1 * KB_WIDTH, 1 * KB_HEIGHT, 2 * KB_WIDTH, 2 * KB_HEIGHT}, // INC + + // G component + {3 * KB_WIDTH, 2 * KB_HEIGHT, 4 * KB_WIDTH, 3 * KB_HEIGHT}, // COLOR + {2 * KB_WIDTH, 2 * KB_HEIGHT, 3 * KB_WIDTH, 3 * KB_HEIGHT}, // EDIT + {0 * KB_WIDTH, 2 * KB_HEIGHT, 1 * KB_WIDTH, 3 * KB_HEIGHT}, // DEC + {1 * KB_WIDTH, 2 * KB_HEIGHT, 2 * KB_WIDTH, 3 * KB_HEIGHT}, // INC + + // B component + {3 * KB_WIDTH, 3 * KB_HEIGHT, 4 * KB_WIDTH, 4 * KB_HEIGHT}, // COLOR + {2 * KB_WIDTH, 3 * KB_HEIGHT, 3 * KB_WIDTH, 4 * KB_HEIGHT}, // EDIT + {0 * KB_WIDTH, 3 * KB_HEIGHT, 1 * KB_WIDTH, 4 * KB_HEIGHT}, // DEC + {1 * KB_WIDTH, 3 * KB_HEIGHT, 2 * KB_WIDTH, 4 * KB_HEIGHT}, // INC +#else + // control bar + {1 * CTRL_WIDTH, 4 * CTRL_HEIGHT, 2 * CTRL_WIDTH, 5 * CTRL_HEIGHT}, // PREV + {2 * CTRL_WIDTH, 4 * CTRL_HEIGHT, 3 * CTRL_WIDTH, 5 * CTRL_HEIGHT}, // NEXT + + // menu buttons + {1 * KB_WIDTH, 0 * KB_HEIGHT, 2 * KB_WIDTH, 1 * KB_HEIGHT}, // RESET + {2 * KB_WIDTH, 0 * KB_HEIGHT, 3 * KB_WIDTH, 1 * KB_HEIGHT}, // CANCEL + {3 * KB_WIDTH, 0 * KB_HEIGHT, 4 * KB_WIDTH, 1 * KB_HEIGHT}, // OK + + // R component + {0 * KB_WIDTH, 1 * KB_HEIGHT, 1 * KB_WIDTH, 2 * KB_HEIGHT}, // COLOR + {1 * KB_WIDTH, 1 * KB_HEIGHT, 2 * KB_WIDTH, 2 * KB_HEIGHT}, // EDIT + {2 * KB_WIDTH, 1 * KB_HEIGHT, 3 * KB_WIDTH, 2 * KB_HEIGHT}, // DEC + {3 * KB_WIDTH, 1 * KB_HEIGHT, 4 * KB_WIDTH, 2 * KB_HEIGHT}, // INC + + // G component + {0 * KB_WIDTH, 2 * KB_HEIGHT, 1 * KB_WIDTH, 3 * KB_HEIGHT}, // COLOR + {1 * KB_WIDTH, 2 * KB_HEIGHT, 2 * KB_WIDTH, 3 * KB_HEIGHT}, // EDIT + {2 * KB_WIDTH, 2 * KB_HEIGHT, 3 * KB_WIDTH, 3 * KB_HEIGHT}, // DEC + {3 * KB_WIDTH, 2 * KB_HEIGHT, 4 * KB_WIDTH, 3 * KB_HEIGHT}, // INC + + // B component + {0 * KB_WIDTH, 3 * KB_HEIGHT, 1 * KB_WIDTH, 4 * KB_HEIGHT}, // COLOR + {1 * KB_WIDTH, 3 * KB_HEIGHT, 2 * KB_WIDTH, 4 * KB_HEIGHT}, // EDIT + {2 * KB_WIDTH, 3 * KB_HEIGHT, 3 * KB_WIDTH, 4 * KB_HEIGHT}, // DEC + {3 * KB_WIDTH, 3 * KB_HEIGHT, 4 * KB_WIDTH, 4 * KB_HEIGHT}, // INC +#endif +}; + +#ifdef KEYBOARD_ON_LEFT +const GUI_RECT ledColorRect = { + 3 * KB_WIDTH, 0 * KB_HEIGHT, 4 * KB_WIDTH, 1 * KB_HEIGHT}; + +const GUI_RECT ledPageRect = { + 2 * CTRL_WIDTH, 4 * CTRL_HEIGHT, 3 * CTRL_WIDTH, 5 * KB_HEIGHT}; +#else +const GUI_RECT ledColorRect = { + 0 * KB_WIDTH, 0 * KB_HEIGHT, 1 * KB_WIDTH, 1 * KB_HEIGHT}; + +const GUI_RECT ledPageRect = { + 0 * CTRL_WIDTH, 4 * CTRL_HEIGHT, 1 * CTRL_WIDTH, 5 * KB_HEIGHT}; +#endif + +// area rectangles +const GUI_RECT ledAreaRect[2] = { + {0, 0, LCD_WIDTH, LCD_HEIGHT - CTRL_HEIGHT}, // keyboard area + {0, 4 * CTRL_HEIGHT, LCD_WIDTH, LCD_HEIGHT} // control bar area +}; + +const char *const ledKeyString[2] = { + "<", // PREV + ">", // NEXT +}; + +const char * const ledString[LED_VECT_SIZE] = {"R", "G", "B", "W", "P", "I"}; + +const LED_VECT ledRed = {0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF}; +const LED_VECT ledGreen = {0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF}; +const LED_VECT ledBlue = {0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF}; +const LED_VECT ledWhite = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; +const LED_VECT ledOff = {0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}; + +LED_VECT ledValue = {0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF}; + +uint8_t ledPage = 0; +uint8_t ledIndex = 0; + +void ledSendValue(const LED_VECT * led) +{ + storeCmd("M150 R%d U%d B%d W%d P%d I%d\n", (*led)[0], (*led)[1], (*led)[2], (*led)[3], (*led)[4], (*led)[5]); +} + +void ledGetValue(LED_VECT * led) +{ + for (int i = 0; i < LED_VECT_SIZE; i++) + (*led)[i] = ledValue[i]; +} + +void ledSetValue(const LED_VECT * led, bool skipNeopixel) +{ + int size = skipNeopixel ? LED_VECT_SIZE - 2 : LED_VECT_SIZE; + + for (int i = 0; i < size; i++) + ledValue[i] = (*led)[i]; +} + +uint8_t ledGetComponentIndex(uint8_t index) +{ + return ledPage * PAGE_ITEMS + index; +} + +uint8_t ledGetComponentValue(uint8_t index) +{ + return ledValue[ledGetComponentIndex(index)]; +} + +static inline uint8_t ledEditComponentValue(uint8_t index) +{ + uint8_t realIndex = ledGetComponentIndex(index); + + return ledValue[realIndex] = editIntValue(LED_MIN_VALUE, LED_MAX_VALUE, ledValue[realIndex], ledValue[realIndex]); +} + +uint8_t ledUpdateComponentValue(uint8_t index, int8_t unit, int8_t direction) +{ + uint8_t realIndex = ledGetComponentIndex(index); + + return ledValue[realIndex] = NOBEYOND(LED_MIN_VALUE, ledValue[realIndex] + (int16_t) (direction * unit), LED_MAX_VALUE); +} + +uint8_t ledGetControlIndex(uint8_t keyNum) +{ + return (keyNum - (LED_KEY_OK + 1)) / 4; +} + +uint8_t ledGetControlSubIndex(uint8_t keyNum) +{ + return (keyNum - (LED_KEY_OK + 1)) % 4; +} + +uint16_t ledGetRGBColor(LED_VECT * led) +{ + uint8_t r = (*led)[0] >> 3; + uint8_t g = (*led)[1] >> 2; + uint8_t b = (*led)[2] >> 3; + return ((r & 0x001F) << 11) | ((g & 0x003F) << 5) | ((b & 0x001F)); // RGB color in RGB 565 16 bit format +} + +uint16_t ledGetComponentRGBColor(uint8_t component, uint8_t index) +{ + LED_VECT led = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // component RGB color in RGB 565 16 bit format + + led[index] = component; + + return ledGetRGBColor(&led); +} + +static inline void ledDrawPageNumber(void) +{ + char tempstr[10]; + + sprintf(tempstr, "%d/%d", ledPage + 1, PAGE_NUM); + + drawStandardValue(&ledPageRect, VALUE_STRING, &tempstr, true, CTRL_FONT_COLOR, CTRL_BG_COLOR, 1, true); +} + +void ledDrawControl(uint8_t index, bool isFocused, bool drawFocus, bool drawAll) +{ + GUI_RECT rect, rect2; + uint16_t bgColorFocus; + uint8_t realIndex = ledGetComponentIndex(index); + uint8_t i = (LED_KEY_OK + 1) + index * 4; + uint8_t j = i + 1; + + rect = rect2 = ledKeyRect[i]; + + #ifdef KEYBOARD_ON_LEFT + rect.x0 = rect2.x1 = (rect.x0 + rect.x1) / 2; + #else + rect.x1 = rect2.x0 = (rect.x0 + rect.x1) / 2; + #endif + + bgColorFocus = isFocused ? KB_BORDER_COLOR : KB_BG_COLOR; + + // draw focus border + if (drawFocus) + drawBorder(&ledKeyRect[i], bgColorFocus, 2); + + // draw LED component string + drawStandardValue(&rect, VALUE_STRING, ledString[realIndex], true, KB_FONT_COLOR, bgColorFocus, 3, drawFocus); + + // draw LED component RGB color + drawStandardValue(&rect2, VALUE_NONE, NULL, true, KB_FONT_COLOR, ledGetComponentRGBColor(ledValue[realIndex], realIndex), 3, true); + + // draw LED component value + drawStandardValue(&ledKeyRect[j], VALUE_BYTE, &ledValue[realIndex], true, KB_FONT_COLOR, KB_BORDER_COLOR, 4, true); + + if (drawAll) + { + // draw LED component value area borders (outer) + drawBorder(&ledKeyRect[j], KB_BORDER_COLOR, 2); + + // draw LED component value area borders (inner) + drawBorder(&ledKeyRect[j], KB_BORDER_COLOR_2, 3); + + // draw buttons + drawStandardValue(&ledKeyRect[j + 1], VALUE_STRING, ledKeyString[LED_KEY_PREV], true, KB_FONT_COLOR, KB_BG_COLOR, 3, true); + drawStandardValue(&ledKeyRect[j + 2], VALUE_STRING, ledKeyString[LED_KEY_NEXT], true, KB_FONT_COLOR, KB_BG_COLOR, 3, true); + } +} + +void ledDrawButton(uint8_t index, uint8_t isPressed) +{ + if (index >= KEY_NUM) + return; + + if (isPressed) + { + if (index <= LED_KEY_NEXT) + drawStandardValue(&ledKeyRect[index], VALUE_STRING, ledKeyString[index], true, CTRL_BG_COLOR, CTRL_FONT_COLOR, 1, true); + else + drawBorder(&ledKeyRect[index], KB_FONT_COLOR, 1); + } + else + { + if (index <= LED_KEY_NEXT) + drawStandardValue(&ledKeyRect[index], VALUE_STRING, ledKeyString[index], true, CTRL_FONT_COLOR, CTRL_BG_COLOR, 1, true); + else + drawBorder(&ledKeyRect[index], KB_BG_COLOR, 1); + } +} + +void ledDrawKeyboard(void) +{ + // draw horizontal button borders + GUI_SetColor(KB_BORDER_COLOR); + + for (int i = 1; i < (KB_ROW_NUM); i++) + { + GUI_HLine(0, (i * KB_HEIGHT), LCD_WIDTH); + } + + // draw LED component RGB colors, values and buttons + GUI_SetTextMode(GUI_TEXTMODE_TRANS); + + for (uint8_t i = 0; i < KEY_NUM; i++) + { + if (i <= LED_KEY_NEXT) // if control bar key + { + ledDrawButton(i, false); + } + else if (i > LED_KEY_OK) // if not unicode string + { + if (ledGetControlSubIndex(i) == 0) + ledDrawControl(ledGetControlIndex(i), false, true, true); + } + } + + // draw unicode string + DrawCharIcon(&ledKeyRect[LED_KEY_RESET], MIDDLE, ICONCHAR_RESET, false, 0); + DrawCharIcon(&ledKeyRect[LED_KEY_CANCEL], MIDDLE, ICONCHAR_CANCEL, false, 0); + DrawCharIcon(&ledKeyRect[LED_KEY_OK], MIDDLE, ICONCHAR_OK, false, 0); + + // draw focus for current LED component + ledDrawControl(ledIndex, true, true, false); + + // draw RGB color + drawStandardValue(&ledColorRect, VALUE_NONE, NULL, true, KB_FONT_COLOR, ledGetRGBColor(&ledValue), 3, true); + + // draw page number + ledDrawPageNumber(); + + // restore default + GUI_RestoreColorDefault(); +} + +void ledDrawMenu(void) +{ + setMenu(MENU_TYPE_FULLSCREEN, NULL, COUNT(ledKeyRect), ledKeyRect, ledDrawButton, &ledDrawMenu); + + // clear keyboard area + GUI_SetBkColor(KB_BG_COLOR); + GUI_ClearPrect(&ledAreaRect[0]); + + // clear control bar area + GUI_SetBkColor(CTRL_BG_COLOR); + GUI_ClearPrect(&ledAreaRect[1]); + + // draw control bar area shadow border + GUI_SetColor(CTRL_BORDER_COLOR); + GUI_HLine(ledAreaRect[1].x0, ledAreaRect[1].y0, ledAreaRect[1].x1); // first row of control bar used for shadow border + + // draw RGB color border + drawBorder(&ledColorRect, KB_BORDER_COLOR, 2); + + // draw keyboard + ledDrawKeyboard(); +} + +void menuLEDColorCustom(void) +{ + LED_KEY_VALUES key_num = LED_KEY_IDLE; + LED_VECT origLedValue; + uint8_t newIndex; + uint16_t newValue, curValue; + bool updateForced, sendingNeeded; + + ledGetValue(&origLedValue); // get initial LED color components vector + newIndex = ledIndex; + newValue = curValue = ledGetComponentValue(newIndex); + updateForced = sendingNeeded = false; + + ledDrawMenu(); + + #if LCD_ENCODER_SUPPORT + encoderPosition = 0; + #endif + + while (infoMenu.menu[infoMenu.cur] == menuLEDColorCustom) + { + key_num = menuKeyGetValue(); + switch (key_num) + { + // previous page + case LED_KEY_PREV: + if (ledPage > 0) + { + ledPage--; + + updateForced = true; + } + break; + + // next page + case LED_KEY_NEXT: + if (ledPage < (PAGE_NUM - 1)) + { + ledPage++; + + updateForced = true; + } + break; + + // apply new LED color and exit + case LED_KEY_OK: + ledGetValue(&origLedValue); + // no break here + + // restore original LED color and exit + case LED_KEY_CANCEL: + infoMenu.cur--; + // no break here + + // restore original LED color + case LED_KEY_RESET: + ledSetValue(&origLedValue, false); + + updateForced = true; + break; + + // use rotary encoder to update LED component value + case LED_KEY_IDLE: + #if LCD_ENCODER_SUPPORT + if (encoderPosition) + { + curValue = ledUpdateComponentValue(ledIndex, 1, (encoderPosition > 0) ? 1 : -1); + + encoderPosition = 0; + } + #endif + break; + + default: + ledIndex = ledGetControlIndex(key_num); // get control index + + switch (ledGetControlSubIndex(key_num)) // get control sub index + { + case 1: + { + curValue = ledEditComponentValue(ledIndex); + + sendingNeeded = true; + + ledDrawMenu(); + break; + } + + // decrease LED component value + case 2: + curValue = ledUpdateComponentValue(ledIndex, 1, -1); + break; + + // increase LED component value + case 3: + curValue = ledUpdateComponentValue(ledIndex, 1, 1); + break; + + default: + break; + } + break; + } + + if (updateForced) + ledDrawKeyboard(); // draw all + + if (newIndex != ledIndex) + { + ledDrawControl(newIndex, false, true, false); // drop focus and draw LED component value + ledDrawControl(ledIndex, true, true, false); // get focus and draw LED component value + + newIndex = ledIndex; + newValue = curValue = ledGetComponentValue(newIndex); // always load the value for the new index + } + + if (newValue != curValue) + { + ledDrawControl(ledIndex, newIndex == ledIndex, false, false); // draw changed LED component value + drawStandardValue(&ledColorRect, VALUE_NONE, NULL, true, KB_FONT_COLOR, ledGetRGBColor(&ledValue), 3, true); // draw RGB color + + newValue = curValue; + sendingNeeded = true; + } + + if ((sendingNeeded && nextScreenUpdate(LED_UPDATE_TIME)) || updateForced) + { + ledSendValue(&ledValue); + + updateForced = sendingNeeded = false; + } + + loopProcess(); + } + + // restore default + GUI_RestoreColorDefault(); +} + +const MENUITEMS LEDColorItems = { + // title + LABEL_RGB_SETTINGS, + // icon label + { + {ICON_RGB_RED, LABEL_RED}, + {ICON_RGB_GREEN, LABEL_GREEN}, + {ICON_RGB_BLUE, LABEL_BLUE}, + {ICON_RGB_WHITE, LABEL_WHITE}, + {ICON_CUSTOM, LABEL_CUSTOM}, + {ICON_RGB_WHITE, LABEL_ON}, + {ICON_RGB_OFF, LABEL_OFF}, + {ICON_BACK, LABEL_BACK}, + } +}; + +void menuLEDColor(void) +{ + KEY_VALUES key_num = KEY_IDLE; + + menuDrawPage(&LEDColorItems); + + while (infoMenu.menu[infoMenu.cur] == menuLEDColor) + { + key_num = menuKeyGetValue(); + switch (key_num) + { + // red + case KEY_ICON_0: + ledSetValue(&ledRed, true); + break; + + // green + case KEY_ICON_1: + ledSetValue(&ledGreen, true); + break; + + // blue + case KEY_ICON_2: + ledSetValue(&ledBlue, true); + break; + + // white + case KEY_ICON_3: + ledSetValue(&ledWhite, true); + break; + + // custom LED color + case KEY_ICON_4: + infoMenu.menu[++infoMenu.cur] = menuLEDColorCustom; + break; + + // turn off + case KEY_ICON_6: + ledSendValue(&ledOff); + break; + + case KEY_ICON_7: + infoMenu.cur--; + break; + + default: + break; + } + + if (key_num <= KEY_ICON_5) // change LED color + ledSendValue(&ledValue); + + loopProcess(); + } +} diff --git a/TFT/src/User/Menu/LEDColor.h b/TFT/src/User/Menu/LEDColor.h new file mode 100644 index 0000000000..2cfcad1c94 --- /dev/null +++ b/TFT/src/User/Menu/LEDColor.h @@ -0,0 +1,14 @@ +#ifndef _LED_COLOR_H_ +#define _LED_COLOR_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +void menuLEDColor(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/TFT/src/User/Menu/LevelCorner.h b/TFT/src/User/Menu/LevelCorner.h index b26a6e6955..1f2c846975 100644 --- a/TFT/src/User/Menu/LevelCorner.h +++ b/TFT/src/User/Menu/LevelCorner.h @@ -1,11 +1,12 @@ #ifndef _LEVEL_CORNER_H_ #define _LEVEL_CORNER_H_ -#include #ifdef __cplusplus extern "C" { #endif +#include + void SetLevelCornerPosition(uint8_t point, float position); void menuLevelCorner(void); diff --git a/TFT/src/User/Menu/MachineSettings.c b/TFT/src/User/Menu/MachineSettings.c index 578ccfeba0..67d6cd6798 100644 --- a/TFT/src/User/Menu/MachineSettings.c +++ b/TFT/src/User/Menu/MachineSettings.c @@ -126,65 +126,6 @@ void menuCustom(void) } } -void menuRGBSettings(void) -{ - MENUITEMS RGBItems = { - // title - LABEL_RGB_SETTINGS, - // icon label - { - {ICON_RGB_RED, LABEL_RED}, - {ICON_RGB_GREEN, LABEL_GREEN}, - {ICON_RGB_BLUE, LABEL_BLUE}, - {ICON_RGB_WHITE, LABEL_WHITE}, - {ICON_RGB_OFF, LABEL_OFF}, - {ICON_BACKGROUND, LABEL_BACKGROUND}, - {ICON_BACKGROUND, LABEL_BACKGROUND}, - {ICON_BACK, LABEL_BACK}, - } - }; - - KEY_VALUES key_num = KEY_IDLE; - - menuDrawPage(&RGBItems); - - while (infoMenu.menu[infoMenu.cur] == menuRGBSettings) - { - key_num = menuKeyGetValue(); - switch (key_num) - { - case KEY_ICON_0: //Red - storeCmd("M150 R255 U0 B0 P255\n"); - break; - - case KEY_ICON_1: //Green - storeCmd("M150 R0 U255 B0 P255\n"); - break; - - case KEY_ICON_2: //Blue - storeCmd("M150 R0 U0 B255 P255\n"); - break; - - case KEY_ICON_3: //White - storeCmd("M150 R255 U255 B255 P255\n"); - break; - - case KEY_ICON_4: //Turn Off - storeCmd("M150 R0 U0 B0 P0\n"); - break; - - case KEY_ICON_7: - infoMenu.cur--; - break; - - default: - break; - } - - loopProcess(); - } -} - #ifdef QUICK_EEPROM_BUTTON void menuEepromSettings(void) @@ -304,7 +245,7 @@ void menuMachineSettings(void) break; case KEY_ICON_3: - infoMenu.menu[++infoMenu.cur] = menuRGBSettings; + infoMenu.menu[++infoMenu.cur] = menuLEDColor; break; case KEY_ICON_4: diff --git a/TFT/src/User/Menu/MeshEditor.c b/TFT/src/User/Menu/MeshEditor.c index 7431c6eaef..226db26423 100644 --- a/TFT/src/User/Menu/MeshEditor.c +++ b/TFT/src/User/Menu/MeshEditor.c @@ -1,17 +1,14 @@ #include "MeshEditor.h" #include "includes.h" +// value ranges #define MESH_GRID_SIZE (MESH_GRID_MAX_POINTS_X * MESH_GRID_MAX_POINTS_Y) #define MESH_MAX_PARSED_ROWS 30 // maximum number of data rows to parse for retrieving the mesh // grid from the "M420 T1 V1" command output provided by the Marlin FW #define MESH_MAX_RETRIEVE_ATTEMPTS 20 // maximum number of attempts to retrieve the data format from Marlin FW #define MESH_LINE_EDGE_DISTANCE 4 -// colors -#define VALUE_FONT_COLOR infoSettings.font_color -#define VALUE_BG_COLOR infoSettings.list_button_color -#define VALUE_BORDER_COLOR 0x4b0d - +// data structures typedef struct { const uint8_t colsToSkip; @@ -69,38 +66,6 @@ typedef struct char saveTitle[120]; } MESH_DATA; -#define MESH_GRID_HEIGHT (LCD_HEIGHT - ICON_START_Y) -#define MESH_GRID_WIDTH MESH_GRID_HEIGHT -#define MESH_POINT_MIN_RATIO 3.0f -#define MESH_POINT_MED_RATIO 5.0f -#define MESH_POINT_MAX_RATIO 8.0f - -#define MESH_INFO_ROW_NUM 1 -#define MESH_INFO_COL_NUM 3 -#define MESH_INFO_HEIGHT (ICON_START_Y / MESH_INFO_ROW_NUM) -#define MESH_INFO_WIDTH (MESH_GRID_WIDTH / MESH_INFO_COL_NUM) - -#define MESH_KEY_ROW_NUM 6 -#define MESH_KEY_COL_NUM 2 -#define MESH_KEY_HEIGHT (LCD_HEIGHT / MESH_KEY_ROW_NUM) -#define MESH_KEY_WIDTH (LCD_WIDTH - MESH_GRID_WIDTH) / MESH_KEY_COL_NUM - -#ifdef MESH_LEFT_KEYBOARD - #define MESH_GRID_X0 (LCD_WIDTH - MESH_GRID_WIDTH) - #define MESH_GRID_Y0 ICON_START_Y - #define MESH_INFO_X0 (LCD_WIDTH - MESH_GRID_WIDTH) - #define MESH_INFO_Y0 0 - #define MESH_KEY_X0 0 - #define MESH_KEY_Y0 0 -#else - #define MESH_GRID_X0 0 - #define MESH_GRID_Y0 ICON_START_Y - #define MESH_INFO_X0 0 - #define MESH_INFO_Y0 0 - #define MESH_KEY_X0 MESH_GRID_WIDTH - #define MESH_KEY_Y0 0 -#endif - typedef enum { ME_INFO_MIN = 0, @@ -135,10 +100,49 @@ typedef enum ME_AREA_IDLE = IDLE_TOUCH, } MESH_AREA_VALUES; +// colors +#define MESH_FONT_COLOR infoSettings.font_color +#define MESH_BG_COLOR infoSettings.bg_color +#define MESH_BORDER_COLOR infoSettings.list_border_color +#define MESH_BORDER_COLOR_2 0x4b0d + +// layout sizes +#define MESH_GRID_HEIGHT (LCD_HEIGHT - ICON_START_Y) +#define MESH_GRID_WIDTH MESH_GRID_HEIGHT +#define MESH_POINT_MIN_RATIO 3.0f +#define MESH_POINT_MED_RATIO 5.0f +#define MESH_POINT_MAX_RATIO 8.0f + +#define MESH_INFO_ROW_NUM 1 +#define MESH_INFO_COL_NUM 3 +#define MESH_INFO_HEIGHT (ICON_START_Y / MESH_INFO_ROW_NUM) +#define MESH_INFO_WIDTH (MESH_GRID_WIDTH / MESH_INFO_COL_NUM) + +#define MESH_KEY_ROW_NUM 6 +#define MESH_KEY_COL_NUM 2 +#define MESH_KEY_HEIGHT (LCD_HEIGHT / MESH_KEY_ROW_NUM) +#define MESH_KEY_WIDTH (LCD_WIDTH - MESH_GRID_WIDTH) / MESH_KEY_COL_NUM + +#ifdef KEYBOARD_ON_LEFT + #define MESH_GRID_X0 (LCD_WIDTH - MESH_GRID_WIDTH) + #define MESH_GRID_Y0 ICON_START_Y + #define MESH_INFO_X0 (LCD_WIDTH - MESH_GRID_WIDTH) + #define MESH_INFO_Y0 0 + #define MESH_KEY_X0 0 + #define MESH_KEY_Y0 0 +#else + #define MESH_GRID_X0 0 + #define MESH_GRID_Y0 ICON_START_Y + #define MESH_INFO_X0 0 + #define MESH_INFO_Y0 0 + #define MESH_KEY_X0 MESH_GRID_WIDTH + #define MESH_KEY_Y0 0 +#endif + const GUI_RECT meshGridRect = {MESH_GRID_X0, MESH_GRID_Y0, MESH_GRID_X0 + MESH_GRID_WIDTH, MESH_GRID_Y0 + MESH_GRID_HEIGHT}; const GUI_RECT meshInfoRect[ME_INFO_NUM] = { -#ifdef MESH_LEFT_KEYBOARD +#ifdef KEYBOARD_ON_LEFT {MESH_INFO_X0 + 1 * MESH_INFO_WIDTH, MESH_INFO_Y0 + 0 * MESH_INFO_HEIGHT, MESH_INFO_X0 + 2 * MESH_INFO_WIDTH, MESH_INFO_Y0 + 1 * MESH_INFO_HEIGHT},// min value {MESH_INFO_X0 + 2 * MESH_INFO_WIDTH, MESH_INFO_Y0 + 0 * MESH_INFO_HEIGHT, MESH_INFO_X0 + 3 * MESH_INFO_WIDTH, MESH_INFO_Y0 + 1 * MESH_INFO_HEIGHT},// max value {MESH_INFO_X0 + 0 * MESH_INFO_WIDTH, MESH_INFO_Y0 + 0 * MESH_INFO_HEIGHT, MESH_INFO_X0 + 1 * MESH_INFO_WIDTH, MESH_INFO_Y0 + 1 * MESH_INFO_HEIGHT},// original value @@ -151,7 +155,7 @@ const GUI_RECT meshInfoRect[ME_INFO_NUM] = { }; const GUI_RECT meshKeyRect[ME_KEY_NUM] = { -#ifdef MESH_LEFT_KEYBOARD +#ifdef KEYBOARD_ON_LEFT {MESH_KEY_X0 + 1 * MESH_KEY_WIDTH, MESH_KEY_Y0 + 0 * MESH_KEY_HEIGHT, MESH_KEY_X0 + 2 * MESH_KEY_WIDTH, MESH_KEY_Y0 + 1 * MESH_KEY_HEIGHT}, // SAVE {MESH_KEY_X0 + 0 * MESH_KEY_WIDTH, MESH_KEY_Y0 + 0 * MESH_KEY_HEIGHT, MESH_KEY_X0 + 1 * MESH_KEY_WIDTH, MESH_KEY_Y0 + 1 * MESH_KEY_HEIGHT}, // OK {MESH_KEY_X0 + 1 * MESH_KEY_WIDTH, MESH_KEY_Y0 + 1 * MESH_KEY_HEIGHT, MESH_KEY_X0 + 2 * MESH_KEY_WIDTH, MESH_KEY_Y0 + 2 * MESH_KEY_HEIGHT}, // RESET @@ -533,7 +537,7 @@ void meshDrawGridCell(uint16_t index, uint16_t edgeDistance, bool clearBgColor) GUI_ClearRect(meshGridRect.x0 + col * cellWidth + 1, meshGridRect.y0 + row * cellHeight + 1, meshGridRect.x0 + (col + 1) * cellWidth - 1, meshGridRect.y0 + (row + 1) * cellHeight - 1); - GUI_SetColor(infoSettings.list_border_color); + GUI_SetColor(MESH_BORDER_COLOR); GUI_DrawLine(meshGridRect.x0 + col * cellWidth + edgeDistance, meshGridRect.y0 + row * cellHeight + cellHeight / 2, meshGridRect.x0 + (col + 1) * cellWidth - edgeDistance, meshGridRect.y0 + row * cellHeight + cellHeight / 2); @@ -545,14 +549,14 @@ void meshDrawGridCell(uint16_t index, uint16_t edgeDistance, bool clearBgColor) GUI_FillCircle(meshGridRect.x0 + col * cellWidth + cellWidth / 2, meshGridRect.y0 + row * cellHeight + cellHeight / 2, radius); - GUI_SetColor(infoSettings.font_color); + GUI_SetColor(MESH_FONT_COLOR); } void meshDrawGrid(void) { meshFullUpdateValueMinMax(); - GUI_ClearRect(meshGridRect.x0 + 1, meshGridRect.y0 + 1, meshGridRect.x1 - 1, meshGridRect.y1 - 1); + drawBackground(&meshGridRect, MESH_BG_COLOR, 1); uint16_t size = meshGetSize(); for (uint16_t i = 0; i < size; i++) @@ -561,42 +565,16 @@ void meshDrawGrid(void) } } -void meshDrawInfoCell(const GUI_RECT *rect, float *val, bool largeFont, uint16_t color, uint16_t bgColor, uint16_t edgeDistance, bool clearBgColor) -{ - uint16_t origBgColor = GUI_GetBkColor(); - - if (val != NULL || clearBgColor) - { - GUI_SetBkColor(bgColor); - GUI_ClearRect(rect->x0 + edgeDistance, rect->y0 + edgeDistance, rect->x1 - edgeDistance, rect->y1 - edgeDistance); - } - - if (val != NULL) - { - char tempstr[20]; - - sprintf(tempstr, "%.3f", *val); - - GUI_SetColor(color); - setLargeFont(largeFont); - GUI_DispStringInPrect(rect, (uint8_t *) tempstr); - setLargeFont(false); - } - - GUI_SetColor(infoSettings.font_color); - GUI_SetBkColor(origBgColor); -} - void meshDrawInfo(float *minVal, float *maxVal, float *origVal, float *curVal) { if (minVal != NULL) - meshDrawInfoCell(&meshInfoRect[ME_INFO_MIN], minVal, false, meshGetRGBColor(*minVal), infoSettings.bg_color, 1, false); + drawStandardValue(&meshInfoRect[ME_INFO_MIN], VALUE_FLOAT, minVal, false, meshGetRGBColor(*minVal), MESH_BG_COLOR, 1, true); if (maxVal != NULL) - meshDrawInfoCell(&meshInfoRect[ME_INFO_MAX], maxVal, false, meshGetRGBColor(*maxVal), infoSettings.bg_color, 1, false); + drawStandardValue(&meshInfoRect[ME_INFO_MAX], VALUE_FLOAT, maxVal, false, meshGetRGBColor(*maxVal), MESH_BG_COLOR, 1, true); - meshDrawInfoCell(&meshInfoRect[ME_INFO_ORIG], origVal, false, infoSettings.font_color, infoSettings.bg_color, 1, false); - meshDrawInfoCell(&meshInfoRect[ME_INFO_CUR], curVal, true, VALUE_FONT_COLOR, VALUE_BG_COLOR, 2, false); + drawStandardValue(&meshInfoRect[ME_INFO_ORIG], VALUE_FLOAT, origVal, false, MESH_FONT_COLOR, MESH_BG_COLOR, 1, true); + drawStandardValue(&meshInfoRect[ME_INFO_CUR], VALUE_FLOAT, curVal, true, MESH_FONT_COLOR, MESH_BORDER_COLOR, 4, true); } void meshDrawFullInfo(void) @@ -609,46 +587,46 @@ void meshDrawFullInfo(void) meshDrawInfo(&minValue, &maxValue, &origValue, &curValue); } -void meshKeyPress(uint8_t index, uint8_t isPressed) +void meshDrawButton(uint8_t index, uint8_t isPressed) { if (index >= ME_KEY_NUM) return; + uint16_t color; + if (isPressed) { if (index != ME_KEY_EDIT) - GUI_SetColor(infoSettings.list_border_color); + color = MESH_BORDER_COLOR; else - GUI_SetColor(VALUE_FONT_COLOR); + color = MESH_FONT_COLOR; } else { if (index != ME_KEY_EDIT) - GUI_SetColor(infoSettings.bg_color); + color = MESH_BG_COLOR; else - GUI_SetColor(VALUE_BG_COLOR); + color = MESH_BORDER_COLOR; } - GUI_DrawRect(meshKeyRect[index].x0 + 2, meshKeyRect[index].y0 + 2, meshKeyRect[index].x1 - 2, meshKeyRect[index].y1 - 2); + drawBorder(&meshKeyRect[index], color, 1); // restore default font color - GUI_SetColor(infoSettings.font_color); + GUI_SetColor(MESH_FONT_COLOR); } void meshDrawKeyboard(void) { - TSC_ReDrawIcon = meshKeyPress; - - setLargeFont(true); - + // draw buttons GUI_SetTextMode(GUI_TEXTMODE_TRANS); for (uint8_t i = 0; i < ME_KEY_NUM; i++) { - if (!(i == ME_KEY_SAVE || i == ME_KEY_OK || i == ME_KEY_RESET || i == ME_KEY_HOME)) // if not a unicode string - GUI_DispStringInPrect(&meshKeyRect[i], (uint8_t *) meshKeyString[i]); + if (i > ME_KEY_EDIT) // if not a unicode string + drawStandardValue(&meshKeyRect[i], VALUE_STRING, meshKeyString[i], true, MESH_FONT_COLOR, MESH_BG_COLOR, 3, true); } + // draw unicode string if (infoMachineSettings.EEPROM == 1) DrawCharIcon(&meshKeyRect[ME_KEY_SAVE], MIDDLE, ICONCHAR_SAVE, false, 0); @@ -656,17 +634,18 @@ void meshDrawKeyboard(void) DrawCharIcon(&meshKeyRect[ME_KEY_RESET], MIDDLE, ICONCHAR_RESET, false, 0); DrawCharIcon(&meshKeyRect[ME_KEY_HOME], MIDDLE, ICONCHAR_MOVE, false, 0); + // restore default GUI_RestoreColorDefault(); - - setLargeFont(false); } void meshDrawMenu(void) { + setMenu(MENU_TYPE_FULLSCREEN, NULL, COUNT(meshKeyRect), meshKeyRect, meshDrawButton, &meshDrawMenu); + // clear screen - GUI_Clear(infoSettings.bg_color); + GUI_Clear(MESH_BG_COLOR); - GUI_SetColor(infoSettings.list_border_color); + GUI_SetColor(MESH_BORDER_COLOR); // draw area borders GUI_DrawPrect(&meshAreaRect[ME_AREA_GRID]); // draw grid area borders @@ -674,16 +653,13 @@ void meshDrawMenu(void) GUI_DrawPrect(&meshAreaRect[ME_AREA_KEY]); // draw key borders // draw value area borders (outer) - GUI_DrawRect(meshInfoRect[ME_INFO_CUR].x0, meshInfoRect[ME_INFO_CUR].y0, - meshInfoRect[ME_INFO_CUR].x1, meshInfoRect[ME_INFO_CUR].y1); - - GUI_SetColor(VALUE_BORDER_COLOR); + drawBorder(&meshInfoRect[ME_INFO_CUR], MESH_BORDER_COLOR, 2); // draw value area borders (inner) - GUI_DrawRect(meshInfoRect[ME_INFO_CUR].x0 + 1, meshInfoRect[ME_INFO_CUR].y0 + 1, - meshInfoRect[ME_INFO_CUR].x1 - 1, meshInfoRect[ME_INFO_CUR].y1 - 1); + drawBorder(&meshInfoRect[ME_INFO_CUR], MESH_BORDER_COLOR_2, 3); - GUI_SetColor(infoSettings.font_color); + // restore default font color + GUI_SetColor(MESH_FONT_COLOR); // draw grid and keyboard meshDrawGrid(); @@ -885,7 +861,6 @@ void menuMeshEditor(void) mustStoreCmd("M420 V1 T1\n"); // retrieve the mesh data - setMenu(MENU_TYPE_FULLSCREEN, NULL, COUNT(meshKeyRect), meshKeyRect, meshKeyPress, &meshDrawMenu); meshDrawMenu(); #if LCD_ENCODER_SUPPORT @@ -930,7 +905,6 @@ void menuMeshEditor(void) curValue = menuMeshTuner(meshGetCol(), meshGetJ(), meshGetValue(meshGetIndex())); meshSetValue(curValue); - setMenu(MENU_TYPE_FULLSCREEN, NULL, COUNT(meshKeyRect), meshKeyRect, meshKeyPress, &meshDrawMenu); meshDrawMenu(); } break; @@ -1008,4 +982,7 @@ void menuMeshEditor(void) meshDeallocData(); // deallocate mesh data } + + // restore default + GUI_RestoreColorDefault(); } diff --git a/TFT/src/User/Menu/ScreenSettings.c b/TFT/src/User/Menu/ScreenSettings.c index 173e61316d..ac38c44970 100644 --- a/TFT/src/User/Menu/ScreenSettings.c +++ b/TFT/src/User/Menu/ScreenSettings.c @@ -122,7 +122,7 @@ void menuEmulatorBGColor(void) totalItems[i].titlelabel = lcd_color_names[i]; } - listWidgetCreate(title, totalItems, COUNT(totalItems), cur_item/ LISTITEM_PER_PAGE); + listWidgetCreate(title, totalItems, COUNT(totalItems), cur_item / LISTITEM_PER_PAGE); while (infoMenu.menu[infoMenu.cur] == menuEmulatorBGColor) { diff --git a/TFT/src/User/Menu/Terminal.c b/TFT/src/User/Menu/Terminal.c index e968e272d2..a7c5e303dd 100644 --- a/TFT/src/User/Menu/Terminal.c +++ b/TFT/src/User/Menu/Terminal.c @@ -32,8 +32,7 @@ typedef enum typedef enum { - TERM_PAGE_NUMBER = 0, - TERM_PAGE_UP, + TERM_PAGE_UP = 0, TERM_PAGE_DOWN, TERM_TOGGLE_ACK, TERM_BACK, @@ -100,13 +99,13 @@ typedef enum #define CTRL_COL_COUNT 4 // control button count for keyboard view // keyboard key sizes -#define KEY_WIDTH LCD_WIDTH / KB_COL_COUNT + 0.5 +#define KEY_WIDTH (LCD_WIDTH / KB_COL_COUNT + 0.5) #define KEY_HEIGHT ROW_HEIGHT #define KEY_COUNT (1 + (KB_COL_COUNT * KB_ROW_COUNT) + (CTRL_COL_COUNT)) // send + all keys + control bar keys // control bar sizes -#define CTRL_WIDTH (LCD_WIDTH / CTRL_COL_COUNT) // control bar button width in keyboard view -#define TERMINAL_CTRL_WIDTH (LCD_WIDTH / TERM_KEY_COUNT) // control bar button width in terminal view +#define CTRL_WIDTH (LCD_WIDTH / CTRL_COL_COUNT) // control bar button width in keyboard view +#define TERMINAL_CTRL_WIDTH (LCD_WIDTH / (TERM_KEY_COUNT + 1)) // control bar button width in terminal view + page textbox #define CTRL_HEIGHT ROW_HEIGHT // value textbox inset padding @@ -120,7 +119,7 @@ typedef enum #define CURSOR_H_OFFSET 2 #define CURSOR_END_Y ((KB_START_ROW + KB_ROW_COUNT) * KEY_HEIGHT) -// gcode.command draw area inside textbox +// gcode command draw area inside textbox const GUI_RECT textBoxRect = { 0 + TEXTBOX_INSET, (COMMAND_START_ROW + 0) * CTRL_HEIGHT + TEXTBOX_INSET, 3 * CTRL_WIDTH - TEXTBOX_INSET, (COMMAND_START_ROW + 1) * CTRL_HEIGHT - TEXTBOX_INSET}; @@ -234,13 +233,15 @@ const GUI_RECT editorAreaRect[3] = { }; const GUI_RECT terminalKeyRect[TERM_KEY_COUNT] = { - {0 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT - CTRL_HEIGHT, 1 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT}, // page number {1 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT - CTRL_HEIGHT, 2 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT}, // page down {2 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT - CTRL_HEIGHT, 3 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT}, // page up {3 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT - CTRL_HEIGHT, 4 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT}, // ACK {4 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT - CTRL_HEIGHT, 5 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT}, // Back }; +const GUI_RECT terminalPageRect = { + 0 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT - CTRL_HEIGHT, 1 * TERMINAL_CTRL_WIDTH, LCD_HEIGHT}; // page number + const GUI_RECT terminalAreaRect[2] = { {0, 0, LCD_WIDTH, CURSOR_END_Y}, // terminal area {0, CURSOR_END_Y, LCD_WIDTH, LCD_HEIGHT}, // control area @@ -309,10 +310,10 @@ const char * const gcodeKeyABC[KEY_COUNT] = { }; const uint16_t fontSrcColor[3][3] = { - // Gcode ACK Background - {COLORSCHEME1_TERM_GCODE, COLORSCHEME1_TERM_ACK, COLORSCHEME1_TERM_BACK}, // Material Dark - {COLORSCHEME2_TERM_GCODE, COLORSCHEME2_TERM_ACK, COLORSCHEME2_TERM_BACK}, // Material Light - {COLORSCHEME3_TERM_GCODE, COLORSCHEME3_TERM_ACK, COLORSCHEME3_TERM_BACK}, // High Contrast + // Gcode ACK Background + {COLORSCHEME1_TERM_GCODE, COLORSCHEME1_TERM_ACK, COLORSCHEME1_TERM_BACK}, // Material Dark + {COLORSCHEME2_TERM_GCODE, COLORSCHEME2_TERM_ACK, COLORSCHEME2_TERM_BACK}, // Material Light + {COLORSCHEME3_TERM_GCODE, COLORSCHEME3_TERM_ACK, COLORSCHEME3_TERM_BACK}, // High Contrast }; char * terminalBuf; @@ -344,14 +345,17 @@ static inline void keyboardDrawButton(uint8_t index, uint8_t isPressed) fontcolor = CTRL_FONT_COLOR; bgcolor = MAT_GREEN; break; + case GKEY_BACK: fontcolor = CTRL_FONT_COLOR; bgcolor = MAT_RED; break; + case GKEY_ABC_123: fontcolor = CTRL_FONT_COLOR; bgcolor = MAT_SLATE; break; + default: break; } @@ -367,62 +371,51 @@ static inline void keyboardDrawButton(uint8_t index, uint8_t isPressed) .radius = BTN_ROUND_CORNER, .rect = rectBtn}; - if (index != GKEY_SEND) - setLargeFont(true); - // draw button - GUI_DrawButton(&btn, isPressed); + if (index != GKEY_SEND) + setLargeFont(true); + // draw button + GUI_DrawButton(&btn, isPressed); + setLargeFont(false); #else // KEYBOARD_MATERIAL_THEME + uint16_t color; + uint16_t bgColor; + if (isPressed) { if (index > GKEY_BACK) { - GUI_SetColor(KEY_BG_COLOR); - GUI_SetBkColor(KEY_FONT_COLOR); + color = KEY_BG_COLOR; + bgColor = KEY_FONT_COLOR; } else { - GUI_SetColor(BAR_BG_COLOR); - GUI_SetBkColor(BAR_FONT_COLOR); + color = BAR_BG_COLOR; + bgColor = BAR_FONT_COLOR; } } else { if (index > GKEY_BACK) { - GUI_SetColor(KEY_FONT_COLOR); - GUI_SetBkColor(KEY_BG_COLOR); + color = KEY_FONT_COLOR; + bgColor = KEY_BG_COLOR; } else { - GUI_SetColor(BAR_FONT_COLOR); - GUI_SetBkColor(BAR_BG_COLOR); + color = BAR_FONT_COLOR; + bgColor = BAR_BG_COLOR; } } - if (index != GKEY_SEND) - setLargeFont(true); - - GUI_ClearRect(editorKeyRect[index].x0 + 1, editorKeyRect[index].y0 + 1, // skip border because used by button border - editorKeyRect[index].x1 - 1, editorKeyRect[index].y1 - 1); - - GUI_DispStringInRect(editorKeyRect[index].x0 + 1, editorKeyRect[index].y0 + 1, - editorKeyRect[index].x1 - 1, editorKeyRect[index].y1 - 1, - (uint8_t *)((numpad) ? gcodeKey123[index] : gcodeKeyABC[index])); - + drawStandardValue(&editorKeyRect[index], VALUE_STRING, (numpad) ? gcodeKey123[index] : gcodeKeyABC[index], + index != GKEY_SEND, color, bgColor, 1, true); #endif // KEYBOARD_MATERIAL_THEME - - setLargeFont(false); } static inline void drawGcodeText(char *gcode) { - GUI_SetColor(TEXTBOX_FONT_COLOR); - GUI_SetBkColor(TEXTBOX_BG_COLOR); - GUI_ClearRect(textBoxRect.x0 + 1, textBoxRect.y0 + 1, textBoxRect.x1 - 1, textBoxRect.y1 - 1); // skip border because used by shadow border - - if (gcode != NULL) - GUI_DispStringInRect(textBoxRect.x0 + 1, textBoxRect.y0 + 1, textBoxRect.x1 - 1, textBoxRect.y1 - 1, (uint8_t *)gcode); + drawStandardValue(&textBoxRect, VALUE_STRING, gcode, false, TEXTBOX_FONT_COLOR, TEXTBOX_BG_COLOR, 1, true); } static inline void drawKeyboard(void) @@ -474,6 +467,7 @@ static inline void keyboardDrawMenu(void) #endif GUI_SetTextMode(GUI_TEXTMODE_TRANS); + // draw keyboard and gcode value drawKeyboard(); drawGcodeText(NULL); @@ -547,8 +541,11 @@ static inline void menuKeyboardView(void) lastIndex = nowIndex; drawGcodeText(gcodeBuf); } + loopBackEnd(); } + + // restore default GUI_RestoreColorDefault(); } @@ -623,10 +620,10 @@ TERMINAL_SRC getLastSrc(char * ptr) static inline void terminalDrawButton(uint8_t index, uint8_t isPressed) { - if (index >= TERM_KEY_COUNT || index == 0) + if (index >= TERM_KEY_COUNT) return; - const char * terminalKey[] = { "1/1", "<", ">", (char *)textSelect(itemToggle[infoSettings.terminalACK].index), "Back"}; + const char * terminalKey[] = {"<", ">", (char *)textSelect(itemToggle[infoSettings.terminalACK].index), "Back"}; #ifdef KEYBOARD_MATERIAL_THEME uint16_t fontcolor = KEY_FONT_COLOR; @@ -650,51 +647,37 @@ static inline void terminalDrawButton(uint8_t index, uint8_t isPressed) .pLineColor = fontcolor, .radius = BTN_ROUND_CORNER, .rect = rectBtn}; - #else - - if (isPressed) - { - GUI_SetColor(BAR_BG_COLOR); - GUI_SetBkColor(BAR_FONT_COLOR); - } - else - { - GUI_SetColor(BAR_FONT_COLOR); - GUI_SetBkColor(BAR_BG_COLOR); - } - #endif // KEYBOARD_MATERIAL_THEME - setLargeFont(true); - - #ifdef KEYBOARD_MATERIAL_THEME + setLargeFont(true); GUI_DrawButton(&btn, isPressed); + setLargeFont(false); #else - GUI_ClearRect(terminalKeyRect[index].x0, terminalKeyRect[index].y0 + 1, // skip first row because used by shadow border - terminalKeyRect[index].x1, terminalKeyRect[index].y1 - 1); - GUI_DispStringInRect(terminalKeyRect[index].x0, terminalKeyRect[index].y0 + 1, - terminalKeyRect[index].x1, terminalKeyRect[index].y1 - 1, - (uint8_t *)terminalKey[index]); - #endif + uint16_t color; + uint16_t bgColor; - setLargeFont(false); + if (isPressed) + { + color = BAR_BG_COLOR; + bgColor = BAR_FONT_COLOR; + } + else + { + color = BAR_FONT_COLOR; + bgColor = BAR_BG_COLOR; + } + + drawStandardValue(&terminalKeyRect[index], VALUE_STRING, terminalKey[index], true, color, bgColor, 1, true); + #endif // KEYBOARD_MATERIAL_THEME } static inline void terminalDrawPageNumber(void) { - GUI_SetBkColor(BAR_BG_COLOR); - GUI_ClearRect(terminalKeyRect[TERM_PAGE_NUMBER].x0, terminalKeyRect[TERM_PAGE_NUMBER].y0 + 1, // skip first row because used by shadow border - terminalKeyRect[TERM_PAGE_NUMBER].x1, terminalKeyRect[TERM_PAGE_NUMBER].y1); - char tempstr[10]; + sprintf(tempstr, "%d/%d", abs(((terminalData->pageTail - terminalData->pageHead) - terminalData->pageIndex) + 1), abs((terminalData->pageTail - terminalData->pageHead) + 1)); - GUI_SetColor(BAR_FONT_COLOR); - setLargeFont(true); - GUI_DispStringInRect(terminalKeyRect[TERM_PAGE_NUMBER].x0, terminalKeyRect[TERM_PAGE_NUMBER].y0 + 1, - terminalKeyRect[TERM_PAGE_NUMBER].x1, terminalKeyRect[TERM_PAGE_NUMBER].y1 - 1, - (uint8_t *)tempstr); - setLargeFont(false); + drawStandardValue(&terminalPageRect, VALUE_STRING, &tempstr, true, BAR_FONT_COLOR, BAR_BG_COLOR, 1, true); } static inline void terminalDrawMenu(void) @@ -863,6 +846,7 @@ void menuTerminalWindow(void) terminalData->oldPageIndex = 0; terminalData->lastSrc = (TERMINAL_ACK + 1); + // restore default GUI_RestoreColorDefault(); } diff --git a/TFT/src/User/Menu/common.c b/TFT/src/User/Menu/common.c index 3e4248e50d..656f96464d 100644 --- a/TFT/src/User/Menu/common.c +++ b/TFT/src/User/Menu/common.c @@ -111,6 +111,78 @@ bool nextScreenUpdate(uint32_t duration) } } +const void drawBorder(const GUI_RECT *rect, uint16_t color, uint16_t edgeDistance) +{ + //uint16_t origColor = GUI_GetColor(); + + GUI_SetColor(color); + GUI_DrawRect(rect->x0 + edgeDistance, rect->y0 + edgeDistance, + rect->x1 - edgeDistance, rect->y1 - edgeDistance); + + //GUI_SetColor(origColor); +} + +const void drawBackground(const GUI_RECT *rect, uint16_t bgColor, uint16_t edgeDistance) +{ + //uint16_t origBgColor = GUI_GetBkColor(); + + GUI_SetBkColor(bgColor); + GUI_ClearRect(rect->x0 + edgeDistance, rect->y0 + edgeDistance, + rect->x1 - edgeDistance, rect->y1 - edgeDistance); + + //GUI_SetBkColor(origBgColor); +} + +const void drawStandardValue(const GUI_RECT *rect, VALUE_TYPE valType, const void *val, bool largeFont, + uint16_t color, uint16_t bgColor, uint16_t edgeDistance, bool clearBgColor) +{ + uint16_t origColor = GUI_GetColor(); + uint16_t origBgColor = GUI_GetBkColor(); + + if (clearBgColor) + drawBackground(rect, bgColor, edgeDistance); + + if (val != NULL) + { + char tempstr[20] = "\0"; + const char * buf = tempstr; + + switch (valType) + { + case VALUE_BYTE: + sprintf(tempstr, "%d", *((uint8_t *) val)); + break; + + case VALUE_INT: + sprintf(tempstr, "%d", *((uint16_t *) val)); + break; + + case VALUE_FLOAT: + sprintf(tempstr, "%.3f", *((float *) val)); + break; + + case VALUE_STRING: + buf = val; + break; + + default: + break; + } + + GUI_SetColor(color); + GUI_SetBkColor(bgColor); + + setLargeFont(largeFont); + GUI_DispStringInRect(rect->x0 + edgeDistance, rect->y0 + edgeDistance, + rect->x1 - edgeDistance, rect->y1 - edgeDistance, + (uint8_t *) buf); + setLargeFont(false); + } + + GUI_SetColor(origColor); + GUI_SetBkColor(origBgColor); +} + const bool warmupTemperature(uint8_t toolIndex, void (* callback)(void)) { if (heatGetCurrentTemp(toolIndex) < infoSettings.min_ext_temp) diff --git a/TFT/src/User/Menu/common.h b/TFT/src/User/Menu/common.h index 6bb9d426f6..06b924270a 100644 --- a/TFT/src/User/Menu/common.h +++ b/TFT/src/User/Menu/common.h @@ -15,6 +15,15 @@ extern "C" { #define ITEM_EXT_LEN_NUM 5 #define ITEM_TOGGLE_NUM 2 +typedef enum +{ + VALUE_NONE = 0, + VALUE_BYTE, + VALUE_INT, + VALUE_FLOAT, + VALUE_STRING, +} VALUE_TYPE; + extern uint8_t currentTool; extern uint8_t currentFan; extern uint8_t currentSpeedID; @@ -39,6 +48,13 @@ extern const uint16_t iconToggle[ITEM_TOGGLE_NUM]; bool nextScreenUpdate(uint32_t duration); +extern const void drawBorder(const GUI_RECT *rect, uint16_t color, uint16_t edgeDistance); + +extern const void drawBackground(const GUI_RECT *rect, uint16_t bgColor, uint16_t edgeDistance); + +extern const void drawStandardValue(const GUI_RECT *rect, VALUE_TYPE valType, const void *val, bool largeFont, + uint16_t color, uint16_t bgColor, uint16_t edgeDistance, bool clearBgColor); + extern const bool warmupTemperature(uint8_t toolIndex, void (* callback)(void)); extern const void cooldownTemperature(void); diff --git a/TFT/src/User/config.ini b/TFT/src/User/config.ini index f7fd735d51..41de0617e4 100644 --- a/TFT/src/User/config.ini +++ b/TFT/src/User/config.ini @@ -122,7 +122,7 @@ mesh_min_color:7 ## Color used by the Mesh Editor menu for drawing the mesh with the maximum value in the grid mesh_max_color:2 -#### Terminal text Color Scheme +#### Terminal Text Color Scheme # Select as color scheme for displaying text in Teminal menu. # Options: [Material Dark: 0, Material Light: 1, High Contrast: 2] # Material Dark: Dark background with light font color and orange command font color. @@ -135,7 +135,7 @@ terminal_color_scheme:0 # Options: [enable: 1, disable: 0] rotate_ui:0 -#### Temperature ACK in Terminal +#### Temperature ACK In Terminal # Show or hide temperature ACK in Terminal menu. # Options: [show: 1, hide: 0] terminal_ack:0 @@ -301,21 +301,21 @@ fan_max:F0:255 F1:255 F2:255 F3:255 F4:255 F5:255 CtL:255 CtI:255 size_min:X0 Y0 Z0 size_max:X235 Y235 Z250 -#### Default X & Y Move Speeds/feedrates +#### Default X & Y Move Speeds/Feedrates # Move speeds used in move menu to move X and Y axes. # Format: [move_speed: S N F] # Unit: [feedrate in mm/min] # Value range: [min: 10, max: 12000] xy_speed:S1000 N3000 F5000 -#### Default Z Speeds/feedrates +#### Default Z Speeds/Feedrates # Move speeds used in move menu to move Z axis. # Format: [move_speed: S N F] # Unit: [feedrate in mm/min] # Value range: [min: 10, max: 12000] z_speed:S500 N1000 F2000 -#### Default Extruder Speeds/feedrates +#### Default Extruder Speeds/Feedrates # Speed settings used to extrude/retract. # Format: [ext_speed: S N F] # Unit: [feedrate in mm/min] @@ -588,7 +588,7 @@ knob_led_color:0 # Options: [true: 1, false: 0] knob_led_idle:1 -#### Knob LED pixels (only for TFT43 V3.0, TFT50 V3.0 & TFT70 V3.0) +#### Knob LED Pixels (only for TFT43 V3.0, TFT50 V3.0 & TFT70 V3.0) # Set the number of LEDs in the strip connected the "Neopixel" port of TFT. # It shares the same signal line as "knob_led". 0 means the default number in TFT hardware, # Greater than 0 means the number of LEDs in the strip. diff --git a/TFT/src/User/includes.h b/TFT/src/User/includes.h index f39d143c43..22efea9023 100644 --- a/TFT/src/User/includes.h +++ b/TFT/src/User/includes.h @@ -91,7 +91,7 @@ #include "Printing.h" #include "More.h" #include "Speed.h" -#include "ledcolor.h" +#include "LCD_LEDColor.h" #include "ParameterSettings.h" #include "NotificationMenu.h" @@ -129,6 +129,7 @@ #include "MeshEditor.h" #include "CaseLight.h" #include "MeshValid.h" +#include "LEDColor.h" #define MAX_MENU_DEPTH 10 // max sub menu depth typedef void (*FP_MENU)(void);