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 25881ac6e..3a3eb302d 100644 --- a/Copy to SD Card root directory to update/config.ini +++ b/Copy to SD Card root directory to update/config.ini @@ -109,7 +109,7 @@ # P2: [min: 0, max: 11] # P3: [min: 0, max: 11] # P4: [min: 0, max: 11] -# Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250000: 8, 500000: 9, 921600: 10, 1000000: 11] +# Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250K: 8, 500K: 9, 921600: 10, 1M: 11, 1958400: 12, 2M: 13] serial_port:P1:6 P2:0 P3:0 P4:0 #### TX Slots 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 b62a220f7..ae6528267 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 @@ -72,7 +72,7 @@ # P2: [min: 0, max: 11] # P3: [min: 0, max: 11] # P4: [min: 0, max: 11] -# Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250000: 8, 500000: 9, 921600: 10, 1000000: 11] +# Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250K: 8, 500K: 9, 921600: 10, 1M: 11, 1958400: 12, 2M: 13] serial_port:P1:5 P2:0 P3:0 P4:0 #### TX Slots diff --git a/TFT/src/User/API/AddonHardware.c b/TFT/src/User/API/AddonHardware.c index d3b36ea09..362dc54f8 100644 --- a/TFT/src/User/API/AddonHardware.c +++ b/TFT/src/User/API/AddonHardware.c @@ -41,7 +41,7 @@ enum FILAMENT_SENSOR_SMART, }; -static uint32_t posE_nextUpdateTime = FIL_ALARM_REMINDER_TIME; // give TFT time to connect to mainboard first before polling for runout +static uint32_t posE_lastUpdateTime = FIL_ALARM_REMINDER_TIME; // give TFT time to connect to mainboard first before polling for runout static bool posE_sendingWaiting = false; static bool sfs_alive = false; // use an encoder disc to toggles the runout. Suitable for BigTreeTech Smart Filament Sensor @@ -87,9 +87,9 @@ static bool FIL_NormalRunoutDetect(void) { static bool runout = false; static int32_t trigBalance = 0; - static uint32_t nextUpdateTime = 0; + static uint32_t lastUpdateTime = 0; - if (OS_GetTimeMs() < nextUpdateTime) + if (OS_GetTimeMs() - lastUpdateTime < infoSettings.runout_noise) { bool pinState = false; uint8_t toolNum = heatGetToolIndex(); @@ -144,7 +144,7 @@ static bool FIL_NormalRunoutDetect(void) runout = (trigBalance > 0); trigBalance = 0; - nextUpdateTime = OS_GetTimeMs() + infoSettings.runout_noise; + lastUpdateTime = OS_GetTimeMs(); return runout; } @@ -160,10 +160,10 @@ static inline bool FIL_SmartRunoutDetect(void) do { // send M114 E to query extrude position continuously - if (OS_GetTimeMs() < posE_nextUpdateTime) // if next check time not yet elapsed, do nothing + if (OS_GetTimeMs() - posE_lastUpdateTime < FIL_POS_E_REFRESH_TIME) // if next check time not yet elapsed, do nothing break; - posE_nextUpdateTime = OS_GetTimeMs() + FIL_POS_E_REFRESH_TIME; // extend next check time + posE_lastUpdateTime = OS_GetTimeMs(); // extend next check time // if M114 previously enqueued and not yet sent or pending command // (to avoid collision in gcode response processing), do nothing @@ -219,7 +219,7 @@ void FIL_BE_CheckRunout(void) void FIL_FE_CheckRunout(void) { - static uint32_t nextReminderTime = 0; + static uint32_t lastReminderTime = 0; if (!getPrintRunout() && !getRunoutAlarm()) return; @@ -230,10 +230,10 @@ void FIL_FE_CheckRunout(void) popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_FILAMENT_RUNOUT, LABEL_CONFIRM, LABEL_NULL, setRunoutAlarmFalse, NULL, NULL); } - if (OS_GetTimeMs() >= nextReminderTime && getRunoutAlarm()) + if ((OS_GetTimeMs() - lastReminderTime >= FIL_ALARM_REMINDER_TIME) && getRunoutAlarm()) { BUZZER_PLAY(SOUND_ERROR); - nextReminderTime = OS_GetTimeMs() + FIL_ALARM_REMINDER_TIME; + lastReminderTime = OS_GetTimeMs(); } } diff --git a/TFT/src/User/API/FanControl.c b/TFT/src/User/API/FanControl.c index 6cb59b60e..943b0c691 100644 --- a/TFT/src/User/API/FanControl.c +++ b/TFT/src/User/API/FanControl.c @@ -74,12 +74,12 @@ uint8_t fanGetCurPercent(const uint8_t i) void loopCheckFan(void) { - static uint32_t nextUpdateTime = 0; + static uint32_t lastUpdateTime = 0; - if (OS_GetTimeMs() < nextUpdateTime) // avoid rapid fire, clogging the queue + if (OS_GetTimeMs() - lastUpdateTime < FAN_REFRESH_TIME) // avoid rapid fire, clogging the queue return; - nextUpdateTime = OS_GetTimeMs() + FAN_REFRESH_TIME; // extend next check time + lastUpdateTime = OS_GetTimeMs(); for (uint8_t i = 0; i < MAX_FAN_COUNT; i++) { diff --git a/TFT/src/User/API/Mainboard_FlowControl.c b/TFT/src/User/API/Mainboard_FlowControl.c index 552931041..fda80fd89 100644 --- a/TFT/src/User/API/Mainboard_FlowControl.c +++ b/TFT/src/User/API/Mainboard_FlowControl.c @@ -54,6 +54,16 @@ void loopBackEnd(void) USB_LoopProcess(); #endif + // check changes in encoder steps + #if LCD_ENCODER_SUPPORT + #ifdef HAS_EMULATOR + if (MENU_IS_NOT(menuMarlinMode)) + #endif + { + LCD_Enc_CheckSteps(); + } + #endif + if ((priorityCounter.be++ % BE_PRIORITY_DIVIDER) != 0) // a divider value of 16 -> run 6% of the time only return; @@ -81,16 +91,6 @@ void loopBackEnd(void) FIL_BE_CheckRunout(); #endif - // check changes in encoder steps - #if LCD_ENCODER_SUPPORT - #ifdef HAS_EMULATOR - if (MENU_IS_NOT(menuMarlinMode)) - #endif - { - LCD_Enc_CheckSteps(); - } - #endif - // check mode switching #ifdef HAS_EMULATOR Mode_CheckSwitching(); @@ -103,7 +103,7 @@ void loopBackEnd(void) // check if Back is pressed and held #ifdef SMART_HOME - loopCheckBackPress(); + // loopCheckBackPress(); // not needed anymore, done in menu.c #endif // check LCD screen dimming diff --git a/TFT/src/User/API/Notification.c b/TFT/src/User/API/Notification.c index 12824bb67..05df1ffbb 100644 --- a/TFT/src/User/API/Notification.c +++ b/TFT/src/User/API/Notification.c @@ -78,7 +78,7 @@ void drawToast(bool redraw) if (!redraw) // if notification is new { BUZZER_PLAY(curSound); // play sound - nextToastTime = OS_GetTimeMs() + SEC_TO_MS(TOAST_DURATION); // set new timer + nextToastTime = OS_GetTimeMs(); } GUI_SetTextMode(GUI_TEXTMODE_TRANS); @@ -121,7 +121,7 @@ static inline bool toastAvailable(void) void loopToast(void) { // if no new toast is available or it is not yet expired on screen or in case a full screen menu is displayed, do nothing - if (_toastAvailable == false || OS_GetTimeMs() < nextToastTime || getMenuType() == MENU_TYPE_FULLSCREEN) + if (_toastAvailable == false || ((OS_GetTimeMs() - nextToastTime) < SEC_TO_MS(TOAST_DURATION)) || getMenuType() == MENU_TYPE_FULLSCREEN) return; if (toastAvailable()) diff --git a/TFT/src/User/API/Printing.c b/TFT/src/User/API/Printing.c index 99dcb6c67..914cf9bfb 100644 --- a/TFT/src/User/API/Printing.c +++ b/TFT/src/User/API/Printing.c @@ -26,7 +26,7 @@ static bool extrusionDuringPause = false; // flag for extrusion during Print -> static bool filamentRunoutAlarm = false; static float lastEPos = 0; // used only to update stats in infoPrintSummary -static uint32_t nextUpdateTime = 0; +static uint32_t lastUpdateTime = 0; static bool sendingWaiting = false; PRINT_SUMMARY infoPrintSummary = {.name[0] = '\0', 0, 0, 0, 0, false}; @@ -917,7 +917,7 @@ void loopPrintFromTFT(void) void printSetNextUpdateTime(void) { - nextUpdateTime = OS_GetTimeMs() + SEC_TO_MS(infoSettings.m27_refresh_time); + lastUpdateTime = OS_GetTimeMs(); } void printClearSendingWaiting(void) @@ -940,10 +940,11 @@ void loopPrintFromOnboard(void) do { // send M27 to query SD print status continuously - if (OS_GetTimeMs() < nextUpdateTime) // if next check time not yet elapsed, do nothing + if ((OS_GetTimeMs() - lastUpdateTime) < SEC_TO_MS(infoSettings.m27_refresh_time)) // if next check time not yet elapsed, do nothing break; - printSetNextUpdateTime(); // extend next check time + //printSetNextUpdateTime(); // extend next check time + lastUpdateTime = OS_GetTimeMs(); // if M27 previously enqueued and not yet sent, do nothing if (sendingWaiting) diff --git a/TFT/src/User/API/ProbeHeightControl.c b/TFT/src/User/API/ProbeHeightControl.c index 8bc3615f3..ab4598ede 100644 --- a/TFT/src/User/API/ProbeHeightControl.c +++ b/TFT/src/User/API/ProbeHeightControl.c @@ -109,12 +109,12 @@ void probeHeightMove(float unit) // query for new coordinates void probeHeightQueryCoord(void) { - static uint32_t nextUpdateTime = 0; + static uint32_t lastUpdateTime = 0; - if (OS_GetTimeMs() < nextUpdateTime) + if ((OS_GetTimeMs() - lastUpdateTime) < PROBE_REFRESH_TIME) return; - nextUpdateTime = OS_GetTimeMs() + PROBE_REFRESH_TIME; + lastUpdateTime = OS_GetTimeMs(); coordinateQuery(0); // query position manually for delay less than 1 second } diff --git a/TFT/src/User/API/RRFStatusControl.c b/TFT/src/User/API/RRFStatusControl.c index 91cc4195a..11f7acf44 100644 --- a/TFT/src/User/API/RRFStatusControl.c +++ b/TFT/src/User/API/RRFStatusControl.c @@ -121,12 +121,12 @@ void rrfStatusQuery(void) { if (infoHost.connected) { - static uint32_t rrf_next_query_time = 0; + static uint32_t rrf_last_query_time = 0; - if (OS_GetTimeMs() < rrf_next_query_time) + if ((OS_GetTimeMs() - rrf_last_query_time) < rrf_query_interval) return; - rrf_next_query_time = OS_GetTimeMs() + rrf_query_interval; + rrf_last_query_time = OS_GetTimeMs(); // don't send status queries while in the terminal menu to avoid flooding the console if (MENU_IS(menuTerminal)) diff --git a/TFT/src/User/API/SerialConnection.c b/TFT/src/User/API/SerialConnection.c index deb3b1399..655778c08 100644 --- a/TFT/src/User/API/SerialConnection.c +++ b/TFT/src/User/API/SerialConnection.c @@ -25,10 +25,10 @@ const SERIAL_PORT_INFO serialPort[SERIAL_PORT_COUNT] = { }; const uint32_t baudrateValues[BAUDRATE_COUNT] = { - 0, 2400, 9600, 19200, 38400, 57600, 115200, 230400, 250000, 500000, 921600, 1000000}; + 0, 2400, 9600, 19200, 38400, 57600, 115200, 230400, 250000, 500000, 921600, 1000000, 1958400, 2000000}; const char * const baudrateNames[BAUDRATE_COUNT] = { - "OFF", "2400", "9600", "19200", "38400", "57600", "115200", "230400", "250000", "500000", "921600", "1000000"}; + "OFF", "2400", "9600", "19200", "38400", "57600", "115200", "230400", "250K", "500K", "921600", "1M", "1958400", "2M"}; void Serial_Init(SERIAL_PORT_INDEX portIndex) { diff --git a/TFT/src/User/API/SerialConnection.h b/TFT/src/User/API/SerialConnection.h index 5eec11997..e348750c2 100644 --- a/TFT/src/User/API/SerialConnection.h +++ b/TFT/src/User/API/SerialConnection.h @@ -10,7 +10,7 @@ extern "C" { #include "variants.h" // for SERIAL_PORT_2 etc. #include "Serial.h" // for dmaL1DataTX etc. -#define BAUDRATE_COUNT 12 +#define BAUDRATE_COUNT 14 typedef enum { diff --git a/TFT/src/User/API/SpeedControl.c b/TFT/src/User/API/SpeedControl.c index 86985a28d..8550fe852 100644 --- a/TFT/src/User/API/SpeedControl.c +++ b/TFT/src/User/API/SpeedControl.c @@ -36,12 +36,12 @@ uint16_t speedGetCurPercent(const uint8_t tool) void loopCheckSpeed(void) { - static uint32_t nextUpdateTime = 0; + static uint32_t lastUpdateTime = 0; - if (OS_GetTimeMs() < nextUpdateTime) // avoid rapid fire, clogging the queue + if ((OS_GetTimeMs() - lastUpdateTime) < SPEED_REFRESH_TIME) // avoid rapid fire, clogging the queue return; - nextUpdateTime = OS_GetTimeMs() + SPEED_REFRESH_TIME; // extend next check time + lastUpdateTime = OS_GetTimeMs(); // extend next check time for (uint8_t i = 0; i < SPEED_NUM; i++) { diff --git a/TFT/src/User/API/Temperature.c b/TFT/src/User/API/Temperature.c index 91f67f403..508f10f42 100644 --- a/TFT/src/User/API/Temperature.c +++ b/TFT/src/User/API/Temperature.c @@ -216,10 +216,10 @@ void heatSyncUpdateSeconds(const uint8_t seconds) void heatSetNextUpdateTime(void) { - heat_next_update_time = OS_GetTimeMs() + SEC_TO_MS(heat_update_seconds); + heat_next_update_time = OS_GetTimeMs(); - if (infoMachineSettings.autoReportTemp) - heat_next_update_time += AUTOREPORT_TIMEOUT; +// if (infoMachineSettings.autoReportTemp) +// heat_next_update_time += AUTOREPORT_TIMEOUT; } void heatClearSendingWaiting(void) @@ -234,10 +234,11 @@ void loopCheckHeater(void) // feature to automatically report the temperatures or (if M155 is supported) check temperature auto-report timeout // and resend M155 command in case of timeout expired - if (OS_GetTimeMs() < heat_next_update_time) // if next check time not yet elapsed, do nothing - break; + if ((OS_GetTimeMs() - heat_next_update_time) < (SEC_TO_MS(heat_update_seconds) + (infoMachineSettings.autoReportTemp ? AUTOREPORT_TIMEOUT : 0))) // if next check time not yet elapsed, do nothing + break; - heatSetNextUpdateTime(); // extend next check time +// heatSetNextUpdateTime(); // extend next check time + heat_next_update_time = OS_GetTimeMs(); // if M105/M155 previously enqueued and not yet sent or pending command // (to avoid collision in gcode response processing), do nothing diff --git a/TFT/src/User/API/Touch_Encoder.c b/TFT/src/User/API/Touch_Encoder.c index 722c59aa7..19c9c5fd1 100644 --- a/TFT/src/User/API/Touch_Encoder.c +++ b/TFT/src/User/API/Touch_Encoder.c @@ -8,7 +8,6 @@ bool Touch_Enc_ReadPen(uint16_t duration) if (XPT2046_Read_Pen()) // if touch screen not pressed { lastTime = OS_GetTimeMs(); - return false; } diff --git a/TFT/src/User/API/Touch_Screen.c b/TFT/src/User/API/Touch_Screen.c index 3bb2421cf..dc3714b01 100644 --- a/TFT/src/User/API/Touch_Screen.c +++ b/TFT/src/User/API/Touch_Screen.c @@ -81,7 +81,7 @@ uint16_t TS_KeyValue(uint8_t totalRect, const GUI_RECT * menuRect) for (i = 0; i < totalRect; i++) { - if ((x > menuRect[i].x0) && (x < menuRect[i].x1) && (y > menuRect[i].y0) && (y < menuRect[i].y1)) + if ((x >= menuRect[i].x0) && (x <= menuRect[i].x1) && (y >= menuRect[i].y0) && (y <= menuRect[i].y1)) { #ifdef BUZZER_PIN if (TS_Sound == true) @@ -106,21 +106,21 @@ uint16_t KEY_GetValue(uint8_t totalRect, const GUI_RECT * menuRect) { if (firstPress) { - key_num = TS_KeyValue(totalRect, menuRect); + key_num = TS_KeyValue(totalRect, menuRect); // store the pressed key number firstPress = false; if (TS_ReDrawIcon) TS_ReDrawIcon(key_num, 1); } } - else + else // not pressed { - if (firstPress == false) + if (!firstPress) // not pressed anymore { if (TS_ReDrawIcon) TS_ReDrawIcon(key_num, 0); - key_return = key_num; + key_return = key_num; // return stored key number key_num = IDLE_TOUCH; firstPress = true; @@ -163,6 +163,7 @@ static inline uint8_t TS_CalibrationEnsure(uint16_t x, uint16_t y) if (lcd_x < x + TS_ERR_RANGE && lcd_x > x - TS_ERR_RANGE && lcd_y > y - TS_ERR_RANGE && lcd_y < y + TS_ERR_RANGE) { + Buzzer_AddSound(BUZZER_FREQUENCY_HZ, BUZZER_FREQUENCY_DURATION_MS); GUI_DispStringCenter(LCD_WIDTH / 2, LCD_HEIGHT - 40, (int32_t)LABEL_ADJUST_OK); Delay_ms(1000); } @@ -174,6 +175,7 @@ static inline uint8_t TS_CalibrationEnsure(uint16_t x, uint16_t y) GUI_DispStringCenter(LCD_WIDTH / 2, LCD_HEIGHT - 40, (int32_t)LABEL_ADJUST_FAILED); GUI_DispDec(0, 0, lcd_x, 3, 0); GUI_DispDec(0, 20, lcd_y, 3, 0); + Buzzer_AddSound(100, 200); Delay_ms(1000); return 0; @@ -211,12 +213,13 @@ void TS_Calibrate(void) GUI_DrawPoint(LCD_X[tp_num], LCD_Y[tp_num] - i); } - while (TS_IsPressed() == false); - + while (!TS_IsPressed()); + Buzzer_AddSound(BUZZER_FREQUENCY_HZ, BUZZER_FREQUENCY_DURATION_MS); + TP_X[tp_num] = XPT2046_Repeated_Compare_AD(CMD_RDX); TP_Y[tp_num] = XPT2046_Repeated_Compare_AD(CMD_RDY); - while (TS_IsPressed() != false); + while (TS_IsPressed()); } K = (X1 - X3) * (Y2 - Y3) - (X2 - X3) * (Y1 - Y3); diff --git a/TFT/src/User/API/UI/ListManager.c b/TFT/src/User/API/UI/ListManager.c index 2f6b63ea0..c2498cd2d 100644 --- a/TFT/src/User/API/UI/ListManager.c +++ b/TFT/src/User/API/UI/ListManager.c @@ -156,7 +156,7 @@ uint8_t listViewGetCurPage(void) uint16_t listViewGetSelectedIndex(void) { - KEY_VALUES key_num = menuKeyGetValue(); + KEY_VALUES key_num = menuKeyGetValue(false); if (key_num < LISTITEM_PER_PAGE) { diff --git a/TFT/src/User/API/UI/Numpad.c b/TFT/src/User/API/UI/Numpad.c index 0759c3499..81e7632be 100644 --- a/TFT/src/User/API/UI/Numpad.c +++ b/TFT/src/User/API/UI/Numpad.c @@ -236,7 +236,7 @@ double numPadFloat(uint8_t * title, double param_val, double reset_val, bool neg while (TS_Sound == false) // TS_TouchSound gets true only when exit from numpad is requested { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { @@ -421,7 +421,7 @@ int32_t numPadInt(uint8_t * title, int32_t param_val, int32_t reset_val, bool ne while (TS_Sound == false) // TS_TouchSound gets true only when exit from numpad is requested { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/API/menu.c b/TFT/src/User/API/menu.c index 26b6df10a..92e9f3ae0 100644 --- a/TFT/src/User/API/menu.c +++ b/TFT/src/User/API/menu.c @@ -4,6 +4,7 @@ #include "Notification.h" #define STATUS_BAR_REFRESH_TIME 2000 // refresh time in ms +uint8_t longPressed = 0; const GUI_RECT exhibitRect = { #ifdef PORTRAIT_MODE @@ -607,7 +608,7 @@ void setReminderMsg(int16_t inf, SYS_STATUS status) reminder.inf = inf; reminder.status = status; - reminder.time = OS_GetTimeMs() + STATUS_BAR_REFRESH_TIME; + reminder.time = OS_GetTimeMs(); if (menuType != MENU_TYPE_FULLSCREEN) drawReminderMsg(); @@ -615,16 +616,17 @@ void setReminderMsg(int16_t inf, SYS_STATUS status) void loopReminderManage(void) { - if (reminder.status == SYS_STATUS_IDLE || OS_GetTimeMs() < reminder.time) return; + if (reminder.status == SYS_STATUS_IDLE || ((OS_GetTimeMs() - reminder.time) < STATUS_BAR_REFRESH_TIME)) + return; - if (infoHost.connected == false) + if (!infoHost.connected) { if (reminder.status == SYS_STATUS_DISCONNECTED) // no change, return return; else setReminderMsg(LABEL_UNCONNECTED, SYS_STATUS_DISCONNECTED); // set the no printer attached reminder } - else if (infoHost.listening_mode == true || isWritingMode() == true) + else if (infoHost.listening_mode || isWritingMode()) { if (reminder.status == SYS_STATUS_LISTENING) // no change, return return; @@ -656,13 +658,12 @@ void drawBusySign(void) busySign.status = SYS_STATUS_BUSY; } - - busySign.time = OS_GetTimeMs() + STATUS_BAR_REFRESH_TIME; + busySign.time = OS_GetTimeMs(); } void loopBusySignClear(void) { - if (busySign.status == SYS_STATUS_IDLE || OS_GetTimeMs() < busySign.time) + if (busySign.status == SYS_STATUS_IDLE || ((OS_GetTimeMs() - busySign.time) < STATUS_BAR_REFRESH_TIME)) return; busySign.status = SYS_STATUS_IDLE; // clear busy signal status @@ -709,7 +710,6 @@ LISTITEMS * getCurListItems(void) GUI_POINT getIconStartPoint(int index) { GUI_POINT p = {curRect[index].x0, curRect[index].y0}; - return p; } @@ -765,7 +765,6 @@ void menuRefreshListPage(void) for (uint8_t i = 0; i < ITEM_PER_PAGE; i++) { RAPID_PRINTING_COMM() // perform backend printing loop between drawing icons to avoid printer idling - menuDrawListItem(&curListItems->items[i], i); } } @@ -799,7 +798,6 @@ void setMenu(MENU_TYPE menu_type, LABEL * title, uint16_t rectCount, const GUI_R void menuSetTitle(const LABEL * title) { curTitle = title; - menuDrawTitle(); } @@ -820,7 +818,6 @@ void menuDrawTitle(void) if (toastRunning()) { drawToast(true); - return; } @@ -883,7 +880,6 @@ static void itemDrawIconPress(uint8_t position, uint8_t is_press) if (curListItems->items[position].icon == CHARICON_NULL) { GUI_ClearPrect(rect); - return; } @@ -897,10 +893,10 @@ static void itemDrawIconPress(uint8_t position, uint8_t is_press) // when there is a button value, the icon changes color and redraws static void itemDrawIconPress_PS(uint8_t position, uint8_t is_press) { - if (position < PS_KEY_6 || position > PS_KEY_9) return; + if (position < PS_KEY_6 || position > PS_KEY_9) + return; position -= PS_TOUCH_OFFSET; - const GUI_RECT * rect = curRect + position; if (is_press) // turn green when pressed @@ -949,7 +945,6 @@ void menuDrawPage(const MENUITEMS * menuItems) for (i = 0; i < ITEM_PER_PAGE; i++) { menuDrawItem(&curMenuItems->items[i], i); - RAPID_PRINTING_COMM() // perform backend printing loop between drawing icons to avoid printer idling } @@ -1001,7 +996,7 @@ void showLiveInfo(uint8_t index, const LIVE_INFO * liveicon, bool redrawIcon) for (uint8_t i = 0; i < LIVEICON_LINES; i++) { - if (liveicon->enabled[i] == true) + if (liveicon->enabled[i]) { GUI_POINT loc; @@ -1044,7 +1039,6 @@ void showLiveInfo(uint8_t index, const LIVE_INFO * liveicon, bool redrawIcon) { GUI_SetTextMode(liveicon->lines[i].text_mode); GUI_SetBkColor(liveicon->lines[i].bk_color); - GUI_DispString(iconPt.x + loc.x, iconPt.y + loc.y, liveicon->lines[i].text); } else @@ -1063,7 +1057,6 @@ void displayExhibitHeader(const char * titleStr, const char * unitStr) if (titleStr != NULL) { char tempstr[20]; - sprintf(tempstr, "%-8s", titleStr); GUI_DispString(exhibitRect.x0, exhibitRect.y0, (uint8_t *)tempstr); } @@ -1086,156 +1079,149 @@ void displayExhibitValue(const char * valueStr) } // get button value -KEY_VALUES menuKeyGetValue(void) +KEY_VALUES menuKeyGetValue(bool returnLongPressed) { KEY_VALUES tempkey = KEY_IDLE; - if (tempkey == KEY_IDLE) + switch (menuType) { - switch (menuType) + case MENU_TYPE_ICON: { - case MENU_TYPE_ICON: + if (MENU_IS(menuStatus)) + { + tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keySS), rect_of_keySS); + } + else if (MENU_IS(menuPrinting)) { - if (MENU_IS(menuStatus)) - { - tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keySS), rect_of_keySS); - } - else if (MENU_IS(menuPrinting)) - { - if (isPrinting() || isPrintingFromOnboard()) - tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keyPS), rect_of_keyPS); - else - tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keyPS_end), rect_of_keyPS_end); - - if (tempkey == (KEY_VALUES)PS_KEY_TITLEBAR) - tempkey = KEY_TITLEBAR; - } - else if ((MENU_IS(menuHeat)) || - (MENU_IS(menuLoadUnload)) || - (MENU_IS(menuMPC)) || - (MENU_IS(menuPid)) || - (MENU_IS(menuTuneExtruder)) || - (MENU_IS(menuFan)) || - (MENU_IS(menuExtrude)) || - (MENU_IS(menuSpeed)) || - (MENU_IS(menuZOffset)) || - (MENU_IS(menuMBL)) || - (MENU_IS(menuBabystep)) || - (MENU_IS(menuMeshEditor))) - { - tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keysIN), rect_of_keysIN); - } + if (isPrinting() || isPrintingFromOnboard()) + tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keyPS), rect_of_keyPS); else - { - tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_key), rect_of_key); - } - break; + tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keyPS_end), rect_of_keyPS_end); + + if (tempkey == (KEY_VALUES)PS_KEY_TITLEBAR) + tempkey = KEY_TITLEBAR; + } + else if ((MENU_IS(menuHeat)) || + (MENU_IS(menuLoadUnload)) || + (MENU_IS(menuMPC)) || + (MENU_IS(menuPid)) || + (MENU_IS(menuTuneExtruder)) || + (MENU_IS(menuFan)) || + (MENU_IS(menuExtrude)) || + (MENU_IS(menuSpeed)) || + (MENU_IS(menuZOffset)) || + (MENU_IS(menuMBL)) || + (MENU_IS(menuBabystep)) || + (MENU_IS(menuMeshEditor))) + { + tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keysIN), rect_of_keysIN); + } + else + { + tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_key), rect_of_key); } - case MENU_TYPE_LISTVIEW: - tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keyListView), rect_of_keyListView); + // let label press work as if icon was pressed + if ((tempkey >= KEY_LABEL_0) && (tempkey <= KEY_LABEL_7)) + tempkey = tempkey - KEY_LABEL_0; + break; + } - if (tempkey == ITEM_PER_PAGE) - tempkey = KEY_TITLEBAR; - break; + case MENU_TYPE_LISTVIEW: + tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keyListView), rect_of_keyListView); - case MENU_TYPE_OTHER: - if ((KEY_VALUES)KEY_GetValue(1, rect_of_titleBar) == 0) - tempkey = KEY_TITLEBAR; - else - tempkey = (KEY_VALUES)KEY_GetValue(curRectCount, curRect); - break; + if (tempkey == ITEM_PER_PAGE) + tempkey = KEY_TITLEBAR; + break; - case MENU_TYPE_FULLSCREEN: - default: + case MENU_TYPE_OTHER: + if ((KEY_VALUES)KEY_GetValue(1, rect_of_titleBar) == 0) + tempkey = KEY_TITLEBAR; + else tempkey = (KEY_VALUES)KEY_GetValue(curRectCount, curRect); - break; - } + break; + + case MENU_TYPE_FULLSCREEN: + default: + tempkey = (KEY_VALUES)KEY_GetValue(curRectCount, curRect); + break; } if (menuType != MENU_TYPE_FULLSCREEN && tempkey == KEY_TITLEBAR) { titleBarPress(); - - tempkey = KEY_IDLE; + return KEY_IDLE; } + if (returnLongPressed && longPressed && (tempkey != KEY_IDLE)) // register long pressed flag + tempkey = KEY_LONG_PRESSED + tempkey; // signal long pressed + #if LCD_ENCODER_SUPPORT - if (tempkey == KEY_IDLE) + if (tempkey == KEY_IDLE) // nothing pressed, check encoder status tempkey = LCD_Enc_KeyValue(); #endif - return tempkey; -} - -// smart home (long press on back button to go to status screen) -#ifdef SMART_HOME - -void loopCheckBackPress(void) -{ - static bool longPress = false; - #ifdef HAS_EMULATOR static bool backHeld = false; #endif - if (!TS_IsPressed()) + if (!TS_IsPressed()) // not pressed (anymore) { - longPress = false; + if (longPressed) + longPressed--; // don't immediately cancel longPressed, delay by 1 cycle #ifdef HAS_EMULATOR backHeld = false; #else - Touch_Enc_ReadPen(0); // reset TSC press timer + Touch_Enc_ReadPen(0); // reset TSC press timer #endif - - return; } - if (isPrinting()) // no jump to main menu while printing - return; - - if (getMenuType() != MENU_TYPE_ICON) - return; - - if ((infoMenu.cur == 0) || (MENU_IS(menuMode))) - return; + if (isPrinting() || // no jump to "main menu" while printing + getMenuType() != MENU_TYPE_ICON || // only jump if in a "icon menu" + infoMenu.cur == 0 || // already in "main menu" + MENU_IS(menuMode)) // no jump from "mode switching menu" + return tempkey; #ifdef HAS_EMULATOR - if (backHeld == true) // prevent mode selection or screenshot if Back button is held - { - backHeld = Touch_Enc_ReadPen(0); - - return; - } + if (backHeld) // prevent mode selection or screenshot if Back button is held + backHeld = Touch_Enc_ReadPen(0); // reset TSC press timer #endif - if (longPress == false && Touch_Enc_ReadPen(LONG_TOUCH)) // check if longpress already handled and check if TSC is pressed and held - { - KEY_VALUES tempKey = KEY_IDLE; + if (!longPressed && Touch_Enc_ReadPen(LONG_TOUCH)) // detect long press + { // check if longpressed already handled and check if TSC is pressed and held + KEY_VALUES tempkey2 = KEY_IDLE; - longPress = true; TS_Sound = false; if (MENU_IS(menuPrinting)) - tempKey = TS_KeyValue(COUNT(rect_of_keySS), rect_of_keySS); + tempkey2 = TS_KeyValue(COUNT(rect_of_keySS), rect_of_keySS); else - tempKey = TS_KeyValue(COUNT(rect_of_key), rect_of_key); + tempkey2 = TS_KeyValue(COUNT(rect_of_key), rect_of_key); TS_Sound = true; - if (tempKey != KEY_IDLE && getCurMenuItems()->items[tempKey].label.index == LABEL_BACK) // check if Back button is held + if (tempkey2 < COUNT(getCurMenuItems()->items)) { - BUZZER_PLAY(SOUND_OK); + longPressed = 2; // enable longPressed status for at least 2 cycles - #ifdef HAS_EMULATOR - backHeld = true; - #endif - - infoMenu.menu[1] = infoMenu.menu[infoMenu.cur]; // prepare menu tree for jump to 0 - infoMenu.cur = 1; + if (getCurMenuItems()->items[tempkey2].label.index == LABEL_BACK) // check if Back button is held + { + #ifdef HAS_EMULATOR + backHeld = true; + #endif + + #ifdef SMART_HOME + BUZZER_PLAY(SOUND_OK); // sound to indicate back to root menu is triggered + infoMenu.menu[1] = infoMenu.menu[infoMenu.cur]; // prepare menu tree for jump to 0 + infoMenu.cur = 1; + #endif // SMART_HOME + } + else + if (returnLongPressed) + BUZZER_PLAY(SOUND_KEYPRESS); } } -} -#endif // SMART_HOME + return tempkey; +} \ No newline at end of file diff --git a/TFT/src/User/API/menu.h b/TFT/src/User/API/menu.h index 04555bfbf..6f614758b 100644 --- a/TFT/src/User/API/menu.h +++ b/TFT/src/User/API/menu.h @@ -9,7 +9,8 @@ extern "C" { #include #include "GUI.h" -#define IDLE_TOUCH 0xFFFF +#define KEY_LONG_PRESSED 1024 // Use power of 2 for efficiency +#define IDLE_TOUCH (KEY_LONG_PRESSED - 1) #define ITEM_PER_PAGE 8 #define PS_TOUCH_OFFSET 2 // printing screen icon index offset for touch input @@ -198,13 +199,11 @@ void showLiveInfo(uint8_t index, const LIVE_INFO * liveicon, bool redrawIcon); void displayExhibitHeader(const char * titleStr, const char * unitStr); void displayExhibitValue(const char * valueStr); -KEY_VALUES menuKeyGetValue(void); +KEY_VALUES menuKeyGetValue(bool returnLongPressed); // smart home #ifdef SMART_HOME #define LONG_TOUCH (MODE_SWITCHING_INTERVAL / 3) // keep it lower than MODE_SWITCHING_INTERVAL - - void loopCheckBackPress(void); #endif #ifdef __cplusplus diff --git a/TFT/src/User/Configuration.h b/TFT/src/User/Configuration.h index 0c745f22d..2daa400a7 100644 --- a/TFT/src/User/Configuration.h +++ b/TFT/src/User/Configuration.h @@ -34,7 +34,7 @@ * P2: [min: 0, max: 11] * P3: [min: 0, max: 11] * P4: [min: 0, max: 11] - * Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250000: 8, 500000: 9, 921600: 10, 1000000: 11] + * Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250000: 8, 500000: 9, 921600: 10, 1000000: 11, 1958400: 12, 2000000: 13] */ #define SP_1 6 // Default: 6 #define SP_2 0 // Default: 0 diff --git a/TFT/src/User/Menu/ABL.c b/TFT/src/User/Menu/ABL.c index 0bf09aa48..2fb08facb 100644 --- a/TFT/src/User/Menu/ABL.c +++ b/TFT/src/User/Menu/ABL.c @@ -126,7 +126,7 @@ static void menuUBLSaveLoad(void) while (MENU_IS(menuUBLSaveLoad)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/BLTouch.c b/TFT/src/User/Menu/BLTouch.c index be0fab0fa..8636977be 100644 --- a/TFT/src/User/Menu/BLTouch.c +++ b/TFT/src/User/Menu/BLTouch.c @@ -41,7 +41,7 @@ void menuBLTouch(void) while (MENU_IS(menuBLTouch)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Babystep.c b/TFT/src/User/Menu/Babystep.c index deef34325..cdb750b0a 100644 --- a/TFT/src/User/Menu/Babystep.c +++ b/TFT/src/User/Menu/Babystep.c @@ -132,7 +132,7 @@ void menuBabystep(void) { unit = moveLenSteps[moveLenSteps_index]; babystep = babystepGetValue(); // always load current babystep - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/BedLeveling.c b/TFT/src/User/Menu/BedLeveling.c index a8c2c77b7..f84f71735 100644 --- a/TFT/src/User/Menu/BedLeveling.c +++ b/TFT/src/User/Menu/BedLeveling.c @@ -94,7 +94,7 @@ void menuBedLeveling(void) while (MENU_IS(menuBedLeveling)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/BedLevelingLayer2.c b/TFT/src/User/Menu/BedLevelingLayer2.c index f47e446f8..486585c39 100644 --- a/TFT/src/User/Menu/BedLevelingLayer2.c +++ b/TFT/src/User/Menu/BedLevelingLayer2.c @@ -72,7 +72,7 @@ void menuBedLevelingLayer2(void) while (MENU_IS(menuBedLevelingLayer2)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/CaseLight.c b/TFT/src/User/Menu/CaseLight.c index 0e222b914..3017c1bf8 100644 --- a/TFT/src/User/Menu/CaseLight.c +++ b/TFT/src/User/Menu/CaseLight.c @@ -75,7 +75,7 @@ void menuCaseLight(void) while (MENU_IS(menuCaseLight)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/ConnectionSettings.c b/TFT/src/User/Menu/ConnectionSettings.c index d22d2a224..6244e4fdb 100644 --- a/TFT/src/User/Menu/ConnectionSettings.c +++ b/TFT/src/User/Menu/ConnectionSettings.c @@ -153,7 +153,7 @@ void menuConnectionSettings(void) while (MENU_IS(menuConnectionSettings)) { - curIndex = menuKeyGetValue(); + curIndex = menuKeyGetValue(false); switch (curIndex) { diff --git a/TFT/src/User/Menu/Extrude.c b/TFT/src/User/Menu/Extrude.c index 2cac30b5e..0fd739c6b 100644 --- a/TFT/src/User/Menu/Extrude.c +++ b/TFT/src/User/Menu/Extrude.c @@ -61,7 +61,9 @@ void menuExtrude(void) while (MENU_IS(menuExtrude)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(true); + bool longPressed = (key_num & KEY_LONG_PRESSED); + key_num %= KEY_LONG_PRESSED; switch (key_num) { @@ -82,7 +84,7 @@ void menuExtrude(void) break; case KEY_ICON_4: - if (infoSettings.ext_count > 1) + if ((infoSettings.ext_count > 1) && (!longPressed)) { curExtruder_index = (curExtruder_index + 1) % infoSettings.ext_count; @@ -90,6 +92,9 @@ void menuExtrude(void) } else { + if (longPressed && (infoSettings.ext_count > 1)) // long pressed sound + BUZZER_PLAY(SOUND_OK); + heatSetCurrentIndex(curExtruder_index); // preselect current nozzle for "Heat" menu OPEN_MENU(menuHeat); diff --git a/TFT/src/User/Menu/Fan.c b/TFT/src/User/Menu/Fan.c index ea55dbfc1..e39e6d118 100644 --- a/TFT/src/User/Menu/Fan.c +++ b/TFT/src/User/Menu/Fan.c @@ -50,7 +50,7 @@ void menuFan(void) while (MENU_IS(menuFan)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Heat.c b/TFT/src/User/Menu/Heat.c index 8663685da..568e6755d 100644 --- a/TFT/src/User/Menu/Heat.c +++ b/TFT/src/User/Menu/Heat.c @@ -49,13 +49,18 @@ void menuHeat(void) { actCurrent = heatGetCurrentTemp(tool_index); actTarget = setTarget = heatGetTargetTemp(tool_index); - key_num = menuKeyGetValue(); - + key_num = menuKeyGetValue(true); + bool longPressed = (key_num & KEY_LONG_PRESSED); + key_num %= KEY_LONG_PRESSED; + switch (key_num) { case KEY_ICON_0: case KEY_DECREASE: - setTarget -= degreeSteps[degreeSteps_index]; + if (longPressed) + setTarget = 0; + else + setTarget -= degreeSteps[degreeSteps_index]; break; case KEY_INFOBOX: @@ -68,7 +73,16 @@ void menuHeat(void) case KEY_ICON_3: case KEY_INCREASE: - setTarget += degreeSteps[degreeSteps_index]; + if (longPressed) + { + BUZZER_PLAY(SOUND_OK); + if (tool_index < infoSettings.hotend_count) + setTarget = 200; + else + setTarget = 75; + } + else + setTarget += degreeSteps[degreeSteps_index]; break; case KEY_ICON_4: diff --git a/TFT/src/User/Menu/Home.c b/TFT/src/User/Menu/Home.c index 6da057725..4566de892 100644 --- a/TFT/src/User/Menu/Home.c +++ b/TFT/src/User/Menu/Home.c @@ -25,7 +25,7 @@ void menuHome(void) while (MENU_IS(menuHome)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/LEDColor.c b/TFT/src/User/Menu/LEDColor.c index 65135aed9..9a5b1244a 100644 --- a/TFT/src/User/Menu/LEDColor.c +++ b/TFT/src/User/Menu/LEDColor.c @@ -332,7 +332,7 @@ static void menuLEDColorCustom(void) while (MENU_IS(menuLEDColorCustom)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { @@ -489,7 +489,7 @@ void menuLEDColor(void) while (MENU_IS(menuLEDColor)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/LevelCorner.c b/TFT/src/User/Menu/LevelCorner.c index 6dd35a2d0..ffe38cb3e 100644 --- a/TFT/src/User/Menu/LevelCorner.c +++ b/TFT/src/User/Menu/LevelCorner.c @@ -75,7 +75,7 @@ void menuLevelCorner(void) while (MENU_IS(menuLevelCorner)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Leveling.c b/TFT/src/User/Menu/Leveling.c index f89d9b73c..17a78c4a3 100644 --- a/TFT/src/User/Menu/Leveling.c +++ b/TFT/src/User/Menu/Leveling.c @@ -36,7 +36,7 @@ void menuManualLeveling(void) while (MENU_IS(menuManualLeveling)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/LoadUnload.c b/TFT/src/User/Menu/LoadUnload.c index 0b7b3308e..28071f268 100644 --- a/TFT/src/User/Menu/LoadUnload.c +++ b/TFT/src/User/Menu/LoadUnload.c @@ -48,7 +48,7 @@ void menuLoadUnload(void) while (MENU_IS(menuLoadUnload)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); // show reminder for process running if any button is pressed if (isPendingCmd() && key_num != KEY_IDLE) diff --git a/TFT/src/User/Menu/MBL.c b/TFT/src/User/Menu/MBL.c index 0923dc110..25ce130d2 100644 --- a/TFT/src/User/Menu/MBL.c +++ b/TFT/src/User/Menu/MBL.c @@ -172,7 +172,7 @@ void menuMBL(void) { unit = moveLenSteps[curUnit_index]; coordinateGetAllActual(&curValue); - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/MPC.c b/TFT/src/User/Menu/MPC.c index 9c759dc45..743088f0e 100644 --- a/TFT/src/User/Menu/MPC.c +++ b/TFT/src/User/Menu/MPC.c @@ -197,7 +197,7 @@ void menuMPC(void) { if (mpcTuning.status == DONE) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/MachineSettings.c b/TFT/src/User/Menu/MachineSettings.c index b4c14c1a0..5fe466e66 100644 --- a/TFT/src/User/Menu/MachineSettings.c +++ b/TFT/src/User/Menu/MachineSettings.c @@ -52,7 +52,7 @@ static void menuEepromSettings(void) while (MENU_IS(menuEepromSettings)) { - curIndex = menuKeyGetValue(); + curIndex = menuKeyGetValue(false); switch (curIndex) { @@ -132,7 +132,7 @@ void menuMachineSettings(void) while (MENU_IS(menuMachineSettings)) { - curIndex = menuKeyGetValue(); + curIndex = menuKeyGetValue(false); switch (curIndex) { diff --git a/TFT/src/User/Menu/MainPage.c b/TFT/src/User/Menu/MainPage.c index 937de3f6c..90c029325 100644 --- a/TFT/src/User/Menu/MainPage.c +++ b/TFT/src/User/Menu/MainPage.c @@ -39,7 +39,7 @@ void menuMain(void) while (MENU_IS(menuMain)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/MeshEditor.c b/TFT/src/User/Menu/MeshEditor.c index 2cebcfc5b..75047b63b 100644 --- a/TFT/src/User/Menu/MeshEditor.c +++ b/TFT/src/User/Menu/MeshEditor.c @@ -808,7 +808,7 @@ void menuMeshEditor(void) while (MENU_IS(menuMeshEditor)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/MeshTuner.c b/TFT/src/User/Menu/MeshTuner.c index e6e4386aa..b31f87ec7 100644 --- a/TFT/src/User/Menu/MeshTuner.c +++ b/TFT/src/User/Menu/MeshTuner.c @@ -101,7 +101,7 @@ float menuMeshTuner(uint16_t col, uint16_t row, float value) { unit = moveLenSteps[curUnit_index]; coordinateGetAllActual(&curValue); - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/MeshValid.c b/TFT/src/User/Menu/MeshValid.c index 37e051577..d64023deb 100644 --- a/TFT/src/User/Menu/MeshValid.c +++ b/TFT/src/User/Menu/MeshValid.c @@ -33,7 +33,7 @@ void menuMeshValid(void) while (MENU_IS(menuMeshValid)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/More.c b/TFT/src/User/Menu/More.c index 6705ce6c1..e8c2d87e0 100644 --- a/TFT/src/User/Menu/More.c +++ b/TFT/src/User/Menu/More.c @@ -41,7 +41,7 @@ void menuMore(void) while (MENU_IS(menuMore)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Move.c b/TFT/src/User/Menu/Move.c index ba72194e4..545d06a11 100644 --- a/TFT/src/User/Menu/Move.c +++ b/TFT/src/User/Menu/Move.c @@ -141,7 +141,9 @@ void menuMove(void) while (MENU_IS(menuMove)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(true); + bool longPressed = (key_num & KEY_LONG_PRESSED); + key_num %= KEY_LONG_PRESSED; switch (key_num) { @@ -151,12 +153,22 @@ void menuMove(void) case KEY_ICON_2: storeMoveCmd(Z_AXIS, amount); break; // Z move up if no invert case KEY_ICON_3: - item_moveLen_index = (item_moveLen_index + 1) % ITEM_MOVE_LEN_NUM; - moveItems.items[key_num] = itemMoveLen[item_moveLen_index]; - - menuDrawItem(&moveItems.items[key_num], key_num); - - amount = moveLenSteps[item_moveLen_index]; + if (longPressed) { + infoSettings.move_speed = (infoSettings.move_speed + 1) % ITEM_SPEED_NUM; + if (infoSettings.move_speed == 0) + addToast(DIALOG_TYPE_INFO, (char *) textSelect(LABEL_SLOW)); + if (infoSettings.move_speed == 1) + addToast(DIALOG_TYPE_INFO, (char *) textSelect(LABEL_NORMAL)); + if (infoSettings.move_speed == 2) + addToast(DIALOG_TYPE_INFO, (char *) textSelect(LABEL_FAST)); + } + else + { + item_moveLen_index = (item_moveLen_index + 1) % ITEM_MOVE_LEN_NUM; + moveItems.items[key_num] = itemMoveLen[item_moveLen_index]; + menuDrawItem(&moveItems.items[key_num], key_num); + amount = moveLenSteps[item_moveLen_index]; + } break; case KEY_ICON_4: storeMoveCmd(X_AXIS, -amount); break; // X move decrease if no invert diff --git a/TFT/src/User/Menu/NotificationMenu.c b/TFT/src/User/Menu/NotificationMenu.c index 1e03bf5ae..e0957e609 100644 --- a/TFT/src/User/Menu/NotificationMenu.c +++ b/TFT/src/User/Menu/NotificationMenu.c @@ -67,7 +67,7 @@ void menuNotification(void) while (MENU_IS(menuNotification)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Pid.c b/TFT/src/User/Menu/Pid.c index 8373f71c0..0115232d3 100644 --- a/TFT/src/User/Menu/Pid.c +++ b/TFT/src/User/Menu/Pid.c @@ -50,7 +50,7 @@ static void pidRun(void) static inline void pidStart(void) { - pidTimeout = OS_GetTimeMs() + PID_PROCESS_TIMEOUT; // set timeout for overall PID process + pidTimeout = OS_GetTimeMs(); // set timeout for overall PID process LED_SetEventColor(&ledRed, false); // set (neopixel) LED light to RED LCD_SET_KNOB_LED_IDLE(false); // set infoSettings.knob_led_idle temporary to OFF @@ -159,7 +159,7 @@ void menuPid(void) { if (pidStatus == PID_IDLE) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { @@ -242,7 +242,7 @@ void menuPid(void) if (getMenuType() != MENU_TYPE_SPLASH) popupSplash(DIALOG_TYPE_INFO, LABEL_SCREEN_INFO, LABEL_BUSY); - if (OS_GetTimeMs() >= pidTimeout) + if (OS_GetTimeMs() - pidTimeout >= PID_PROCESS_TIMEOUT) pidUpdateStatus(PID_TIMEOUT); if (pidStatus != PID_RUNNING) diff --git a/TFT/src/User/Menu/PreheatMenu.c b/TFT/src/User/Menu/PreheatMenu.c index 145b7dfbe..1d8a200ca 100755 --- a/TFT/src/User/Menu/PreheatMenu.c +++ b/TFT/src/User/Menu/PreheatMenu.c @@ -121,7 +121,7 @@ void menuPreheat(void) while (MENU_IS(menuPreheat)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Print.c b/TFT/src/User/Menu/Print.c index 36a2d59fe..2682aba29 100644 --- a/TFT/src/User/Menu/Print.c +++ b/TFT/src/User/Menu/Print.c @@ -251,7 +251,7 @@ void menuPrintFromSource(void) if (list_mode != true) // select item from icon view { pageCount = (infoFile.folderCount + infoFile.fileCount + (NUM_PER_PAGE - 1)) / NUM_PER_PAGE; - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { @@ -422,7 +422,7 @@ void menuPrint(void) while (MENU_IS(menuPrint)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/PrintingMenu.c b/TFT/src/User/Menu/PrintingMenu.c index f4e8e760a..40ea50632 100644 --- a/TFT/src/User/Menu/PrintingMenu.c +++ b/TFT/src/User/Menu/PrintingMenu.c @@ -662,7 +662,7 @@ void menuPrinting(void) toggleInfo(); - KEY_VALUES key_num = menuKeyGetValue(); + KEY_VALUES key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/ScreenSettings.c b/TFT/src/User/Menu/ScreenSettings.c index 47fac1d4f..d6323ab6e 100644 --- a/TFT/src/User/Menu/ScreenSettings.c +++ b/TFT/src/User/Menu/ScreenSettings.c @@ -564,7 +564,7 @@ void menuScreenSettings(void) while (MENU_IS(menuScreenSettings)) { - curIndex = menuKeyGetValue(); + curIndex = menuKeyGetValue(false); switch (curIndex) { diff --git a/TFT/src/User/Menu/SettingsMenu.c b/TFT/src/User/Menu/SettingsMenu.c index a4247514f..17d1f6b0e 100644 --- a/TFT/src/User/Menu/SettingsMenu.c +++ b/TFT/src/User/Menu/SettingsMenu.c @@ -156,7 +156,7 @@ void menuSettings(void) while (MENU_IS(menuSettings)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Speed.c b/TFT/src/User/Menu/Speed.c index 73051986d..ba2589c10 100644 --- a/TFT/src/User/Menu/Speed.c +++ b/TFT/src/User/Menu/Speed.c @@ -66,7 +66,7 @@ void menuSpeed(void) while (MENU_IS(menuSpeed)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/StatusScreen.c b/TFT/src/User/Menu/StatusScreen.c index 9fc705797..90b463395 100644 --- a/TFT/src/User/Menu/StatusScreen.c +++ b/TFT/src/User/Menu/StatusScreen.c @@ -315,7 +315,7 @@ void menuStatus(void) statusScrollMsg(); - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Terminal.c b/TFT/src/User/Menu/Terminal.c index b8d490c1b..b6fd0d13e 100644 --- a/TFT/src/User/Menu/Terminal.c +++ b/TFT/src/User/Menu/Terminal.c @@ -562,7 +562,7 @@ static inline void menuKeyboardView(void) if (MENU_IS_NOT(menuTerminal)) break; - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { @@ -851,18 +851,22 @@ static void menuTerminalView(void) if (MENU_IS_NOT(menuTerminal)) break; - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { case TERM_PAGE_UP: // page up if (terminalData->pageIndex < terminalData->pageCount) terminalData->pageIndex++; + else + terminalData->pageIndex = 0; break; case TERM_PAGE_DOWN: // page down if (terminalData->pageIndex > 0) terminalData->pageIndex--; + else + terminalData->pageIndex = terminalData->pageCount; break; case TERM_TOGGLE_ACK: // toggle ack in terminal diff --git a/TFT/src/User/Menu/Touchmi.c b/TFT/src/User/Menu/Touchmi.c index 0b64d2fa4..8df3da00a 100644 --- a/TFT/src/User/Menu/Touchmi.c +++ b/TFT/src/User/Menu/Touchmi.c @@ -25,7 +25,7 @@ void menuTouchMi(void) while (MENU_IS(menuTouchMi)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/TuneExtruder.c b/TFT/src/User/Menu/TuneExtruder.c index 9917267a3..6d46be3fb 100644 --- a/TFT/src/User/Menu/TuneExtruder.c +++ b/TFT/src/User/Menu/TuneExtruder.c @@ -65,7 +65,7 @@ static void menuNewExtruderESteps(void) while (MENU_IS(menuNewExtruderESteps)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { @@ -186,7 +186,7 @@ void menuTuneExtruder(void) { actCurrent = heatGetCurrentTemp(tool_index); actTarget = heatGetTargetTemp(tool_index); - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/Tuning.c b/TFT/src/User/Menu/Tuning.c index 48136c755..ded14c2a8 100644 --- a/TFT/src/User/Menu/Tuning.c +++ b/TFT/src/User/Menu/Tuning.c @@ -44,7 +44,7 @@ void menuTuning(void) while (MENU_IS(menuTuning)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/UnifiedHeat.c b/TFT/src/User/Menu/UnifiedHeat.c index 02323b1ef..3fbee70ec 100644 --- a/TFT/src/User/Menu/UnifiedHeat.c +++ b/TFT/src/User/Menu/UnifiedHeat.c @@ -25,7 +25,7 @@ void menuUnifiedHeat(void) while (MENU_IS(menuUnifiedHeat)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/UnifiedMove.c b/TFT/src/User/Menu/UnifiedMove.c index 3c884eccc..22ff57749 100644 --- a/TFT/src/User/Menu/UnifiedMove.c +++ b/TFT/src/User/Menu/UnifiedMove.c @@ -44,7 +44,7 @@ void menuUnifiedMove(void) while (MENU_IS(menuUnifiedMove)) { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Menu/ZOffset.c b/TFT/src/User/Menu/ZOffset.c index 31da6ca13..7a99e2b8d 100644 --- a/TFT/src/User/Menu/ZOffset.c +++ b/TFT/src/User/Menu/ZOffset.c @@ -138,7 +138,7 @@ void menuZOffset(void) { unit = moveLenSteps[curUnit_index]; z_offset = offsetGetValue(); // always load current Z offset - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { diff --git a/TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h b/TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h index a6825b9d7..37e74e04f 100644 --- a/TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h +++ b/TFT/src/User/Variants/pin_MKS_TFT35_V1_0.h @@ -85,6 +85,9 @@ #define SERIAL_PORT_HOST _USART3 // default USART port for host communication #endif +#define USART6_TX_PIN PC6 +#define USART6_RX_PIN PC7 + // Serial port for debugging #ifdef SERIAL_DEBUG_ENABLED #define SERIAL_DEBUG_PORT SERIAL_PORT_3 diff --git a/TFT/src/User/config.ini b/TFT/src/User/config.ini index 25881ac6e..3a3eb302d 100644 --- a/TFT/src/User/config.ini +++ b/TFT/src/User/config.ini @@ -109,7 +109,7 @@ # P2: [min: 0, max: 11] # P3: [min: 0, max: 11] # P4: [min: 0, max: 11] -# Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250000: 8, 500000: 9, 921600: 10, 1000000: 11] +# Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250K: 8, 500K: 9, 921600: 10, 1M: 11, 1958400: 12, 2M: 13] serial_port:P1:6 P2:0 P3:0 P4:0 #### TX Slots diff --git a/TFT/src/User/config_rrf.ini b/TFT/src/User/config_rrf.ini index b62a220f7..ae6528267 100644 --- a/TFT/src/User/config_rrf.ini +++ b/TFT/src/User/config_rrf.ini @@ -72,7 +72,7 @@ # P2: [min: 0, max: 11] # P3: [min: 0, max: 11] # P4: [min: 0, max: 11] -# Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250000: 8, 500000: 9, 921600: 10, 1000000: 11] +# Options: [OFF (port disabled): 0, 2400: 1, 9600: 2, 19200: 3, 38400: 4, 57600: 5, 115200: 6, 230400: 7, 250K: 8, 500K: 9, 921600: 10, 1M: 11, 1958400: 12, 2M: 13] serial_port:P1:5 P2:0 P3:0 P4:0 #### TX Slots diff --git a/TFT/src/User/os_timer.c b/TFT/src/User/os_timer.c index 3031c0704..d7ca66958 100644 --- a/TFT/src/User/os_timer.c +++ b/TFT/src/User/os_timer.c @@ -97,7 +97,7 @@ void OS_TaskLoop(OS_TASK * task_t) if (task_t->is_exist == 0) return; - if (OS_GetTimeMs() < task_t->next_time) + if ((OS_GetTimeMs() - task_t->next_time) < task_t->time_ms) return; if (task_t->is_repeat == 0) @@ -106,7 +106,7 @@ void OS_TaskLoop(OS_TASK * task_t) } else { - task_t->next_time = OS_GetTimeMs() + task_t->time_ms; + task_t->next_time = OS_GetTimeMs(); } (*task_t->task)(task_t->para); @@ -116,7 +116,7 @@ void OS_TaskEnable(OS_TASK * task_t, uint8_t is_exec, uint8_t is_repeat) { task_t->is_exist =1; task_t->is_repeat = is_repeat; - task_t->next_time = OS_GetTimeMs() + task_t->time_ms; + task_t->next_time = OS_GetTimeMs(); if (is_exec) (*task_t->task)(task_t->para);