diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 13623cadf0b2b..7dbaaed08fb81 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -70,7 +70,7 @@
// @section info
// Author info of this build printed to the host during boot and M115
-#define STRING_CONFIG_H_AUTHOR "(Michal Rábek, default config)" // Who made the changes.
+#define STRING_CONFIG_H_AUTHOR "(Michalcin, default config)" // Who made the changes.
//#define CUSTOM_VERSION_FILE Version.h // Path from the root directory (no quotes)
/**
@@ -128,7 +128,7 @@
// Choose the name from boards.h that matches your setup
#ifndef MOTHERBOARD
- #define MOTHERBOARD BOARD_RAMPS_14_EFB
+ #define MOTHERBOARD BOARD_RAMPS_S_12_EEFB
#endif
// Name displayed in the LCD "Ready" message and Info menu
@@ -445,7 +445,7 @@
// Below this temperature the heater will be switched off
// because it probably indicates a broken thermistor wire.
-#define HEATER_0_MINTEMP 5
+#define HEATER_0_MINTEMP 15
#define HEATER_1_MINTEMP 5
#define HEATER_2_MINTEMP 5
#define HEATER_3_MINTEMP 5
@@ -453,7 +453,7 @@
#define HEATER_5_MINTEMP 5
#define HEATER_6_MINTEMP 5
#define HEATER_7_MINTEMP 5
-#define BED_MINTEMP 5
+#define BED_MINTEMP 15
// Above this temperature the heater will be switched off.
// This can protect components from overheating, but NOT from shorts and failures.
@@ -745,7 +745,7 @@
* Override with M203
* X, Y, Z, E0 [, E1[, E2...]]
*/
-#define DEFAULT_MAX_FEEDRATE { 300, 300, 5, 25 }
+#define DEFAULT_MAX_FEEDRATE { 100, 100, 30, 50 }
//#define LIMITED_MAX_FR_EDITING // Limit edit via M203 or LCD to DEFAULT_MAX_FEEDRATE * 2
#if ENABLED(LIMITED_MAX_FR_EDITING)
@@ -758,7 +758,7 @@
* Override with M201
* X, Y, Z, E0 [, E1[, E2...]]
*/
-#define DEFAULT_MAX_ACCELERATION { 3000, 3000, 100, 10000 }
+#define DEFAULT_MAX_ACCELERATION { 1250, 1250, 100, 2000 }
//#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2
#if ENABLED(LIMITED_MAX_ACCEL_EDITING)
@@ -773,9 +773,9 @@
* M204 R Retract Acceleration
* M204 T Travel Acceleration
*/
-#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E acceleration for printing moves
+#define DEFAULT_ACCELERATION 400 // X, Y, Z and E acceleration for printing moves
#define DEFAULT_RETRACT_ACCELERATION 3000 // E acceleration for retracts
-#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration for travel (non printing) moves
+#define DEFAULT_TRAVEL_ACCELERATION 400 // X, Y, Z acceleration for travel (non printing) moves
/**
* Default Jerk limits (mm/s)
@@ -1167,7 +1167,7 @@
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
-#define Z_MAX_POS 200
+#define Z_MAX_POS 135
/**
* Software Endstops
@@ -1431,7 +1431,7 @@
* Add a bed leveling sub-menu for ABL or MBL.
* Include a guided procedure if manual probing is enabled.
*/
-//#define LCD_BED_LEVELING
+#define LCD_BED_LEVELING
#if ENABLED(LCD_BED_LEVELING)
#define MESH_EDIT_Z_STEP 0.025 // (mm) Step size while manually probing Z axis.
@@ -1721,7 +1721,7 @@
* M76 - Pause the print job timer
* M77 - Stop the print job timer
*/
-#define PRINTJOB_TIMER_AUTOSTART
+//#define PRINTJOB_TIMER_AUTOSTART
/**
* Print Counter
@@ -1888,7 +1888,7 @@
// If CLOCKWISE normally moves DOWN this makes it go UP.
// If CLOCKWISE normally moves UP this makes it go DOWN.
//
-//#define REVERSE_MENU_DIRECTION
+#define REVERSE_MENU_DIRECTION
//
// This option reverses the encoder direction for Select Screen.
@@ -2440,6 +2440,7 @@
//#define TOUCH_CALIBRATION_Y -8981
//#define TOUCH_OFFSET_X -43
//#define TOUCH_OFFSET_Y 257
+ //#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
#if ENABLED(TFT_COLOR_UI)
//#define SINGLE_TOUCH_NAVIGATION
diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 1486b943f94cc..c2940ce96e680 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -1326,9 +1326,6 @@
*/
//#define USB_FLASH_DRIVE_SUPPORT
#if ENABLED(USB_FLASH_DRIVE_SUPPORT)
- #define USB_CS_PIN SDSS
- #define USB_INTR_PIN SD_DETECT_PIN
-
/**
* USB Host Shield Library
*
@@ -1339,7 +1336,18 @@
* is less tested and is known to interfere with Servos.
* [1] This requires USB_INTR_PIN to be interrupt-capable.
*/
+ //#define USE_UHS2_USB
//#define USE_UHS3_USB
+
+ /**
+ * Native USB Host supported by some boards (USB OTG)
+ */
+ //#define USE_OTG_USB_HOST
+
+ #if DISABLED(USE_OTG_USB_HOST)
+ #define USB_CS_PIN SDSS
+ #define USB_INTR_PIN SD_DETECT_PIN
+ #endif
#endif
/**
diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp
new file mode 100644
index 0000000000000..ed743361e681c
--- /dev/null
+++ b/Marlin/src/HAL/STM32/usb_host.cpp
@@ -0,0 +1,117 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
+
+#include "../../inc/MarlinConfig.h"
+
+#if BOTH(USE_OTG_USB_HOST, USBHOST)
+
+#include "usb_host.h"
+#include "../shared/Marduino.h"
+#include "usbh_core.h"
+#include "usbh_msc.h"
+
+USBH_HandleTypeDef hUsbHost;
+USBHost usb;
+BulkStorage bulk(&usb);
+
+static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) {
+ switch(id) {
+ case HOST_USER_SELECT_CONFIGURATION:
+ //SERIAL_ECHOLNPGM("APPLICATION_SELECT_CONFIGURATION");
+ break;
+ case HOST_USER_DISCONNECTION:
+ //SERIAL_ECHOLNPGM("APPLICATION_DISCONNECT");
+ //usb.setUsbTaskState(USB_STATE_RUNNING);
+ break;
+ case HOST_USER_CLASS_ACTIVE:
+ //SERIAL_ECHOLNPGM("APPLICATION_READY");
+ usb.setUsbTaskState(USB_STATE_RUNNING);
+ break;
+ case HOST_USER_CONNECTION:
+ break;
+ default:
+ break;
+ }
+}
+
+bool USBHost::start() {
+ if (USBH_Init(&hUsbHost, USBH_UserProcess, TERN(USE_USB_HS_IN_FS, HOST_HS, HOST_FS)) != USBH_OK) {
+ SERIAL_ECHOLNPGM("Error: USBH_Init");
+ return false;
+ }
+ if (USBH_RegisterClass(&hUsbHost, USBH_MSC_CLASS) != USBH_OK) {
+ SERIAL_ECHOLNPGM("Error: USBH_RegisterClass");
+ return false;
+ }
+ if (USBH_Start(&hUsbHost) != USBH_OK) {
+ SERIAL_ECHOLNPGM("Error: USBH_Start");
+ return false;
+ }
+ return true;
+}
+
+void USBHost::Task() {
+ USBH_Process(&hUsbHost);
+}
+
+uint8_t USBHost::getUsbTaskState() {
+ return usb_task_state;
+}
+
+void USBHost::setUsbTaskState(uint8_t state) {
+ usb_task_state = state;
+ if (usb_task_state == USB_STATE_RUNNING) {
+ MSC_LUNTypeDef info;
+ USBH_MSC_GetLUNInfo(&hUsbHost, usb.lun, &info);
+ capacity = info.capacity.block_nbr / 2000;
+ block_size = info.capacity.block_size;
+ block_count = info.capacity.block_nbr;
+ // SERIAL_ECHOLNPAIR("info.capacity.block_nbr : %ld\n", info.capacity.block_nbr);
+ // SERIAL_ECHOLNPAIR("info.capacity.block_size: %d\n", info.capacity.block_size);
+ // SERIAL_ECHOLNPAIR("capacity : %d MB\n", capacity);
+ }
+};
+
+bool BulkStorage::LUNIsGood(uint8_t t) {
+ return USBH_MSC_IsReady(&hUsbHost) && USBH_MSC_UnitIsReady(&hUsbHost, t);
+}
+
+uint32_t BulkStorage::GetCapacity(uint8_t lun) {
+ return usb->block_count;
+}
+
+uint16_t BulkStorage::GetSectorSize(uint8_t lun) {
+ return usb->block_size;
+}
+
+uint8_t BulkStorage::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf) {
+ return USBH_MSC_Read(&hUsbHost, lun, addr, buf, blocks) != USBH_OK;
+}
+
+uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) {
+ return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast (buf), blocks) != USBH_OK;
+}
+
+#endif // USE_OTG_USB_HOST && USBHOST
+#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
diff --git a/Marlin/src/HAL/STM32/usb_host.h b/Marlin/src/HAL/STM32/usb_host.h
new file mode 100644
index 0000000000000..932b139137475
--- /dev/null
+++ b/Marlin/src/HAL/STM32/usb_host.h
@@ -0,0 +1,97 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+<<<<<<< HEAD:Marlin/src/module/thermistor/thermistor_503.h
+// Zonestar (Z8XM2) Heated Bed thermistor. Added By AvanOsch
+// These are taken from the Zonestar settings in original Repetier firmware: Z8XM2_ZRIB_LCD12864_V51.zip
+const temp_entry_t temptable_503[] PROGMEM = {
+ { OV( 12), 300 },
+ { OV( 27), 270 },
+ { OV( 47), 250 },
+ { OV( 68), 230 },
+ { OV( 99), 210 },
+ { OV( 120), 200 },
+ { OV( 141), 190 },
+ { OV( 171), 180 },
+ { OV( 201), 170 },
+ { OV( 261), 160 },
+ { OV( 321), 150 },
+ { OV( 401), 140 },
+ { OV( 451), 130 },
+ { OV( 551), 120 },
+ { OV( 596), 110 },
+ { OV( 626), 105 },
+ { OV( 666), 100 },
+ { OV( 697), 90 },
+ { OV( 717), 85 },
+ { OV( 798), 69 },
+ { OV( 819), 65 },
+ { OV( 870), 55 },
+ { OV( 891), 51 },
+ { OV( 922), 39 },
+ { OV( 968), 28 },
+ { OV( 980), 23 },
+ { OV( 991), 17 },
+ { OV( 1001), 9 },
+ { OV(1021), -27 },
+ { OV(1023), -200}
+};
+=======
+#include
+
+typedef enum {
+ USB_STATE_INIT,
+ USB_STATE_ERROR,
+ USB_STATE_RUNNING,
+} usb_state_t;
+
+class USBHost {
+public:
+ bool start();
+ void Task();
+ uint8_t getUsbTaskState();
+ void setUsbTaskState(uint8_t state);
+ uint8_t regRd(uint8_t reg) { return 0x0; };
+ uint8_t usb_task_state = USB_STATE_INIT;
+ uint8_t lun = 0;
+ uint32_t capacity = 0;
+ uint16_t block_size = 0;
+ uint32_t block_count = 0;
+};
+
+class BulkStorage {
+public:
+ BulkStorage(USBHost *usb) : usb(usb) {};
+
+ bool LUNIsGood(uint8_t t);
+ uint32_t GetCapacity(uint8_t lun);
+ uint16_t GetSectorSize(uint8_t lun);
+ uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf);
+ uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf);
+
+ USBHost *usb;
+};
+
+extern USBHost usb;
+extern BulkStorage bulk;
+>>>>>>> 4ad633bae235f0a47972d6d7873e614b8286d914:Marlin/src/HAL/STM32/usb_host.h
diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h
index 058008646f043..56e80b87dc9d1 100644
--- a/Marlin/src/core/macros.h
+++ b/Marlin/src/core/macros.h
@@ -216,6 +216,7 @@
#define ANY_BUTTON(V...) DO(BTNEX,||,V)
#define WITHIN(N,L,H) ((N) >= (L) && (N) <= (H))
+#define ISEOL(C) ((C) == '\n' || (C) == '\r')
#define NUMERIC(a) WITHIN(a, '0', '9')
#define DECIMAL(a) (NUMERIC(a) || a == '.')
#define HEXCHR(a) (NUMERIC(a) ? (a) - '0' : WITHIN(a, 'a', 'f') ? ((a) - 'a' + 10) : WITHIN(a, 'A', 'F') ? ((a) - 'A' + 10) : -1)
diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h
index 0bb0253149ebc..a4c07de465ddd 100644
--- a/Marlin/src/feature/e_parser.h
+++ b/Marlin/src/feature/e_parser.h
@@ -76,7 +76,6 @@ class EmergencyParser {
FORCE_INLINE static void disable() { enabled = false; }
FORCE_INLINE static void update(State &state, const uint8_t c) {
- #define ISEOL(C) ((C) == '\n' || (C) == '\r')
switch (state) {
case EP_RESET:
switch (c) {
diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp
index d23e9ee07fc31..98fe91db40741 100644
--- a/Marlin/src/gcode/queue.cpp
+++ b/Marlin/src/gcode/queue.cpp
@@ -158,8 +158,6 @@ bool GCodeQueue::_enqueue(const char* cmd, bool say_ok/*=false*/
return true;
}
-#define ISEOL(C) ((C) == '\n' || (C) == '\r')
-
/**
* Enqueue with Serial Echo
* Return true if the command was consumed
diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h
index ed01f54a0bbd8..ed38032c13eac 100644
--- a/Marlin/src/inc/Conditionals_LCD.h
+++ b/Marlin/src/inc/Conditionals_LCD.h
@@ -833,6 +833,11 @@
#else
// Clear probe pin settings when no probe is selected
#undef Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
+ #undef USE_PROBE_FOR_Z_HOMING
+#endif
+
+#if Z_HOME_DIR > 0
+ #define HOME_Z_FIRST // If homing away from BED do Z first
#endif
#if Z_HOME_DIR > 0
@@ -1168,6 +1173,12 @@
#elif ENABLED(TFT_INTERFACE_FSMC)
#define TFT_480x320
#endif
+#elif ENABLED(TFT_COLOR_UI) && TFT_HEIGHT == 272
+ #if ENABLED(TFT_INTERFACE_SPI)
+ #define TFT_480x272_SPI
+ #elif ENABLED(TFT_INTERFACE_FSMC)
+ #define TFT_480x272
+ #endif
#endif
// Fewer lines with touch buttons on-screen
@@ -1177,6 +1188,9 @@
#elif EITHER(TFT_480x320, TFT_480x320_SPI)
#define HAS_UI_480x320 1
#define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
+#elif EITHER(TFT_480x272, TFT_480x272_SPI)
+ #define HAS_UI_480x272 1
+ #define LCD_HEIGHT TERN(TOUCH_SCREEN, 6, 7)
#endif
// This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046'
@@ -1198,6 +1212,17 @@
#endif
#endif
+// XPT2046_** Compatibility
+#if !(defined(TOUCH_CALIBRATION_X) || defined(TOUCH_CALIBRATION_Y) || defined(TOUCH_OFFSET_X) || defined(TOUCH_OFFSET_Y) || defined(TOUCH_ORIENTATION))
+ #if defined(XPT2046_X_CALIBRATION) && defined(XPT2046_Y_CALIBRATION) && defined(XPT2046_X_OFFSET) && defined(XPT2046_Y_OFFSET)
+ #define TOUCH_CALIBRATION_X XPT2046_X_CALIBRATION
+ #define TOUCH_CALIBRATION_Y XPT2046_Y_CALIBRATION
+ #define TOUCH_OFFSET_X XPT2046_X_OFFSET
+ #define TOUCH_OFFSET_Y XPT2046_Y_OFFSET
+ #define TOUCH_ORIENTATION TOUCH_LANDSCAPE
+ #endif
+#endif
+
#if MB(ANET_ET4, ANET_ET4P)
#define IS_ANET_ET 1
#endif
diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h
index f99e363d7b647..dda0298740bf2 100644
--- a/Marlin/src/inc/Conditionals_adv.h
+++ b/Marlin/src/inc/Conditionals_adv.h
@@ -382,6 +382,14 @@
#define POLL_JOG
#endif
+#ifndef HOMING_BUMP_MM
+ #define HOMING_BUMP_MM { 0, 0, 0 }
+#endif
+
+#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && NONE(USE_OTG_USB_HOST, USE_UHS3_USB)
+ #define USE_UHS2_USB
+#endif
+
/**
* Driver Timings (in nanoseconds)
* NOTE: Driver timing order is longest-to-shortest duration.
diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h
index 949828d5f8000..62c954c899a90 100644
--- a/Marlin/src/inc/SanityCheck.h
+++ b/Marlin/src/inc/SanityCheck.h
@@ -721,7 +721,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN) && NONE(HAS_MARLINUI_U8GLIB, TOUCH_UI_FTDI_EVE)
#error "SHOW_CUSTOM_BOOTSCREEN requires Graphical LCD or TOUCH_UI_FTDI_EVE."
#elif ENABLED(CUSTOM_STATUS_SCREEN_IMAGE) && !HAS_MARLINUI_U8GLIB
- #error "CUSTOM_STATUS_SCREEN_IMAGE requires a Graphical LCD."
+ #error "CUSTOM_STATUS_SCREEN_IMAGE requires a 128x64 DOGM B/W Graphical LCD."
#endif
/**
@@ -2912,10 +2912,14 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
#error "PRINTCOUNTER requires EEPROM_SETTINGS."
#endif
-#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && !PINS_EXIST(USB_CS, USB_INTR)
+#if ENABLED(USB_FLASH_DRIVE_SUPPORT) && !PINS_EXIST(USB_CS, USB_INTR) && DISABLED(USE_OTG_USB_HOST)
#error "USB_CS_PIN and USB_INTR_PIN are required for USB_FLASH_DRIVE_SUPPORT."
#endif
+#if ENABLED(USE_OTG_USB_HOST) && !defined(HAS_OTG_USB_HOST_SUPPORT)
+ #error "The current board does not support USE_OTG_USB_HOST."
+#endif
+
#if ENABLED(SD_FIRMWARE_UPDATE) && !defined(__AVR_ATmega2560__)
#error "SD_FIRMWARE_UPDATE requires an ATmega2560-based (Arduino Mega) board."
#endif
diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h
index 8905b3a82e280..b673b83a0d372 100644
--- a/Marlin/src/inc/Version.h
+++ b/Marlin/src/inc/Version.h
@@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
- #define STRING_DISTRIBUTION_DATE "2020-12-28"
+ #define STRING_DISTRIBUTION_DATE "2020-12-30"
#endif
/**
diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp
index 96e322bbec012..38b62db3b4d09 100644
--- a/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp
+++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp
@@ -417,12 +417,20 @@ void lv_gcode_file_read(uint8_t *data_buf) {
}
uint16_t c = card.get();
- // check if we have more data or finished the line (CR)
- if (c == '\r') break;
+ // check for more data or end of line (CR or LF)
+ if (ISEOL(c)) {
+ c = card.get(); // more eol?
+ if (!ISEOL(c)) card.setIndex(card.getIndex() - 1);
+ break;
+ }
card.setIndex(card.getIndex() - 1);
k++;
j = 0;
ignore_start = false;
+ if (k > 1) {
+ card.closefile();
+ break;
+ }
}
#if HAS_TFT_LVGL_UI_SPI
for (i = 0; i < 200;) {
diff --git a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
index 8ce317c571910..f13a4b36cfb53 100644
--- a/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
+++ b/Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
@@ -369,8 +369,9 @@ lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p
}
//sd
+extern uint8_t public_buf[512];
char *cur_namefff;
-uint32_t sd_read_base_addr = 0,sd_read_addr_offset = 0;
+uint32_t sd_read_base_addr = 0, sd_read_addr_offset = 0, small_image_size = 409;
lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
//cur_namefff = strrchr(path, '/');
char name_buf[100];
@@ -381,6 +382,11 @@ lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_
sd_read_base_addr = lv_open_gcode_file((char *)name_buf);
sd_read_addr_offset = sd_read_base_addr;
if (sd_read_addr_offset == UINT32_MAX) return LV_FS_RES_NOT_EX;
+ // find small image size
+ card.read(public_buf, 512);
+ public_buf[511] = '\0';
+ char* eol = strpbrk((const char*)public_buf, "\n\r");
+ small_image_size = (uintptr_t)eol - (uintptr_t)((uint32_t *)(&public_buf[0])) + 1;
return LV_FS_RES_OK;
}
@@ -406,14 +412,14 @@ lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t b
}
lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos) {
- sd_read_addr_offset = sd_read_base_addr + (pos - 4) / 200 * 409;
+ sd_read_addr_offset = sd_read_base_addr + (pos - 4) / 200 * small_image_size;
lv_gcode_file_seek(sd_read_addr_offset);
return LV_FS_RES_OK;
}
lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p) {
if (sd_read_addr_offset) *pos_p = 0;
- else *pos_p = (sd_read_addr_offset - sd_read_base_addr) / 409 * 200 + 4;
+ else *pos_p = (sd_read_addr_offset - sd_read_base_addr) / small_image_size * 200 + 4;
return LV_FS_RES_OK;
}
diff --git a/Marlin/src/lcd/tft/tft.h b/Marlin/src/lcd/tft/tft.h
index d3ef62ec5b2e7..99d335d135f68 100644
--- a/Marlin/src/lcd/tft/tft.h
+++ b/Marlin/src/lcd/tft/tft.h
@@ -43,6 +43,9 @@
#elif HAS_UI_480x320
#define TFT_WIDTH 480
#define TFT_HEIGHT 320
+#elif HAS_UI_480x272
+ #define TFT_WIDTH 480
+ #define TFT_HEIGHT 272
#else
#error "Unsupported display resolution!"
#endif
diff --git a/Marlin/src/lcd/tft/tft_image.cpp b/Marlin/src/lcd/tft/tft_image.cpp
index 8f8b6106996a8..9cc6fb15e4a08 100644
--- a/Marlin/src/lcd/tft/tft_image.cpp
+++ b/Marlin/src/lcd/tft/tft_image.cpp
@@ -25,12 +25,14 @@
const tImage NoLogo = { nullptr, 0, 0, NOCOLORS };
-const tImage MarlinLogo112x38x1 = { (void *)marlin_logo_112x38x1, 112, 38, GREYSCALE1 };
-const tImage MarlinLogo228x255x2 = { (void *)marlin_logo_228x255x2, 228, 255, GREYSCALE2 };
-const tImage MarlinLogo228x255x4 = { (void *)marlin_logo_228x255x4, 228, 255, GREYSCALE4 };
-const tImage MarlinLogo195x59x16 = { (void *)marlin_logo_195x59x16, 195, 59, HIGHCOLOR };
-const tImage MarlinLogo320x240x16 = { (void *)marlin_logo_320x240x16, 320, 240, HIGHCOLOR };
-const tImage MarlinLogo480x320x16 = { (void *)marlin_logo_480x320x16, 480, 320, HIGHCOLOR };
+#if ENABLED(SHOW_BOOTSCREEN)
+ const tImage MarlinLogo112x38x1 = { (void *)marlin_logo_112x38x1, 112, 38, GREYSCALE1 };
+ const tImage MarlinLogo228x255x2 = { (void *)marlin_logo_228x255x2, 228, 255, GREYSCALE2 };
+ const tImage MarlinLogo228x255x4 = { (void *)marlin_logo_228x255x4, 228, 255, GREYSCALE4 };
+ const tImage MarlinLogo195x59x16 = { (void *)marlin_logo_195x59x16, 195, 59, HIGHCOLOR };
+ const tImage MarlinLogo320x240x16 = { (void *)marlin_logo_320x240x16, 320, 240, HIGHCOLOR };
+ const tImage MarlinLogo480x320x16 = { (void *)marlin_logo_480x320x16, 480, 320, HIGHCOLOR };
+#endif
const tImage Background320x30x16 = { (void *)background_320x30x16, 320, 30, HIGHCOLOR };
const tImage HotEnd_64x64x4 = { (void *)hotend_64x64x4, 64, 64, GREYSCALE4 };
diff --git a/Marlin/src/lcd/tft/tft_image.h b/Marlin/src/lcd/tft/tft_image.h
index 1f13967ba248c..21bd2d665fc68 100644
--- a/Marlin/src/lcd/tft/tft_image.h
+++ b/Marlin/src/lcd/tft/tft_image.h
@@ -22,7 +22,7 @@
#pragma once
#include "stdint.h"
-
+#include "../../inc/MarlinConfigPre.h"
extern const uint8_t marlin_logo_112x38x1[];
extern const uint8_t marlin_logo_228x255x2[];
@@ -120,12 +120,14 @@ typedef struct __attribute__((__packed__)) {
extern const tImage NoLogo;
-extern const tImage MarlinLogo112x38x1;
-extern const tImage MarlinLogo228x255x2;
-extern const tImage MarlinLogo228x255x4;
-extern const tImage MarlinLogo195x59x16;
-extern const tImage MarlinLogo320x240x16;
-extern const tImage MarlinLogo480x320x16;
+#if ENABLED(SHOW_BOOTSCREEN)
+ extern const tImage MarlinLogo112x38x1;
+ extern const tImage MarlinLogo228x255x2;
+ extern const tImage MarlinLogo228x255x4;
+ extern const tImage MarlinLogo195x59x16;
+ extern const tImage MarlinLogo320x240x16;
+ extern const tImage MarlinLogo480x320x16;
+#endif
extern const tImage Background320x30x16;
extern const tImage HotEnd_64x64x4;
diff --git a/Marlin/src/lcd/tft/ui_320x240.h b/Marlin/src/lcd/tft/ui_320x240.h
index 0f928eea37728..249a21c4f1060 100644
--- a/Marlin/src/lcd/tft/ui_320x240.h
+++ b/Marlin/src/lcd/tft/ui_320x240.h
@@ -44,7 +44,7 @@ void menu_item(const uint8_t row, bool sel = false);
#define ABSOLUTE_ZERO -273.15
const tImage Images[imgCount] = {
- TERN(BOOT_MARLIN_LOGO_SMALL, MarlinLogo195x59x16, MarlinLogo320x240x16),
+ TERN(SHOW_BOOTSCREEN, TERN(BOOT_MARLIN_LOGO_SMALL, MarlinLogo195x59x16, MarlinLogo320x240x16), NoLogo),
HotEnd_64x64x4,
Bed_64x64x4,
Bed_Heated_64x64x4,
diff --git a/Marlin/src/lcd/tft/ui_480x320.cpp b/Marlin/src/lcd/tft/ui_480x320.cpp
index ddd08e4d0d790..f7955fb1bd598 100644
--- a/Marlin/src/lcd/tft/ui_480x320.cpp
+++ b/Marlin/src/lcd/tft/ui_480x320.cpp
@@ -22,7 +22,7 @@
#include "../../inc/MarlinConfigPre.h"
-#if HAS_UI_480x320
+#if HAS_UI_480x320 || HAS_UI_480x272
#include "ui_480x320.h"
@@ -56,9 +56,9 @@
void MarlinUI::tft_idle() {
#if ENABLED(TOUCH_SCREEN)
if (draw_menu_navigation) {
- add_control(104, 286, PAGE_UP, imgPageUp, encoderTopLine > 0);
- add_control(344, 286, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
- add_control(224, 286, BACK, imgBack);
+ add_control(104, TFT_HEIGHT - 34, PAGE_UP, imgPageUp, encoderTopLine > 0);
+ add_control(344, TFT_HEIGHT - 34, PAGE_DOWN, imgPageDown, encoderTopLine + LCD_HEIGHT < screen_items);
+ add_control(224, TFT_HEIGHT - 34, BACK, imgBack);
draw_menu_navigation = false;
}
#endif
@@ -259,10 +259,12 @@ void MarlinUI::draw_status_screen() {
}
}
+ y += TERN(HAS_UI_480x272, 118, 128);
+
// coordinates
- tft.canvas(4, 132, TFT_WIDTH - 8, 34);
+ tft.canvas(4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
- tft.add_rectangle(0, 0, TFT_WIDTH - 8, 34, COLOR_AXIS_HOMED);
+ tft.add_rectangle(0, 0, TFT_WIDTH - 8, FONT_LINE_HEIGHT, COLOR_AXIS_HOMED);
tft.add_text( 16, 3, COLOR_AXIS_HOMED , "X");
tft.add_text(192, 3, COLOR_AXIS_HOMED , "Y");
@@ -290,10 +292,11 @@ void MarlinUI::draw_status_screen() {
offset -= tft_string.width();
}
tft.add_text(455 - tft_string.width() - offset, 3, not_homed ? COLOR_AXIS_NOT_HOMED : COLOR_AXIS_HOMED, tft_string);
- TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, 132, TFT_WIDTH - 8, 34));
+ TERN_(TOUCH_SCREEN, touch.add_control(MOVE_AXIS, 4, y, TFT_WIDTH - 8, FONT_LINE_HEIGHT));
+ y += TERN(HAS_UI_480x272, 38, 48);
// feed rate
- tft.canvas(96, 180, 100, 32);
+ tft.canvas(96, y, 100, 32);
tft.set_background(COLOR_BACKGROUND);
uint16_t color = feedrate_percentage == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
tft.add_image(0, 0, imgFeedRate, color);
@@ -303,7 +306,7 @@ void MarlinUI::draw_status_screen() {
TERN_(TOUCH_SCREEN, touch.add_control(FEEDRATE, 96, 176, 100, 32));
// flow rate
- tft.canvas(284, 180, 100, 32);
+ tft.canvas(284, y, 100, 32);
tft.set_background(COLOR_BACKGROUND);
color = planner.flow_percentage[0] == 100 ? COLOR_RATE_100 : COLOR_RATE_ALTERED;
tft.add_image(0, 0, imgFlowRate, color);
@@ -312,36 +315,38 @@ void MarlinUI::draw_status_screen() {
tft.add_text(36, 1, color , tft_string);
TERN_(TOUCH_SCREEN, touch.add_control(FLOWRATE, 284, 176, 100, 32, active_extruder));
+ #if ENABLED(TOUCH_SCREEN)
+ add_control(404, y, menu_main, imgSettings);
+ TERN_(SDSUPPORT, add_control(12, y, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
+ #endif
+
+ y += TERN(HAS_UI_480x272, 36, 44);
// print duration
char buffer[14];
duration_t elapsed = print_job_timer.duration();
elapsed.toDigital(buffer);
- tft.canvas((TFT_WIDTH - 128) / 2, 224, 128, 29);
+ tft.canvas((TFT_WIDTH - 128) / 2, y, 128, 29);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(buffer);
tft.add_text(tft_string.center(128), 0, COLOR_PRINT_TIME, tft_string);
+ y += TERN(HAS_UI_480x272, 28, 36);
// progress bar
const uint8_t progress = ui.get_progress_percent();
- tft.canvas(4, 260, TFT_WIDTH - 8, 9);
+ tft.canvas(4, y, TFT_WIDTH - 8, 9);
tft.set_background(COLOR_PROGRESS_BG);
tft.add_rectangle(0, 0, TFT_WIDTH - 8, 9, COLOR_PROGRESS_FRAME);
if (progress)
tft.add_bar(1, 1, ((TFT_WIDTH - 10) * progress) / 100, 7, COLOR_PROGRESS_BAR);
+ y += 20;
// status message
- tft.canvas(0, 280, TFT_WIDTH, 29);
+ tft.canvas(0, y, TFT_WIDTH, FONT_LINE_HEIGHT - 5);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(status_message);
tft_string.trim();
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_STATUS_MESSAGE, tft_string);
-
-
- #if ENABLED(TOUCH_SCREEN)
- add_control(404, 180, menu_main, imgSettings);
- TERN_(SDSUPPORT, add_control(12, 180, menu_media, imgSD, !printingIsActive(), COLOR_CONTROL_ENABLED, card.isMounted() && printingIsActive() ? COLOR_BUSY : COLOR_CONTROL_DISABLED));
- #endif
}
// Draw a static item with no left-right margin required. Centered by default.
@@ -450,9 +455,9 @@ void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const valu
void TFT::draw_edit_screen_buttons() {
#if ENABLED(TOUCH_SCREEN)
- add_control(64, 256, DECREASE, imgDecrease);
- add_control(352, 256, INCREASE, imgIncrease);
- add_control(208, 256, CLICK, imgConfirm);
+ add_control(64, TFT_HEIGHT - 64, DECREASE, imgDecrease);
+ add_control(352, TFT_HEIGHT - 64, INCREASE, imgIncrease);
+ add_control(208, TFT_HEIGHT - 64, CLICK, imgConfirm);
#endif
}
@@ -481,8 +486,8 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
tft.add_text(tft_string.center(TFT_WIDTH), 0, COLOR_MENU_TEXT, tft_string);
}
#if ENABLED(TOUCH_SCREEN)
- add_control(88, 256, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
- add_control(328, 256, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
+ add_control(88, TFT_HEIGHT - 64, CANCEL, imgCancel, true, yesno ? HALF(COLOR_CONTROL_CANCEL) : COLOR_CONTROL_CANCEL);
+ add_control(328, TFT_HEIGHT - 64, CONFIRM, imgConfirm, true, yesno ? COLOR_CONTROL_CONFIRM : HALF(COLOR_CONTROL_CONFIRM));
#endif
}
@@ -541,7 +546,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
lpos = pos.asLogical();
- tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2 - 43, 120, 43);
+ tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(X_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
@@ -549,7 +554,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
tft_string.trim();
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
- tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2, 120, 43);
+ tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, 120, MENU_ITEM_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(Y_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
@@ -557,7 +562,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
tft_string.trim();
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
- tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2 + 43, 120, 43);
+ tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 + MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(Z_LBL);
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
@@ -566,13 +571,13 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
- tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - 48) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 5, 48, 43);
+ tft.canvas(GRID_OFFSET_X + (GRID_WIDTH - 48) / 2, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET - 5, 48, MENU_ITEM_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(ui8tostr3rj(x_plot));
tft_string.trim();
tft.add_text(tft_string.center(48), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
- tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET + 16 - 24, GRID_OFFSET_Y + (GRID_HEIGHT - 43) / 2, 48, 43);
+ tft.canvas(GRID_OFFSET_X + GRID_WIDTH + CONTROL_OFFSET + 16 - 24, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2, 48, MENU_ITEM_HEIGHT);
tft.set_background(COLOR_BACKGROUND);
tft_string.set(ui8tostr3rj(y_plot));
tft_string.trim();
@@ -586,7 +591,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
add_control(GRID_OFFSET_X + CONTROL_OFFSET, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, - ENCODER_STEPS_PER_MENU_ITEM, imgLeft);
add_control(GRID_OFFSET_X + GRID_WIDTH - CONTROL_OFFSET - 32, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, UBL, ENCODER_STEPS_PER_MENU_ITEM, imgRight);
add_control(320, GRID_OFFSET_Y + GRID_HEIGHT + CONTROL_OFFSET, CLICK, imgLeveling);
- add_control(224, 286, BACK, imgBack);
+ add_control(224, TFT_HEIGHT - 34, BACK, imgBack);
#endif
}
#endif // AUTO_BED_LEVELING_UBL
@@ -644,7 +649,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
#endif // TOUCH_SCREEN_CALIBRATION
void menu_line(const uint8_t row, uint16_t color) {
- tft.canvas(0, 4 + 45 * row, TFT_WIDTH, 43);
+ tft.canvas(0, 4 + (MENU_ITEM_HEIGHT + 2) * row, TFT_WIDTH, MENU_ITEM_HEIGHT);
tft.set_background(color);
}
@@ -661,7 +666,7 @@ void menu_item(const uint8_t row, bool sel ) {
menu_line(row, sel ? COLOR_SELECTION_BG : COLOR_BACKGROUND);
#if ENABLED(TOUCH_SCREEN)
const TouchControlType tct = TERN(SINGLE_TOUCH_NAVIGATION, true, sel) ? MENU_CLICK : MENU_ITEM;
- touch.add_control(tct, 0, 4 + 45 * row, TFT_WIDTH, 43, encoderTopLine + row);
+ touch.add_control(tct, 0, 4 + (MENU_ITEM_HEIGHT + 2) * row, TFT_WIDTH, MENU_ITEM_HEIGHT, encoderTopLine + row);
#endif
}
diff --git a/Marlin/src/lcd/tft/ui_480x320.h b/Marlin/src/lcd/tft/ui_480x320.h
index cc62ee8cce739..e3a688f112b15 100644
--- a/Marlin/src/lcd/tft/ui_480x320.h
+++ b/Marlin/src/lcd/tft/ui_480x320.h
@@ -38,13 +38,22 @@ void draw_fan_status(uint16_t x, uint16_t y, const bool blink);
void menu_line(const uint8_t row, uint16_t color = COLOR_BACKGROUND);
void menu_item(const uint8_t row, bool sel = false);
-#define MENU_FONT_NAME Helvetica18
-#define SYMBOLS_FONT_NAME Helvetica18_symbols
+#if HAS_UI_480x320
+ #define MENU_FONT_NAME Helvetica18
+ #define SYMBOLS_FONT_NAME Helvetica18_symbols
+ #define MENU_ITEM_HEIGHT 43
+ #define FONT_LINE_HEIGHT 34
+#elif HAS_UI_480x272
+ #define MENU_FONT_NAME Helvetica14
+ #define SYMBOLS_FONT_NAME Helvetica14_symbols
+ #define MENU_ITEM_HEIGHT 36
+ #define FONT_LINE_HEIGHT 24
+#endif
#define ABSOLUTE_ZERO -273.15
const tImage Images[imgCount] = {
- TERN(BOOT_MARLIN_LOGO_SMALL, MarlinLogo195x59x16, MarlinLogo480x320x16),
+ TERN(SHOW_BOOTSCREEN, TERN(BOOT_MARLIN_LOGO_SMALL, MarlinLogo195x59x16, MarlinLogo480x320x16), NoLogo),
HotEnd_64x64x4,
Bed_64x64x4,
Bed_Heated_64x64x4,
diff --git a/Marlin/src/lcd/tft_io/ssd1963.h b/Marlin/src/lcd/tft_io/ssd1963.h
index af42e306c616f..8564b28bfb1dd 100644
--- a/Marlin/src/lcd/tft_io/ssd1963.h
+++ b/Marlin/src/lcd/tft_io/ssd1963.h
@@ -39,10 +39,10 @@
IF_0((TFT_ORIENTATION) & TFT_INVERT_X, SSD1963_MADCTL_FH) | \
IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, SSD1963_MADCTL_FV)
-#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR
- #define SSD1963_COLOR SSD1963_MADCTL_BGR
-#elif TFT_COLOR == TFT_COLOR_RGB
+#if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_RGB
#define SSD1963_COLOR SSD1963_MADCTL_RGB
+#elif TFT_COLOR == TFT_COLOR_BGR
+ #define SSD1963_COLOR SSD1963_MADCTL_BGR
#endif
#define SSD1963_MADCTL_DATA (SSD1963_ORIENTATION) | (SSD1963_COLOR)
diff --git a/Marlin/src/lcd/tft_io/touch_calibration.cpp b/Marlin/src/lcd/tft_io/touch_calibration.cpp
index 159f09d087ce8..3c24d427342b9 100644
--- a/Marlin/src/lcd/tft_io/touch_calibration.cpp
+++ b/Marlin/src/lcd/tft_io/touch_calibration.cpp
@@ -23,6 +23,11 @@
#include "touch_calibration.h"
+#define TOUCH_CALIBRATION_MAX_RETRIES 5
+
+#define DEBUG_OUT ENABLED(DEBUG_TOUCH_CALIBRATION)
+#include "../../core/debug_out.h"
+
TouchCalibration touch_calibration;
touch_calibration_t TouchCalibration::calibration;
@@ -31,23 +36,40 @@ touch_calibration_point_t TouchCalibration::calibration_points[4];
uint8_t TouchCalibration::failed_count;
void TouchCalibration::validate_calibration() {
- const bool landscape = validate_precision_x(0, 1) && validate_precision_x(2, 3) && validate_precision_y(0, 2) && validate_precision_y(1, 3);
- const bool portrait = validate_precision_y(0, 1) && validate_precision_y(2, 3) && validate_precision_x(0, 2) && validate_precision_x(1, 3);
+ #define VALIDATE_PRECISION(XY, A, B) validate_precision_##XY(CALIBRATION_##A, CALIBRATION_##B)
+ const bool landscape = VALIDATE_PRECISION(x, TOP_LEFT, BOTTOM_LEFT)
+ && VALIDATE_PRECISION(x, TOP_RIGHT, BOTTOM_RIGHT)
+ && VALIDATE_PRECISION(y, TOP_LEFT, TOP_RIGHT)
+ && VALIDATE_PRECISION(y, BOTTOM_LEFT, BOTTOM_RIGHT);
+ const bool portrait = VALIDATE_PRECISION(y, TOP_LEFT, BOTTOM_LEFT)
+ && VALIDATE_PRECISION(y, TOP_RIGHT, BOTTOM_RIGHT)
+ && VALIDATE_PRECISION(x, TOP_LEFT, TOP_RIGHT)
+ && VALIDATE_PRECISION(x, BOTTOM_LEFT, BOTTOM_RIGHT);
+ #undef VALIDATE_PRECISION
- if (landscape || portrait) {
+ #define CAL_PTS(N) calibration_points[CALIBRATION_##N]
+ if (landscape) {
+ calibration_state = CALIBRATION_SUCCESS;
+ calibration.x = ((CAL_PTS(TOP_RIGHT).x - CAL_PTS(TOP_LEFT).x) << 17) / (CAL_PTS(BOTTOM_RIGHT).raw_x + CAL_PTS(TOP_RIGHT).raw_x - CAL_PTS(BOTTOM_LEFT).raw_x - CAL_PTS(TOP_LEFT).raw_x);
+ calibration.y = ((CAL_PTS(BOTTOM_LEFT).y - CAL_PTS(TOP_LEFT).y) << 17) / (CAL_PTS(BOTTOM_RIGHT).raw_y - CAL_PTS(TOP_RIGHT).raw_y + CAL_PTS(BOTTOM_LEFT).raw_y - CAL_PTS(TOP_LEFT).raw_y);
+ calibration.offset_x = CAL_PTS(TOP_LEFT).x - int16_t(((CAL_PTS(TOP_LEFT).raw_x + CAL_PTS(BOTTOM_LEFT).raw_x) * calibration.x) >> 17);
+ calibration.offset_y = CAL_PTS(TOP_LEFT).y - int16_t(((CAL_PTS(TOP_LEFT).raw_y + CAL_PTS(TOP_RIGHT).raw_y) * calibration.y) >> 17);
+ calibration.orientation = TOUCH_LANDSCAPE;
+ }
+ else if (portrait) {
calibration_state = CALIBRATION_SUCCESS;
- calibration.x = ((calibration_points[2].x - calibration_points[0].x) << 17) / (calibration_points[3].raw_x + calibration_points[2].raw_x - calibration_points[1].raw_x - calibration_points[0].raw_x);
- calibration.y = ((calibration_points[1].y - calibration_points[0].y) << 17) / (calibration_points[3].raw_y - calibration_points[2].raw_y + calibration_points[1].raw_y - calibration_points[0].raw_y);
- calibration.offset_x = calibration_points[0].x - int16_t(((calibration_points[0].raw_x + calibration_points[1].raw_x) * calibration.x) >> 17);
- calibration.offset_y = calibration_points[0].y - int16_t(((calibration_points[0].raw_y + calibration_points[2].raw_y) * calibration.y) >> 17);
- calibration.orientation = landscape ? TOUCH_LANDSCAPE : TOUCH_PORTRAIT;
+ calibration.x = ((CAL_PTS(TOP_RIGHT).x - CAL_PTS(TOP_LEFT).x) << 17) / (CAL_PTS(BOTTOM_RIGHT).raw_y + CAL_PTS(TOP_RIGHT).raw_y - CAL_PTS(BOTTOM_LEFT).raw_y - CAL_PTS(TOP_LEFT).raw_y);
+ calibration.y = ((CAL_PTS(BOTTOM_LEFT).y - CAL_PTS(TOP_LEFT).y) << 17) / (CAL_PTS(BOTTOM_RIGHT).raw_x - CAL_PTS(TOP_RIGHT).raw_x + CAL_PTS(BOTTOM_LEFT).raw_x - CAL_PTS(TOP_LEFT).raw_x);
+ calibration.offset_x = CAL_PTS(TOP_LEFT).x - int16_t(((CAL_PTS(TOP_LEFT).raw_y + CAL_PTS(BOTTOM_LEFT).raw_y) * calibration.x) >> 17);
+ calibration.offset_y = CAL_PTS(TOP_LEFT).y - int16_t(((CAL_PTS(TOP_LEFT).raw_x + CAL_PTS(TOP_RIGHT).raw_x) * calibration.y) >> 17);
+ calibration.orientation = TOUCH_PORTRAIT;
}
else {
calibration_state = CALIBRATION_FAIL;
calibration_reset();
- // Retry up to 5 times before reporting the failure
- if (need_calibration() && failed_count++ < 5) calibration_state = CALIBRATION_TOP_LEFT;
+ if (need_calibration() && failed_count++ < TOUCH_CALIBRATION_MAX_RETRIES) calibration_state = CALIBRATION_TOP_LEFT;
}
+ #undef CAL_PTS
if (calibration_state == CALIBRATION_SUCCESS) {
SERIAL_ECHOLNPGM("Touch screen calibration completed");
@@ -55,7 +77,7 @@ void TouchCalibration::validate_calibration() {
SERIAL_ECHOLNPAIR("TOUCH_CALIBRATION_Y ", calibration.y);
SERIAL_ECHOLNPAIR("TOUCH_OFFSET_X ", calibration.offset_x);
SERIAL_ECHOLNPAIR("TOUCH_OFFSET_Y ", calibration.offset_y);
- SERIAL_ECHOPGM("TOUCH_ORIENTATION "); if (calibration.orientation == TOUCH_LANDSCAPE) SERIAL_ECHOLNPGM("TOUCH_LANDSCAPE"); else SERIAL_ECHOLNPGM("TOUCH_PORTRAIT");
+ SERIAL_ECHO_TERNARY(calibration.orientation == TOUCH_LANDSCAPE, "TOUCH_ORIENTATION ", "TOUCH_LANDSCAPE", "TOUCH_PORTRAIT", "\n");
}
}
@@ -68,6 +90,7 @@ bool TouchCalibration::handleTouch(uint16_t x, uint16_t y) {
if (calibration_state < CALIBRATION_SUCCESS) {
calibration_points[calibration_state].raw_x = x;
calibration_points[calibration_state].raw_y = y;
+ DEBUG_ECHOLNPAIR("TouchCalibration - State: ", calibration_state, ", x: ", calibration_points[calibration_state].x, ", raw_x: ", x, ", y: ", calibration_points[calibration_state].y, ", raw_y: ", y);
}
switch (calibration_state) {
diff --git a/Marlin/src/module/thermistor/thermistor_503.h b/Marlin/src/module/thermistor/thermistor_503.h
index fc4bffffdb58b..543600a7aa21f 100644
--- a/Marlin/src/module/thermistor/thermistor_503.h
+++ b/Marlin/src/module/thermistor/thermistor_503.h
@@ -55,3 +55,40 @@ const temp_entry_t temptable_503[] PROGMEM = {
{ OV(1021), -27 },
{ OV(1023), -200}
};
+#include
+
+typedef enum {
+ USB_STATE_INIT,
+ USB_STATE_ERROR,
+ USB_STATE_RUNNING,
+} usb_state_t;
+
+class USBHost {
+public:
+ bool start();
+ void Task();
+ uint8_t getUsbTaskState();
+ void setUsbTaskState(uint8_t state);
+ uint8_t regRd(uint8_t reg) { return 0x0; };
+ uint8_t usb_task_state = USB_STATE_INIT;
+ uint8_t lun = 0;
+ uint32_t capacity = 0;
+ uint16_t block_size = 0;
+ uint32_t block_count = 0;
+};
+
+class BulkStorage {
+public:
+ BulkStorage(USBHost *usb) : usb(usb) {};
+
+ bool LUNIsGood(uint8_t t);
+ uint32_t GetCapacity(uint8_t lun);
+ uint16_t GetSectorSize(uint8_t lun);
+ uint8_t Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, uint8_t *buf);
+ uint8_t Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf);
+
+ USBHost *usb;
+};
+
+extern USBHost usb;
+extern BulkStorage bulk;
diff --git a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h
index 68cfe65601d17..6d9d225efffcc 100644
--- a/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h
+++ b/Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h
@@ -189,7 +189,7 @@
// Reduce baud rate to improve software serial reliability
#define TMC_BAUD_RATE 19200
-#endif // TMC2208 || TMC2209
+#endif // HAS_TMC_UART
//
// Temperature Sensors
diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h
index 93890e9aa777d..3118a521bbeb0 100644
--- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h
+++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h
@@ -40,7 +40,6 @@
//
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
//
-
#define DISABLE_DEBUG
//
@@ -59,6 +58,11 @@
//
#define SPI_DEVICE 2
+//
+// Servos
+//
+#define SERVO0_PIN PA8 // Enable BLTOUCH
+
//
// Limit Switches
//
@@ -155,7 +159,7 @@
// Reduce baud rate to improve software serial reliability
#define TMC_BAUD_RATE 19200
-#endif // TMC2208 || TMC2209
+#endif // HAS_TMC_UART
//
// Temperature Sensors
@@ -200,8 +204,6 @@
#define FIL_RUNOUT_PIN PA4
#endif
-#define SERVO0_PIN PA8 // Enable BLTOUCH
-
//#define LED_PIN PB2
//
diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h
index e6a1e929993ba..b3cfe5b6baa79 100644
--- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h
+++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h
@@ -52,6 +52,13 @@
#define SPI_DEVICE 2
+//
+// Servos
+//
+#ifndef SERVO0_PIN
+ #define SERVO0_PIN PA8 // Enable BLTOUCH support on IO0 (WIFI connector)
+#endif
+
//
// Limit Switches
//
@@ -91,6 +98,7 @@
#ifndef DEFAULT_PWM_MOTOR_CURRENT
#define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 }
#endif
+
//
// Temperature Sensors
//
@@ -111,10 +119,6 @@
#define POWER_LOSS_PIN PA2 // PW_DET
#define PS_ON_PIN PA3 // PW_OFF
-#ifndef SERVO0_PIN
- #define SERVO0_PIN PA8 // Enable BLTOUCH support on IO0 (WIFI connector)
-#endif
-
#define MT_DET_1_PIN PA4
#define MT_DET_PIN_INVERTING false
diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h
index c430671b2effe..ea3a7a1eea8e9 100644
--- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h
+++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h
@@ -56,6 +56,11 @@
#define SPI_DEVICE 2
+//
+// Servos
+//
+#define SERVO0_PIN PA8 // Enable BLTOUCH
+
//
// Limit Switches
//
@@ -148,8 +153,6 @@
#define FIL_RUNOUT2_PIN PE6
#endif
-#define SERVO0_PIN PA8 // Enable BLTOUCH support
-
//#define LED_PIN PB2
//
diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h
index 063e548a329be..6ef3a0804384e 100644
--- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h
+++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h
@@ -43,7 +43,6 @@
//
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
//
-
#define DISABLE_DEBUG
//
@@ -62,6 +61,11 @@
//
#define SPI_DEVICE 2
+//
+// Servos
+//
+#define SERVO0_PIN PA8 // Enable BLTOUCH
+
//
// Limit Switches
//
@@ -163,7 +167,7 @@
// Reduce baud rate to improve software serial reliability
#define TMC_BAUD_RATE 19200
-#endif // TMC2208 || TMC2209
+#endif // HAS_TMC_UART
//
// Temperature Sensors
@@ -218,8 +222,6 @@
#define FIL_RUNOUT2_PIN PE6
#endif
-#define SERVO0_PIN PA8 // Enable BLTOUCH
-
//#define LED_PIN PB2
//
diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h
index 65aa5cc39e59a..89bb41b1979b1 100644
--- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h
+++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h
@@ -48,7 +48,7 @@
//
// Servos
//
-#define SERVO0_PIN PA8 // BLTOUCH
+#define SERVO0_PIN PA8 // Enable BLTOUCH
//
// Limit Switches
diff --git a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h
index 7f429d4497e03..0721aab844074 100644
--- a/Marlin/src/pins/stm32f4/pins_ANET_ET4.h
+++ b/Marlin/src/pins/stm32f4/pins_ANET_ET4.h
@@ -155,11 +155,6 @@
#define TOUCH_INT_PIN PB1
#endif
-// Touchscreen calibration does not work correctly with ANET_ET5_TFT35 or ANET_ET4_TFT28
-#if ENABLED(TOUCH_SCREEN_CALIBRATION)
- #undef TOUCH_SCREEN_CALIBRATION
-#endif
-
#if ENABLED(ANET_ET5_TFT35)
#ifndef TOUCH_CALIBRATION_X
#define TOUCH_CALIBRATION_X 17125
diff --git a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h
index bfa4007658dbe..d594e3ca49673 100644
--- a/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h
+++ b/Marlin/src/pins/stm32f4/pins_BTT_GTR_V1_0.h
@@ -35,6 +35,9 @@
#define I2C_EEPROM
#define MARLIN_EEPROM_SIZE 0x2000 // 8KB (24C64 ... 64Kb = 8KB)
+// USB Flash Drive support
+#define HAS_OTG_USB_HOST_SUPPORT
+
#define TP // Enable to define servo and probe pins
//
diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h
index 235ed1edcc4c5..be05ebcfa9cd2 100644
--- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h
+++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_common.h
@@ -44,6 +44,9 @@
#define FLASH_EEPROM_LEVELING
#endif
+// USB Flash Drive support
+#define HAS_OTG_USB_HOST_SUPPORT
+
//
// Servos
//
diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h
index e2b3f2c317c65..c3f8309d9d536 100644
--- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h
+++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h
@@ -31,17 +31,27 @@
#define BOARD_INFO_NAME "MKS Robin Nano V3"
+// USB Flash Drive support
+#define HAS_OTG_USB_HOST_SUPPORT
+
// Avoid conflict with TIMER_TONE
-#define STEP_TIMER 10
+#define STEP_TIMER 10
// Use one of these or SDCard-based Emulation will be used
//#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation
//#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation
#define I2C_EEPROM
+#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
//
// Release PB4 (Z_DIR_PIN) from JTAG NRST role
//
+//#define DISABLE_DEBUG
+
+//
+// Servos
+//
+#define SERVO0_PIN PA8 // Enable BLTOUCH
//
// Limit Switches
@@ -98,8 +108,8 @@
//
// Software SPI pins for TMC2130 stepper drivers
+// This board only supports SW SPI for stepper drivers
//
-// This board only support SW SPI for stepper drivers
#if HAS_TMC_SPI
#define TMC_USE_SW_SPI
#endif
@@ -186,14 +196,13 @@
//#define KILL_PIN PA2
//#define KILL_PIN_INVERTING true
-#define SERVO0_PIN PA8 // Enable BLTOUCH support
//#define LED_PIN PB2
// Random Info
-#define USB_SERIAL -1 //Usb Serial
-#define WIFI_SERIAL 3 //USART3
-#define MKS_WIFI_MODULE_SERIAL 1 //USART1
-#define MKS_WIFI_MODULE_SPI 2 //SPI2
+#define USB_SERIAL -1 // USB Serial
+#define WIFI_SERIAL 3 // USART3
+#define MKS_WIFI_MODULE_SERIAL 1 // USART1
+#define MKS_WIFI_MODULE_SPI 2 // SPI2
#ifndef SDCARD_CONNECTION
#define SDCARD_CONNECTION ONBOARD
@@ -331,7 +340,7 @@
//#define MKS_LCD12864B
//#undef SHOW_BOOTSCREEN
- #else // !MKS_MINI_12864
+ #else // !MKS_MINI_12864
#define LCD_PINS_D4 PE14
#if ENABLED(ULTIPANEL)
@@ -346,5 +355,3 @@
#endif // !MKS_MINI_12864
#endif // HAS_SPI_LCD
-
-#define HAS_OTG_USB_HOST_SUPPORT
diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h
index 05648cf1207e7..719f8773f56d8 100644
--- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h
+++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h
@@ -30,22 +30,32 @@
#define BOARD_INFO_NAME "MKS Robin PRO V2"
// Avoid conflict with TIMER_TONE
-#define STEP_TIMER 10
+#define STEP_TIMER 10
// Use one of these or SDCard-based Emulation will be used
//#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation
//#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation
#define I2C_EEPROM
+#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
+
+// USB Flash Drive support
+#define HAS_OTG_USB_HOST_SUPPORT
//
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
//
+//#define DISABLE_DEBUG
//
// Note: MKS Robin board is using SPI2 interface.
//
//#define SPI_MODULE 2
+//
+// Servos
+//
+#define SERVO0_PIN PA8 // Enable BLTOUCH
+
//
// Limit Switches
//
@@ -55,8 +65,6 @@
#define E0_DIAG_PIN PC4
#define E1_DIAG_PIN PE7
-//
-
#define X_STOP_PIN PA15
#define Y_STOP_PIN PA12
#define Z_MIN_PIN PA11
@@ -159,7 +167,7 @@
// Reduce baud rate to improve software serial reliability
#define TMC_BAUD_RATE 19200
-#endif // TMC2208 || TMC2209
+#endif // HAS_TMC_UART
//
// Temperature Sensors
@@ -186,19 +194,18 @@
//
// Misc. Functions
//
-// #define POWER_LOSS_PIN PA2 // PW_DET
-// #define PS_ON_PIN PA3 // PW_OFF
-// #define SUICIDE_PIN PB2 // Enable MKSPWC support
-// #define KILL_PIN PA2 // Enable MKSPWC support
-// #define KILL_PIN_INVERTING true // Enable MKSPWC support
-#define SERVO0_PIN PA8 // Enable BLTOUCH support
+//#define POWER_LOSS_PIN PA2 // PW_DET
+//#define PS_ON_PIN PA3 // PW_OFF
+//#define SUICIDE_PIN PB2 // Enable MKSPWC support
+//#define KILL_PIN PA2 // Enable MKSPWC support
+//#define KILL_PIN_INVERTING true // Enable MKSPWC support
//#define LED_PIN PB2
#ifndef SDCARD_CONNECTION
#define SDCARD_CONNECTION ONBOARD
#endif
-// #define USE_NEW_SPI_API 1
+//#define USE_NEW_SPI_API 1
//
// Onboard SD card
@@ -243,7 +250,7 @@
//
// LCD / Controller
#define SPI_FLASH
-#define HAS_SPI_FLASH 1
+#define HAS_SPI_FLASH 1
#define SPI_DEVICE 2
#define SPI_FLASH_SIZE 0x1000000
#if ENABLED(SPI_FLASH)
@@ -316,7 +323,7 @@
#define LCD_READ_ID 0xD3
#define LCD_USE_DMA_SPI
- // #define TFT_DRIVER ST7796
+ //#define TFT_DRIVER ST7796
#define TFT_BUFFER_SIZE 14400
#elif HAS_SPI_LCD
diff --git a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h
index 90dcfc46e424f..466cce565df14 100644
--- a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h
+++ b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h
@@ -36,7 +36,7 @@
// Decrease delays and flash wear by spreading writes across the
// 128 kB sector allocated for EEPROM emulation.
// Not yet supported on F7 hardware
- // #define FLASH_EEPROM_LEVELING
+ //#define FLASH_EEPROM_LEVELING
#endif
/**
@@ -188,9 +188,6 @@
#define LCD_PINS_RS PF12 // LCD_RS
#define LCD_PINS_ENABLE PD15 // LCD_EN
#define LCD_PINS_D4 PB13 // LCD_D4
- // #define LCD_PINS_D5
- // #define LCD_PINS_D6
- // #define LCD_PINS_D7
#define BTN_EN1 PF13 // BTN_EN1
#define BTN_EN2 PE9 // BTN_EN2
diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp
index 539d31654265d..28a18cd9d86b9 100644
--- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp
+++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp
@@ -44,8 +44,9 @@
#include "../../core/serial.h"
#include "../../module/temperature.h"
-static_assert(USB_CS_PIN != -1, "USB_CS_PIN must be defined");
-static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined");
+#if DISABLED(USE_OTG_USB_HOST) && !PINS_EXIST(USB_CS, USB_INTR)
+ #error "USB_FLASH_DRIVE_SUPPORT requires USB_CS_PIN and USB_INTR_PIN to be defined."
+#endif
#if ENABLED(USE_UHS3_USB)
#define NO_AUTO_SPEED
@@ -81,6 +82,17 @@ static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined");
#define UHS_START (usb.Init() == 0)
#define UHS_STATE(state) UHS_USB_HOST_STATE_##state
+#elif ENABLED(USE_OTG_USB_HOST)
+
+ #if HAS_SD_HOST_DRIVE
+ #include HAL_PATH(../../HAL, msc_sd.h)
+ #endif
+
+ #include HAL_PATH(../../HAL, usb_host.h)
+
+ #define UHS_START usb.start()
+ #define rREVISION 0
+ #define UHS_STATE(state) USB_STATE_##state
#else
#include "lib-uhs2/Usb.h"
#include "lib-uhs2/masstorage.h"
@@ -250,7 +262,7 @@ bool Sd2Card::isInserted() {
return state == MEDIA_READY;
}
-bool Sd2Card::ready() {
+bool Sd2Card::isReady() {
return state > DO_STARTUP;
}
diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h
index 8ca95ba7061cb..83245168abcae 100644
--- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h
+++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h
@@ -23,26 +23,27 @@
/**
* \file
- * \brief Sd2Card class for V2 SD/SDHC cards
+ * \brief Sd2Card class for USB Flash Drive
*/
-
#include "../SdFatConfig.h"
#include "../SdInfo.h"
-/**
- * Define SOFTWARE_SPI to use bit-bang SPI
- */
-#if EITHER(MEGA_SOFT_SPI, USE_SOFTWARE_SPI)
- #define SOFTWARE_SPI
-#endif
+#if DISABLED(USE_OTG_USB_HOST)
+ /**
+ * Define SOFTWARE_SPI to use bit-bang SPI
+ */
+ #if EITHER(MEGA_SOFT_SPI, USE_SOFTWARE_SPI)
+ #define SOFTWARE_SPI
+ #endif
-// SPI pin definitions - do not edit here - change in SdFatConfig.h
-#if ENABLED(SOFTWARE_SPI)
- #warning "Auto-assigning '10' as the SD_CHIP_SELECT_PIN."
- #define SD_CHIP_SELECT_PIN 10 // Software SPI chip select pin for the SD
-#else
- // hardware pin defs
- #define SD_CHIP_SELECT_PIN SS_PIN // The default chip select pin for the SD card is SS.
+ // SPI pin definitions - do not edit here - change in SdFatConfig.h
+ #if ENABLED(SOFTWARE_SPI)
+ #warning "Auto-assigning '10' as the SD_CHIP_SELECT_PIN."
+ #define SD_CHIP_SELECT_PIN 10 // Software SPI chip select pin for the SD
+ #else
+ // hardware pin defs
+ #define SD_CHIP_SELECT_PIN SS_PIN // The default chip select pin for the SD card is SS.
+ #endif
#endif
class Sd2Card {
@@ -54,22 +55,24 @@ class Sd2Card {
public:
static bool usbStartup();
- bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=SD_CHIP_SELECT_PIN);
+ bool init(const uint8_t sckRateID=0, const pin_t chipSelectPin=TERN(USE_OTG_USB_HOST, 0, SD_CHIP_SELECT_PIN));
static void idle();
- inline bool readStart(const uint32_t block) { pos = block; return ready(); }
+ inline bool readStart(const uint32_t block) { pos = block; return isReady(); }
inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); }
inline bool readStop() const { return true; }
- inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return ready(); }
+ inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return isReady(); }
inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); }
inline bool writeStop() const { return true; }
bool readBlock(uint32_t block, uint8_t* dst);
bool writeBlock(uint32_t blockNumber, const uint8_t* src);
+ bool readCSD(csd_t* csd) { return true; };
+
uint32_t cardSize();
static bool isInserted();
- static bool ready();
+ bool isReady();
};
diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h
index e0e8239aac08a..f7f9e23e99e7d 100644
--- a/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h
+++ b/buildroot/share/PlatformIO/variants/BIGTREE_GTR_V1/hal_conf_extra.h
@@ -44,7 +44,7 @@
#undef HAL_IRDA_MODULE_ENABLED
#undef HAL_SMARTCARD_MODULE_ENABLED
#undef HAL_WWDG_MODULE_ENABLED
-#undef HAL_HCD_MODULE_ENABLED
+//#undef HAL_HCD_MODULE_ENABLED
#undef HAL_FMPI2C_MODULE_ENABLED
#undef HAL_SPDIFRX_MODULE_ENABLED
#undef HAL_DFSDM_MODULE_ENABLED
diff --git a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h
index e0e8239aac08a..f7f9e23e99e7d 100644
--- a/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h
+++ b/buildroot/share/PlatformIO/variants/BIGTREE_SKR_PRO_1v1/hal_conf_extra.h
@@ -44,7 +44,7 @@
#undef HAL_IRDA_MODULE_ENABLED
#undef HAL_SMARTCARD_MODULE_ENABLED
#undef HAL_WWDG_MODULE_ENABLED
-#undef HAL_HCD_MODULE_ENABLED
+//#undef HAL_HCD_MODULE_ENABLED
#undef HAL_FMPI2C_MODULE_ENABLED
#undef HAL_SPDIFRX_MODULE_ENABLED
#undef HAL_DFSDM_MODULE_ENABLED
diff --git a/buildroot/tests/STM32F103VE_longer-tests b/buildroot/tests/STM32F103VE_longer-tests
old mode 100755
new mode 100644
index 461f128873b86..1c90744c0110d
--- a/buildroot/tests/STM32F103VE_longer-tests
+++ b/buildroot/tests/STM32F103VE_longer-tests
@@ -8,7 +8,16 @@ set -e
use_example_configs Alfawise/U20
opt_enable BAUD_RATE_GCODE
-exec_test $1 $2 "Full-featured U20 config" "$3"
+exec_test $1 $2 "CLASSIC_UI U20 config" "$3"
+
+use_example_configs Alfawise/U20
+opt_enable BAUD_RATE_GCODE TFT_COLOR_UI
+opt_disable TFT_CLASSIC_UI CUSTOM_STATUS_SCREEN_IMAGE
+exec_test $1 $2 "COLOR_UI U20 config" "$3"
+
+use_example_configs Alfawise/U20-bltouch
+opt_enable BAUD_RATE_GCODE
+exec_test $1 $2 "BLTouch U20 config"
# cleanup
restore_configs
diff --git a/platformio.ini b/platformio.ini
index 2aff7aad233c8..3e87968eef397 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -59,7 +59,7 @@ default_src_filter = + - - +
- -
-
-
- -
+ - -
-
-
-
@@ -272,7 +272,8 @@ HAS_DGUS_LCD = src_filter=+ +
EXTUI_EXAMPLE = src_filter=+
MALYAN_LCD = src_filter=+
-USB_FLASH_DRIVE_SUPPORT = src_filter=+
+USE_UHS2_USB = src_filter=+
+USE_UHS3_USB = src_filter=+
AUTO_BED_LEVELING_BILINEAR = src_filter=+
AUTO_BED_LEVELING_(3POINT|(BI)?LINEAR) = src_filter=+
MESH_BED_LEVELING = src_filter=+ +
@@ -1278,6 +1279,23 @@ extra_scripts = ${common.extra_scripts}
debug_tool = stlink
debug_init_break =
+#
+# USB Flash Drive mix-ins for STM32
+#
+[stm32_flash_drive]
+platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip
+build_flags = ${common_stm32.build_flags}
+ -DHAL_PCD_MODULE_ENABLED -DHAL_HCD_MODULE_ENABLED
+ -DUSBHOST -DUSBH_IRQ_PRIO=3 -DUSBH_IRQ_SUBPRIO=4
+
+#
+# BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support
+#
+[env:BIGTREE_SKR_PRO_usb_flash_drive]
+extends = env:BIGTREE_SKR_PRO
+platform_packages = ${stm32_flash_drive.platform_packages}
+build_flags = ${stm32_flash_drive.build_flags}
+
#
# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4)
#
@@ -1290,6 +1308,14 @@ extra_scripts = ${common.extra_scripts}
build_flags = ${common_stm32.build_flags}
-DSTM32F407IX -DVECT_TAB_OFFSET=0x8000
+#
+# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support
+#
+[env:BIGTREE_GTR_V1_0_usb_flash_drive]
+extends = env:BIGTREE_GTR_V1_0
+platform_packages = ${stm32_flash_drive.platform_packages}
+build_flags = ${stm32_flash_drive.build_flags}
+
#
# BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4)
#
@@ -1392,13 +1418,16 @@ extra_scripts = ${common.extra_scripts}
#
[env:mks_robin_pro2]
platform = ${common_stm32.platform}
+platform_packages = ${stm32_flash_drive.platform_packages}
extends = common_stm32
-build_flags = ${common_stm32.build_flags} -DHAL_HCD_MODULE_ENABLED -DUSBHOST
+build_flags = ${stm32_flash_drive.build_flags}
board = genericSTM32F407VET6
board_build.core = stm32
board_build.variant = MARLIN_F4x7Vx
board_build.ldscript = ldscript.ld
board_build.firmware = firmware.bin
+board_build.offset = 0x0000
+board_upload.offset_address = 0x08000000
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
debug_tool = jlink
upload_protocol = jlink
@@ -1427,6 +1456,21 @@ extra_scripts = ${common.extra_scripts}
pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
buildroot/share/PlatformIO/scripts/stm32_bootloader.py
+#
+# MKS Robin Nano V3 with USB Flash Drive Support
+# Currently, using a STM32duino fork, until USB Host get merged
+#
+[env:mks_robin_nano_v3_usb_flash_drive]
+extends = env:mks_robin_nano_v3
+platform_packages = ${stm32_flash_drive.platform_packages}
+build_flags = ${stm32_flash_drive.build_flags}
+ -DUSBCON
+ -DUSE_USBHOST_HS
+ -DUSBD_IRQ_PRIO=5
+ -DUSBD_IRQ_SUBPRIO=6
+ -DUSE_USB_HS_IN_FS
+ -DUSBD_USE_CDC
+
#################################
# #
# Other Architectures #