From 10ea9561eaf6b47c5e26c40505c01911a99c21d9 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 20 Oct 2020 11:24:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2=D1=8B=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=BF=D0=B0=D1=80=D0=BA=D0=BE=D0=B2=D0=BA=D0=B5?= =?UTF-8?q?=20=D0=BF=D0=BE=20M600?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update from Marlin Fix print float values --- Marlin/Configuration.h | 2 +- Marlin/src/HAL/SAMD51/HAL.h | 3 +- Marlin/src/HAL/STM32/fastio.h | 10 +- Marlin/src/HAL/STM32/pinsDebug_STM32duino.h | 10 +- .../src/HAL/shared/backtrace/unwmemaccess.cpp | 2 +- Marlin/src/core/boards.h | 1 + Marlin/src/core/serial.h | 2 +- Marlin/src/gcode/calibrate/G34.cpp | 3 +- Marlin/src/inc/Version.h | 2 +- .../src/lcd/extui/lib/mks_ui/pic_manager.cpp | 17 +- .../lib/mks_ui/tft_lvgl_configuration.cpp | 7 +- Marlin/src/lcd/tft/touch.cpp | 4 - Marlin/src/lcd/tft_io/ili9328.h | 8 +- Marlin/src/lcd/tft_io/r65105.h | 8 +- Marlin/src/module/mks_wifi/mks_wifi.cpp | 35 --- Marlin/src/module/mks_wifi/mks_wifi.h | 9 +- .../module/mks_wifi/mks_wifi_serial_out.cpp | 109 ++++++++++ .../src/module/mks_wifi/mks_wifi_serial_out.h | 35 +++ Marlin/src/module/motion.cpp | 4 +- Marlin/src/module/motion.h | 10 +- Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h | 201 ++++++++++++++++++ platformio.ini | 13 +- 23 files changed, 414 insertions(+), 83 deletions(-) create mode 100644 Marlin/src/module/mks_wifi/mks_wifi_serial_out.cpp create mode 100644 Marlin/src/module/mks_wifi/mks_wifi_serial_out.h create mode 100644 Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index aa49e92906..d730c603e1 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1593,7 +1593,7 @@ EEPROM_W25Q #if ENABLED(NOZZLE_PARK_FEATURE) // Specify a park position as { X, Y, Z_raise } - #define NOZZLE_PARK_POINT { (X_MIN_POS + 10), (Y_MAX_POS - 10), 20 } + #define NOZZLE_PARK_POINT { (X_MIN_POS + 10), 10, 20 } //#define NOZZLE_PARK_X_ONLY // X move only is required to park //#define NOZZLE_PARK_Y_ONLY // Y move only is required to park #define NOZZLE_PARK_Z_RAISE_MIN 2 // (mm) Always raise Z by at least this distance diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index abc6c04a69..7cb3635bd7 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -35,7 +35,8 @@ // MYSERIAL0 required before MarlinSerial includes! - #define _MSERIAL(X) Serial##X + #define __MSERIAL(X) Serial##X + #define _MSERIAL(X) __MSERIAL(X) #define MSERIAL(X) _MSERIAL(INCREMENT(X)) #if SERIAL_PORT == -1 diff --git a/Marlin/src/HAL/STM32/fastio.h b/Marlin/src/HAL/STM32/fastio.h index f000d68cf0..ea28b8f3bf 100644 --- a/Marlin/src/HAL/STM32/fastio.h +++ b/Marlin/src/HAL/STM32/fastio.h @@ -51,15 +51,15 @@ void FastIO_init(); // Must be called before using fast io macros #if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32L0xx) || defined(STM32L4xx) #define _WRITE(IO, V) do { \ - if (V) FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO])) ; \ - else FastIOPortMap[STM_PORT(digitalPin[IO])]->BRR = _BV32(STM_PIN(digitalPin[IO])) ; \ + if (V) FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \ + else FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \ }while(0) #else - #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO]) + ((V) ? 0 : 16))) + #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO)) + ((V) ? 0 : 16))) #endif -#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPin[IO])]->IDR, _BV32(STM_PIN(digitalPin[IO])))) -#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPin[IO])]->ODR ^= _BV32(STM_PIN(digitalPin[IO]))) +#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO))))) +#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR ^= _BV32(STM_PIN(digitalPinToPinName(IO)))) #define _GET_MODE(IO) #define _SET_MODE(IO,M) pinMode(IO, M) diff --git a/Marlin/src/HAL/STM32/pinsDebug_STM32duino.h b/Marlin/src/HAL/STM32/pinsDebug_STM32duino.h index 09f2bb54e6..71480153a7 100644 --- a/Marlin/src/HAL/STM32/pinsDebug_STM32duino.h +++ b/Marlin/src/HAL/STM32/pinsDebug_STM32duino.h @@ -51,8 +51,8 @@ * It contains: * - name of the signal * - the Ard_num assigned by the pins_YOUR_BOARD.h file using the platform defines. - * EXAMPLE: "#define KILL_PIN PB1" results in Ard_num of 57. 57 is then used as an - * index into digitalPin[] to get the Port_pin number + * EXAMPLE: "#define KILL_PIN PB1" results in Ard_num of 57. 57 is then used as the + * argument to digitalPinToPinName(IO) to get the Port_pin number * - if it is a digital or analog signal. PWMs are considered digital here. * * pin_xref is a structure generated by this header file. It is generated by the @@ -68,8 +68,6 @@ * signal. The Arduino pin number is listed by the M43 I command. */ -extern const PinName digitalPin[]; // provided by the platform - //////////////////////////////////////////////////////// // // make a list of the Arduino pin numbers in the Port/Pin order @@ -137,7 +135,7 @@ const XrefInfo pin_xref[] PROGMEM = { uint8_t get_pin_mode(const pin_t Ard_num) { uint32_t mode_all = 0; - const PinName dp = digitalPin[Ard_num]; + const PinName dp = digitalPinToPinName(Ard_num); switch (PORT_ALPHA(dp)) { case 'A' : mode_all = GPIOA->MODER; break; case 'B' : mode_all = GPIOB->MODER; break; @@ -218,7 +216,7 @@ bool pwm_status(const pin_t Ard_num) { void pwm_details(const pin_t Ard_num) { if (pwm_status(Ard_num)) { uint32_t alt_all = 0; - const PinName dp = digitalPin[Ard_num]; + const PinName dp = digitalPinToPinName(Ard_num); pin_t pin_number = uint8_t(PIN_NUM(dp)); const bool over_7 = pin_number >= 8; const uint8_t ind = over_7 ? 1 : 0; diff --git a/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp b/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp index 4b085f90ce..c93494d485 100644 --- a/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp +++ b/Marlin/src/HAL/shared/backtrace/unwmemaccess.cpp @@ -85,7 +85,7 @@ #define START_FLASH_ADDR 0x08000000 #define END_FLASH_ADDR 0x08100000 -#elif MB(REMRAM_V1) +#elif MB(REMRAM_V1, NUCLEO_F767ZI) // For STM32F765VI in RemRam v1 // SRAM (0x20000000 - 0x20080000) (512kb) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 8658c85785..da7d15ec33 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -363,6 +363,7 @@ #define BOARD_REMRAM_V1 5001 // RemRam v1 #define BOARD_TEENSY41 5002 // Teensy 4.1 #define BOARD_T41U5XBB 5003 // T41U5XBB Teensy 4.1 breakout board +#define BOARD_NUCLEO_F767ZI 5004 // ST NUCLEO-F767ZI Dev Board // // Espressif ESP32 WiFi diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index dca5a5ddea..d93f1961df 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -22,7 +22,7 @@ #pragma once #include "../inc/MarlinConfig.h" -#include "../module/mks_wifi/mks_wifi.h" +#include "../module/mks_wifi/mks_wifi_serial_out.h" #include /** * Define debug bit-masks diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index fd876d3fe9..0ca4490eb6 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -38,7 +38,8 @@ void GcodeSuite::G34() { - if (homing_needed()) return; + // Home before the alignment procedure + if (!all_axes_known()) home_all_axes(); SET_SOFT_ENDSTOP_LOOSE(true); TEMPORARY_BED_LEVELING_STATE(false); diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 28ff6c6f8f..06525ed04f 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-10-13" + #define STRING_DISTRIBUTION_DATE "2020-10-15" #endif /** diff --git a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp index d6f5fbf8b5..07ac563802 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp @@ -266,19 +266,24 @@ void spiFlashErase_PIC() { W25QXX.init(SPI_QUARTER_SPEED); //erase 0x001000 -64K for (pic_sectorcnt = 0; pic_sectorcnt < (64 - 4) / 4; pic_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_SectorErase(PICINFOADDR + pic_sectorcnt * 4 * 1024); } //erase 64K -- 6M - for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) + for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_BlockErase((pic_sectorcnt + 1) * 64 * 1024); + } } #if HAS_SPI_FLASH_FONT void spiFlashErase_FONT() { volatile uint32_t Font_sectorcnt = 0; W25QXX.init(SPI_QUARTER_SPEED); - for (Font_sectorcnt = 0; Font_sectorcnt < 32-1; Font_sectorcnt++) + for (Font_sectorcnt = 0; Font_sectorcnt < 32-1; Font_sectorcnt++) { + watchdog_refresh(); W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024); + } } #endif @@ -410,6 +415,7 @@ uint8_t public_buf[512]; return; } + watchdog_refresh(); disp_assets_update_progress(fn); W25QXX.init(SPI_QUARTER_SPEED); @@ -422,18 +428,21 @@ uint8_t public_buf[512]; totalSizeLoaded += pfileSize; if (assetType == ASSET_TYPE_LOGO) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); Pic_Logo_Write((uint8_t *)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_TITLE_LOGO) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); Pic_TitleLogo_Write((uint8_t *)fn, public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); } else if (assetType == ASSET_TYPE_G_PREVIEW) { do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); default_view_Write(public_buf, pbr); } while (pbr >= BMP_WRITE_BUF_LEN); @@ -443,6 +452,7 @@ uint8_t public_buf[512]; SPIFlash.beginWrite(Pic_Write_Addr); #if HAS_SPI_FLASH_COMPRESSION do { + watchdog_refresh(); pbr = file.read(public_buf, SPI_FLASH_PageSize); TERN_(MARLIN_DEV_MODE, totalSizes += pbr); SPIFlash.writeData(public_buf, SPI_FLASH_PageSize); @@ -463,6 +473,7 @@ uint8_t public_buf[512]; else if (assetType == ASSET_TYPE_FONT) { Pic_Write_Addr = UNIGBK_FLASH_ADDR; do { + watchdog_refresh(); pbr = file.read(public_buf, BMP_WRITE_BUF_LEN); W25QXX.SPI_FLASH_BufferWrite(public_buf, Pic_Write_Addr, pbr); Pic_Write_Addr += pbr; @@ -482,9 +493,11 @@ uint8_t public_buf[512]; disp_assets_update(); disp_assets_update_progress("Erasing pics..."); + watchdog_refresh(); spiFlashErase_PIC(); #if HAS_SPI_FLASH_FONT disp_assets_update_progress("Erasing fonts..."); + watchdog_refresh(); spiFlashErase_FONT(); #endif 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 ecd4eb482a..5a8c498608 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 @@ -123,8 +123,11 @@ void tft_lvgl_init() { //spi_flash_read_test(); #if ENABLED(SDSUPPORT) + watchdog_refresh(); UpdateAssets(); #endif + + watchdog_refresh(); mks_test_get(); touch.Init(); @@ -473,8 +476,8 @@ void lv_encoder_pin_init() { #endif - - static uint8_t buttons = newbutton; + static uint8_t buttons = 0; + buttons = newbutton; static uint8_t lastEncoderBits; #define encrot0 0 diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 2124a42e28..80c65f074a 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -295,10 +295,6 @@ bool Touch::get_point(int16_t *x, int16_t *y) { if (is_touched && calibration.orientation != TOUCH_ORIENTATION_NONE) { *x = int16_t((int32_t(*x) * calibration.x) >> 16) + calibration.offset_x; *y = int16_t((int32_t(*y) * calibration.y) >> 16) + calibration.offset_y; - #if (TFT_ROTATION & TFT_ROTATE_180) - *x = TFT_WIDTH - *x; - *y = TFT_HEIGHT - *y; - #endif } return is_touched; } diff --git a/Marlin/src/lcd/tft_io/ili9328.h b/Marlin/src/lcd/tft_io/ili9328.h index 6c3d37d62c..b50517adfe 100644 --- a/Marlin/src/lcd/tft_io/ili9328.h +++ b/Marlin/src/lcd/tft_io/ili9328.h @@ -48,11 +48,13 @@ #define ILI9328_DRVCTL_DATA ILI9328_DRVCTL_SS #define ILI9328_GATE_SCANCTL1_DATA 0x2700 #endif + /* -#define ILI9328_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9328_ETMOD_AM) | \ - IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9328_ETMOD_ID1) | \ - IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9328_ETMOD_ID0) +#define ILI9328_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, ILI9328_ETMOD_AM) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, ILI9328_ETMOD_ID1) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, ILI9328_ETMOD_ID0) */ + #define ILI9328_ETMOD_ORIENTATION (ILI9328_ETMOD_AM | ILI9328_ETMOD_ID1 | ILI9328_ETMOD_ID0) #if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR diff --git a/Marlin/src/lcd/tft_io/r65105.h b/Marlin/src/lcd/tft_io/r65105.h index 950277ea18..8be2afe442 100644 --- a/Marlin/src/lcd/tft_io/r65105.h +++ b/Marlin/src/lcd/tft_io/r65105.h @@ -50,11 +50,13 @@ #define R61505_DRVCTL_DATA R61505_DRVCTL_SS #define R61505_DRVCTRL_DATA 0x2700 #endif + /* -#define R61505_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, R61505_ETMOD_AM) | \ - IF_0((TFT_ORIENTATION) & TFT_INVERT_X, R61505_ETMOD_ID0) | \ - IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, R61505_ETMOD_ID1) +#define R61505_ETMOD_ORIENTATION IF_0((TFT_ORIENTATION) & TFT_EXCHANGE_XY, R61505_ETMOD_AM) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_X, R61505_ETMOD_ID0) | \ + IF_0((TFT_ORIENTATION) & TFT_INVERT_Y, R61505_ETMOD_ID1) */ + #define R61505_ETMOD_ORIENTATION (R61505_ETMOD_AM | R61505_ETMOD_ID0 | R61505_ETMOD_ID1) #if !defined(TFT_COLOR) || TFT_COLOR == TFT_COLOR_BGR diff --git a/Marlin/src/module/mks_wifi/mks_wifi.cpp b/Marlin/src/module/mks_wifi/mks_wifi.cpp index 01c45d7b4e..cadcdd1b96 100644 --- a/Marlin/src/module/mks_wifi/mks_wifi.cpp +++ b/Marlin/src/module/mks_wifi/mks_wifi.cpp @@ -328,42 +328,7 @@ void mks_wifi_parse_packet(ESP_PROTOC_FRAME *packet){ } -void mks_wifi_print_var(uint8_t count, ...){ - va_list args; - uint8_t data; - va_start(args, count); - - while (count--) { - data = va_arg(args, unsigned); - mks_wifi_out_add(&data, 1); - } - va_end(args); -} - - -void mks_wifi_print(const char *s){ - mks_wifi_out_add((uint8_t *)s, strnlen((char *)s,ESP_PACKET_DATA_MAX_SIZE)); -} - -void mks_wifi_print(int i){ - char str[100]; - - sprintf(str,"%d",i); - mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); -} - - -void mks_wifi_println(const char *s){ - mks_wifi_out_add((uint8_t *)s, strnlen((char *)s,ESP_PACKET_DATA_MAX_SIZE)); -} - -void mks_wifi_println(float f){ - char str[100]; - - sprintf(str,"%ld\n",(uint32_t)f); - mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); -} uint16_t mks_wifi_build_packet(uint8_t *packet, ESP_PROTOC_FRAME *esp_frame){ uint16_t packet_size=0; diff --git a/Marlin/src/module/mks_wifi/mks_wifi.h b/Marlin/src/module/mks_wifi/mks_wifi.h index 5a0fa1fe70..3c20cce2b6 100644 --- a/Marlin/src/module/mks_wifi/mks_wifi.h +++ b/Marlin/src/module/mks_wifi/mks_wifi.h @@ -5,6 +5,7 @@ #include "../../inc/MarlinConfig.h" #include "../../libs/Segger/log.h" #include "mks_wifi_settings.h" +#include "mks_wifi_serial_out.h" #ifdef MKS_WIFI @@ -60,13 +61,5 @@ uint8_t check_char_allowed(char data); void mks_wifi_send(uint8_t *packet, uint16_t size); -void mks_wifi_print_var(uint8_t count, ...); - -void mks_wifi_print(const char *s); -void mks_wifi_print(int i); - -void mks_wifi_println(const char *s); -void mks_wifi_println(float); - #endif #endif \ No newline at end of file diff --git a/Marlin/src/module/mks_wifi/mks_wifi_serial_out.cpp b/Marlin/src/module/mks_wifi/mks_wifi_serial_out.cpp new file mode 100644 index 0000000000..ecd59553aa --- /dev/null +++ b/Marlin/src/module/mks_wifi/mks_wifi_serial_out.cpp @@ -0,0 +1,109 @@ +#include "mks_wifi_serial_out.h" +#include "mks_wifi.h" +#ifdef MKS_WIFI + + +void mks_wifi_print_var(uint8_t count, ...){ + va_list args; + uint8_t data; + + va_start(args, count); + + while (count--) { + data = va_arg(args, unsigned); + mks_wifi_out_add(&data, 1); + } + va_end(args); +} + + +// PRINT functions + +void mks_wifi_print(const char *s){ + mks_wifi_out_add((uint8_t *)s, strnlen((char *)s,ESP_PACKET_DATA_MAX_SIZE)); +} + +//Signed int +void mks_wifi_print(int32 i){ + char str[12]; + + sprintf(str,"%d",i); + mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); +} +//Unsigned int +void mks_wifi_print(uint32 i){ + char str[12]; + + sprintf(str,"%ld",i); + mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); +} +//Float +void mks_wifi_print(double f){ + char str[12]; + + sprintf(str,"%.2f",f); + mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); +} + +/* +void mks_wifi_print(int i){ + mks_wifi_print((int32)i); +} +*/ +void mks_wifi_print(long int i){ + mks_wifi_print((int32)i); +} + +void mks_wifi_print(unsigned int i){ + mks_wifi_print((uint32_t)i); +} +void mks_wifi_print(float f){ + mks_wifi_print((double)f); +} + + +//PRINTLN +void mks_wifi_println(const char *s){ + char str[100]; + + sprintf(str,"%s\n",s); + mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); +} +//Int +void mks_wifi_println(int32 i){ + char str[14]; + sprintf(str,"%d\n",i); + mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); +} +//Unsigned int +void mks_wifi_println(uint32 i){ + char str[14]; + sprintf(str,"%ld\n",i); + mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); +} +//Float +void mks_wifi_println(double f){ + char str[14]; + + sprintf(str,"%.2f\n",f); + mks_wifi_out_add((uint8_t *)str, strnlen((char *)str,ESP_PACKET_DATA_MAX_SIZE)); +} +/* +void mks_wifi_println(int i){ + mks_wifi_println((int32)i); +} +*/ +void mks_wifi_println(long int i){ + mks_wifi_println((int32)i); +} + +void mks_wifi_println(unsigned int i){ + mks_wifi_println((uint32_t)i); +} +void mks_wifi_println(float f){ + mks_wifi_println((double)f); +} + + + +#endif diff --git a/Marlin/src/module/mks_wifi/mks_wifi_serial_out.h b/Marlin/src/module/mks_wifi/mks_wifi_serial_out.h new file mode 100644 index 0000000000..de0db7d2be --- /dev/null +++ b/Marlin/src/module/mks_wifi/mks_wifi_serial_out.h @@ -0,0 +1,35 @@ +#ifndef MKS_WIFI_SERIAL_OUT_H +#define MKS_WIFI_SERIAL_OUT_H + +#include "../../MarlinCore.h" +#include "../../inc/MarlinConfig.h" +#include "../../libs/Segger/log.h" +#include "mks_wifi_settings.h" + +#ifdef MKS_WIFI + + +void mks_wifi_print_var(uint8_t count, ...); + +void mks_wifi_print(const char *s); +void mks_wifi_print(int32 i); +void mks_wifi_print(uint32 i); +void mks_wifi_print(double f); +//void mks_wifi_print(int i); +void mks_wifi_print(long int i); +void mks_wifi_print(unsigned int i); +void mks_wifi_print(float f); + + +void mks_wifi_println(const char *s); +void mks_wifi_println(int32 i); +void mks_wifi_println(uint32 i); +void mks_wifi_println(double f); +//void mks_wifi_println(int i); +void mks_wifi_println(long int i); +void mks_wifi_println(unsigned int i); +void mks_wifi_println(float f); + +#endif + +#endif \ No newline at end of file diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 92712b0c22..5b3fab10b1 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -536,9 +536,9 @@ void restore_feedrate_and_scaling() { // Software Endstops are based on the configured limits. soft_endstops_t soft_endstop = { + true, false, { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }, - { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }, - { true, false } + { X_MAX_POS, Y_MAX_POS, Z_MAX_POS } }; /** diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 338eb387cf..85b70c057a 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -151,12 +151,10 @@ inline float home_bump_mm(const AxisEnum axis) { #if HAS_SOFTWARE_ENDSTOPS typedef struct { - xyz_pos_t min, max; - struct { - bool _enabled:1; - bool _loose:1; - }; + bool _enabled, _loose; bool enabled() { return _enabled && !_loose; } + + xyz_pos_t min, max; void get_manual_axis_limits(const AxisEnum axis, float &amin, float &amax) { amin = -100000; amax = 100000; // "No limits" #if HAS_SOFTWARE_ENDSTOPS @@ -200,7 +198,7 @@ inline float home_bump_mm(const AxisEnum axis) { extern soft_endstops_t soft_endstop; #define apply_motion_limits(V) NOOP #define update_software_endstops(...) NOOP - #define SET_SOFT_ENDSTOP_LOOSE() NOOP + #define SET_SOFT_ENDSTOP_LOOSE(V) NOOP #endif // !HAS_SOFTWARE_ENDSTOPS diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index a7888e54d4..c5dbd20876 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -634,6 +634,8 @@ #include "stm32f7/pins_THE_BORG.h" // STM32F7 env:STM32F7 #elif MB(REMRAM_V1) #include "stm32f7/pins_REMRAM_V1.h" // STM32F7 env:STM32F7 +#elif MB(NUCLEO_F767ZI) + #include "stm32f7/pins_NUCLEO_F767ZI.h" // STM32F7 env:NUCLEO_F767ZI #elif MB(TEENSY41) #include "teensy4/pins_TEENSY41.h" // Teensy-4.x env:teensy41 #elif MB(T41U5XBB) diff --git a/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h new file mode 100644 index 0000000000..5e3d5f4ab5 --- /dev/null +++ b/Marlin/src/pins/stm32f7/pins_NUCLEO_F767ZI.h @@ -0,0 +1,201 @@ +/** + * 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 + +#ifndef STM32F767xx + #error "Oops! Select an STM32F767 environment" +#endif + +#define BOARD_INFO_NAME "NUCLEO-F767ZI" +#define DEFAULT_MACHINE_NAME "Prototype Board" + +#if NO_EEPROM_SELECTED + #define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // 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 +#endif + +/** + * Timer assignments + * + * TIM1 - + * TIM2 - Hardware PWM (Fan/Heater Pins) + * TIM3 - Hardware PWM (Servo Pins) + * TIM4 - STEP_TIMER (Marlin) + * TIM5 - + * TIM6 - TIMER_TONE (variant.h) + * TIM7 - TIMER_SERVO (variant.h) + * TIM9 - TIMER_SERIAL (platformio.ini) + * TIM10 - For some reason trips Watchdog when used for SW Serial + * TIM11 - + * TIM12 - + * TIM13 - + * TIM14 - TEMP_TIMER (Marlin) + * + */ +#define STEP_TIMER 4 +#define TEMP_TIMER 14 + + +/** + * These pin assignments are arbitrary and intending for testing purposes. + * Assignments may not be ideal, and not every assignment has been tested. + * Proceed at your own risk. + * _CN7_ + * (X_STEP) PC6 | · · | PB8 (X_EN) + * (X_DIR) PB15 | · · | PB9 (X_CS) + * (LCD_D4) PB13 | · · | AVDD + * _CN8_ PB12 | · · | GND + * NC | · · | PC8 (HEATER_0) PA15 | · · | PA5 (SCLK) + * IOREF | · · | PC9 (BEEPER) PC7 | · · | PA6 (MISO) + * RESET | · · | PC10 (SERVO1_PIN) PB5 | · · | PA7 (MOSI) + * +3.3V | · · | PC11 (HEATER_BED) PB3 | · · | PD14 (SD_DETECT) + * +5V | · · | PC12 (SDSS) PA4 | · · | PD15 (LCD_ENABLE) + * GND | · · | PD2 (SERVO0_PIN) PB4 | · · | PF12 (LCD_RS) + * GND | · · | PG2  ̄ ̄ ̄ + * VIN | · · | PG3 +_*  ̄ ̄ ̄ _CN10 + * AVDD | · · | PF13 (BTN_EN1) + * _CN9_ AGND | · · | PE9 (BTN_EN2) + * (TEMP_0) PA3 | · · | PD7 GND | · · | PE11 (BTN_ENC) + * (TEMP_BED) PC0 | · · | PD6 PB1 | · · | PF14 + * PC3 | · · | PD5 PC2 | · · | PE13 + * PF3 | · · | PD4 PF4 | · · | PF15 + * PF5 | · · | PD3 (E_STEP) PB6 | · · | PG14 (E_EN) + * PF10 | · · | GND (E_DIR) PB2 | · · | PG9 (E_CS) + * NC | · · | PE2 GND | · · | PE8 + * PA7 | · · | PE4 PD13 | · · | PE7 + * PF2 | · · | PE5 PD12 | · · | GND + * (Y_STEP) PF1 | · · | PE6 (Y_EN) (Z_STEP) PD11 | · · | PE10 (Z_EN) + * (Y_DIR) PF0 | · · | PE3 (Y_CS) (Z_DIR) PE2 | · · | PE12 (Z_CS) + * GND | · · | PF8 GND | · · | PE14 + * (Z_MAX) PD0 | · · | PF7 (X_MIN) PA0 | · · | PE15 + * (Z_MIN) PD1 | · · | PF9 (X_MAX) PB0 | · · | PB10 (FAN) + * (Y_MAX) PG0 | · · | PG1 (Y_MIN) PE0 | · · | PB11 (FAN1) + *  ̄ ̄ ̄  ̄ ̄ ̄ ̄ + */ + +#define X_MIN_PIN PF7 +#define X_MAX_PIN PF9 +#define Y_MIN_PIN PG1 +#define Y_MAX_PIN PG0 +#define Z_MIN_PIN PD1 +#define Z_MAX_PIN PD0 + +// +// Steppers +// +#define X_STEP_PIN PC6 +#define X_DIR_PIN PB15 +#define X_ENABLE_PIN PB8 +#define X_CS_PIN PB9 + +#define Y_STEP_PIN PF1 +#define Y_DIR_PIN PF0 +#define Y_ENABLE_PIN PE6 +#define Y_CS_PIN PE3 + +#define Z_STEP_PIN PD11 +#define Z_DIR_PIN PE2 +#define Z_ENABLE_PIN PE10 +#define Z_CS_PIN PE12 + +#define E0_STEP_PIN PB6 +#define E0_DIR_PIN PB2 +#define E0_ENABLE_PIN PG14 +#define E0_CS_PIN PG9 + +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PB9 + #define X_SERIAL_RX_PIN PB9 + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN PE3 + + #define Z_SERIAL_TX_PIN PE12 + #define Z_SERIAL_RX_PIN PE12 + + #define E_SERIAL_TX_PIN PG9 + #define E_SERIAL_RX_PIN PG9 +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA3 +#define TEMP_BED_PIN PC0 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA15 // PWM Capable, TIM2_CH1 +#define HEATER_BED_PIN PB3 // PWM Capable, TIM2_CH2 + +#ifndef FAN_PIN + #define FAN_PIN PB10 // PWM Capable, TIM2_CH3 +#endif +#define FAN1_PIN PB11 // PWM Capable, TIM2_CH4 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN FAN1_PIN +#endif + +// +// Servos +// +#define SERVO0_PIN PB4 // PWM Capable, TIM3_CH1 +#define SERVO1_PIN PB5 // PWM Capable, TIM3_CH2 + +// SPI for external SD Card (Not entirely sure this will work) +#define SCK_PIN PA5 +#define MISO_PIN PA6 +#define MOSI_PIN PA7 +#define SS_PIN PA4 +#define SDSS PA4 + +#define LED_PIN LED_BLUE + +// +// LCD / Controller +// +#if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BEEPER_PIN PC7 // LCD_BEEPER + #define BTN_ENC PE11 // BTN_ENC + #define SD_DETECT_PIN PD14 + #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 + + #define BOARD_ST7920_DELAY_1 DELAY_NS(125) + #define BOARD_ST7920_DELAY_2 DELAY_NS(63) + #define BOARD_ST7920_DELAY_3 DELAY_NS(780) +#endif diff --git a/platformio.ini b/platformio.ini index a9afb19054..db29864261 100644 --- a/platformio.ini +++ b/platformio.ini @@ -445,7 +445,7 @@ board = megaatmega2560 # [env:mega2560ext] platform = atmelavr -extends = mega2560 +extends = env:mega2560 board = megaatmega2560 board_build.variant = megaextendedpins extra_scripts = ${common.extra_scripts} @@ -856,6 +856,17 @@ board = remram_v1 build_flags = ${common.build_flags} -DUSE_STM32GENERIC -DSTM32GENERIC -DSTM32F7 -DMENU_USB_SERIAL -DMENU_SERIAL=SerialUSB -DHAL_IWDG_MODULE_ENABLED src_filter = ${common.default_src_filter} + - +# +# ST NUCLEO-F767ZI Development Board +# This environment is for testing purposes prior to control boards +# being readily available based on STM32F7 MCUs +# +[env:NUCLEO_F767ZI] +platform = ${common_stm32.platform} +extends = common_stm32 +board = nucleo_f767zi +build_flags = ${common_stm32.build_flags} -DTIMER_SERIAL=TIM9 + # # ARMED (STM32) #