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 25881ac6ea..3a3eb302d0 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 b62a220f7d..ae6528267f 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 d3b36ea093..362dc54f89 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 6cb59b60ee..943b0c6918 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/HW_Init.c b/TFT/src/User/API/HW_Init.c index ceefad1b0f..e6945504fe 100644 --- a/TFT/src/User/API/HW_Init.c +++ b/TFT/src/User/API/HW_Init.c @@ -109,7 +109,7 @@ void HW_Init(void) LCD_Enc_InitActiveSignal(); #endif - if (readIsTSCExist() == false) // read settings parameter + if (!readIsTSCExist()) // read settings parameter { LCD_RefreshDirection(infoSettings.rotated_ui); TS_Calibrate(); diff --git a/TFT/src/User/API/Language/utf8_decode.c b/TFT/src/User/API/Language/utf8_decode.c index f9ea5178ea..db86038a6d 100644 --- a/TFT/src/User/API/Language/utf8_decode.c +++ b/TFT/src/User/API/Language/utf8_decode.c @@ -213,7 +213,7 @@ uint16_t GUI_StrPixelWidth_label(int16_t index) { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText((uint8_t *)tempstr, index) == false) + if (!loadLabelText((uint8_t *)tempstr, index)) return 0; return GUI_StrPixelWidth_str(tempstr); diff --git a/TFT/src/User/API/LevelingControl.c b/TFT/src/User/API/LevelingControl.c index a15f36c236..6fd736ba14 100644 --- a/TFT/src/User/API/LevelingControl.c +++ b/TFT/src/User/API/LevelingControl.c @@ -72,7 +72,7 @@ void levelingMoveToPoint(LEVELING_POINT point) levelingGetPointCoords(coords); - if (coordinateIsKnown() == false) + if (!coordinateIsKnown()) storeCmd("G28\n"); storeCmd("G0 Z%.3f F%d\n", infoSettings.level_z_raise, infoSettings.level_feedrate[FEEDRATE_Z]); @@ -86,7 +86,7 @@ void levelingProbePoint(LEVELING_POINT point) levelingGetPointCoords(coords); - if (coordinateIsKnown() == false) + if (!coordinateIsKnown()) probeHeightHomeAndRaise(); // home and raise nozzle if (infoSettings.touchmi_sensor != 0) diff --git a/TFT/src/User/API/Mainboard_AckHandler.c b/TFT/src/User/API/Mainboard_AckHandler.c index 48d028e1f8..449a8c7912 100644 --- a/TFT/src/User/API/Mainboard_AckHandler.c +++ b/TFT/src/User/API/Mainboard_AckHandler.c @@ -378,7 +378,7 @@ void parseAck(void) // TFT to printer connection handling //---------------------------------------- - if (infoHost.connected == false) + if (!infoHost.connected) { // parse error information even though not connected to printer if (ack_seen(magic_error)) diff --git a/TFT/src/User/API/Mainboard_CmdHandler.c b/TFT/src/User/API/Mainboard_CmdHandler.c index 719fc163fd..b46964289c 100644 --- a/TFT/src/User/API/Mainboard_CmdHandler.c +++ b/TFT/src/User/API/Mainboard_CmdHandler.c @@ -417,7 +417,7 @@ static bool openRemoteTFT(bool writingMode) if (!writingMode) // if reading mode { // mount FS and open the file (infoFile.source and infoFile.path are used) - if (mountFS() == true && f_open(&file, infoFile.path, FA_OPEN_EXISTING | FA_READ) == FR_OK) + if (mountFS() && f_open(&file, infoFile.path, FA_OPEN_EXISTING | FA_READ) == FR_OK) { char buf[10]; @@ -436,7 +436,7 @@ static bool openRemoteTFT(bool writingMode) else // if writing mode { // mount FS and open the file (infoFile.source and infoFile.path are used) - if (mountFS() == true && f_open(&file, infoFile.path, FA_OPEN_ALWAYS | FA_WRITE) == FR_OK) + if (mountFS() && f_open(&file, infoFile.path, FA_OPEN_ALWAYS | FA_WRITE) == FR_OK) { Serial_Forward(cmd_port_index, "Writing to file: "); Serial_Forward(cmd_port_index, infoFile.path); @@ -700,7 +700,7 @@ void sendQueueCmd(void) Serial_Forward(cmd_port_index, "Begin file list\n"); // then mount FS and scan for files (infoFile.source and infoFile.path are used) - if (mountFS() == true && scanPrintFiles() == true) + if (mountFS() && scanPrintFiles()) { for (uint16_t i = 0; i < infoFile.fileCount; i++) { @@ -857,7 +857,7 @@ void sendQueueCmd(void) if (initRemoteTFT()) // examples: "M30 SD:/test/cap2.gcode\n", "M30 S /test/cap2.gcode\n" { // then mount FS and delete the file (infoFile.source and infoFile.path are used) - if (mountFS() == true && f_unlink(infoFile.path) == FR_OK) + if (mountFS() && f_unlink(infoFile.path) == FR_OK) Serial_Forward(cmd_port_index, "File deleted: "); else Serial_Forward(cmd_port_index, "Deletion failed, File: "); @@ -912,7 +912,7 @@ void sendQueueCmd(void) msgText = parseM118(rawMsg, &hasE, &hasA); // format: + + + "\n" - snprintf(msg, CMD_MAX_SIZE, "%s%s%s\n", (hasE == true) ? "echo:" : "", (hasA == true) ? "//" : "", msgText); + snprintf(msg, CMD_MAX_SIZE, "%s%s%s\n", hasE ? "echo:" : "", hasA ? "//" : "", msgText); int32_t fwdPort = cmd_seen('P') ? cmd_value() : SUP_PORTS; @@ -1570,7 +1570,7 @@ void sendQueueCmd(void) // - if TFT is connected, update tx slots and tx count // - if TFT is not connected, consider the command as an out of band message // - if (sendCmd(false, avoid_terminal) == true && infoHost.connected == true) + if (sendCmd(false, avoid_terminal) && infoHost.connected) { // decrease the number of available tx slots and increase the pending commands tx count // diff --git a/TFT/src/User/API/Mainboard_FlowControl.c b/TFT/src/User/API/Mainboard_FlowControl.c index 5529310412..fda80fd89a 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 12824bb67a..5a104aab0f 100644 --- a/TFT/src/User/API/Notification.c +++ b/TFT/src/User/API/Notification.c @@ -19,7 +19,7 @@ static bool _toastRunning = false; // "true" when a toast notification is static bool _toastAvailable = false; // "true" when a new toast is added. "false" when no more toasts to display are available static uint8_t nextToastIndex = 0; // next index to store new toast static uint8_t curToastDisplay = 0; // current toast notification being displayed -static uint32_t nextToastTime = 0; // time to change to next toast notification +static uint32_t lastToastTime = 0; // time to change to next toast notification // message notification variables static NOTIFICATION msglist[MAX_MSG_COUNT]; // message notification array @@ -45,7 +45,7 @@ void drawToast(bool redraw) if (!redraw) curToastDisplay = (curToastDisplay + 1) % TOAST_MSG_COUNT; - if (toastlist[curToastDisplay].isNew == true || redraw) + if (toastlist[curToastDisplay].isNew || redraw) { // set toast notification running status _toastRunning = true; @@ -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 + lastToastTime = OS_GetTimeMs(); } GUI_SetTextMode(GUI_TEXTMODE_TRANS); @@ -110,7 +110,7 @@ static inline bool toastAvailable(void) { for (int i = 0; i < TOAST_MSG_COUNT; i++) { - if (toastlist[i].isNew == true) + if (toastlist[i].isNew) return true; } @@ -121,14 +121,14 @@ 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 || ((OS_GetTimeMs() - lastToastTime) < SEC_TO_MS(TOAST_DURATION)) || getMenuType() == MENU_TYPE_FULLSCREEN) return; if (toastAvailable()) { drawToast(false); } - else if (_toastRunning == true) + else if (_toastRunning) { _toastRunning = false; _toastAvailable = false; diff --git a/TFT/src/User/API/PowerFailed.c b/TFT/src/User/API/PowerFailed.c index 79945c4048..eda4ed3457 100644 --- a/TFT/src/User/API/PowerFailed.c +++ b/TFT/src/User/API/PowerFailed.c @@ -149,7 +149,7 @@ bool powerFailedInitRestore(void) mustStoreCmd("G92 E%.5f\nG1 F%d\n", infoBreakPoint.axis[E_AXIS], infoBreakPoint.feedrate); mustStoreCmd(infoBreakPoint.relative ? "G91\n" : "G90\n"); - if (infoBreakPoint.relative_e == false) + if (!infoBreakPoint.relative_e) mustStoreCmd("M82\n"); } diff --git a/TFT/src/User/API/Printing.c b/TFT/src/User/API/Printing.c index 99dcb6c670..1637512ab6 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}; @@ -614,7 +614,7 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType) { case FS_TFT_SD: case FS_TFT_USB: - if (isPause == true && pauseType == PAUSE_M0) + if (isPause && pauseType == PAUSE_M0) TASK_LOOP_WHILE(isNotEmptyCmdQueue()); // wait for the communication to be clean static COORDINATE tmp; @@ -632,8 +632,8 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType) { coordinateGetAll(&tmp); - if (isCoorRelative == true) mustStoreCmd("G90\n"); - if (isExtrudeRelative == true) mustStoreCmd("M82\n"); + if (isCoorRelative) mustStoreCmd("G90\n"); + if (isExtrudeRelative) mustStoreCmd("M82\n"); if (heatGetCurrentTemp(heatGetCurrentHotend()) > infoSettings.min_ext_temp) { @@ -648,8 +648,8 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType) infoSettings.pause_feedrate[FEEDRATE_XY]); } - if (isCoorRelative == true) mustStoreCmd("G91\n"); - if (isExtrudeRelative == true) mustStoreCmd("M83\n"); + if (isCoorRelative) mustStoreCmd("G91\n"); + if (isExtrudeRelative) mustStoreCmd("M83\n"); } // store pause type only on pause @@ -663,10 +663,10 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType) } else if (pauseType == PAUSE_NORMAL) // send command only for pause originated from TFT { - if (isCoorRelative == true) mustStoreCmd("G90\n"); - if (isExtrudeRelative == true) mustStoreCmd("M82\n"); + if (isCoorRelative) mustStoreCmd("G90\n"); + if (isExtrudeRelative) mustStoreCmd("M82\n"); - if (extrusionDuringPause == true) // check if extrusion done during Print -> Pause + if (extrusionDuringPause) // check if extrusion done during Print -> Pause { // no purge extrusionDuringPause = false; } @@ -685,8 +685,8 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType) mustStoreCmd("G92 E%.5f\n", tmp.axis[E_AXIS]); mustStoreCmd("G1 F%d\n", tmp.feedrate); - if (isCoorRelative == true) mustStoreCmd("G91\n"); - if (isExtrudeRelative == true) mustStoreCmd("M83\n"); + if (isCoorRelative) mustStoreCmd("G91\n"); + if (isExtrudeRelative) mustStoreCmd("M83\n"); } } break; @@ -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/Printing.h b/TFT/src/User/API/Printing.h index 449014a431..b14cfcaae2 100644 --- a/TFT/src/User/API/Printing.h +++ b/TFT/src/User/API/Printing.h @@ -12,7 +12,7 @@ extern "C" { #ifdef RAPID_SERIAL_COMM #define RAPID_SERIAL_LOOP() loopBackEnd() - #define RAPID_PRINTING_COMM() if (isPrinting() == true && infoSettings.serial_always_on != 1) {loopBackEnd();} + #define RAPID_PRINTING_COMM() if (isPrinting() && infoSettings.serial_always_on != 1) {loopBackEnd();} #else #define RAPID_SERIAL_LOOP() #define RAPID_PRINTING_COMM() diff --git a/TFT/src/User/API/ProbeHeightControl.c b/TFT/src/User/API/ProbeHeightControl.c index 8bc3615f3b..ab4598eded 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 91cc4195a7..11f7acf440 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 deb3b13993..655778c08c 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 5eec11997e..e348750c27 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 86985a28d2..1c92e92069 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 91f67f4036..e520c8bea6 100644 --- a/TFT/src/User/API/Temperature.c +++ b/TFT/src/User/API/Temperature.c @@ -64,7 +64,7 @@ void heatSetTargetTemp(uint8_t index, const int16_t temp, const TEMP_SOURCE temp break; case FROM_CMD: - if (GET_BIT(heat_feedback_waiting, index) == false) + if (!GET_BIT(heat_feedback_waiting, index)) { heater.T[index].target = temp; SET_BIT_ON(heat_feedback_waiting, index); @@ -113,14 +113,14 @@ void heatCoolDown(void) bool heatGetIsWaiting(const uint8_t index) { - return (heater.T[index].waiting == true); + return (heater.T[index].waiting); } bool heatHasWaiting(void) { for (uint8_t i = 0; i < MAX_HEATER_COUNT; i++) { - if (heater.T[i].waiting == true) + if (heater.T[i].waiting) return true; } @@ -136,9 +136,9 @@ void heatSetIsWaiting(uint8_t index, const bool isWaiting) heater.T[index].waiting = isWaiting; - if (isWaiting == true) // wait heating now, query more frequently + if (isWaiting) // wait heating now, query more frequently heatSetUpdateSeconds(TEMPERATURE_QUERY_FAST_SECONDS); - else if (heatHasWaiting() == false) + else if (!heatHasWaiting()) heatSetUpdateSeconds(TEMPERATURE_QUERY_SLOW_SECONDS); } @@ -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 722c59aa7e..19c9c5fd18 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 3bb2421cf9..3bccf2f14a 100644 --- a/TFT/src/User/API/Touch_Screen.c +++ b/TFT/src/User/API/Touch_Screen.c @@ -81,10 +81,10 @@ 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) + if (TS_Sound) BUZZER_PLAY(SOUND_KEYPRESS); #endif @@ -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,8 @@ 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); } @@ -170,6 +172,8 @@ static inline uint8_t TS_CalibrationEnsure(uint16_t x, uint16_t y) { while (TS_IsPressed()); + Buzzer_AddSound(100, 200); + GUI_SetColor(RED); GUI_DispStringCenter(LCD_WIDTH / 2, LCD_HEIGHT - 40, (int32_t)LABEL_ADJUST_FAILED); GUI_DispDec(0, 0, lcd_x, 3, 0); @@ -211,12 +215,14 @@ 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/GUI.c b/TFT/src/User/API/UI/GUI.c index 65fa33be10..1cc99d46a1 100644 --- a/TFT/src/User/API/UI/GUI.c +++ b/TFT/src/User/API/UI/GUI.c @@ -939,7 +939,7 @@ void _GUI_DispLabel(int16_t x, int16_t y, uint16_t index) { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return; _GUI_DispString(x, y, tempstr); @@ -949,7 +949,7 @@ const uint8_t * _GUI_DispLenLabel(int16_t x, int16_t y, uint16_t index, uint16_t { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return NULL; return _GUI_DispLenString(x, y, tempstr, pixelWidth, truncate); @@ -959,7 +959,7 @@ void _GUI_DispLabelRight(int16_t x, int16_t y, uint16_t index) { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return; _GUI_DispStringRight(x, y, tempstr); @@ -969,7 +969,7 @@ void _GUI_DispLabelCenter(int16_t x, int16_t y, uint16_t index) { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return; _GUI_DispStringCenter(x, y, tempstr); @@ -979,7 +979,7 @@ void _GUI_DispLabelInRect(int16_t sx, int16_t sy, int16_t ex, int16_t ey, uint16 { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return; _GUI_DispStringInRect(sx, sy, ex, ey, tempstr); @@ -989,7 +989,7 @@ void _GUI_DispLabelInPrect(const GUI_RECT * rect, uint16_t index) { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return; _GUI_DispStringInPrect(rect, tempstr); @@ -999,7 +999,7 @@ void _GUI_DispLabelInRectEOL(int16_t sx, int16_t sy, int16_t ex, int16_t ey, uin { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return; _GUI_DispStringInRectEOL(sx, sy, ex, ey, tempstr); @@ -1009,7 +1009,7 @@ void _GUI_DispLabelInPrectEOL(const GUI_RECT * rect, uint16_t index) { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return; _GUI_DispStringInPrectEOL(rect, tempstr); @@ -1019,7 +1019,7 @@ void _GUI_DispLabelOnIcon(uint16_t iconIndex, GUI_POINT iconPoint, GUI_POINT tex { uint8_t tempstr[MAX_LANG_LABEL_LENGTH]; - if (loadLabelText(tempstr, index) == false) + if (!loadLabelText(tempstr, index)) return; _GUI_DispStringOnIcon(iconIndex, iconPoint, textPos, tempstr); diff --git a/TFT/src/User/API/UI/ListManager.c b/TFT/src/User/API/UI/ListManager.c index 2f6b63ea09..c2498cd2d8 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 0759c34991..2e3a3e2429 100644 --- a/TFT/src/User/API/UI/Numpad.c +++ b/TFT/src/User/API/UI/Numpad.c @@ -234,9 +234,9 @@ double numPadFloat(uint8_t * title, double param_val, double reset_val, bool neg setMenu(MENU_TYPE_FULLSCREEN, NULL, COUNT(rect_of_numkey), rect_of_numkey, drawKeypadButton, NULL); Draw_keyboard(numTitle, false, negative); - while (TS_Sound == false) // TS_TouchSound gets true only when exit from numpad is requested + while (!TS_Sound) // TS_TouchSound gets true only when exit from numpad is requested { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { @@ -286,7 +286,7 @@ double numPadFloat(uint8_t * title, double param_val, double reset_val, bool neg case NUM_KEY_8: case NUM_KEY_9: case NUM_KEY_0: - if (valueFirstPress == true) + if (valueFirstPress) { valueFirstPress = false; bufIndex = lastIndex = 0; @@ -314,7 +314,7 @@ double numPadFloat(uint8_t * title, double param_val, double reset_val, bool neg break; case NUM_KEY_DEC: - if (valueFirstPress == true) + if (valueFirstPress) { valueFirstPress = false; parameterBuf[0] = '0'; @@ -342,7 +342,7 @@ double numPadFloat(uint8_t * title, double param_val, double reset_val, bool neg case NUM_KEY_MINUS: if (negative) { - if (valueFirstPress == true) + if (valueFirstPress) { valueFirstPress = false; parameterBuf[0] = '0'; @@ -419,9 +419,9 @@ int32_t numPadInt(uint8_t * title, int32_t param_val, int32_t reset_val, bool ne drawValue(parameterBuf); - while (TS_Sound == false) // TS_TouchSound gets true only when exit from numpad is requested + while (!TS_Sound) // TS_TouchSound gets true only when exit from numpad is requested { - key_num = menuKeyGetValue(); + key_num = menuKeyGetValue(false); switch (key_num) { @@ -467,7 +467,7 @@ int32_t numPadInt(uint8_t * title, int32_t param_val, int32_t reset_val, bool ne case NUM_KEY_8: case NUM_KEY_9: case NUM_KEY_0: - if (valueFirstPress == true) + if (valueFirstPress) { valueFirstPress = false; val = 0; diff --git a/TFT/src/User/API/Vfs/vfs.c b/TFT/src/User/API/Vfs/vfs.c index 621e80d722..600ae9ce0a 100644 --- a/TFT/src/User/API/Vfs/vfs.c +++ b/TFT/src/User/API/Vfs/vfs.c @@ -188,7 +188,7 @@ static char * isSupportedFile(const char * filename) // add a file name or folder name to file list bool addFile(bool isFile, const char * shortName, const char * longName) { - if (isFile == true) // if file + if (isFile) // if file { // if file list is full or filename doesn't provide a supported filename extension if (infoFile.fileCount >= FILE_NUM || isSupportedFile(shortName) == NULL) diff --git a/TFT/src/User/API/comment.c b/TFT/src/User/API/comment.c index 5aa84b2609..d1f885770b 100644 --- a/TFT/src/User/API/comment.c +++ b/TFT/src/User/API/comment.c @@ -59,7 +59,7 @@ void parseComment(void) } // check for "time" keyword in comment to retrieve total or elapsed time, Cura specific - else if (strcmp(token, "time") == 0 && slicerTimePresence == false) // check if first word is "time" + else if (strcmp(token, "time") == 0 && !slicerTimePresence) // check if first word is "time" { if ((token = strtok(NULL, TOKEN_DELIMITERS)) != NULL) { @@ -86,7 +86,7 @@ void parseComment(void) } // check for "remaining" keyword in comment to retrieve remaining time, IdeaMaker specific - else if (strcmp(token, "remaining") == 0 && slicerTimePresence == false) // check if first word is "remaining" + else if (strcmp(token, "remaining") == 0 && !slicerTimePresence) // check if first word is "remaining" { if ((token = strtok(NULL, TOKEN_DELIMITERS)) != NULL) { diff --git a/TFT/src/User/API/config.c b/TFT/src/User/API/config.c index f7a701b590..4508ef57ae 100644 --- a/TFT/src/User/API/config.c +++ b/TFT/src/User/API/config.c @@ -1129,7 +1129,7 @@ static bool readConfigFile(const char * path, void (* lineParser)(), uint16_t ma CONFIGFILE configFile; CurConfigFile = &configFile; - if (f_file_exists(path) == false) + if (!f_file_exists(path)) return false; if (f_open(&configFile.file, path, FA_OPEN_EXISTING | FA_READ) != FR_OK) @@ -1322,7 +1322,7 @@ void resetConfig(void) bool getConfigFromFile(char * configPath) { - if (f_file_exists(configPath) == false) + if (!f_file_exists(configPath)) { PRINTDEBUG("configFile not found\n"); diff --git a/TFT/src/User/API/menu.c b/TFT/src/User/API/menu.c index 26b6df10ae..5094a4c17b 100644 --- a/TFT/src/User/API/menu.c +++ b/TFT/src/User/API/menu.c @@ -5,6 +5,8 @@ #define STATUS_BAR_REFRESH_TIME 2000 // refresh time in ms +uint8_t longPressed = 0; + const GUI_RECT exhibitRect = { #ifdef PORTRAIT_MODE // exhibitRect is 2 ICON Space in the Lowest Row and 2 Center column. @@ -268,7 +270,7 @@ const GUI_RECT rect_of_keyPS[] = { // PS = PRINT SCREEN, This template is used t }; #ifdef PORTRAIT_MODE - static const GUI_RECT rect_of_keyPS_draw[] = { // VERTICAL GUI Printing menu for drawing UI + static const GUI_RECT rect_of_keyPS_draw[] = { // VERTICAL GUI Printing menu for drawing UI {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, @@ -607,7 +609,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 +617,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; @@ -657,12 +660,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 @@ -860,12 +863,16 @@ void menuDrawTitle(void) // when there is a button value, the icon changes color and redraws static void itemDrawIconPress(uint8_t position, uint8_t is_press) { - if (position > KEY_ICON_7) return; + if (position > KEY_ICON_7) + return; if (menuType == MENU_TYPE_ICON) { - if (curMenuItems == NULL) return; - if (curMenuItems->items[position].icon == ICON_NULL) return; + if (curMenuItems == NULL) + return; + + if (curMenuItems->items[position].icon == ICON_NULL) + return; const GUI_RECT * rect = curRect + position; @@ -876,7 +883,8 @@ static void itemDrawIconPress(uint8_t position, uint8_t is_press) } else if (menuType == MENU_TYPE_LISTVIEW) { // draw rec over list item if pressed - if (curListItems == NULL) return; + if (curListItems == NULL) + return; const GUI_RECT * rect = rect_of_keyListView + position; @@ -897,7 +905,8 @@ 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; @@ -1001,7 +1010,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; @@ -1086,102 +1095,93 @@ 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)) { - 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); - } - else - { - tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_key), rect_of_key); - } - break; + 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); - case MENU_TYPE_LISTVIEW: - tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keyListView), rect_of_keyListView); - - if (tempkey == ITEM_PER_PAGE) + if (tempkey == (KEY_VALUES)PS_KEY_TITLEBAR) tempkey = KEY_TITLEBAR; - break; + } + 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); + } + break; + } - 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; + case MENU_TYPE_LISTVIEW: + tempkey = (KEY_VALUES)KEY_GetValue(COUNT(rect_of_keyListView), rect_of_keyListView); + + 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; @@ -1189,53 +1189,59 @@ void loopCheckBackPress(void) Touch_Enc_ReadPen(0); // reset TSC press timer #endif - return; + return tempkey; } - 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 + if (backHeld) // prevent mode selection or screenshot if Back button is held { - backHeld = Touch_Enc_ReadPen(0); - - return; + backHeld = Touch_Enc_ReadPen(0); // reset TSC press timer + return tempkey; } #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; +} diff --git a/TFT/src/User/API/menu.h b/TFT/src/User/API/menu.h index 04555bfbfe..3393082ea4 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 0c745f22d8..2daa400a71 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/Fatfs/myfatfs.c b/TFT/src/User/Fatfs/myfatfs.c index 371eb42b1b..4307b4fe19 100644 --- a/TFT/src/User/Fatfs/myfatfs.c +++ b/TFT/src/User/Fatfs/myfatfs.c @@ -111,12 +111,12 @@ bool scanPrintFilesFatFs(void) if ((finfo.fattrib & AM_DIR) == AM_DIR) // if folder { - if (addFile(false, finfo.fname, NULL) == true) // if folder successfully added to folder list + if (addFile(false, finfo.fname, NULL)) // if folder successfully added to folder list folderDate[infoFile.folderCount - 1] = ((uint32_t)(finfo.fdate) << 16) | finfo.ftime; // copy date/time modified } else // if file { - if (addFile(true, finfo.fname, NULL) == true) // if file successfully added to file list + if (addFile(true, finfo.fname, NULL)) // if file successfully added to file list fileDate[infoFile.fileCount - 1] = ((uint32_t)(finfo.fdate) << 16) | finfo.ftime; // copy date/time modified } } diff --git a/TFT/src/User/Hal/STM32_USB_HOST_Library/Class/MSC/src/usbh_msc_core.c b/TFT/src/User/Hal/STM32_USB_HOST_Library/Class/MSC/src/usbh_msc_core.c index 4d5dd63ed9..6b3299e6ed 100644 --- a/TFT/src/User/Hal/STM32_USB_HOST_Library/Class/MSC/src/usbh_msc_core.c +++ b/TFT/src/User/Hal/STM32_USB_HOST_Library/Class/MSC/src/usbh_msc_core.c @@ -349,7 +349,7 @@ static USBH_Status USBH_MSC_Handle(USB_OTG_CORE_HANDLE *pdev , MSC_Machine.maxLun = *(MSC_Machine.buff) ; /* If device has more that one logical unit then it is not supported */ - if((MSC_Machine.maxLun > 0) && (maxLunExceed == FALSE)) + if((MSC_Machine.maxLun > 0) && !maxLunExceed) { maxLunExceed = TRUE; pphost->usr_cb->DeviceNotSupported(); diff --git a/TFT/src/User/Hal/gd32f20x/Serial.c b/TFT/src/User/Hal/gd32f20x/Serial.c index 98fcaf2857..5291eabe52 100644 --- a/TFT/src/User/Hal/gd32f20x/Serial.c +++ b/TFT/src/User/Hal/gd32f20x/Serial.c @@ -269,7 +269,7 @@ void Serial_Put(uint8_t port, const char * msg) // ISR, serial interrupt handler void USART_IRQHandler(uint8_t port) { - #if IDLE_LINE_IT == true // IDLE Line interrupt + #if IDLE_LINE_IT // IDLE Line interrupt if ((USART_STAT0(Serial[port].uart) & USART_STAT0_IDLEF) != RESET) // check for IDLE Line interrupt { USART_STAT0(Serial[port].uart); // clear IDLE Line bit diff --git a/TFT/src/User/Hal/gd32f30x/Serial.c b/TFT/src/User/Hal/gd32f30x/Serial.c index f725ec1a98..e67dee8e92 100644 --- a/TFT/src/User/Hal/gd32f30x/Serial.c +++ b/TFT/src/User/Hal/gd32f30x/Serial.c @@ -259,7 +259,7 @@ void Serial_Put(uint8_t port, const char * msg) // ISR, serial interrupt handler void USART_IRQHandler(uint8_t port) { - #if IDLE_LINE_IT == true // IDLE Line interrupt + #if IDLE_LINE_IT // IDLE Line interrupt if ((USART_STAT0(Serial[port].uart) & USART_STAT0_IDLEF) != RESET) // check for IDLE Line interrupt { USART_STAT0(Serial[port].uart); // clear IDLE Line bit diff --git a/TFT/src/User/Hal/stm32f10x/Serial.c b/TFT/src/User/Hal/stm32f10x/Serial.c index f11100eb35..792c708f8f 100644 --- a/TFT/src/User/Hal/stm32f10x/Serial.c +++ b/TFT/src/User/Hal/stm32f10x/Serial.c @@ -236,7 +236,7 @@ void Serial_Put(uint8_t port, const char * msg) // ISR, serial interrupt handler void USART_IRQHandler(uint8_t port) { - #if IDLE_LINE_IT == true // IDLE Line interrupt + #if IDLE_LINE_IT // IDLE Line interrupt if ((Serial[port].uart->SR & USART_SR_IDLE) != RESET) // check for IDLE Line interrupt { Serial[port].uart->SR; // clear IDLE Line bit diff --git a/TFT/src/User/Hal/stm32f2_f4xx/Serial.c b/TFT/src/User/Hal/stm32f2_f4xx/Serial.c index a7e9e874f6..25089d3cec 100644 --- a/TFT/src/User/Hal/stm32f2_f4xx/Serial.c +++ b/TFT/src/User/Hal/stm32f2_f4xx/Serial.c @@ -287,7 +287,7 @@ void Serial_Put(uint8_t port, const char * msg) // ISR, serial interrupt handler void USART_IRQHandler(uint8_t port) { - #if IDLE_LINE_IT == true // IDLE Line interrupt + #if IDLE_LINE_IT // IDLE Line interrupt if ((Serial[port].uart->SR & USART_SR_IDLE) != RESET) // check for IDLE Line interrupt { Serial[port].uart->SR; // clear IDLE Line bit diff --git a/TFT/src/User/Menu/ABL.c b/TFT/src/User/Menu/ABL.c index 0bf09aa480..863255eeef 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) { @@ -140,7 +140,7 @@ static void menuUBLSaveLoad(void) break; case KEY_ICON_7: - if (ublSlotSaved == true && infoMachineSettings.EEPROM == 1) + if (ublSlotSaved && infoMachineSettings.EEPROM == 1) popupDialog(DIALOG_TYPE_QUESTION, LABEL_ABL_SETTINGS_UBL, LABEL_ABL_SLOT_EEPROM, LABEL_CONFIRM, LABEL_CANCEL, saveEepromSettings, NULL, NULL); ublSlotSaved = false; diff --git a/TFT/src/User/Menu/BLTouch.c b/TFT/src/User/Menu/BLTouch.c index be0fab0fa5..8636977be0 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 deef34325a..cdb750b0a4 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 a8c2c77b7a..f84f717350 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 f47e446f85..486585c395 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 0e222b9145..3017c1bf85 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 d22d2a224a..6244e4fdbb 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 2cac30b5ea..9801490319 100644 --- a/TFT/src/User/Menu/Extrude.c +++ b/TFT/src/User/Menu/Extrude.c @@ -38,7 +38,7 @@ void menuExtrude(void) menuDrawPage(&extrudeItems); - if (eAxisBackup.handled == false) + if (!eAxisBackup.handled) { TASK_LOOP_WHILE(isNotEmptyCmdQueue()); // wait for the communication to be clean @@ -54,14 +54,17 @@ void menuExtrude(void) extruderReDraw(curExtruder_index, extrAmount, true); - if (eAxisBackup.relative == false) // set extruder to relative + if (!eAxisBackup.relative) // set extruder to relative mustStoreCmd("M83\n"); heatSetUpdateSeconds(TEMPERATURE_QUERY_FAST_SECONDS); 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 +85,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 +93,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); @@ -163,16 +169,16 @@ void menuExtrude(void) loopProcess(); } - if (eAxisBackup.handled == false) // the user exited from menu (not any other process/popup/etc) + if (!eAxisBackup.handled) // the user exited from menu (not any other process/popup/etc) { // restore E axis coordinate, feedrate and relativeness to pre-extrude state mustStoreCmd("G92 E%.5f\n", eAxisBackup.coordinate); mustStoreCmd("G0 F%d\n", eAxisBackup.feedrate); - if (eAxisBackup.relative == false) + if (!eAxisBackup.relative) mustStoreCmd("M82\n"); // set extruder to absolute } // set slow update time if not waiting for target temperature - if (heatHasWaiting() == false) + if (!heatHasWaiting()) heatSetUpdateSeconds(TEMPERATURE_QUERY_SLOW_SECONDS); } diff --git a/TFT/src/User/Menu/Fan.c b/TFT/src/User/Menu/Fan.c index ea55dbfc17..e39e6d118d 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 8663685da7..b6893ab40a 100644 --- a/TFT/src/User/Menu/Heat.c +++ b/TFT/src/User/Menu/Heat.c @@ -49,13 +49,19 @@ 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 +74,18 @@ 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: @@ -123,6 +140,6 @@ void menuHeat(void) last_nozzle_index = tool_index; // save last used hotend index // set slow update time if not waiting for target temperature - if (heatHasWaiting() == false) + if (!heatHasWaiting()) heatSetUpdateSeconds(TEMPERATURE_QUERY_SLOW_SECONDS); } diff --git a/TFT/src/User/Menu/Home.c b/TFT/src/User/Menu/Home.c index 6da0577255..4566de892e 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 65135aed91..9a5b1244ab 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 6dd35a2d01..ffe38cb3e1 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 f89d9b73c5..17a78c4a34 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 0b7b3308e4..5cc18228e6 100644 --- a/TFT/src/User/Menu/LoadUnload.c +++ b/TFT/src/User/Menu/LoadUnload.c @@ -33,7 +33,7 @@ void menuLoadUnload(void) { KEY_VALUES key_num = KEY_IDLE; - if (eAxisBackup.handled == false) + if (!eAxisBackup.handled) { TASK_LOOP_WHILE(isNotEmptyCmdQueue()); // wait for the communication to be clean @@ -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) @@ -168,10 +168,10 @@ void menuLoadUnload(void) loopProcess(); } - if (eAxisBackup.handled == false) // the user exited from menu (not any other process/popup/etc) + if (!eAxisBackup.handled) // the user exited from menu (not any other process/popup/etc) mustStoreCmd("G92 E%.5f\n", eAxisBackup.coordinate); // reset E axis position in Marlin to pre - load/unload state // set slow update time if not waiting for target temperature - if (heatHasWaiting() == false) + if (!heatHasWaiting()) heatSetUpdateSeconds(TEMPERATURE_QUERY_SLOW_SECONDS); } diff --git a/TFT/src/User/Menu/MBL.c b/TFT/src/User/Menu/MBL.c index 0923dc110f..25ce130d29 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 9c759dc45f..743088f0ef 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 b4c14c1a02..5fe466e666 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 937de3f6c2..90c0293259 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 2cebcfc5b7..298fc1821a 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) { @@ -827,7 +827,7 @@ void menuMeshEditor(void) break; case ME_KEY_EDIT: - if (coordinateIsKnown() == false) + if (!coordinateIsKnown()) probeHeightHome(); // home, disable ABL and raise nozzle // call mesh tuner menu and set current mesh value, if changed diff --git a/TFT/src/User/Menu/MeshTuner.c b/TFT/src/User/Menu/MeshTuner.c index e6e4386aa0..b31f87ec76 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 37e0515775..d64023deb2 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 6705ce6c14..e8c2d87e04 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 ba72194e45..4c418bd793 100644 --- a/TFT/src/User/Menu/Move.c +++ b/TFT/src/User/Menu/Move.c @@ -141,7 +141,10 @@ 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 +154,27 @@ 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 1e03bf5ae8..e0957e6094 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/PersistentInfo.c b/TFT/src/User/Menu/PersistentInfo.c index 6ce613162a..300bc7b619 100644 --- a/TFT/src/User/Menu/PersistentInfo.c +++ b/TFT/src/User/Menu/PersistentInfo.c @@ -10,7 +10,7 @@ static bool temperatureStatusValid(void) { if (infoSettings.persistent_info != 1) return false; - if (infoHost.connected == false) return false; + if (!infoHost.connected) return false; if (toastRunning()) return false; if (MENU_IS(menuPrinting)) return false; diff --git a/TFT/src/User/Menu/Pid.c b/TFT/src/User/Menu/Pid.c index 8373f71c03..0115232d33 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/Popup.c b/TFT/src/User/Menu/Popup.c index d901df732a..806ab002ee 100644 --- a/TFT/src/User/Menu/Popup.c +++ b/TFT/src/User/Menu/Popup.c @@ -210,7 +210,7 @@ void showDialog(DIALOG_TYPE type, void (* ok_action)(), void (* cancel_action)() void loopPopup(void) { // display the last received popup message, overriding previous popup messages, if any - if (popup_redraw == false) + if (!popup_redraw) return; popup_redraw = false; diff --git a/TFT/src/User/Menu/PreheatMenu.c b/TFT/src/User/Menu/PreheatMenu.c index 145b7dfbef..1d8a200caf 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 36a2d59fec..ca49ac31c0 100644 --- a/TFT/src/User/Menu/Print.c +++ b/TFT/src/User/Menu/Print.c @@ -94,7 +94,7 @@ static inline void gcodeIconDraw(void) // in order to properly access the file (e.g. for print thumbnail preview, printing etc.), FQDN short (not long) // filename (filename extension must be restored, if previously hidden) must be used for the file path // - if (enterFolder(restoreFilenameExtension(baseIndex + i - infoFile.folderCount)) == false) + if (!enterFolder(restoreFilenameExtension(baseIndex + i - infoFile.folderCount))) break; // if model preview bmp exists, display bmp directly without writing to flash @@ -153,7 +153,7 @@ static bool printPageItemSelected(uint16_t index) // in order to properly access the folder (e.g. for browsing its files and folders), short (not long) // folder name must be used for the file path // - if (enterFolder(infoFile.folder[index]) == false) + if (!enterFolder(infoFile.folder[index])) { hasUpdate = false; } @@ -173,7 +173,7 @@ static bool printPageItemSelected(uint16_t index) // in order to properly access the file (e.g. for print thumbnail preview, printing etc.), FQDN short (not long) // filename (filename extension must be restored, if previously hidden) must be used for the file path // - if (infoHost.connected == false || enterFolder(infoFile.file[infoFile.fileIndex]) == false) + if (!infoHost.connected || !enterFolder(infoFile.file[infoFile.fileIndex])) { hasUpdate = false; } @@ -222,7 +222,7 @@ void menuPrintFromSource(void) GUI_Clear(infoSettings.bg_color); GUI_DispStringInRect(0, 0, LCD_WIDTH, LCD_HEIGHT, LABEL_LOADING); - if (mountFS() == true && scanPrintFiles() == true) + if (mountFS() && scanPrintFiles()) { if (MENU_IS_NOT(menuPrintFromSource)) // menu index has to be modified when "scanPrintFilesGcodeFs" (echo,error,warning popup windows) return; @@ -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) { @@ -276,7 +276,7 @@ void menuPrintFromSource(void) case KEY_ICON_7: infoFile.curPage = 0; - if (isRootFolder() == true) + if (isRootFolder()) { clearInfoFile(); @@ -306,7 +306,7 @@ void menuPrintFromSource(void) switch (key_num) { case KEY_BACK: - if (isRootFolder() == true) + if (isRootFolder()) { clearInfoFile(); @@ -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/PrintRestore.c b/TFT/src/User/Menu/PrintRestore.c index a3c9525f5e..5483f82cc6 100644 --- a/TFT/src/User/Menu/PrintRestore.c +++ b/TFT/src/User/Menu/PrintRestore.c @@ -10,7 +10,7 @@ void menuPrintRestore(void) GUI_DispString((LCD_WIDTH - GUI_StrPixelWidth(LABEL_LOADING)) / 2, LCD_HEIGHT / 2 - BYTE_HEIGHT, LABEL_LOADING); - if (mountFS() == true && powerFailedExist()) // powerFailedExist function sets both infoFile.path and PLR filename + if (mountFS() && powerFailedExist()) // powerFailedExist function sets both infoFile.path and PLR filename { char okTxt[MAX_LANG_LABEL_LENGTH]; char cancelTxt[MAX_LANG_LABEL_LENGTH]; diff --git a/TFT/src/User/Menu/PrintingMenu.c b/TFT/src/User/Menu/PrintingMenu.c index f4e8e760a6..cbbe00bdd7 100644 --- a/TFT/src/User/Menu/PrintingMenu.c +++ b/TFT/src/User/Menu/PrintingMenu.c @@ -432,7 +432,7 @@ static inline void drawPrintInfo(void) rect_of_keySS[KEY_INFOBOX].y0 + STATUS_MSG_ICON_YOFFSET, rect_of_keySS[KEY_INFOBOX].x1 - STATUS_MSG_TITLE_XOFFSET, rect_of_keySS[KEY_INFOBOX].y1 - STATUS_MSG_ICON_YOFFSET, - (uint8_t *)textSelect((isAborted() == true) ? LABEL_PROCESS_ABORTED : LABEL_PRINT_FINISHED)); + (uint8_t *)textSelect((isAborted()) ? LABEL_PROCESS_ABORTED : LABEL_PRINT_FINISHED)); GUI_SetColor(INFOMSG_FONT_COLOR); GUI_SetBkColor(INFOMSG_BG_COLOR); @@ -447,7 +447,7 @@ void printSummaryPopup(void) time_2_string(showInfo, (char *)textSelect(LABEL_PRINT_TIME), infoPrintSummary.time); - if (isAborted() == true) + if (isAborted()) { sprintf(tempstr, "\n\n%s", (char *)textSelect(LABEL_PROCESS_ABORTED)); strcat(showInfo, tempstr); @@ -514,7 +514,7 @@ void menuPrinting(void) memset(&nowHeat, 0, sizeof(HEATER)); - if (lastPrinting == true) + if (lastPrinting) { setPauseResumeIcon(&printingItems, lastPause); printingItems.items[KEY_ICON_5].icon = (infoFile.source < FS_ONBOARD_MEDIA && isPrintModelIcon()) ? ICON_PREVIEW : ICON_BABYSTEP; @@ -540,7 +540,7 @@ void menuPrinting(void) drawLiveInfo(); #ifndef PORTRAIT_MODE - if (lastPrinting == false) + if (!lastPrinting) drawPrintInfo(); #endif @@ -604,7 +604,7 @@ void menuPrinting(void) if (ABS(curLayerHeight - usedLayerHeight) >= LAYER_DELTA) layerDrawEnabled = true; - if (layerDrawEnabled == true) + if (layerDrawEnabled) { usedLayerHeight = curLayerHeight; @@ -653,7 +653,7 @@ void menuPrinting(void) lastPrinting = isPrinting(); #ifdef PORTRAIT_MODE - if (lastPrinting == false) + if (!lastPrinting) printSummaryPopup(); #endif @@ -662,7 +662,7 @@ void menuPrinting(void) toggleInfo(); - KEY_VALUES key_num = menuKeyGetValue(); + KEY_VALUES key_num = menuKeyGetValue(false); switch (key_num) { @@ -709,7 +709,7 @@ void menuPrinting(void) break; case PS_KEY_6: - if (lastPrinting == true) // if printing + if (lastPrinting) // if printing { // Pause button if (getHostDialog()) addToast(DIALOG_TYPE_ERROR, (char *)textSelect(LABEL_BUSY)); @@ -733,7 +733,7 @@ void menuPrinting(void) break; case PS_KEY_9: - if (lastPrinting == true) // if printing + if (lastPrinting) // if printing { // Stop button popupDialog(DIALOG_TYPE_ALERT, LABEL_WARNING, LABEL_STOP_PRINT, LABEL_CONFIRM, LABEL_CANCEL, abortPrint, NULL, NULL); } diff --git a/TFT/src/User/Menu/RRFMacros.c b/TFT/src/User/Menu/RRFMacros.c index b869d849f1..bbb3742566 100644 --- a/TFT/src/User/Menu/RRFMacros.c +++ b/TFT/src/User/Menu/RRFMacros.c @@ -83,7 +83,7 @@ void menuCallMacro(void) case KEY_BACK: infoFile.curPage = 0; - if (isRootFolder() == true) + if (isRootFolder()) { clearInfoFile(); @@ -105,7 +105,7 @@ void menuCallMacro(void) { if (key_num < infoFile.folderCount) // folder { - if (enterFolder(infoFile.folder[key_num]) == false) + if (!enterFolder(infoFile.folder[key_num])) break; scanInfoFilesFs(); @@ -114,10 +114,10 @@ void menuCallMacro(void) } else if (key_num < infoFile.fileCount + infoFile.folderCount) // gcode { - if (infoHost.connected == false) + if (!infoHost.connected) break; - if (enterFolder(infoFile.longFile[key_num - infoFile.folderCount]) == false) + if (!enterFolder(infoFile.longFile[key_num - infoFile.folderCount])) break; runMacro(infoFile.file[key_num - infoFile.folderCount]); diff --git a/TFT/src/User/Menu/ScreenSettings.c b/TFT/src/User/Menu/ScreenSettings.c index 47fac1d4f7..d6323ab6e9 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 a4247514fb..17d1f6b0ea 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 73051986da..ba2589c107 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 9fc705797a..7521622ace 100644 --- a/TFT/src/User/Menu/StatusScreen.c +++ b/TFT/src/User/Menu/StatusScreen.c @@ -86,7 +86,7 @@ void statusSetReady(void) { strncpy_no_pad(msgTitle, (char *)textSelect(LABEL_STATUS), sizeof(msgTitle)); - if (infoHost.connected == false) + if (!infoHost.connected) strncpy_no_pad(msgBody, (char *)textSelect(LABEL_UNCONNECTED), sizeof(msgBody)); else snprintf(msgBody, sizeof(msgBody), "%s %s", machine_type, (char *)textSelect(LABEL_READY)); @@ -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 b8d490c1b3..0919449379 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) { @@ -583,7 +583,7 @@ static inline void menuKeyboardView(void) case GKEY_SEND: if (nowIndex) { - if (saveEnabled == true) // avoid saving again a gcode called from gcode history table + if (saveEnabled) // avoid saving again a gcode called from gcode history table { strcpy(keyboardData->gcodeTable[saveGcodeIndex], gcodeBuf); // save gcode to history table saveGcodeIndex = (saveGcodeIndex + 1) % MAX_GCODE_COUNT; // move to next save index in the gcode history table @@ -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 0b64d2fa40..8df3da00aa 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 9917267a3b..fde926fd70 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) { @@ -238,7 +238,7 @@ void menuTuneExtruder(void) break; } - if (loadRequested == true && heatSetTool(tool_index)) + if (loadRequested && heatSetTool(tool_index)) { switch (warmupNozzle()) { @@ -276,6 +276,6 @@ void menuTuneExtruder(void) } // set slow update time if not waiting for target temperature - if (heatHasWaiting() == false) + if (!heatHasWaiting()) heatSetUpdateSeconds(TEMPERATURE_QUERY_SLOW_SECONDS); } diff --git a/TFT/src/User/Menu/Tuning.c b/TFT/src/User/Menu/Tuning.c index 48136c7556..ded14c2a88 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 02323b1eff..3fbee70ec7 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 3c884eccc6..22ff57749f 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 31da6ca134..7a99e2b8db 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 a6825b9d77..37e74e04fb 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 25881ac6ea..3a3eb302d0 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 b62a220f7d..ae6528267f 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/my_misc.c b/TFT/src/User/my_misc.c index 9c4575f34a..63304af955 100644 --- a/TFT/src/User/my_misc.c +++ b/TFT/src/User/my_misc.c @@ -72,10 +72,8 @@ uint8_t * uint8_2_string(uint8_t num, uint8_t * str) if (_4bits <= 9) str[i] = _4bits + '0'; - else if (_4bits >= 0xA && _4bits <= 0xF) - str[i] = _4bits - 0xA + 'A'; else - str[i] = 'F'; + str[i] = _4bits - 0xA + 'A'; num <<= 4; } diff --git a/TFT/src/User/os_timer.c b/TFT/src/User/os_timer.c index 3031c0704e..5b54394c3b 100644 --- a/TFT/src/User/os_timer.c +++ b/TFT/src/User/os_timer.c @@ -97,26 +97,22 @@ 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->last_time) < task_t->time_ms) return; if (task_t->is_repeat == 0) - { task_t->is_exist = 0; - } else - { - task_t->next_time = OS_GetTimeMs() + task_t->time_ms; - } + task_t->last_time = OS_GetTimeMs(); (*task_t->task)(task_t->para); } void OS_TaskEnable(OS_TASK * task_t, uint8_t is_exec, uint8_t is_repeat) { - task_t->is_exist =1; + task_t->is_exist = 1; task_t->is_repeat = is_repeat; - task_t->next_time = OS_GetTimeMs() + task_t->time_ms; + task_t->last_time = OS_GetTimeMs(); if (is_exec) (*task_t->task)(task_t->para); diff --git a/TFT/src/User/os_timer.h b/TFT/src/User/os_timer.h index 0a6ee60a3c..6b7916d0fd 100644 --- a/TFT/src/User/os_timer.h +++ b/TFT/src/User/os_timer.h @@ -22,7 +22,7 @@ typedef void (* FP_TASK)(void *); typedef struct { uint32_t time_ms; - uint32_t next_time; + uint32_t last_time; FP_TASK task; void * para; uint8_t is_exist;