Skip to content

Commit

Permalink
resolves bigtreetech#1945
Browse files Browse the repository at this point in the history
  • Loading branch information
digant73 committed Jul 29, 2021
1 parent 6e7fd9e commit ff1e8ee
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 47 deletions.
15 changes: 10 additions & 5 deletions Copy to SD Card root directory to update/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@
#--------------------------------------------------------------------

#### Enable Status Screen
# Status screen or home screen displays the current temperature, fan and speeds.
# If this disabled, the main menu will become the default home screen.
# If enabled, the Status Screen menu will become the default home screen.
# If disabled, the Main menu will become the default home screen.
#
# NOTE: Both the Status Screen and Main menus display the current temperature, fan and speeds.
# Furthermore, the Status Screen menu provides the status area reporting the printer notifications.
#
# Options: [disable: 0, enable: 1]
status_screen:1

Expand Down Expand Up @@ -217,7 +221,7 @@ ack_notification:1
# stored on the notification screen. The notification screen reporting the history of the
# received notifications is displayed pressing on the notification bar.
#
# NOTE: Marlin notifications are also always displayed on the status screen.
# NOTE: Marlin notifications are also always displayed on the Status Screen menu.
# Furthermore, they are also displayed on the notification bar as toast messages
# in case the current menu is not the Status menu.
#
Expand Down Expand Up @@ -252,9 +256,10 @@ prog_disp_type:2
#### Default Mode
# Set Marlin/Touch mode as the default mode at startup.
#
# NOTE: Mode switching is still possible by holding down the encorder for two seconds.
# NOTE: Mode switching is possible only for Marlin Mode and Touch Mode by a long press of
# three seconds on the display or holding down the encorder button for two seconds.
#
# Options: [Marlin Mode: 0, Touch Mode: 1]
# Options: [Marlin Mode: 0, Touch Mode: 1, Blocked Marlin Mode: 2, Blocked Touch Mode: 3]
default_mode:1

#### Serial Always ON
Expand Down
15 changes: 10 additions & 5 deletions Copy to SD Card root directory to update/config_rrf.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@
#--------------------------------------------------------------------

#### Enable Status Screen
# Status screen or home screen displays the current temperature, fan and speeds.
# If this disabled, the main menu will become the default home screen.
# If enabled, the Status Screen menu will become the default home screen.
# If disabled, the Main menu will become the default home screen.
#
# NOTE: Both the Status Screen and Main menus display the current temperature, fan and speeds.
# Furthermore, the Status Screen menu provides the status area reporting the printer notifications.
#
# Options: [disable: 0, enable: 1]
status_screen:1

Expand Down Expand Up @@ -217,7 +221,7 @@ ack_notification:1
# stored on the notification screen. The notification screen reporting the history of the
# received notifications is displayed pressing on the notification bar.
#
# NOTE: Marlin notifications are also always displayed on the status screen.
# NOTE: Marlin notifications are also always displayed on the Status Screen menu.
# Furthermore, they are also displayed on the notification bar as toast messages
# in case the current menu is not the Status menu.
#
Expand Down Expand Up @@ -252,9 +256,10 @@ prog_disp_type:2
#### Default Mode
# Set Marlin/Touch mode as the default mode at startup.
#
# NOTE: Mode switching is still possible by holding down the encorder for two seconds.
# NOTE: Mode switching is possible only for Marlin Mode and Touch Mode by a long press of
# three seconds on the display or holding down the encorder button for two seconds.
#
# Options: [Marlin Mode: 0, Touch Mode: 1]
# Options: [Marlin Mode: 0, Touch Mode: 1, Blocked Marlin Mode: 2, Blocked Touch Mode: 3]
default_mode:1

#### Serial Always ON
Expand Down
2 changes: 2 additions & 0 deletions TFT/src/User/API/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef enum
#define LANGUAGE_CHECK_SIGN (LANGUAGE_FLASH_SIGN + LANGUAGE_ADDR + LABEL_NUM)
#define ICON_CHECK_SIGN (ICON_FLASH_SIGN + ICON_ADDR(0) + ICON_PREVIEW)

#define MAX_MODE_COUNT 4
#define MAX_EXT_COUNT 6
#define MAX_HOTEND_COUNT 6
#define MAX_HEATER_COUNT (2 + MAX_HOTEND_COUNT) // chamber + bed + hotend
Expand Down Expand Up @@ -81,6 +82,7 @@ typedef enum
{
LCD12864 = 0,
LCD2004,
MODE_TYPE_COUNT
} MARLIN_MODE_TYPE;

typedef struct
Expand Down
4 changes: 2 additions & 2 deletions TFT/src/User/API/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ void parseConfigKey(uint16_t index)
#ifdef HAS_EMULATOR

case C_INDEX_MODE:
SET_VALID_INT_VALUE(infoSettings.mode, 0, MODE_COUNT - 1);
SET_VALID_INT_VALUE(infoSettings.mode, 0, MAX_MODE_COUNT - 1);
break;

case C_INDEX_SERIAL_ON:
Expand Down Expand Up @@ -681,7 +681,7 @@ void parseConfigKey(uint16_t index)
}

case C_INDEX_MARLIN_TYPE:
SET_VALID_INT_VALUE(infoSettings.marlin_type, 0, MODE_COUNT - 1);
SET_VALID_INT_VALUE(infoSettings.marlin_type, 0, MODE_TYPE_COUNT - 1);
break;

#endif // ST7920_EMULATOR || LCD2004_EMULATOR
Expand Down
12 changes: 8 additions & 4 deletions TFT/src/User/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@

/**
* Enable Status Screen
* Status screen or home screen displays the current temperature, fan and speeds.
* If this disabled, the main menu will become the default home screen.
* If enabled, the Status Screen menu will become the default home screen.
* If disabled, the Main menu will become the default home screen.
*
* NOTE: Both the Status Screen and Main menus display the current temperature, fan and speeds.
* Furthermore, the Status Screen menu provides the status area reporting the printer notifications.
*
* Options: [disable: 0, enable: 1]
*/
Expand Down Expand Up @@ -95,9 +98,10 @@
* Default Mode
* Set Marlin/Touch mode as the default mode at startup.
*
* NOTE: Mode switching is still possible by holding down the encorder for two seconds.
* NOTE: Mode switching is possible only for Marlin Mode and Touch Mode by a long press of
* three seconds on the display or holding down the encorder button for two seconds.
*
* Options: [Marlin Mode: MODE_MARLIN, Touch Mode: MODE_SERIAL_TSC]
* Options: [Marlin Mode: 0, Touch Mode: 1, Blocked Marlin Mode: 2, Blocked Touch Mode: 3]
*/
#define DEFAULT_LCD_MODE MODE_SERIAL_TSC // Default: MODE_SERIAL_TSC

Expand Down
28 changes: 14 additions & 14 deletions TFT/src/User/Menu/Popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define POPUP_MAX_CHAR (X_MAX_CHAR * MAX_MSG_LINES)

static BUTTON bottomSingleBtn = {
//button location color before pressed color after pressed
// button location color before pressed color after pressed
POPUP_RECT_SINGLE_CONFIRM, NULL, 5, 1, DARKGREEN, DARKGREEN, MAT_LOWWHITE, DARKGREEN, WHITE, DARKGREEN
};

Expand All @@ -19,15 +19,15 @@ const GUI_RECT doubleBtnRect[] = {POPUP_RECT_DOUBLE_CONFIRM, POPUP_RECT_DOUBLE_C
static const GUI_RECT singleBtnRect = POPUP_RECT_SINGLE_CONFIRM;

static WINDOW window = {
DIALOG_TYPE_INFO, //default window type
POPUP_RECT_WINDOW, //rectangle position and size of popup window
POPUP_TITLE_HEIGHT, //height of title bar
POPUP_BOTTOM_HEIGHT, //height of action bar
2, //window border width
GRAY, //window border color
{DARKGRAY, MAT_LOWWHITE}, //Title bar font color / background color
{DARKGRAY, MAT_LOWWHITE}, //Message area font color / background color
{DARKGRAY, MAT_LOWWHITE}, //actionbar font color / background color
DIALOG_TYPE_INFO, // default window type
POPUP_RECT_WINDOW, // rectangle position and size of popup window
POPUP_TITLE_HEIGHT, // height of title bar
POPUP_BOTTOM_HEIGHT, // height of action bar
2, // window border width
GRAY, // window border color
{DARKGRAY, MAT_LOWWHITE}, // Title bar font color / background color
{DARKGRAY, MAT_LOWWHITE}, // Message area font color / background color
{DARKGRAY, MAT_LOWWHITE}, // actionbar font color / background color
};

static BUTTON *windowButton = NULL;
Expand Down Expand Up @@ -195,7 +195,7 @@ void _setDialogCancelTextLabel(int16_t index)
*/
void showDialog(DIALOG_TYPE type, void (*ok_action)(), void (*cancel_action)(), void (*loop_action)())
{
if (infoSettings.mode == MODE_MARLIN)
if ((infoSettings.mode % MODE_COUNT) == MODE_MARLIN) // if standard/blocked Marlin mode, then exit
return;

popup_redraw = true;
Expand All @@ -215,7 +215,7 @@ void loopPopup(void)

LCD_Wake();

//display the last received popup message, overriding previous popup messages, if any
// display the last received popup message, overriding previous popup messages, if any
if (popup_cancel[0])
{
popupDrawPage(popup_type, bottomDoubleBtn, popup_title, popup_msg, popup_ok, popup_cancel);
Expand All @@ -234,9 +234,9 @@ void loopPopup(void)
return;
}

//avoid to nest menuDialog popup type (while a menuNotification popup type can be overridden)
// avoid to nest menuDialog popup type (while a menuNotification popup type can be overridden)
if (infoMenu.menu[infoMenu.cur] != menuDialog)
{ //handle the user interaction, then reload the previous menu
{ // handle the user interaction, then reload the previous menu
infoMenu.menu[++infoMenu.cur] = menuDialog;
}
}
30 changes: 18 additions & 12 deletions TFT/src/User/Menu/SelectMode.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bool freshBoot = true;
bool skipMode = false;

const GUI_RECT rect_of_mode[MODE_COUNT] = {
//2 select icon
// 2 select icon
{1 * SPACE_SELEX + 0 * ICON_WIDTH, SPACE_SELEY, 1 * SPACE_SELEX + 1 * ICON_WIDTH, SPACE_SELEY + ICON_HEIGHT},
{3 * SPACE_SELEX + 1 * ICON_WIDTH, SPACE_SELEY, 3 * SPACE_SELEX + 2 * ICON_WIDTH, SPACE_SELEY + ICON_HEIGHT},
};
Expand Down Expand Up @@ -71,10 +71,10 @@ void drawSelectedMode(int8_t nowMode)
void loopCheckMode(void)
{
// #ifndef SERIAL_ALWAYS_ON
// IDEALLY I would like to be able to swap even when the TFT is in printing mode
// but before I can allow that I need a way to make sure that we swap back into
// the right mode (and correct screen) and I really want a reliable way to DETECT
// that the TFT should be in printing mode even when the print was started externally.
// IDEALLY I would like to be able to swap even when the TFT is in printing mode
// but before I can allow that I need a way to make sure that we swap back into
// the right mode (and correct screen) and I really want a reliable way to DETECT
// that the TFT should be in printing mode even when the print was started externally.
if (isPrinting() || infoHost.printing || skipMode)
return;

Expand All @@ -88,6 +88,10 @@ void loopCheckMode(void)
#endif
)
{
// NOTE: leave this check after LCD_ReadPen() to allow the Smart Home feature to work properly
if (infoSettings.mode >= MODE_COUNT) // if blocked mode, then exit
return;

infoMenu.menu[++infoMenu.cur] = menuMode;
}
}
Expand All @@ -104,10 +108,10 @@ void menuMode(void)

#if LCD_ENCODER_SUPPORT
while (!XPT2046_Read_Pen() || encoder_ReadBtn(LCD_BUTTON_INTERVALS))
; //wait for button release
; // wait for button release
#else
while (!XPT2046_Read_Pen())
; //wait for touch release
; // wait for touch release
#endif

#if LCD_ENCODER_SUPPORT
Expand Down Expand Up @@ -204,7 +208,7 @@ static inline void setupModeHardware(uint8_t mode)
#endif

#if !defined(MKS_TFT)
//causes hang if we deinit spi1
// causes hang if we deinit spi1
SD_DeInit();
#endif
}
Expand All @@ -213,15 +217,17 @@ static inline void setupModeHardware(uint8_t mode)
// Change UI Mode
void switchMode(void)
{
int8_t nowMode = infoSettings.mode % MODE_COUNT; // Marlin mode or Touch mode
infoMenu.cur = 0;
setupModeHardware(infoSettings.mode);

switch (infoSettings.mode)
setupModeHardware(nowMode);

switch (nowMode)
{
case MODE_SERIAL_TSC:
GUI_RestoreColorDefault();
if (infoSettings.status_screen == 1) //if Unified menu is selected
infoMenu.menu[infoMenu.cur] = menuStatus; //status screen as default screen on boot
if (infoSettings.status_screen == 1) // if Unified menu is selected
infoMenu.menu[infoMenu.cur] = menuStatus; // status screen as default screen on boot
else
infoMenu.menu[infoMenu.cur] = menuMain; // classic UI

Expand Down
15 changes: 10 additions & 5 deletions TFT/src/User/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@
#--------------------------------------------------------------------

#### Enable Status Screen
# Status screen or home screen displays the current temperature, fan and speeds.
# If this disabled, the main menu will become the default home screen.
# If enabled, the Status Screen menu will become the default home screen.
# If disabled, the Main menu will become the default home screen.
#
# NOTE: Both the Status Screen and Main menus display the current temperature, fan and speeds.
# Furthermore, the Status Screen menu provides the status area reporting the printer notifications.
#
# Options: [disable: 0, enable: 1]
status_screen:1

Expand Down Expand Up @@ -217,7 +221,7 @@ ack_notification:1
# stored on the notification screen. The notification screen reporting the history of the
# received notifications is displayed pressing on the notification bar.
#
# NOTE: Marlin notifications are also always displayed on the status screen.
# NOTE: Marlin notifications are also always displayed on the Status Screen menu.
# Furthermore, they are also displayed on the notification bar as toast messages
# in case the current menu is not the Status menu.
#
Expand Down Expand Up @@ -252,9 +256,10 @@ prog_disp_type:2
#### Default Mode
# Set Marlin/Touch mode as the default mode at startup.
#
# NOTE: Mode switching is still possible by holding down the encorder for two seconds.
# NOTE: Mode switching is possible only for Marlin Mode and Touch Mode by a long press of
# three seconds on the display or holding down the encorder button for two seconds.
#
# Options: [Marlin Mode: 0, Touch Mode: 1]
# Options: [Marlin Mode: 0, Touch Mode: 1, Blocked Marlin Mode: 2, Blocked Touch Mode: 3]
default_mode:1

#### Serial Always ON
Expand Down
1 change: 1 addition & 0 deletions TFT/src/User/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void Hardware_GenericInit(void)
#if LCD_ENCODER_SUPPORT
HW_EncoderInit();
#endif

#if ENC_ACTIVE_SIGNAL
HW_EncActiveSignalInit();
#endif
Expand Down

0 comments on commit ff1e8ee

Please sign in to comment.