Browse Source

MKS Robin Nano v3 + TFT_LVGL_UI + WiFi module (#22109)

vanilla_fb_2.0.x
MKS-Sean 3 years ago
committed by Scott Lahteine
parent
commit
cad2f69687
  1. 14
      Marlin/src/HAL/STM32/HAL.cpp
  2. 2
      Marlin/src/HAL/STM32/HAL_MinSerial.cpp
  3. 4
      Marlin/src/HAL/STM32/HAL_SPI.cpp
  4. 4
      Marlin/src/HAL/STM32/MarlinSPI.cpp
  5. 4
      Marlin/src/HAL/STM32/MarlinSerial.cpp
  6. 4
      Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp
  7. 4
      Marlin/src/HAL/STM32/Servo.cpp
  8. 4
      Marlin/src/HAL/STM32/eeprom_flash.cpp
  9. 4
      Marlin/src/HAL/STM32/eeprom_sdcard.cpp
  10. 4
      Marlin/src/HAL/STM32/eeprom_sram.cpp
  11. 4
      Marlin/src/HAL/STM32/eeprom_wired.cpp
  12. 4
      Marlin/src/HAL/STM32/fast_pwm.cpp
  13. 4
      Marlin/src/HAL/STM32/fastio.cpp
  14. 14
      Marlin/src/HAL/STM32/msc_sd.cpp
  15. 4
      Marlin/src/HAL/STM32/tft/gt911.cpp
  16. 4
      Marlin/src/HAL/STM32/tft/tft_fsmc.cpp
  17. 4
      Marlin/src/HAL/STM32/tft/tft_ltdc.cpp
  18. 4
      Marlin/src/HAL/STM32/tft/tft_spi.cpp
  19. 4
      Marlin/src/HAL/STM32/tft/xpt2046.cpp
  20. 4
      Marlin/src/HAL/STM32/timers.cpp
  21. 4
      Marlin/src/HAL/STM32/usb_host.cpp
  22. 4
      Marlin/src/HAL/STM32/usb_serial.cpp
  23. 4
      Marlin/src/HAL/STM32/watchdog.cpp
  24. 7
      Marlin/src/HAL/STM32F1/msc_sd.cpp
  25. 7
      Marlin/src/MarlinCore.cpp
  26. 2
      Marlin/src/core/macros.h
  27. 2
      Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h
  28. 28
      Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp
  29. 5
      Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp
  30. 4
      Marlin/src/lcd/extui/mks_ui/draw_printing.cpp
  31. 122
      Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp
  32. 36
      Marlin/src/lcd/extui/mks_ui/draw_ui.cpp
  33. 16
      Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp
  34. 140
      Marlin/src/lcd/extui/mks_ui/mks_hardware_test.cpp
  35. 6
      Marlin/src/lcd/extui/mks_ui/mks_hardware_test.h
  36. 5
      Marlin/src/lcd/extui/mks_ui/pic_manager.cpp
  37. 37
      Marlin/src/lcd/extui/mks_ui/printer_operation.cpp
  38. 33
      Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp
  39. 34
      Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp
  40. 76
      Marlin/src/lcd/extui/mks_ui/wifiSerial.h
  41. 352
      Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp
  42. 63
      Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h
  43. 18
      Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.cpp
  44. 77
      Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.h
  45. 702
      Marlin/src/lcd/extui/mks_ui/wifi_module.cpp
  46. 4
      Marlin/src/lcd/extui/mks_ui/wifi_module.h
  47. 10
      Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp
  48. 1
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h
  49. 15
      Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h
  50. 4
      buildroot/tests/mks_robin_nano35
  51. 3
      ini/stm32f1-maple.ini

14
Marlin/src/HAL/STM32/HAL.cpp

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "HAL.h"
#include "usb_serial.h"
@ -91,15 +91,13 @@ void HAL_init() {
USB_Hook_init();
#endif
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
#if HAS_SD_HOST_DRIVE
MSC_SD_init(); // Enable USB SD card access
#endif
TERN_(HAS_SD_HOST_DRIVE, MSC_SD_init()); // Enable USB SD card access
#if PIN_EXISTS(USB_CONNECT)
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
delay(1000); // Give OS time to notice
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
delay(1000); // Give OS time to notice
WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING);
#endif
}
@ -167,4 +165,4 @@ void HAL_SYSTICK_Callback() {
if (systick_user_callback) systick_user_callback();
}
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

2
Marlin/src/HAL/STM32/HAL_MinSerial.cpp

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfigPre.h"

4
Marlin/src/HAL/STM32/HAL_SPI.cpp

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -224,4 +224,4 @@ static SPISettings spiConfig;
#endif // SOFTWARE_SPI
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/MarlinSPI.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(STM32H7xx)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) && !defined(STM32H7xx)
#include "MarlinSPI.h"
@ -165,4 +165,4 @@ uint8_t MarlinSPI::dmaSend(const void * transmitBuf, uint16_t length, bool minc)
return 1;
}
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 && !STM32H7xx

4
Marlin/src/HAL/STM32/MarlinSerial.cpp

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
#include "MarlinSerial.h"
@ -101,4 +101,4 @@ void MarlinSerial::_rx_complete_irq(serial_t *obj) {
}
}
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -343,4 +343,4 @@
#endif // !USBD_USE_CDC_COMPOSITE
#endif // SDIO_SUPPORT
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/Servo.cpp

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -107,4 +107,4 @@ void libServo::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriori
}
#endif // HAS_SERVOS
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/eeprom_flash.cpp

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -270,4 +270,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t
}
#endif // FLASH_EEPROM_EMULATION
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/eeprom_sdcard.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
/**
* Implementation of EEPROM settings in SD Card
@ -88,4 +88,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uin
}
#endif // SDCARD_EEPROM_EMULATION
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/eeprom_sram.cpp

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -65,4 +65,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t
}
#endif // SRAM_EEPROM_EMULATION
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/eeprom_wired.cpp

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -75,4 +75,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t
}
#endif // USE_WIRED_EEPROM
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/fast_pwm.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfigPre.h"
@ -56,4 +56,4 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255
}
#endif // NEEDS_HARDWARE_PWM
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/fastio.cpp

@ -20,7 +20,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -31,4 +31,4 @@ void FastIO_init() {
FastIOPortMap[STM_PORT(digitalPin[i])] = get_GPIO_Port(STM_PORT(digitalPin[i]));
}
#endif
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

14
Marlin/src/HAL/STM32/msc_sd.cpp

@ -13,21 +13,24 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfigPre.h"
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && HAS_SD_HOST_DRIVE
#if HAS_SD_HOST_DRIVE
#include "msc_sd.h"
#include "../shared/Marduino.h"
#include "usbd_core.h"
#include "../shared/Marduino.h"
#include "../../sd/cardreader.h"
#include <USB.h>
#include <USBMscHandler.h>
#define BLOCK_SIZE 512
#define PRODUCT_ID 0x29
#include "../../sd/cardreader.h"
class Sd2CardUSBMscHandler : public USBMscHandler {
public:
DiskIODriver* diskIODriver() {
@ -121,4 +124,5 @@ void MSC_SD_init() {
USBDevice.begin();
}
#endif // __STM32F1__ && HAS_SD_HOST_DRIVE
#endif // HAS_SD_HOST_DRIVE
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/tft/gt911.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../../inc/MarlinConfig.h"
@ -199,4 +199,4 @@ bool GT911::getPoint(int16_t *x, int16_t *y) {
}
#endif // TFT_TOUCH_DEVICE_GT911
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/tft/tft_fsmc.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../../inc/MarlinConfig.h"
@ -178,4 +178,4 @@ void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou
}
#endif // HAS_FSMC_TFT
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/tft/tft_ltdc.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../../inc/MarlinConfig.h"
@ -384,4 +384,4 @@ void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou
}
#endif // HAS_LTDC_TFT
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/tft/tft_spi.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../../inc/MarlinConfig.h"
@ -240,4 +240,4 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun
}
#endif // HAS_SPI_TFT
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/tft/xpt2046.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../../inc/MarlinConfig.h"
@ -167,4 +167,4 @@ uint16_t XPT2046::SoftwareIO(uint16_t data) {
}
#endif // HAS_TFT_XPT2046
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/timers.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -319,4 +319,4 @@ static constexpr bool verify_no_timer_conflicts() {
// when hovering over it, making it easy to identify the conflicting timers.
static_assert(verify_no_timer_conflicts(), "One or more timer conflict detected. Examine \"timers_in_use\" to help identify conflict.");
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/usb_host.cpp

@ -20,7 +20,7 @@
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfig.h"
@ -114,4 +114,4 @@ uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t b
}
#endif // USE_OTG_USB_HOST && USBHOST
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/usb_serial.cpp

@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfigPre.h"
@ -51,4 +51,4 @@ void USB_Hook_init() {
}
#endif // EMERGENCY_PARSER && USBD_USE_CDC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

4
Marlin/src/HAL/STM32/watchdog.cpp

@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../inc/MarlinConfigPre.h"
@ -46,4 +46,4 @@ void HAL_watchdog_refresh() {
}
#endif // USE_WATCHDOG
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1

7
Marlin/src/HAL/STM32F1/msc_sd.cpp

@ -13,9 +13,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef __STM32F1__
#include "../../inc/MarlinConfigPre.h"
#if defined(__STM32F1__) && HAS_SD_HOST_DRIVE
#if HAS_SD_HOST_DRIVE
#include "msc_sd.h"
#include "SPI.h"
@ -92,4 +94,5 @@ void MSC_SD_init() {
#endif
}
#endif // __STM32F1__ && HAS_SD_HOST_DRIVE
#endif // HAS_SD_HOST_DRIVE
#endif // __STM32F1__

7
Marlin/src/MarlinCore.cpp

@ -1209,13 +1209,6 @@ void setup() {
#endif
#endif
#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
mks_esp_wifi_init();
WIFISERIAL.begin(WIFI_BAUDRATE);
serial_connect_timeout = millis() + 1000UL;
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#endif
TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime
SETUP_RUN(HAL_init());

2
Marlin/src/core/macros.h

@ -442,7 +442,7 @@
return contains(str, '/') ? findLastPos(findStringEnd(str), '/') : str;
}
// Find the first occurence of a character in a string (or return the last position in the string)
// Find the first occurrence of a character in a string (or return the last position in the string)
constexpr const char* findFirst(const char *str, const char ch) {
return *str == ch || *str == 0 ? (str + 1) : findFirst(str + 1, ch);
}

2
Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h

@ -288,7 +288,7 @@
// Remove compiler warning on an unused variable
#ifndef UNUSED
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC)
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#define UNUSED(X) (void)X
#else
#define UNUSED(x) ((void)(x))

28
Marlin/src/lcd/extui/mks_ui/draw_dialog.cpp

@ -61,7 +61,7 @@ static lv_obj_t *scr, *tempText1, *filament_bar;
extern uint8_t sel_id;
extern bool once_flag, gcode_preview_over;
extern int upload_result;
extern uint32_t upload_time;
extern uint32_t upload_time_sec;
extern uint32_t upload_size;
extern bool temps_update_flag;
@ -406,28 +406,24 @@ void lv_draw_dialog(uint8_t type) {
char buf[200];
int _index = 0;
strcpy(buf, DIALOG_UPLOAD_FINISH_EN);
strcpy_P(buf, PSTR(DIALOG_UPLOAD_FINISH_EN));
_index = strlen(buf);
buf[_index] = '\n';
_index++;
strcat(buf, DIALOG_UPLOAD_SIZE_EN);
buf[_index++] = '\n';
strcat_P(buf, PSTR(DIALOG_UPLOAD_SIZE_EN));
_index = strlen(buf);
buf[_index] = ':';
_index++;
sprintf(&buf[_index], " %d KBytes\n", (int)(upload_size / 1024));
buf[_index++] = ':';
sprintf_P(&buf[_index], PSTR(" %d KBytes\n"), (int)(upload_size / 1024));
strcat(buf, DIALOG_UPLOAD_TIME_EN);
strcat_P(buf, PSTR(DIALOG_UPLOAD_TIME_EN));
_index = strlen(buf);
buf[_index] = ':';
_index++;
sprintf(&buf[_index], " %d s\n", (int)upload_time);
buf[_index++] = ':';
sprintf_P(&buf[_index], PSTR(" %d s\n"), (int)upload_time_sec);
strcat(buf, DIALOG_UPLOAD_SPEED_EN);
strcat_P(buf, PSTR(DIALOG_UPLOAD_SPEED_EN));
_index = strlen(buf);
buf[_index] = ':';
_index++;
sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024));
buf[_index++] = ':';
sprintf_P(&buf[_index], PSTR(" %d KBytes/s\n"), (int)(upload_size / upload_time_sec / 1024));
lv_label_set_text(labelDialog, buf);
lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);

5
Marlin/src/lcd/extui/mks_ui/draw_error_message.cpp

@ -29,9 +29,12 @@
#include "tft_lvgl_configuration.h"
#include "SPI_TFT.h"
#include "mks_hardware_test.h"
#include "../../../inc/MarlinConfig.h"
#if ENABLED(MKS_TEST)
#include "mks_hardware_test.h"
#endif
static lv_obj_t *scr;
void lv_draw_error_message(PGM_P const msg) {

4
Marlin/src/lcd/extui/mks_ui/draw_printing.cpp

@ -47,14 +47,16 @@ static lv_obj_t *scr;
static lv_obj_t *labelExt1, *labelFan, *labelZpos, *labelTime;
static lv_obj_t *labelPause, *labelStop, *labelOperat;
static lv_obj_t *bar1, *bar1ValueText;
static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonExt2, *buttonBedstate, *buttonFanstate, *buttonZpos;
static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonFanstate, *buttonZpos;
#if HAS_MULTI_EXTRUDER
static lv_obj_t *labelExt2;
static lv_obj_t *buttonExt2;
#endif
#if HAS_HEATED_BED
static lv_obj_t* labelBed;
static lv_obj_t* buttonBedstate;
#endif
enum {

122
Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp

@ -27,7 +27,6 @@
#include "draw_tool.h"
#include <lv_conf.h>
#include "tft_lvgl_configuration.h"
#include "mks_hardware_test.h"
#include "draw_ui.h"
#include <lvgl.h>
@ -40,6 +39,10 @@
#include "draw_touch_calibration.h"
#endif
#if ENABLED(MKS_TEST)
#include "mks_hardware_test.h"
#endif
#include <stdio.h>
#define ICON_POS_Y 38
@ -48,14 +51,16 @@
extern lv_group_t* g;
static lv_obj_t *scr;
static lv_obj_t *labelExt1, *labelExt1Target, *labelFan;
static lv_obj_t *buttonExt1, *labelExt1, *buttonFanstate, *labelFan;
#if HAS_MULTI_EXTRUDER
static lv_obj_t *labelExt2, *labelExt2Target;
#if HAS_MULTI_HOTEND
static lv_obj_t *labelExt2;
static lv_obj_t *buttonExt2;
#endif
#if HAS_HEATED_BED
static lv_obj_t *labelBed, *labelBedTarget;
static lv_obj_t* labelBed;
static lv_obj_t* buttonBedstate;
#endif
#if ENABLED(MKS_TEST)
@ -136,18 +141,18 @@ void lv_draw_ready_print() {
lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
}
e1 = lv_label_create_empty(scr);
lv_obj_set_pos(e1, 20, 20);
sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(0));
lv_label_set_text(e1, buf);
#if HAS_HOTEND
e1 = lv_label_create_empty(scr);
lv_obj_set_pos(e1, 20, 20);
sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(0));
lv_label_set_text(e1, buf);
#endif
#if HAS_MULTI_HOTEND
e2 = lv_label_create_empty(scr);
lv_obj_set_pos(e2, 20, 45);
sprintf_P(buf, PSTR("e1: %d"), thermalManager.wholeDegHotend(1));
lv_label_set_text(e2, buf);
#endif
#if HAS_HEATED_BED
bed = lv_label_create_empty(scr);
lv_obj_set_pos(bed, 20, 95);
@ -178,72 +183,27 @@ void lv_draw_ready_print() {
lv_label_set_text(det_info, " ");
}
else {
lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 180, event_handler, ID_TOOL);
lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 180, event_handler, ID_SET);
lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 180, event_handler, ID_PRINT);
lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 150, event_handler, ID_TOOL);
lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 150, event_handler, ID_SET);
lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 150, event_handler, ID_PRINT);
// Monitoring
lv_obj_t *buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT);
#if HAS_MULTI_EXTRUDER
lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 163, ICON_POS_Y, event_handler, ID_INFO_EXT);
#if HAS_HEATED_BED
lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 271, ICON_POS_Y, event_handler, ID_INFO_BED);
#endif
#else
#if HAS_HEATED_BED
lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 210, ICON_POS_Y, event_handler, ID_INFO_BED);
#endif
#if HAS_HOTEND
buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT);
#endif
lv_obj_t *buttonFanstate = lv_big_button_create(scr, "F:/bmp_fan_state.bin", " ", 380, ICON_POS_Y, event_handler, ID_INFO_FAN);
labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr);
labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr);
#if HAS_MULTI_EXTRUDER
labelExt2 = lv_label_create(scr, 163, LABEL_MOD_Y, nullptr);
labelExt2Target = lv_label_create(scr, 163, LABEL_MOD_Y, nullptr);
#if HAS_HEATED_BED
labelBed = lv_label_create(scr, 271, LABEL_MOD_Y, nullptr);
labelBedTarget = lv_label_create(scr, 271, LABEL_MOD_Y, nullptr);
#endif
#else
#if HAS_HEATED_BED
labelBed = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr);
labelBedTarget = lv_label_create(scr, 210, LABEL_MOD_Y, nullptr);
#endif
#endif
labelFan = lv_label_create(scr, 380, 80, nullptr);
itoa(thermalManager.degHotend(0), buf, 10);
lv_label_set_text(labelExt1, buf);
lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(0));
lv_label_set_text(labelExt1Target, buf);
lv_obj_align(labelExt1Target, buttonExt1, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
#if HAS_MULTI_EXTRUDER
itoa(thermalManager.degHotend(1), buf, 10);
lv_label_set_text(labelExt2, buf);
lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetHotend(1));
lv_label_set_text(labelExt2Target, buf);
lv_obj_align(labelExt2Target, buttonExt2, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
#if HAS_MULTI_HOTEND
buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 163, ICON_POS_Y, event_handler, ID_INFO_EXT);
#endif
#if HAS_HEATED_BED
itoa(thermalManager.degBed(), buf, 10);
lv_label_set_text(labelBed, buf);
lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
sprintf_P(buf, PSTR("-> %d"), thermalManager.degTargetBed());
lv_label_set_text(labelBedTarget, buf);
lv_obj_align(labelBedTarget, buttonBedstate, LV_ALIGN_CENTER, 0, TARGET_LABEL_MOD_Y);
buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", TERN(HAS_MULTI_HOTEND, 271, 210), ICON_POS_Y, event_handler, ID_INFO_BED);
#endif
sprintf_P(buf, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0));
lv_label_set_text(labelFan, buf);
lv_obj_align(labelFan, buttonFanstate, LV_ALIGN_CENTER, 0, LABEL_MOD_Y);
TERN_(HAS_HOTEND, labelExt1 = lv_label_create_empty(scr));
TERN_(HAS_MULTI_HOTEND, labelExt2 = lv_label_create_empty(scr));
TERN_(HAS_HEATED_BED, labelBed = lv_label_create_empty(scr));
TERN_(HAS_FAN, labelFan = lv_label_create_empty(scr));
lv_temp_refr();
}
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
@ -256,17 +216,25 @@ void lv_draw_ready_print() {
}
void lv_temp_refr() {
#if HAS_HOTEND
sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0));
lv_label_set_text(labelExt1, public_buf_l);
lv_obj_align(labelExt1, buttonExt1, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
#endif
#if HAS_MULTI_HOTEND
sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1));
lv_label_set_text(labelExt2, public_buf_l);
lv_obj_align(labelExt2, buttonExt2, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
#endif
#if HAS_HEATED_BED
sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.wholeDegBed(), thermalManager.degTargetBed());
lv_label_set_text(labelBed, public_buf_l);
lv_obj_align(labelBed, buttonBedstate, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
#endif
sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(0), thermalManager.degTargetHotend(0));
lv_label_set_text(labelExt1, public_buf_l);
#if HAS_MULTI_EXTRUDER
sprintf(public_buf_l, printing_menu.temp1, thermalManager.wholeDegHotend(1), thermalManager.degTargetHotend(1));
lv_label_set_text(labelExt2, public_buf_l);
#if HAS_FAN
sprintf_P(public_buf_l, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0));
lv_label_set_text(labelFan, public_buf_l);
lv_obj_align(labelFan, buttonFanstate, LV_ALIGN_OUT_BOTTOM_MID, 0, 0);
#endif
}

36
Marlin/src/lcd/extui/mks_ui/draw_ui.cpp

@ -30,7 +30,6 @@
#include "pic_manager.h"
#include "draw_ui.h"
#include "mks_hardware_test.h"
#include <SPI.h>
@ -52,6 +51,10 @@
#include "draw_touch_calibration.h"
#endif
#if ENABLED(MKS_TEST)
#include "mks_hardware_test.h"
#endif
CFG_ITMES gCfgItems;
UI_CFG uiCfg;
DISP_STATE_STACK disp_state_stack;
@ -202,27 +205,27 @@ void ui_cfg_init() {
#if ENABLED(MKS_WIFI_MODULE)
memset(&wifiPara, 0, sizeof(wifiPara));
memset(&ipPara, 0, sizeof(ipPara));
strcpy(wifiPara.ap_name, WIFI_AP_NAME);
strcpy(wifiPara.keyCode, WIFI_KEY_CODE);
strcpy_P(wifiPara.ap_name, PSTR(WIFI_AP_NAME));
strcpy_P(wifiPara.keyCode, PSTR(WIFI_KEY_CODE));
//client
strcpy(ipPara.ip_addr, IP_ADDR);
strcpy(ipPara.mask, IP_MASK);
strcpy(ipPara.gate, IP_GATE);
strcpy(ipPara.dns, IP_DNS);
strcpy_P(ipPara.ip_addr, PSTR(IP_ADDR));
strcpy_P(ipPara.mask, PSTR(IP_MASK));
strcpy_P(ipPara.gate, PSTR(IP_GATE));
strcpy_P(ipPara.dns, PSTR(IP_DNS));
ipPara.dhcp_flag = IP_DHCP_FLAG;
//AP
strcpy(ipPara.dhcpd_ip, AP_IP_ADDR);
strcpy(ipPara.dhcpd_mask, AP_IP_MASK);
strcpy(ipPara.dhcpd_gate, AP_IP_GATE);
strcpy(ipPara.dhcpd_dns, AP_IP_DNS);
strcpy(ipPara.start_ip_addr, IP_START_IP);
strcpy(ipPara.end_ip_addr, IP_END_IP);
strcpy_P(ipPara.dhcpd_ip, PSTR(AP_IP_ADDR));
strcpy_P(ipPara.dhcpd_mask, PSTR(AP_IP_MASK));
strcpy_P(ipPara.dhcpd_gate, PSTR(AP_IP_GATE));
strcpy_P(ipPara.dhcpd_dns, PSTR(AP_IP_DNS));
strcpy_P(ipPara.start_ip_addr, PSTR(IP_START_IP));
strcpy_P(ipPara.end_ip_addr, PSTR(IP_END_IP));
ipPara.dhcpd_flag = AP_IP_DHCP_FLAG;
strcpy((char*)uiCfg.cloud_hostUrl, "baizhongyun.cn");
strcpy_P((char*)uiCfg.cloud_hostUrl, PSTR("baizhongyun.cn"));
uiCfg.cloud_port = 10086;
#endif
@ -1362,7 +1365,10 @@ void print_time_count() {
void LV_TASK_HANDLER() {
lv_task_handler();
if (mks_test_flag == 0x1E) mks_hardware_test();
#if ENABLED(MKS_TEST)
if (mks_test_flag == 0x1E) mks_hardware_test();
#endif
TERN_(HAS_GCODE_PREVIEW, disp_pre_gcode(2, 36));

16
Marlin/src/lcd/extui/mks_ui/irq_overrid.cpp

@ -19,14 +19,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef __STM32F1__
#include "../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
#include "tft_lvgl_configuration.h"
#if ENABLED(MKS_WIFI_MODULE)
#include "draw_ui.h"
#include "wifiSerial.h"
@ -46,15 +46,15 @@
#define WIFI_IO1_RESET() WRITE(WIFI_IO1_PIN, LOW);
void __irq_usart1() {
if ((USART1_BASE->CR1 & USART_CR1_RXNEIE) && (USART1_BASE->SR & USART_SR_RXNE))
WRITE(WIFI_IO1_PIN, HIGH);
if ((USART1_BASE->CR1 & USART_CR1_RXNEIE) && (USART1_BASE->SR & USART_SR_RXNE))
WRITE(WIFI_IO1_PIN, HIGH);
WIFISERIAL.wifi_usart_irq(USART1_BASE);
WIFISERIAL.wifi_usart_irq(USART1_BASE);
}
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
#endif // MKS_WIFI_MODULE
#endif // HAS_TFT_LVGL_UI
#endif // HAS_TFT_LVGL_UI && MKS_WIFI_MODULE
#endif // __STM32F1__

140
Marlin/src/lcd/extui/mks_ui/mks_hardware_test.cpp

@ -27,7 +27,6 @@
#include "tft_lvgl_configuration.h"
#include "draw_ready_print.h"
#include "mks_hardware_test.h"
#include "draw_ui.h"
#include "pic_manager.h"
#include <lvgl.h>
@ -36,51 +35,47 @@
#include "../../../module/temperature.h"
#include "../../../sd/cardreader.h"
uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det3_sta;
#if PIN_EXISTS(MT_DET_2)
uint8_t mt_det2_sta;
#endif
uint8_t endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta;
void test_gpio_readlevel_L() {
#if ENABLED(MKS_TEST)
volatile uint32_t itest;
#if ENABLED(MKS_TEST)
#include "mks_hardware_test.h"
bool pw_det_sta, pw_off_sta, mt_det_sta;
#if PIN_EXISTS(MT_DET_2)
bool mt_det2_sta;
#endif
bool endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta;
void test_gpio_readlevel_L() {
WRITE(WIFI_IO0_PIN, HIGH);
itest = 10000;
while (itest--);
pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 0);
pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 0);
mt_det_sta = (READ(MT_DET_1_PIN) == 0);
delay(10);
pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == LOW);
pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == LOW);
mt_det_sta = (READ(MT_DET_1_PIN) == LOW);
#if PIN_EXISTS(MT_DET_2)
mt_det2_sta = (READ(MT_DET_2_PIN) == 0);
mt_det2_sta = (READ(MT_DET_2_PIN) == LOW);
#endif
endstopx1_sta = (READ(X_MIN_PIN) == 0);
endstopy1_sta = (READ(Y_MIN_PIN) == 0);
endstopz1_sta = (READ(Z_MIN_PIN) == 0);
endstopz2_sta = (READ(Z_MAX_PIN) == 0);
#endif
}
endstopx1_sta = (READ(X_MIN_PIN) == LOW);
endstopy1_sta = (READ(Y_MIN_PIN) == LOW);
endstopz1_sta = (READ(Z_MIN_PIN) == LOW);
endstopz2_sta = (READ(Z_MAX_PIN) == LOW);
}
void test_gpio_readlevel_H() {
#if ENABLED(MKS_TEST)
volatile uint32_t itest;
void test_gpio_readlevel_H() {
WRITE(WIFI_IO0_PIN, LOW);
itest = 10000;
while (itest--);
pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 1);
pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 1);
mt_det_sta = (READ(MT_DET_1_PIN) == 1);
delay(10);
pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == HIGH);
pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == HIGH);
mt_det_sta = (READ(MT_DET_1_PIN) == HIGH);
#if PIN_EXISTS(MT_DET_2)
mt_det2_sta = (READ(MT_DET_2_PIN) == 1);
mt_det2_sta = (READ(MT_DET_2_PIN) == HIGH);
#endif
endstopx1_sta = (READ(X_MIN_PIN) == 1);
endstopy1_sta = (READ(Y_MIN_PIN) == 1);
endstopz1_sta = (READ(Z_MIN_PIN) == 1);
endstopz2_sta = (READ(Z_MAX_PIN) == 1);
#endif
}
endstopx1_sta = (READ(X_MIN_PIN) == HIGH);
endstopy1_sta = (READ(Y_MIN_PIN) == HIGH);
endstopz1_sta = (READ(Z_MIN_PIN) == HIGH);
endstopz2_sta = (READ(Z_MAX_PIN) == HIGH);
}
void init_test_gpio() {
#ifdef MKS_TEST
void init_test_gpio() {
SET_INPUT_PULLUP(X_MIN_PIN);
SET_INPUT_PULLUP(Y_MIN_PIN);
SET_INPUT_PULLUP(Z_MIN_PIN);
@ -102,7 +97,7 @@ void init_test_gpio() {
SET_OUTPUT(Y_ENABLE_PIN);
SET_OUTPUT(Z_ENABLE_PIN);
SET_OUTPUT(E0_ENABLE_PIN);
#if !MB(MKS_ROBIN_E3P)
#if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
SET_OUTPUT(E1_ENABLE_PIN);
#endif
@ -110,11 +105,11 @@ void init_test_gpio() {
WRITE(Y_ENABLE_PIN, LOW);
WRITE(Z_ENABLE_PIN, LOW);
WRITE(E0_ENABLE_PIN, LOW);
#if !MB(MKS_ROBIN_E3P)
#if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
WRITE(E1_ENABLE_PIN, LOW);
#endif
#if MB(MKS_ROBIN_E3P)
#if ENABLED(MKS_HARDWARE_TEST_ONLY_E0)
SET_INPUT_PULLUP(PA1);
SET_INPUT_PULLUP(PA3);
SET_INPUT_PULLUP(PC2);
@ -123,68 +118,56 @@ void init_test_gpio() {
SET_INPUT_PULLUP(PE6);
SET_INPUT_PULLUP(PE7);
#endif
#endif
}
}
void mks_test_beeper() {
#ifdef MKS_TEST
void mks_test_beeper() {
WRITE(BEEPER_PIN, HIGH);
delay(100);
WRITE(BEEPER_PIN, LOW);
delay(100);
#endif
}
}
void mks_gpio_test() {
#if ENABLED(MKS_TEST)
void mks_gpio_test() {
init_test_gpio();
test_gpio_readlevel_L();
test_gpio_readlevel_H();
test_gpio_readlevel_L();
if ((pw_det_sta == 1)
&& (pw_off_sta == 1)
&& (mt_det_sta == 1)
if (pw_det_sta && pw_off_sta && mt_det_sta
#if PIN_EXISTS(MT_DET_2)
&& (mt_det2_sta == 1)
&& mt_det2_sta
#endif
#if MB(MKS_ROBIN_E3P)
&& (READ(PA1) == 0)
&& (READ(PA3) == 0)
&& (READ(PC2) == 0)
&& (READ(PD8) == 0)
&& (READ(PE5) == 0)
&& (READ(PE6) == 0)
&& (READ(PE7) == 0)
#if ENABLED(MKS_HARDWARE_TEST_ONLY_E0)
&& (READ(PA1) == LOW)
&& (READ(PA3) == LOW)
&& (READ(PC2) == LOW)
&& (READ(PD8) == LOW)
&& (READ(PE5) == LOW)
&& (READ(PE6) == LOW)
&& (READ(PE7) == LOW)
#endif
)
disp_det_ok();
else
disp_det_error();
if ( (endstopx1_sta == 1)
&& (endstopy1_sta == 1)
&& (endstopz1_sta == 1)
&& (endstopz2_sta == 1)
)
if (endstopx1_sta && endstopy1_sta && endstopz1_sta && endstopz2_sta)
disp_Limit_ok();
else
disp_Limit_error();
#endif
}
}
void mks_hardware_test() {
#if ENABLED(MKS_TEST)
void mks_hardware_test() {
if (millis() % 2000 < 1000) {
WRITE(X_DIR_PIN, LOW);
WRITE(Y_DIR_PIN, LOW);
WRITE(Z_DIR_PIN, LOW);
WRITE(E0_DIR_PIN, LOW);
#if !MB(MKS_ROBIN_E3P)
#if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
WRITE(E1_DIR_PIN, LOW);
#endif
thermalManager.fan_speed[0] = 255;
#if !MB(MKS_ROBIN_E3P)
#if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
WRITE(HEATER_1_PIN, HIGH); // HE1
#endif
WRITE(HEATER_0_PIN, HIGH); // HE0
@ -195,21 +178,18 @@ void mks_hardware_test() {
WRITE(Y_DIR_PIN, HIGH);
WRITE(Z_DIR_PIN, HIGH);
WRITE(E0_DIR_PIN, HIGH);
#if !MB(MKS_ROBIN_E3P)
#if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
WRITE(E1_DIR_PIN, HIGH);
#endif
thermalManager.fan_speed[0] = 0;
#if !MB(MKS_ROBIN_E3P)
#if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
WRITE(HEATER_1_PIN, LOW); // HE1
#endif
WRITE(HEATER_0_PIN, LOW); // HE0
WRITE(HEATER_BED_PIN, LOW); // HOT-BED
}
if ( (endstopx1_sta == 1) && (endstopx2_sta == 1)
&& (endstopy1_sta == 1) && (endstopy2_sta == 1)
&& (endstopz1_sta == 1) && (endstopz2_sta == 1)
) {
if (endstopx1_sta && endstopx2_sta && endstopy1_sta && endstopy2_sta && endstopz1_sta && endstopz2_sta) {
// nothing here
}
else {
@ -217,9 +197,9 @@ void mks_hardware_test() {
if (disp_state == PRINT_READY_UI)
mks_disp_test();
}
#endif
}
#endif // MKS_TEST
static const uint16_t ASCII_Table_16x24[] PROGMEM = {
// Space ' '

6
Marlin/src/lcd/extui/mks_ui/mks_hardware_test.h

@ -24,10 +24,12 @@
#include <lvgl.h>
void mks_gpio_test();
void mks_hardware_test();
void mks_test_get();
void disp_char_1624(uint16_t x, uint16_t y, uint8_t c, uint16_t charColor, uint16_t bkColor);
void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor, uint16_t bkColor);
void mks_hardware_test();
void disp_assets_update();
void disp_assets_update_progress(const char *msg);
void mks_test_get();
extern uint8_t mks_test_flag;

5
Marlin/src/lcd/extui/mks_ui/pic_manager.cpp

@ -27,7 +27,10 @@
#include "draw_ui.h"
#include "pic_manager.h"
#include "draw_ready_print.h"
#include "mks_hardware_test.h"
#if ENABLED(MKS_TEST)
#include "mks_hardware_test.h"
#endif
#include "SPIFlashStorage.h"
#include "../../../libs/W25Qxx.h"

37
Marlin/src/lcd/extui/mks_ui/printer_operation.cpp

@ -158,19 +158,12 @@ void filament_pin_setup() {
}
void filament_check() {
const int FIL_DELAY = 20;
#if ANY_PIN(MT_DET_1, MT_DET_2, MT_DET_3)
const int FIL_DELAY = 20;
#endif
#if PIN_EXISTS(MT_DET_1)
static int fil_det_count_1 = 0;
if (!READ(MT_DET_1_PIN) && !MT_DET_PIN_INVERTING)
fil_det_count_1++;
else if (READ(MT_DET_1_PIN) && MT_DET_PIN_INVERTING)
fil_det_count_1++;
else if (fil_det_count_1 > 0)
fil_det_count_1--;
if (!READ(MT_DET_1_PIN) && !MT_DET_PIN_INVERTING)
fil_det_count_1++;
else if (READ(MT_DET_1_PIN) && MT_DET_PIN_INVERTING)
if (READ(MT_DET_1_PIN) == MT_DET_PIN_INVERTING)
fil_det_count_1++;
else if (fil_det_count_1 > 0)
fil_det_count_1--;
@ -178,16 +171,7 @@ void filament_check() {
#if PIN_EXISTS(MT_DET_2)
static int fil_det_count_2 = 0;
if (!READ(MT_DET_2_PIN) && !MT_DET_PIN_INVERTING)
fil_det_count_2++;
else if (READ(MT_DET_2_PIN) && MT_DET_PIN_INVERTING)
fil_det_count_2++;
else if (fil_det_count_2 > 0)
fil_det_count_2--;
if (!READ(MT_DET_2_PIN) && !MT_DET_PIN_INVERTING)
fil_det_count_2++;
else if (READ(MT_DET_2_PIN) && MT_DET_PIN_INVERTING)
if (READ(MT_DET_2_PIN) == MT_DET_PIN_INVERTING)
fil_det_count_2++;
else if (fil_det_count_2 > 0)
fil_det_count_2--;
@ -195,16 +179,7 @@ void filament_check() {
#if PIN_EXISTS(MT_DET_3)
static int fil_det_count_3 = 0;
if (!READ(MT_DET_3_PIN) && !MT_DET_PIN_INVERTING)
fil_det_count_3++;
else if (READ(MT_DET_3_PIN) && MT_DET_PIN_INVERTING)
fil_det_count_3++;
else if (fil_det_count_3 > 0)
fil_det_count_3--;
if (!READ(MT_DET_3_PIN) && !MT_DET_PIN_INVERTING)
fil_det_count_3++;
else if (READ(MT_DET_3_PIN) && MT_DET_PIN_INVERTING)
if (READ(MT_DET_3_PIN) == MT_DET_PIN_INVERTING)
fil_det_count_3++;
else if (fil_det_count_3 > 0)
fil_det_count_3--;

33
Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp

@ -45,6 +45,14 @@ XPT2046 touch;
#include "../../../feature/powerloss.h"
#endif
#if HAS_SERVOS
#include "../../../module/servo.h"
#endif
#if EITHER(PROBE_TARE, HAS_Z_SERVO_PROBE)
#include "../../../module/probe.h"
#endif
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
#include "../../tft_io/touch_calibration.h"
#include "draw_touch_calibration.h"
@ -131,10 +139,9 @@ void tft_lvgl_init() {
#if ENABLED(SDSUPPORT)
UpdateAssets();
watchdog_refresh(); // LVGL init takes time
mks_test_get();
#endif
mks_test_get();
touch.Init();
lv_init();
@ -193,8 +200,12 @@ void tft_lvgl_init() {
filament_pin_setup();
lv_encoder_pin_init();
TERN_(MKS_WIFI_MODULE, mks_wifi_firmware_update());
#if ENABLED(MKS_WIFI_MODULE)
mks_esp_wifi_init();
mks_wifi_firmware_update();
#endif
TERN_(HAS_SERVOS, servo_init());
TERN_(HAS_Z_SERVO_PROBE, probe.servo_probe_init());
bool ready = true;
#if ENABLED(POWER_LOSS_RECOVERY)
recovery.load();
@ -207,16 +218,22 @@ void tft_lvgl_init() {
uiCfg.print_state = REPRINTING;
strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m));
card.printLongPath(public_buf_m);
strncpy(list_file.long_name[sel_id], card.longFilename, sizeof(list_file.long_name[0]));
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m));
card.printLongPath(public_buf_m);
strncpy(list_file.long_name[sel_id], card.longFilename, sizeof(list_file.long_name[0]));
#else
strncpy(list_file.long_name[sel_id], recovery.info.sd_filename, sizeof(list_file.long_name[0]));
#endif
lv_draw_printing();
}
#endif
if (ready) lv_draw_ready_print();
if (mks_test_flag == 0x1E) mks_gpio_test();
#if ENABLED(MKS_TEST)
if (mks_test_flag == 0x1E) mks_gpio_test();
#endif
}
void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {

34
Marlin/src/lcd/extui/mks_ui/tft_multi_language.cpp

@ -58,6 +58,8 @@ pause_msg_def pause_msg_menu;
eeprom_def eeprom_menu;
media_select_menu_def media_select_menu;
// TODO: Make all strings PSTR and update accessors for the benefit of AVR
machine_common_def machine_menu;
void machine_setting_disp() {
if (gCfgItems.language == LANG_SIMPLE_CHINESE) {
@ -1093,8 +1095,8 @@ void disp_language_init() {
eeprom_menu.read = EEPROM_SETTINGS_READ_CN;
eeprom_menu.revert = EEPROM_SETTINGS_REVERT_CN;
eeprom_menu.storeTips = EEPROM_STORE_TIPS_CN;
eeprom_menu.readTips = EEPROM_READ_TIPS_CN;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_CN;
eeprom_menu.readTips = EEPROM_READ_TIPS_CN;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_CN;
break;
#if 1
@ -1337,8 +1339,8 @@ void disp_language_init() {
eeprom_menu.read = EEPROM_SETTINGS_READ_T_CN;
eeprom_menu.revert = EEPROM_SETTINGS_REVERT_T_CN;
eeprom_menu.storeTips = EEPROM_STORE_TIPS_T_CN;
eeprom_menu.readTips = EEPROM_READ_TIPS_T_CN;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_T_CN;
eeprom_menu.readTips = EEPROM_READ_TIPS_T_CN;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_T_CN;
break;
case LANG_ENGLISH:
common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_EN;
@ -1571,8 +1573,8 @@ void disp_language_init() {
eeprom_menu.read = EEPROM_SETTINGS_READ_EN;
eeprom_menu.revert = EEPROM_SETTINGS_REVERT_EN;
eeprom_menu.storeTips = EEPROM_STORE_TIPS_EN;
eeprom_menu.readTips = EEPROM_READ_TIPS_EN;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_EN;
eeprom_menu.readTips = EEPROM_READ_TIPS_EN;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_EN;
break;
case LANG_RUSSIAN:
common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_RU;
@ -1896,8 +1898,8 @@ void disp_language_init() {
eeprom_menu.read = EEPROM_SETTINGS_READ_RU;
eeprom_menu.revert = EEPROM_SETTINGS_REVERT_RU;
eeprom_menu.storeTips = EEPROM_STORE_TIPS_RU;
eeprom_menu.readTips = EEPROM_READ_TIPS_RU;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_RU;
eeprom_menu.readTips = EEPROM_READ_TIPS_RU;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_RU;
break;
case LANG_SPANISH:
common_menu.dialog_confirm_title = TITLE_DIALOG_CONFIRM_SP;
@ -2133,8 +2135,8 @@ void disp_language_init() {
eeprom_menu.read = EEPROM_SETTINGS_READ_SP;
eeprom_menu.revert = EEPROM_SETTINGS_REVERT_SP;
eeprom_menu.storeTips = EEPROM_STORE_TIPS_SP;
eeprom_menu.readTips = EEPROM_READ_TIPS_SP;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_SP;
eeprom_menu.readTips = EEPROM_READ_TIPS_SP;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_SP;
break;
#endif // if 1
@ -2367,8 +2369,8 @@ void disp_language_init() {
eeprom_menu.read = EEPROM_SETTINGS_READ_FR;
eeprom_menu.revert = EEPROM_SETTINGS_REVERT_FR;
eeprom_menu.storeTips = EEPROM_STORE_TIPS_FR;
eeprom_menu.readTips = EEPROM_READ_TIPS_FR;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_FR;
eeprom_menu.readTips = EEPROM_READ_TIPS_FR;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_FR;
break;
case LANG_ITALY:
@ -2600,8 +2602,8 @@ void disp_language_init() {
eeprom_menu.read = EEPROM_SETTINGS_READ_IT;
eeprom_menu.revert = EEPROM_SETTINGS_REVERT_IT;
eeprom_menu.storeTips = EEPROM_STORE_TIPS_IT;
eeprom_menu.readTips = EEPROM_READ_TIPS_IT;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_IT;
eeprom_menu.readTips = EEPROM_READ_TIPS_IT;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_IT;
break;
#endif // if 1
@ -2836,8 +2838,8 @@ void disp_language_init() {
eeprom_menu.read = EEPROM_SETTINGS_READ_EN;
eeprom_menu.revert = EEPROM_SETTINGS_REVERT_EN;
eeprom_menu.storeTips = EEPROM_STORE_TIPS_EN;
eeprom_menu.readTips = EEPROM_READ_TIPS_EN;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_EN;
eeprom_menu.readTips = EEPROM_READ_TIPS_EN;
eeprom_menu.revertTips = EEPROM_REVERT_TIPS_EN;
break;
}
}

76
Marlin/src/lcd/extui/mks_ui/wifiSerial.h

@ -21,10 +21,6 @@
*/
#pragma once
#include "tft_lvgl_configuration.h"
#if ENABLED(MKS_WIFI_MODULE)
#ifdef SERIAL_PORT_2
#error "SERIAL_PORT_2 must be disabled with TFT_LVGL_UI* and MKS_WIFI_MODULE."
#endif
@ -33,70 +29,16 @@
#define WIFI_UPLOAD_BAUDRATE 1958400
#define USART_SAFE_INSERT
#define WIFI_RX_BUF_SIZE (1024+1)
#include <libmaple/libmaple_types.h>
#include <libmaple/usart.h>
#include <libmaple/libmaple.h>
#include <libmaple/gpio.h>
#include <libmaple/timer.h>
#include <libmaple/ring_buffer.h>
#define DEFINE_WFSERIAL(name, n)\
WifiSerial name(USART##n, \
BOARD_USART##n##_TX_PIN, \
BOARD_USART##n##_RX_PIN)
class WifiSerial {
public:
uint8 wifiRxBuf[WIFI_RX_BUF_SIZE];
#define WIFI_RX_BUF_SIZE (1024)
#define WIFI_TX_BUF_SIZE (64)
public:
WifiSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin);
/* Set up/tear down */
void begin(uint32 baud);
void begin(uint32 baud,uint8_t config);
void end();
int available();
int read();
int write(uint8_t);
inline void wifi_usart_irq(usart_reg_map *regs) {
/* Handling RXNEIE and TXEIE interrupts.
* RXNE signifies availability of a byte in DR.
*
* See table 198 (sec 27.4, p809) in STM document RM0008 rev 15.
* We enable RXNEIE.
*/
if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) {
#ifdef USART_SAFE_INSERT
/* If the buffer is full and the user defines USART_SAFE_INSERT,
* ignore new bytes. */
rb_safe_insert(this->usart_device->rb, (uint8)regs->DR);
#else
/* By default, push bytes around in the ring buffer. */
rb_push_insert(this->usart_device->rb, (uint8)regs->DR);
#endif
}
/* TXE signifies readiness to send a byte to DR. */
if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) {
if (!rb_is_empty(this->usart_device->wb))
regs->DR=rb_remove(this->usart_device->wb);
else
regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE
}
}
int wifi_rb_is_full();
#include "tft_lvgl_configuration.h"
struct usart_dev *usart_device;
private:
uint8 tx_pin;
uint8 rx_pin;
};
#ifdef __STM32F1__
#include "wifiSerial_STM32F1.h"
#else
#include "wifiSerial_STM32.h"
#endif
extern WifiSerial WifiSerial1;
#define WIFISERIAL WifiSerial1
#endif // MKS_WIFI_MODULE
#define WIFISERIAL WifiSerial1

352
Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp

@ -0,0 +1,352 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
*
*/
#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1)
#include "../../../inc/MarlinConfigPre.h"
#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
#include "tft_lvgl_configuration.h"
#include "draw_ui.h"
#include "wifiSerial.h"
WifiSerial WifiSerial1(USART1);
void WifiSerial::setRx(uint32_t _rx) { _serial.pin_rx = digitalPinToPinName(_rx); }
void WifiSerial::setTx(uint32_t _tx) { _serial.pin_tx = digitalPinToPinName(_tx); }
void WifiSerial::setRx(PinName _rx) { _serial.pin_rx = _rx; }
void WifiSerial::setTx(PinName _tx) { _serial.pin_tx = _tx; }
void WifiSerial::init(PinName _rx, PinName _tx) {
_serial.pin_rx = (_rx == _tx) ? NC : _rx;
_serial.pin_tx = _tx;
_serial.rx_buff = wifiRxBuf;
_serial.rx_head = 0;
_serial.rx_tail = 0;
_serial.tx_buff = wifiTxBuf;
_serial.tx_head = 0;
_serial.tx_tail = 0;
}
WifiSerial::WifiSerial(void *peripheral) {
// If PIN_SERIALy_RX is not defined assume half-duplex
_serial.pin_rx = NC;
// If Serial is defined in variant set
// the Rx/Tx pins for com port if defined
#if defined(Serial) && defined(PIN_SERIAL_TX)
if ((void *)this == (void *)&Serial) {
#ifdef PIN_SERIAL_RX
setRx(PIN_SERIAL_RX);
#endif
setTx(PIN_SERIAL_TX);
} else
#endif
#if defined(PIN_SERIAL1_TX) && defined(USART1_BASE)
if (peripheral == USART1) {
#ifdef PIN_SERIAL1_RX
setRx(PIN_SERIAL1_RX);
#endif
setTx(PIN_SERIAL1_TX);
} else
#endif
#if defined(PIN_SERIAL2_TX) && defined(USART2_BASE)
if (peripheral == USART2) {
#ifdef PIN_SERIAL2_RX
setRx(PIN_SERIAL2_RX);
#endif
setTx(PIN_SERIAL2_TX);
} else
#endif
#if defined(PIN_SERIAL3_TX) && defined(USART3_BASE)
if (peripheral == USART3) {
#ifdef PIN_SERIAL3_RX
setRx(PIN_SERIAL3_RX);
#endif
setTx(PIN_SERIAL3_TX);
} else
#endif
#ifdef PIN_SERIAL4_TX
if (false
#ifdef USART4_BASE
|| peripheral == USART4
#elif defined(UART4_BASE)
|| peripheral == UART4
#endif
) {
#ifdef PIN_SERIAL4_RX
setRx(PIN_SERIAL4_RX);
#endif
setTx(PIN_SERIAL4_TX);
} else
#endif
#ifdef PIN_SERIAL5_TX
if (false
#ifdef USART5_BASE
|| peripheral == USART5
#elif defined(UART5_BASE)
|| peripheral == UART5
#endif
) {
#ifdef PIN_SERIAL5_RX
setRx(PIN_SERIAL5_RX);
#endif
setTx(PIN_SERIAL5_TX);
} else
#endif
#if defined(PIN_SERIAL6_TX) && defined(USART6_BASE)
if (peripheral == USART6) {
#ifdef PIN_SERIAL6_RX
setRx(PIN_SERIAL6_RX);
#endif
setTx(PIN_SERIAL6_TX);
} else
#endif
#ifdef PIN_SERIAL7_TX
if (false
#ifdef USART7_BASE
|| peripheral == USART7
#elif defined(UART7_BASE)
|| peripheral == UART7
#endif
) {
#ifdef PIN_SERIAL7_RX
setRx(PIN_SERIAL7_RX);
#endif
setTx(PIN_SERIAL7_TX);
} else
#endif
#ifdef PIN_SERIAL8_TX
if (false
#ifdef USART8_BASE
|| peripheral == USART8
#elif defined(UART8_BASE)
|| peripheral == UART8
#endif
) {
#ifdef PIN_SERIAL8_RX
setRx(PIN_SERIAL8_RX);
#endif
setTx(PIN_SERIAL8_TX);
} else
#endif
#if defined(PIN_SERIAL9_TX) && defined(UART9_BASE)
if (peripheral == UART9) {
#ifdef PIN_SERIAL9_RX
setRx(PIN_SERIAL9_RX);
#endif
setTx(PIN_SERIAL9_TX);
} else
#endif
#ifdef PIN_SERIAL10_TX
if (false
#ifdef USART10_BASE
|| peripheral == USART10
#elif defined(UART10_BASE)
|| peripheral == UART10
#endif
) {
#ifdef PIN_SERIAL10_RX
setRx(PIN_SERIAL10_RX);
#endif
setTx(PIN_SERIAL10_TX);
} else
#endif
#if defined(PIN_SERIALLP1_TX) && defined(LPUART1_BASE)
if (peripheral == LPUART1) {
#ifdef PIN_SERIALLP1_RX
setRx(PIN_SERIALLP1_RX);
#endif
setTx(PIN_SERIALLP1_TX);
} else
#endif
// else get the pins of the first peripheral occurrence in PinMap
{
_serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX);
_serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX);
}
//if (halfDuplex == HALF_DUPLEX_ENABLED) _serial.pin_rx = NC;
init(_serial.pin_rx, _serial.pin_tx);
}
void WifiSerial::flush() {
// If we have never written a byte, no need to flush. This special
// case is needed since there is no way to force the TXC (transmit
// complete) bit to 1 during initialization
if (!_written) return;
while ((_serial.tx_head != _serial.tx_tail)) {
// nop, the interrupt handler will free up space for us
}
// If we get here, nothing is queued anymore (DRIE is disabled) and
// the hardware finished tranmission (TXC is set).
}
bool WifiSerial::isHalfDuplex() const { return _serial.pin_rx == NC; }
void WifiSerial::enableHalfDuplexRx() {
if (isHalfDuplex()) {
// In half-duplex mode we have to wait for all TX characters to
// be transmitted before we can receive data.
flush();
if (!_rx_enabled) {
_rx_enabled = true;
uart_enable_rx(&_serial);
}
}
}
// Actual interrupt handlers //////////////////////////////////////////////////////////////
void WifiSerial::_rx_complete_irq(serial_t *obj) {
// No Parity error, read byte and store it in the buffer if there is room
unsigned char c;
if (uart_getc(obj, &c) == 0) {
WRITE(WIFI_IO1_PIN, HIGH);
rx_buffer_index_t i = (unsigned int)(obj->rx_head + 1) % WIFI_RX_BUF_SIZE;
// if we should be storing the received character into the location
// just before the tail (meaning that the head would advance to the
// current location of the tail), we're about to overflow the buffer
// and so we don't write the character or advance the head.
if (i != obj->rx_tail) {
obj->rx_buff[obj->rx_head] = c;
obj->rx_head = i;
}
}
}
// Actual interrupt handlers //////////////////////////////////////////////////////////////
int WifiSerial::_tx_complete_irq(serial_t *obj) {
// If interrupts are enabled, there must be more data in the output
// buffer. Send the next byte
obj->tx_tail = (obj->tx_tail + 1) % WIFI_TX_BUF_SIZE;
return (obj->tx_head == obj->tx_tail) ? -1 : 0;
}
void WifiSerial::begin(unsigned long baud) { begin(baud, SERIAL_8N1); }
void WifiSerial::begin(unsigned long baud, byte config) {
uint32_t databits = 0, stopbits = 0, parity = 0;
_baud = baud;
_config = config;
// Manage databits
switch (config & 0x07) {
case 0x02: databits = 6; break;
case 0x04: databits = 7; break;
case 0x06: databits = 8; break;
default: databits = 0; break;
}
if ((config & 0x30) == 0x30) {
parity = UART_PARITY_ODD;
databits++;
}
else if ((config & 0x20) == 0x20) {
parity = UART_PARITY_EVEN;
databits++;
}
else
parity = UART_PARITY_NONE;
stopbits = ((config & 0x08) == 0x08) ? UART_STOPBITS_2 : UART_STOPBITS_1;
switch (databits) {
#ifdef UART_WORDLENGTH_7B
case 7: databits = UART_WORDLENGTH_7B; break;
#endif
case 8: databits = UART_WORDLENGTH_8B; break;
case 9: databits = UART_WORDLENGTH_9B; break;
default:
case 0: Error_Handler(); break;
}
uart_init(&_serial, (uint32_t)baud, databits, parity, stopbits);
enableHalfDuplexRx();
if (baud == WIFI_BAUDRATE)
uart_attach_rx_callback(&_serial, _rx_complete_irq);
else
USART1->CR1 |= USART_CR1_RE; // Preserve word length, etc. Use 'or' to preserve USART_CR1_M_8N1
}
void WifiSerial::end() {
// wait for transmission of outgoing data
flush();
uart_deinit(&_serial);
// clear any received data
_serial.rx_head = _serial.rx_tail;
}
int WifiSerial::available() {
return ((unsigned int)(WIFI_RX_BUF_SIZE + _serial.rx_head - _serial.rx_tail)) % WIFI_RX_BUF_SIZE;
}
//
// I/O
//
int WifiSerial::read() {
enableHalfDuplexRx();
// if the head isn't ahead of the tail, we don't have any characters
if (_serial.rx_head == _serial.rx_tail) return -1;
unsigned char c = _serial.rx_buff[_serial.rx_tail];
_serial.rx_tail = (rx_buffer_index_t)(_serial.rx_tail + 1) % WIFI_RX_BUF_SIZE;
return c;
}
int WifiSerial::write(uint8_t c) {
_written = true;
if (isHalfDuplex()) {
if (_rx_enabled) {
_rx_enabled = false;
uart_enable_tx(&_serial);
}
}
tx_buffer_index_t i = (_serial.tx_head + 1) % WIFI_TX_BUF_SIZE;
// If the output buffer is full, there's nothing for it other than to
// wait for the interrupt handler to empty it a bit
while (i == _serial.tx_tail) {
// nop, the interrupt handler will free up space for us
}
_serial.tx_buff[_serial.tx_head] = c;
_serial.tx_head = i;
if (!serial_tx_active(&_serial))
uart_attach_tx_callback(&_serial, _tx_complete_irq);
return 1;
}
#endif // HAS_TFT_LVGL_UI && MKS_WIFI_MODULE
#endif // !__STM32F1__

63
Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.h

@ -0,0 +1,63 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <inttypes.h>
#include "Stream.h"
#include "uart.h"
class WifiSerial {
protected:
// Has any byte been written to the UART since begin()
bool _written;
serial_t _serial;
public:
uint8_t wifiRxBuf[WIFI_RX_BUF_SIZE];
uint8_t wifiTxBuf[WIFI_TX_BUF_SIZE];
WifiSerial(void *peripheral);
// Set up / tear down
void begin(uint32_t baud);
void begin(uint32_t baud,uint8_t config);
void end();
int available(void);
int read(void);
int write(uint8_t);
// Interrupt handlers
static int _tx_complete_irq(serial_t *obj);
static void _rx_complete_irq(serial_t *obj);
void flush(void);
bool isHalfDuplex(void) const;
void enableHalfDuplexRx(void);
private:
void setRx(uint32_t _rx);
void setTx(uint32_t _tx);
void setRx(PinName _rx);
void setTx(PinName _tx);
void init(PinName _rx, PinName _tx);
bool _rx_enabled;
uint8_t _config;
unsigned long _baud;
};

18
Marlin/src/lcd/extui/mks_ui/wifiSerial.cpp → Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.cpp

@ -1,6 +1,6 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
@ -19,14 +19,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#ifdef __STM32F1__
#include "../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI
#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
#include "tft_lvgl_configuration.h"
#if ENABLED(MKS_WIFI_MODULE)
#include "draw_ui.h"
#include "wifiSerial.h"
@ -59,19 +59,19 @@ WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) {
if (with_irq) usart_enable(usart_device);
else {
usart_reg_map *regs = usart_device->regs;
regs->CR1 |= (USART_CR1_TE | USART_CR1_RE); // don't change the word length etc, and 'or' in the pattern not overwrite |USART_CR1_M_8N1);
regs->CR1 |= (USART_CR1_TE | USART_CR1_RE); // Preserve word length, etc. Use 'or' to preserve USART_CR1_M_8N1
regs->CR1 |= USART_CR1_UE;
}
}
#elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4
#define disable_timer_if_necessary(dev, ch) ((void)0)
#define disable_timer_if_necessary(dev, ch) NOOP
static void usart_enable_no_irq(usart_dev *usart_device, bool with_irq) {
if (with_irq) usart_enable(usart_device);
else {
usart_reg_map *regs = usart_device->regs;
regs->CR1 |= (USART_CR1_TE | USART_CR1_RE); // don't change the word length etc, and 'or' in the pattern not overwrite |USART_CR1_M_8N1);
regs->CR1 |= (USART_CR1_TE | USART_CR1_RE); // Preserve word length, etc. Use 'or' to preserve USART_CR1_M_8N1
regs->CR1 |= USART_CR1_UE;
}
}
@ -137,5 +137,5 @@ int WifiSerial::wifi_rb_is_full() {
return rb_is_full(this->usart_device->rb);
}
#endif // MKS_WIFI_MODULE
#endif // HAS_TFT_LVGL_UI
#endif // HAS_TFT_LVGL_UI && MKS_WIFI_MODULE
#endif // __STM32F1__

77
Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32F1.h

@ -0,0 +1,77 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <libmaple/libmaple_types.h>
#include <libmaple/usart.h>
#include <libmaple/libmaple.h>
#include <libmaple/gpio.h>
#include <libmaple/timer.h>
#include <libmaple/ring_buffer.h>
#define DEFINE_WFSERIAL(name, n) WifiSerial name(USART##n, BOARD_USART##n##_TX_PIN, BOARD_USART##n##_RX_PIN)
class WifiSerial {
public:
uint8 wifiRxBuf[WIFI_RX_BUF_SIZE];
public:
WifiSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin);
/* Set up/tear down */
void begin(uint32 baud);
void begin(uint32 baud,uint8_t config);
void end();
int available();
int read();
int write(uint8_t);
inline void wifi_usart_irq(usart_reg_map *regs) {
/* Handling RXNEIE and TXEIE interrupts.
* RXNE signifies availability of a byte in DR.
*
* See table 198 (sec 27.4, p809) in STM document RM0008 rev 15.
* We enable RXNEIE.
*/
if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) {
#ifdef USART_SAFE_INSERT
/* If the buffer is full and the user defines USART_SAFE_INSERT,
* ignore new bytes. */
rb_safe_insert(this->usart_device->rb, (uint8)regs->DR);
#else
/* By default, push bytes around in the ring buffer. */
rb_push_insert(this->usart_device->rb, (uint8)regs->DR);
#endif
}
/* TXE signifies readiness to send a byte to DR. */
if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) {
if (!rb_is_empty(this->usart_device->wb))
regs->DR=rb_remove(this->usart_device->wb);
else
regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE
}
}
int wifi_rb_is_full();
struct usart_dev *usart_device;
private:
uint8 tx_pin;
uint8 rx_pin;
};

702
Marlin/src/lcd/extui/mks_ui/wifi_module.cpp

File diff suppressed because it is too large

4
Marlin/src/lcd/extui/mks_ui/wifi_module.h

@ -64,6 +64,7 @@ typedef enum{
#define TRANS_RCV_FIFO_BLOCK_NUM 14
typedef struct {
bool receiveEspData;
unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM];
unsigned char *p;
UDISK_DATA_BUFFER_STATE state[TRANS_RCV_FIFO_BLOCK_NUM];
@ -191,6 +192,9 @@ void get_wifi_list_command_send();
void get_wifi_commands();
int readWifiBuf(int8_t *buf, int32_t len);
void mks_wifi_firmware_update();
int usartFifoAvailable(SZ_USART_FIFO *fifo);
int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len);
void esp_port_begin(uint8_t interrupt);
#ifdef __cplusplus
} /* C-declarations for C++ */

10
Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp

@ -40,7 +40,6 @@ extern SZ_USART_FIFO WifiRxFifo;
extern int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len);
extern int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len);
void esp_port_begin(uint8_t interrupt);
extern int usartFifoAvailable(SZ_USART_FIFO *fifo);
void wifi_delay(int n);
#define ARRAY_SIZE(a) sizeof(a) / sizeof((a)[0])
@ -280,7 +279,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
switch (state) {
case begin: // expecting frame start
c = uploadPort_read();
if (c == (uint8_t)0xC0) break;
if (c != (uint8_t)0xC0) break;
state = header;
needBytes = 2;
break;
@ -644,10 +643,7 @@ static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000
void ResetWiFiForUpload(int begin_or_end) {
//#if 0
uint32_t start, now;
start = getWifiTick();
now = start;
uint32_t start = getWifiTick();
if (begin_or_end == 0) {
SET_OUTPUT(WIFI_IO0_PIN);
@ -657,7 +653,7 @@ void ResetWiFiForUpload(int begin_or_end) {
SET_INPUT_PULLUP(WIFI_IO0_PIN);
WIFI_RESET();
while (getWifiTickDiff(start, now) < 500) now = getWifiTick();
while (getWifiTickDiff(start, getWifiTick()) < 500) { /* nada */ }
WIFI_SET();
//#endif
}

1
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h

@ -36,6 +36,7 @@
#define BOARD_INFO_NAME "MKS Robin E3P"
#define BOARD_NO_NATIVE_USB
#define MKS_HARDWARE_TEST_ONLY_E0
//
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role

15
Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h

@ -178,16 +178,16 @@
//
// Misc. Functions
//
#define MT_DET_1 PA4
#define MT_DET_2 PE6
#define MT_DET_1_PIN PA4
#define MT_DET_2_PIN PE6
#define PW_DET PA13
#define PW_OFF PB2
#ifndef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN MT_DET_1
#define FIL_RUNOUT_PIN MT_DET_1_PIN
#endif
#ifndef FIL_RUNOUT2_PIN
#define FIL_RUNOUT2_PIN MT_DET_2
#define FIL_RUNOUT2_PIN MT_DET_2_PIN
#endif
#ifndef POWER_LOSS_PIN
@ -214,6 +214,13 @@
#define SDCARD_CONNECTION ONBOARD
#endif
// MKS WIFI MODULE
#if ENABLED(MKS_WIFI_MODULE)
#define WIFI_IO0_PIN PC13 // MKS ESP WIFI IO0 PIN
#define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN
#define WIFI_RESET_PIN PE9 // MKS ESP WIFI RESET PIN
#endif
//
// Onboard SD card
//

4
buildroot/tests/mks_robin_nano35

@ -21,8 +21,8 @@ exec_test $1 $2 "MKS Robin nano v1.2 Emulated DOGM FSMC" "$3"
use_example_configs Mks/Robin
opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2
opt_disable TFT_INTERFACE_FSMC
opt_enable TFT_INTERFACE_SPI
exec_test $1 $2 "MKS Robin v2 nano Emulated DOGM SPI" "$3"
opt_enable TFT_INTERFACE_SPI MKS_WIFI_MODULE
exec_test $1 $2 "MKS Robin v2 nano Emulated DOGM SPI, MKS_WIFI_MODULE" "$3"
#
# MKS Robin nano v1.2 LVGL FSMC

3
ini/stm32f1-maple.ini

@ -26,8 +26,7 @@
platform = ststm32@~12.1
board_build.core = maple
build_flags = !python Marlin/src/HAL/STM32F1/build_flags.py
${common.build_flags}
-DARDUINO_ARCH_STM32
${common.build_flags} -DARDUINO_ARCH_STM32 -DMAPLE_STM32F1
build_unflags = -std=gnu11 -std=gnu++11
src_filter = ${common.default_src_filter} +<src/HAL/STM32F1>
lib_ignore = SPI, FreeRTOS701, FreeRTOS821

Loading…
Cancel
Save