diff --git a/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp b/Marlin/src/HAL/AVR/u8g/u8g_com_HAL_AVR_sw_spi.cpp similarity index 98% rename from Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp rename to Marlin/src/HAL/AVR/u8g/u8g_com_HAL_AVR_sw_spi.cpp index 79bafe293967..a39fbdb7d324 100644 --- a/Marlin/src/HAL/AVR/u8g_com_HAL_AVR_sw_spi.cpp +++ b/Marlin/src/HAL/AVR/u8g/u8g_com_HAL_AVR_sw_spi.cpp @@ -55,12 +55,12 @@ #if defined(ARDUINO) && !defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_SAM) -#include "../../inc/MarlinConfigPre.h" +#include "../../../inc/MarlinConfigPre.h" #if HAS_MARLINUI_U8GLIB -#include "../shared/Marduino.h" -#include "../shared/Delay.h" +#include "../../shared/Marduino.h" +#include "../../shared/Delay.h" #include diff --git a/Marlin/src/HAL/STM32/u8g/LCD_defines.h b/Marlin/src/HAL/STM32/u8g/LCD_defines.h index 35f1674d69dc..507895d28df0 100644 --- a/Marlin/src/HAL/STM32/u8g/LCD_defines.h +++ b/Marlin/src/HAL/STM32/u8g/LCD_defines.h @@ -27,6 +27,8 @@ uint8_t u8g_com_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL +uint8_t u8g_com_stm32duino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); #define U8G_COM_HAL_SW_SPI_FN u8g_com_std_sw_spi_fn #define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn +#define U8G_COM_SSD_I2C_HAL u8g_com_stm32duino_ssd_i2c_fn diff --git a/Marlin/src/HAL/STM32/u8g/u8g_com_stm32duino_ssd_i2c.cpp b/Marlin/src/HAL/STM32/u8g/u8g_com_stm32duino_ssd_i2c.cpp new file mode 100644 index 000000000000..e9e1d3f8bd74 --- /dev/null +++ b/Marlin/src/HAL/STM32/u8g/u8g_com_stm32duino_ssd_i2c.cpp @@ -0,0 +1,194 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 . + * + */ + +/** + * 2-Wire I2C COM Driver + * + * Handles both Hardware and Software I2C so any pins can be used as SDA and SLC. + * Wire library is used for Hardware I2C. + * SlowSoftWire is used for Software I2C. + * + * Wire / SoftWire library selection can be done automatically at runtime. + * + * SDA and SLC pins must be named DOGLCD_SDA_PIN, DOGLCD_SCL_PIN to distinguish + * from other I2C devices (e.g., EEPROM) that use I2C_SDA_PIN, I2C_SLC_PIN. + */ +#ifdef ARDUINO_ARCH_STM32 + +#include "../../../inc/MarlinConfig.h" + +#if HAS_U8GLIB_I2C_OLED + +#include + +#if ENABLED(U8G_USES_HW_I2C) + #include + #ifndef MASTER_ADDRESS + #define MASTER_ADDRESS 0x01 + #endif +#endif + +#if ENABLED(U8G_USES_SW_I2C) + #include + #include +#endif + +/** + * BUFFER_LENGTH is defined in libraries\Wire\utility\WireBase.h + * Default value is 32 + * Increase this value to 144 to send U8G_COM_MSG_WRITE_SEQ in single block + */ +#ifndef BUFFER_LENGTH + #define BUFFER_LENGTH 32 +#endif +#if BUFFER_LENGTH > 144 + #error "BUFFER_LENGTH should not be greater than 144." +#endif +#define I2C_MAX_LENGTH (BUFFER_LENGTH - 1) + +uint8_t u8g_com_stm32duino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { + // Hardware I2C flag + #ifdef COMPILE_TIME_I2C_IS_HARDWARE + constexpr bool isHardI2C = ENABLED(COMPILE_TIME_I2C_IS_HARDWARE); + #else + static bool isHardI2C = false; + static bool i2c_initialized = false; // Flag to only run init/linking code once + if (!i2c_initialized) { // Init runtime linkages + i2c_initialized = true; // Only do this once + I2C_TypeDef *i2cInstance1 = (I2C_TypeDef *)pinmap_peripheral(digitalPinToPinName(DOGLCD_SDA_PIN), PinMap_I2C_SDA); + I2C_TypeDef *i2cInstance2 = (I2C_TypeDef *)pinmap_peripheral(digitalPinToPinName(DOGLCD_SCL_PIN), PinMap_I2C_SCL); + isHardI2C = (i2cInstance1 && (i2cInstance1 == i2cInstance2)); // Found hardware I2C controller + } + #endif + + static uint8_t msgInitCount = 0; // Ignore all messages until 2nd U8G_COM_MSG_INIT + if (msgInitCount) { + if (msg == U8G_COM_MSG_INIT) msgInitCount--; + if (msgInitCount) return -1; + } + + static uint8_t control; + if (isHardI2C) { // Found hardware I2C controller + #if ENABLED(U8G_USES_HW_I2C) + static TwoWire wire2; // A TwoWire object for use below + switch (msg) { + case U8G_COM_MSG_INIT: + wire2.setClock(400000); + wire2.setSCL(DOGLCD_SCL_PIN); + wire2.setSDA(DOGLCD_SDA_PIN); + wire2.begin(MASTER_ADDRESS, 0); // Start as master + break; + + case U8G_COM_MSG_ADDRESS: // Define cmd (arg_val = 0) or data mode (arg_val = 1) + control = arg_val ? 0x40 : 0x00; + break; + + case U8G_COM_MSG_WRITE_BYTE: + wire2.beginTransmission(0x3C); + wire2.write(control); + wire2.write(arg_val); + wire2.endTransmission(); + break; + + case U8G_COM_MSG_WRITE_SEQ: { + uint8_t* dataptr = (uint8_t*)arg_ptr; + #ifdef I2C_MAX_LENGTH + while (arg_val > 0) { + wire2.beginTransmission(0x3C); + wire2.write(control); + if (arg_val <= I2C_MAX_LENGTH) { + wire2.write(dataptr, arg_val); + arg_val = 0; + } + else { + wire2.write(dataptr, I2C_MAX_LENGTH); + arg_val -= I2C_MAX_LENGTH; + dataptr += I2C_MAX_LENGTH; + } + wire2.endTransmission(); + } + #else + wire2.beginTransmission(0x3C); + wire2.write(control); + wire2.write(dataptr, arg_val); + wire2.endTransmission(); + #endif // I2C_MAX_LENGTH + break; + } + } + #endif + } + else { // Software I2C + #if ENABLED(U8G_USES_SW_I2C) + static SlowSoftWire sWire = SlowSoftWire(DOGLCD_SDA_PIN, DOGLCD_SCL_PIN); + + switch (msg) { + case U8G_COM_MSG_INIT: + sWire.setClock(400000); + sWire.begin(); // Start as master + break; + + case U8G_COM_MSG_ADDRESS: // Define cmd (arg_val = 0) or data mode (arg_val = 1) + control = arg_val ? 0x40 : 0x00; + break; + + case U8G_COM_MSG_WRITE_BYTE: + sWire.beginTransmission((uint8_t)0x3C); + sWire.write((uint8_t)control); + sWire.write((uint8_t)arg_val); + sWire.endTransmission(); + break; + + case U8G_COM_MSG_WRITE_SEQ: { + uint8_t* dataptr = (uint8_t*)arg_ptr; + #ifdef I2C_MAX_LENGTH + while (arg_val > 0) { + sWire.beginTransmission((uint8_t)0x3C); + sWire.write((uint8_t)control); + if (arg_val <= I2C_MAX_LENGTH) { + sWire.write((const uint8_t *)dataptr, (size_t)arg_val); + arg_val = 0; + } + else { + sWire.write((const uint8_t *)dataptr, I2C_MAX_LENGTH); + arg_val -= I2C_MAX_LENGTH; + dataptr += I2C_MAX_LENGTH; + } + sWire.endTransmission(); + } + #else + sWire.beginTransmission((uint8_t)0x3C); + sWire.write((uint8_t)control); + sWire.write((const uint8_t *)dataptr, (size_t)arg_val); + sWire.endTransmission(); + #endif // I2C_MAX_LENGTH + break; + } + } + #endif + } + + return 1; +} + +#endif // HAS_U8GLIB_I2C_OLED +#endif // ARDUINO_ARCH_STM32 diff --git a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp b/Marlin/src/HAL/STM32F1/u8g/u8g_com_stm32duino_swspi.cpp similarity index 100% rename from Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp rename to Marlin/src/HAL/STM32F1/u8g/u8g_com_stm32duino_swspi.cpp diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index bff742a5bcb7..1cf045024e22 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -702,7 +702,7 @@ #define DOGLCD #define IS_U8GLIB_ST7920 1 #define IS_ULTIPANEL 1 - #define ENCODER_PULSES_PER_STEP 2 + #define STD_ENCODER_PULSES_PER_STEP 2 #elif ENABLED(MKS_12864OLED) @@ -831,6 +831,7 @@ #endif #endif +// U8GLIB_SSD1306 may be set alone or for other displays that need it #if ENABLED(IS_U8GLIB_SSD1306) #define U8GLIB_SSD1306 #endif @@ -854,10 +855,25 @@ #endif // 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106 -#if ANY(U8GLIB_SSD1306, U8GLIB_SSD1309, U8GLIB_SH1106) +#if ANY(U8GLIB_SH1106, U8GLIB_SSD1306, U8GLIB_SSD1309) #define HAS_U8GLIB_I2C_OLED 1 #define HAS_WIRED_LCD 1 #define DOGLCD + + // Define this to reduce build size and optimize performance + //#define COMPILE_TIME_I2C_IS_HARDWARE true // true: Hardware false: Software undefined: Solve at runtime + + #ifdef COMPILE_TIME_I2C_IS_HARDWARE + #if COMPILE_TIME_I2C_IS_HARDWARE + #define U8G_USES_HW_I2C + #else + #define U8G_USES_SW_I2C + #endif + #else + #define U8G_USES_HW_I2C + #define U8G_USES_SW_I2C + #endif + #endif /** diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index 30d687ddef5c..5999ad90e232 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -1,3 +1,25 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 . + * + */ + /** * @file lcdprint_u8g.cpp * @brief LCD print api for u8glib diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index 08e197ebb503..c2042009f923 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -310,7 +310,22 @@ void MarlinUI::init_lcd() { #endif #if ANY(MKS_12864OLED, MKS_12864OLED_SSD1306, FYSETC_242_OLED_12864, ZONESTAR_12864OLED, K3D_242_OLED_CONTROLLER) - SET_OUTPUT(LCD_PINS_DC); + + #if defined(LCD_PINS_DC) && LCD_PINS_DC != -1 + #if IS_I2C_LCD + I2C_TypeDef *i2cInstance1 = (I2C_TypeDef *)pinmap_peripheral(digitalPinToPinName(DOGLCD_SDA_PIN), PinMap_I2C_SDA); + I2C_TypeDef *i2cInstance2 = (I2C_TypeDef *)pinmap_peripheral(digitalPinToPinName(DOGLCD_SCL_PIN), PinMap_I2C_SCL); + const bool isSoftI2C = !(i2cInstance1 && (i2cInstance1 == i2cInstance2)); // Using software I2C driver for LCD + #else + constexpr bool isSoftI2C = false; + #endif + if (!isSoftI2C) SET_OUTPUT(LCD_PINS_DC); // For these LCDs, set as output if not using software I2C driver + #endif + + #ifndef LCD_RESET_PIN + #define LCD_RESET_PIN LCD_PINS_RS + #endif + #endif #if PIN_EXISTS(LCD_RESET) diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.h b/Marlin/src/lcd/dogm/marlinui_DOGM.h index 59df915f496e..8edf0b8e5731 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.h +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.h @@ -32,25 +32,30 @@ //#define ALTERNATIVE_LCD +// Defined DOGLCD_SDA_PIN and DOGLCD_SCL_PIN pins indicate I2C LCD +#if PINS_EXIST(DOGLCD_SDA, DOGLCD_SCL) + #define IS_I2C_LCD 1 +#endif + #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) // RepRapWorld Graphical LCD #if HAS_MEDIA #ifdef __SAMD21__ - #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL + #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL // 2 stripes, HW SPI (Shared with SD card. Non-standard LCD adapter on AVR.) #else // Hardware SPI on DUE - #define U8G_CLASS U8GLIB_ST7920_128X64_4X + #define U8G_CLASS U8GLIB_ST7920_128X64_4X // 2 stripes, SW SPI (Original u8glib device) #endif #define U8G_PARAM LCD_PINS_RS #elif (LCD_PINS_D4 == SD_SCK_PIN) && (LCD_PINS_EN == SD_MOSI_PIN) // Hardware SPI shared with SD Card - #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL + #define U8G_CLASS U8GLIB_ST7920_128X64_4X_HAL // 2 stripes, HW SPI (Shared with SD card. Non-standard LCD adapter on AVR.) #define U8G_PARAM LCD_PINS_RS #else // Software SPI - #define U8G_CLASS U8GLIB_ST7920_128X64_4X + #define U8G_CLASS U8GLIB_ST7920_128X64_4X // 2 stripes, SW SPI (Original u8glib device) #define U8G_PARAM LCD_PINS_D4, LCD_PINS_EN, LCD_PINS_RS #endif @@ -126,12 +131,16 @@ // MKS 128x64 (SSD1306) OLED I2C LCD - #define FORCE_SOFT_SPI // SW-SPI - - #if ENABLED(ALTERNATIVE_LCD) - #define U8G_CLASS U8GLIB_SSD1306_128X64_2X // 4 stripes + #if IS_I2C_LCD + #define U8G_CLASS U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE // I2C + #define U8G_PARAM U8G_I2C_OPT_NONE #else - #define U8G_CLASS U8GLIB_SSD1306_128X64 // 8 stripes + #define FORCE_SOFT_SPI // SW-SPI + #if ENABLED(ALTERNATIVE_LCD) + #define U8G_CLASS U8GLIB_SSD1306_128X64_2X // 4 stripes + #else + #define U8G_CLASS U8GLIB_SSD1306_128X64 // 8 stripes + #endif #endif #elif ANY(FYSETC_242_OLED_12864, K3D_242_OLED_CONTROLLER) @@ -164,7 +173,11 @@ // - or - // Zonestar SH1106 OLED SPI LCD - #define FORCE_SOFT_SPI // SW-SPI + #if IS_I2C_LCD + #define U8G_PARAM U8G_I2C_OPT_NONE // I2C LCD + #else + #define FORCE_SOFT_SPI // SW-SPI + #endif #if ENABLED(ALTERNATIVE_LCD) #define U8G_CLASS U8GLIB_SH1106_128X64_2X // 4 stripes #else @@ -232,6 +245,8 @@ #ifndef U8G_PARAM #if ENABLED(FORCE_SOFT_SPI) #define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0 // SW-SPI + #elif IS_I2C_LCD + #define U8G_PARAM U8G_I2C_OPT_NONE // I2C LCD #else #define U8G_PARAM DOGLCD_CS, DOGLCD_A0 // HW-SPI #endif diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index 4eb031e5385a..cb110e9ad9c8 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -1,3 +1,25 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 . + * + */ + /** * Lightweight Status Screen for the RepRapDiscount Full * Graphics Smart Controller (ST7920-based 128x64 LCD) diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h index e096825f8adc..e643172b5e92 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h @@ -1,3 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 + /** * Lightweight Status Screen for the RepRapDiscount Full * Graphics Smart Controller (ST7920-based 128x64 LCD) @@ -12,7 +35,6 @@ * without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. */ -#pragma once #include "../../HAL/shared/HAL_ST7920.h" diff --git a/Marlin/src/lcd/dogm/u8g_dev_ssd1306_sh1106_128x64_I2C.cpp b/Marlin/src/lcd/dogm/u8g_dev_ssd1306_sh1106_128x64_I2C.cpp index b3e579e6a44a..7aeaf11d45d3 100644 --- a/Marlin/src/lcd/dogm/u8g_dev_ssd1306_sh1106_128x64_I2C.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_ssd1306_sh1106_128x64_I2C.cpp @@ -67,7 +67,7 @@ #include "../../inc/MarlinConfigPre.h" -#if HAS_MARLINUI_U8GLIB +#if HAS_U8GLIB_I2C_OLED #include "HAL_LCD_com_defines.h" @@ -76,202 +76,188 @@ #define PAGE_HEIGHT 8 uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq); +uint8_t u8g_Write_Init_Sequence_2_wire(u8g_t *u8g, u8g_dev_t *dev, uint32_t length, const uint8_t *init_seq); -// The sh1106 is compatible to the ssd1306, but is 132x64. 128x64 display area is centered within -// the 132x64. +// SH1106 is compatible with SSD1306, but is 132x64. Display 128x64 centered within the 132x64. static const uint8_t u8g_dev_sh1106_128x64_data_start_2_wire[] PROGMEM = { - 0x010, // set upper 4 bit of the col adr to 0 - 0x002, // set lower 4 bit of the col adr to 2 (centered display with ssd1306) - U8G_ESC_END // end of sequence + 0x10, // Set upper 4 bit of the col adr to 0 + 0x02, // Set lower 4 bit of the col adr to 2 (centered display with ssd1306) + U8G_ESC_END // End of sequence }; -#define SH1106_PAGE_ADR(N) (0x20), (N) -#define SH1106_COLUMN_RANGE(N) (0x21), (((N) >> 8) & 0xFF), ((N) & 0xFF) -#define SH1106_PAGE_RANGE(N,O) (0x22), (N), (O) -#define SH1106_SCROLL(N) ((N) ? 0x2F : 0x2E) -#define SH1106_START_LINE(N) (0x40 | (N)) -#define SH1106_CONTRAST(N) (0x81), (N) -#define SH1106_CHARGE_PUMP(N) (0x8D), ((N) ? 0x14 : 0x10) -#define SH1106_ADC_REVERSE(N) ((N) ? 0xA1 : 0xA0) -#define SH1106_ALL_PIX(N) ((N) ? 0xA5 : 0xA4) -#define SH1106_INVERTED(N) ((N) ? 0xA7 : 0xA6) -#define SH1106_MUX_RATIO(N) (0xA8), (N) -#define SH1106_ON(N) ((N) ? 0xAF : 0xAE) -#define SH1106_OUT_MODE(N) ((N) ? 0xC8 : 0xC0) -#define SH1106_DISP_OFFS(N) (0xD3), (N) -#define SH1106_OSC_FREQ(R,F) (0xD5), ((F) << 4 | (R)) -#define SH1106_CHARGE_PER(P,D) (0xD9), ((D) << 4 | (P)) -#define SH1106_COM_CONFIG(N) (0xDA), ((N) ? 0x12 : 0x02) -#define SH1106_VCOM_DESEL(N) (0xDB), (N) -#define SH1106_NOOP() (0xE3) +#define CMD_PAGE_ADR(N) (0x20), (N) +#define CMD_COLUMN_RANGE(N) (0x21), (((N) >> 8) & 0xFF), ((N) & 0xFF) +#define CMD_PAGE_RANGE(N,O) (0x22), (N), (O) +#define CMD_SCROLL(N) ((N) ? 0x2F : 0x2E) +#define CMD_START_LINE(N) (0x40 | (N)) +#define CMD_CONTRAST(N) (0x81), (N) +#define CMD_CHARGE_PUMP(N) (0x8D), ((N) ? 0x14 : 0x10) +#define CMD_ADC_REVERSE(N) ((N) ? 0xA1 : 0xA0) +#define CMD_ALL_PIX(N) ((N) ? 0xA5 : 0xA4) +#define CMD_INVERTED(N) ((N) ? 0xA7 : 0xA6) +#define CMD_MUX_RATIO(N) (0xA8), (N) +#define CMD_ON(N) ((N) ? 0xAF : 0xAE) +#define CMD_OUT_MODE(N) ((N) ? 0xC8 : 0xC0) +#define CMD_DISP_OFFS(N) (0xD3), (N) +#define CMD_OSC_FREQ(R,F) (0xD5), ((F) << 4 | (R)) +#define CMD_CHARGE_PER(P,D) (0xD9), ((D) << 4 | (P)) +#define CMD_COM_CONFIG(N) (0xDA), ((N) ? 0x12 : 0x02) +#define CMD_VCOM_DESEL(N) (0xDB), (N) +#define CMD_NOOP() (0xE3) -static const uint8_t u8g_dev_sh1106_128x64_init_seq_2_wire[] PROGMEM = { - U8G_ESC_ADR(0), // Initiate command mode - SH1106_ON(0), // Display off, sleep mode - SH1106_MUX_RATIO(0x3F), // Mux ratio - SH1106_DISP_OFFS(0), // Display offset - SH1106_START_LINE(0), // Start line - SH1106_ADC_REVERSE(1), // Segment remap A0/A1 - SH1106_OUT_MODE(1), // C0: scan dir normal, C8: reverse - SH1106_COM_CONFIG(1), // Com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) - SH1106_CONTRAST(0xCF), // [2] set contrast control - SH1106_PAGE_ADR(0x02), // 2012-05-27: page addressing mode - SH1106_COLUMN_RANGE(0x281), // Set column range from 0 through 131 - SH1106_PAGE_RANGE(0, 7), // Set page range from 0 through 7 - SH1106_CHARGE_PER(0x1, 0xF), // [2] pre-charge period 0x22/F1 - SH1106_VCOM_DESEL(0x40), // Vcomh deselect level - SH1106_ALL_PIX(0), // Output ram to display - SH1106_INVERTED(0), // Normal display mode - SH1106_OSC_FREQ(0, 8), // Clock divide ratio (0:1) and oscillator frequency (8) - SH1106_CHARGE_PUMP(1), // [2] charge pump setting (P62): 0x14 enable, 0x10 disable - SH1106_SCROLL(0), // 2012-05-27: Deactivate scroll - SH1106_ON(1), // Display on - U8G_ESC_END // End of sequence +static const uint8_t u8g_dev_sh1106_128x64_init_sequence_2_wire[] PROGMEM = { + CMD_ON(0), // Display OFF, sleep mode + CMD_MUX_RATIO(0x3F), // Mux ratio + CMD_DISP_OFFS(0), // Display offset + CMD_START_LINE(0), // Start line + CMD_ADC_REVERSE(1), // Segment remap A0/A1 + CMD_OUT_MODE(1), // C0: scan dir normal, C8: reverse + CMD_COM_CONFIG(1), // Com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) + CMD_CONTRAST(0xCF), // [2] set contrast control + CMD_PAGE_ADR(0x02), // Page addressing mode + CMD_COLUMN_RANGE(0x281), // Set column range from 0 through 131 + CMD_PAGE_RANGE(0, 7), // Set page range from 0 through 7 + CMD_CHARGE_PER(0x1, 0xF), // [2] pre-charge period 0x22/F1 + CMD_VCOM_DESEL(0x40), // Vcomh deselect level + CMD_ALL_PIX(0), // Output ram to display + CMD_INVERTED(0), // Normal display mode + CMD_OSC_FREQ(0, 8), // Clock divide ratio (0:1) and oscillator frequency (8) + CMD_CHARGE_PUMP(1), // [2] charge pump setting (P62): 0x14 enable, 0x10 disable + CMD_SCROLL(0), // Deactivate scroll + CMD_ON(1), // Display ON }; uint8_t u8g_dev_sh1106_128x64_2x_2_wire_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { switch (msg) { case U8G_DEV_MSG_INIT: u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS); - u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_sh1106_128x64_init_seq_2_wire); + u8g_Write_Init_Sequence_2_wire(u8g, dev, COUNT(u8g_dev_sh1106_128x64_init_sequence_2_wire), u8g_dev_sh1106_128x64_init_sequence_2_wire); break; case U8G_DEV_MSG_STOP: break; case U8G_DEV_MSG_PAGE_NEXT: { u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); - u8g_SetAddress(u8g, dev, 0); // instruction mode + u8g_SetAddress(u8g, dev, 0); // Instruction mode u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_sh1106_128x64_data_start_2_wire); - u8g_WriteByte(u8g, dev, 0x0B0 | (pb->p.page*2)); // select current page - u8g_SetAddress(u8g, dev, 1); // data mode + u8g_WriteByte(u8g, dev, 0x0B0 | (pb->p.page*2)); // Select current page + u8g_SetAddress(u8g, dev, 1); // Data mode u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *) pb->buf); u8g_SetChipSelect(u8g, dev, 0); - u8g_SetAddress(u8g, dev, 0); // instruction mode + u8g_SetAddress(u8g, dev, 0); // Instruction mode u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_sh1106_128x64_data_start_2_wire); - u8g_WriteByte(u8g, dev, 0x0B0 | (pb->p.page*2+1)); // select current page - u8g_SetAddress(u8g, dev, 1); // data mode + u8g_WriteByte(u8g, dev, 0x0B0 | (pb->p.page*2+1)); // Select current page + u8g_SetAddress(u8g, dev, 1); // Data mode u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width); u8g_SetChipSelect(u8g, dev, 0); } break; case U8G_DEV_MSG_SLEEP_ON: - return 1; - case U8G_DEV_MSG_SLEEP_OFF: - return 1; + case U8G_DEV_MSG_SLEEP_OFF: return 1; } return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); } -uint8_t u8g_dev_sh1106_128x64_2x_i2c_2_wire_buf[WIDTH*2] U8G_NOCOMMON ; -u8g_pb_t u8g_dev_sh1106_128x64_2x_i2c_2_wire_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_i2c_2_wire_buf}; +uint8_t u8g_dev_sh1106_128x64_2x_i2c_2_wire_buf[WIDTH * 2] U8G_NOCOMMON; +u8g_pb_t u8g_dev_sh1106_128x64_2x_i2c_2_wire_pb = { { 16, HEIGHT, 0, 0, 0 }, WIDTH, u8g_dev_sh1106_128x64_2x_i2c_2_wire_buf }; u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c_2_wire = { u8g_dev_sh1106_128x64_2x_2_wire_fn, &u8g_dev_sh1106_128x64_2x_i2c_2_wire_pb, U8G_COM_SSD_I2C_HAL }; ///////////////////////////////////////////////////////////////////////////////////////////// static const uint8_t u8g_dev_ssd1306_128x64_data_start_2_wire[] PROGMEM = { - 0x010, // set upper 4 bit of the col adr to 0 - 0x000, // set lower 4 bit of the col adr to 0 - U8G_ESC_END // end of sequence + 0x10, // Set upper 4 bit of the col adr to 0 + 0x00, // Set lower 4 bit of the col adr to 0 + U8G_ESC_END // End of sequence }; -static const uint8_t u8g_dev_ssd1306_128x64_init_seq_2_wire[] PROGMEM = { - U8G_ESC_ADR(0), // initiate command mode - 0x0AE, // display off, sleep mode - 0x0A8, 0x03F, // mux ratio - 0x0D3, 0x00, // display offset - 0x040, // start line - 0x0A1, // segment remap a0/a1 - 0x0C8, // c0: scan dir normal, c8: reverse - 0x0DA, 0x012, // com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) - 0x081, 0x0CF, // [2] set contrast control - 0x020, 0x002, // 2012-05-27: page addressing mode - 0x21, 0, 0x7F, // set column range from 0 through 127 - 0x22, 0, 7, // set page range from 0 through 7 - 0x0D9, 0x0F1, // [2] pre-charge period 0x022/f1 - 0x0DB, 0x040, // vcomh deselect level - 0x0A4, // output ram to display - 0x0A6, // none inverted normal display mode - 0x0D5, 0x080, // clock divide ratio (0x00=1) and oscillator frequency (0x8) - 0x08D, 0x014, // [2] charge pump setting (p62): 0x014 enable, 0x010 disable - 0x02E, // 2012-05-27: Deactivate scroll - 0x0AF, // display on - U8G_ESC_END // end of sequence +static const uint8_t u8g_dev_ssd1306_128x64_init_sequence_2_wire[] PROGMEM = { + CMD_ON(0), // Display OFF, sleep mode + CMD_MUX_RATIO(0x3F), // Mux ratio + CMD_DISP_OFFS(0), // Display offset + CMD_START_LINE(0), // Start line + CMD_ADC_REVERSE(1), // Segment remap a0/a1 + CMD_OUT_MODE(1), // C0: scan dir normal, C8: reverse + CMD_COM_CONFIG(1), // Com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) + CMD_CONTRAST(0x80), // [2] set contrast control + CMD_PAGE_ADR(2), // Page addressing mode 2 + CMD_COLUMN_RANGE(0x07F), // Set column range from 0 through 127 + CMD_PAGE_RANGE(0, 7), // Set page range from 0 through 7 + CMD_CHARGE_PER(0x1, 0xF), // [2] pre-charge period 0x22/f1 + CMD_VCOM_DESEL(0x40), // Vcomh deselect level + CMD_ALL_PIX(0), // Output ram to display + CMD_INVERTED(0), // None inverted normal display mode + CMD_OSC_FREQ(0, 8), // Clock divide ratio (0x00=1) and oscillator frequency (0x08) + CMD_CHARGE_PUMP(1), // [2] charge pump setting (p62): 0x14 enable, 0x10 disable + CMD_SCROLL(0), // Deactivate scroll + CMD_ON(1) // Display ON }; uint8_t u8g_dev_ssd1306_128x64_2x_2_wire_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) { switch (msg) { case U8G_DEV_MSG_INIT: u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS); - u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_ssd1306_128x64_init_seq_2_wire); + u8g_Write_Init_Sequence_2_wire(u8g, dev, COUNT(u8g_dev_ssd1306_128x64_init_sequence_2_wire), u8g_dev_ssd1306_128x64_init_sequence_2_wire); break; case U8G_DEV_MSG_STOP: break; case U8G_DEV_MSG_PAGE_NEXT: { u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); - u8g_SetAddress(u8g, dev, 0); // instruction mode + u8g_SetAddress(u8g, dev, 0); // Instruction mode u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_ssd1306_128x64_data_start_2_wire); - u8g_WriteByte(u8g, dev, 0x0B0 | (pb->p.page*2)); // select current page - u8g_SetAddress(u8g, dev, 1); // data mode - u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *) pb->buf); + u8g_WriteByte(u8g, dev, 0x0B0 | (pb->p.page*2)); // Select current page + u8g_SetAddress(u8g, dev, 1); // Data mode + u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)pb->buf); u8g_SetChipSelect(u8g, dev, 0); - u8g_SetAddress(u8g, dev, 0); // instruction mode + u8g_SetAddress(u8g, dev, 0); // Instruction mode u8g_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_ssd1306_128x64_data_start_2_wire); - u8g_WriteByte(u8g, dev, 0x0B0 | (pb->p.page*2+1)); // select current page - u8g_SetAddress(u8g, dev, 1); // data mode + u8g_WriteByte(u8g, dev, 0x0B0 | (pb->p.page*2+1)); // Select current page + u8g_SetAddress(u8g, dev, 1); // Data mode u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width); u8g_SetChipSelect(u8g, dev, 0); } break; case U8G_DEV_MSG_SLEEP_ON: - return 1; - case U8G_DEV_MSG_SLEEP_OFF: - return 1; + case U8G_DEV_MSG_SLEEP_OFF: return 1; } return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg); } - -uint8_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire_buf[WIDTH*2] U8G_NOCOMMON ; -u8g_pb_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x64_2x_i2c_2_wire_buf}; +uint8_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire_buf[WIDTH * 2] U8G_NOCOMMON; +u8g_pb_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x64_2x_i2c_2_wire_buf }; u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire = { u8g_dev_ssd1306_128x64_2x_2_wire_fn, &u8g_dev_ssd1306_128x64_2x_i2c_2_wire_pb, U8G_COM_SSD_I2C_HAL }; - ///////////////////////////////////////////////////////////////////////////////////////////// -// This routine adds the instruction byte in between the command bytes. This makes the init -// sequences a lot easier to read. +// This routine adds the instruction byte in between the command bytes. +// This makes the init sequences a lot easier to read. -#define I2C_CMD_MODE 0x080 +#define I2C_CMD_MODE 0x80 uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq) { uint8_t is_escape = 0; for (;;) { uint8_t value = u8g_pgm_read(esc_seq); if (is_escape == 0) { - if (value != 255) { - if (u8g_WriteByte(u8g, dev, value) == 0 ) - return 0; - if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0 ) - return 0; + if (value != 0xFF) { + if (u8g_WriteByte(u8g, dev, value) == 0) return 0; + if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0) return 0; } else { is_escape = 1; } } else { - if (value == 255) { - if (u8g_WriteByte(u8g, dev, value) == 0 ) - return 0; - if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0 ) - return 0; + if (value == 0xFF) { + if (u8g_WriteByte(u8g, dev, value) == 0) return 0; + if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0) return 0; } - else if (value == 254) { + else if (value == 0xFE) { break; } - else if (value >= 0x0F0) { - /* not yet used, do nothing */ + else if (value >= 0xF0) { + // Not yet used, do nothing } - else if (value >= 0xE0 ) { + else if (value >= 0xE0) { u8g_SetAddress(u8g, dev, value & 0x0F); } else if (value >= 0xD0) { @@ -286,10 +272,10 @@ uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_s u8g_SetResetHigh(u8g, dev); u8g_Delay(value); } - else if (value >= 0xBE) { /* not yet implemented */ - /* u8g_SetVCC(u8g, dev, value & 0x01); */ + else if (value >= 0xBE) { // not yet implemented + //u8g_SetVCC(u8g, dev, value & 0x01); } - else if (value <= 127) { + else if (value <= 0x7F) { u8g_Delay(value); } is_escape = 0; @@ -299,4 +285,10 @@ uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_s return 1; } -#endif // HAS_MARLINUI_U8GLIB +uint8_t u8g_Write_Init_Sequence_2_wire(u8g_t *u8g, u8g_dev_t *dev, uint32_t length, const uint8_t *init_seq) { + u8g_SetAddress(u8g, dev, 0); // Instruction mode + u8g_WriteSequence(u8g, dev, length, (uint8_t*)init_seq); + return 1; +} + +#endif // HAS_U8GLIB_I2C_OLED diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp index 5d9ef627c985..8fc7a97893bd 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp @@ -1,3 +1,25 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 . + * + */ + /** * @file u8g_fontutf8.cpp * @brief font api for u8g lib diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.h b/Marlin/src/lcd/dogm/u8g_fontutf8.h index 281894509d6f..088808482b1e 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.h +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.h @@ -1,3 +1,26 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 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 + /** * @file fontutf8.h * @brief font api for u8g lib @@ -6,7 +29,6 @@ * @date 2015-02-19 * @copyright GPL/BSD */ -#pragma once #include #include "../utf8.h" diff --git a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp index 11cd7b14ba55..a9c28a8a6897 100644 --- a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp @@ -20,8 +20,8 @@ * */ -// NOTE - the HAL version of the rrd device uses a generic ST7920 device. -// See u8g_dev_st7920_128x64_HAL.cpp for the HAL version. +// NOTE - The HAL version of the RRD device uses a generic ST7920 device. +// See u8g_dev_st7920_128x64_HAL.cpp #include "../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp index 421d90bf7ffa..1d4c1857e09c 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/status_screen.cpp @@ -116,7 +116,7 @@ void StatusScreen::send_buffer(CommandProcessor &cmd, const void *data, uint16_t memcpy_P(block, ptr, nBytes); cmd.write((const void*)block, nBytes); cmd.execute(); - if(cmd.has_fault()) { + if (cmd.has_fault()) { SERIAL_ECHOLNPGM("Recovering from fault: "); cmd.reset(); delay(1000); diff --git a/Marlin/src/pins/esp32/pins_GODI_CONTROLLER_V1_0.h b/Marlin/src/pins/esp32/pins_GODI_CONTROLLER_V1_0.h index 6f8046988e37..7e46ff980bb9 100644 --- a/Marlin/src/pins/esp32/pins_GODI_CONTROLLER_V1_0.h +++ b/Marlin/src/pins/esp32/pins_GODI_CONTROLLER_V1_0.h @@ -130,12 +130,11 @@ // #if ANY(EDUTRONICS_12864OLED_SH1106, EDUTRONICS_12864OLED_SSD1306) - #define LCDSCREEN_NAME "EDUTRONICS 12864 OLED" #define BTN_EN2 1 #define BTN_EN1 3 #define BTN_ENC 0 #define BEEPER_PIN -1 #define KILL_PIN -1 - #define DOGLCD_SDA 21 // SDA - #define DOGLCD_SCL 22 // SCL + #define DOGLCD_SDA_PIN 21 // SDA + #define DOGLCD_SCL_PIN 22 // SCL #endif diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V53.h b/Marlin/src/pins/ramps/pins_ZRIB_V53.h index 85420bdec3f2..13467257e08b 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V53.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V53.h @@ -334,7 +334,6 @@ // #if ENABLED(ZONESTAR_12864LCD) - #define LCDSCREEN_NAME "ZONESTAR LCD12864" #define LCD_SDSS 16 #define LCD_PINS_RS 16 // ST7920 CS (LCD-4) #define LCD_PINS_EN 23 // ST7920 DAT LCD-R/W (LCD-5) @@ -345,7 +344,6 @@ #define BEEPER_PIN 37 #define KILL_PIN 35 #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define LCDSCREEN_NAME "Reprap LCD12864" // Use EXP1 & EXP2 connector #define LCD_PINS_RS 16 // ST7920 CS #define LCD_PINS_EN 17 // ST7920 DAT @@ -362,7 +360,6 @@ //================================================================================ #if ANY(ZONESTAR_12864OLED, ZONESTAR_12864OLED_SSD1306) - #define LCDSCREEN_NAME "ZONESTAR 12864OLED" #define LCD_SDSS 16 #define LCD_PINS_RS 23 // RESET Pull low for 1s to init #define LCD_PINS_DC 17 @@ -386,7 +383,6 @@ //================================================================================ #if ENABLED(ZONESTAR_LCD) - #define LCDSCREEN_NAME "LCD2004 ADCKEY" #define LCD_PINS_RS EXP1_04_PIN #define LCD_PINS_EN EXP1_03_PIN #define LCD_PINS_D4 EXP1_05_PIN diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index ade9c08aa045..125d6764e77e 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -190,7 +190,6 @@ // // LCD 128x64 // - #define LCDSCREEN_NAME "ZONESTAR_12864LCD" #define FORCE_SOFT_SPI //#define LCD_SDSS EXP1_03_PIN #define LCD_PINS_RS EXP1_03_PIN // ST7920 CS (LCD-4) @@ -205,7 +204,6 @@ // // OLED 128x64 // - #define LCDSCREEN_NAME "ZONESTAR 12864OLED" #define FORCE_SOFT_SPI #define LCD_PINS_RS EXP1_06_PIN #define LCD_PINS_DC EXP1_04_PIN diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index d67c0a341db5..14da3b43c5f3 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -310,8 +310,14 @@ #define LCD_BACKLIGHT_PIN -1 #define FORCE_SOFT_SPI + #elif ENABLED(ULTI_CONTROLLER) + + #define LCD_PINS_D6 EXP1_03_PIN + #define DOGLCD_SCL_PIN EXP1_07_PIN // I2C1 + #define DOGLCD_SDA_PIN EXP1_08_PIN // I2C1 + #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1 and MKS_LCD12864A/B are currently supported on the BIGTREE_SKR_E3_DIP." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, ULTI_CONTROLLER, MKS_MINI_12864, FYSETC_MINI_12864_2_1 and MKS_LCD12864A/B are currently supported on the BIGTREE_SKR_E3_DIP." #endif #endif // HAS_WIRED_LCD diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 49b6f25a47e6..648941c23e39 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -164,7 +164,7 @@ #define DOGLCD_SCK EXP1_06_PIN #define DOGLCD_MOSI EXP1_08_PIN - #if ANY(FYSETC_MINI_12864, U8GLIB_ST7920) + #if ANY(FYSETC_MINI_12864, IS_U8GLIB_ST7920) #define FORCE_SOFT_SPI #endif //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 diff --git a/Marlin/src/pins/stm32f1/pins_MD_D301.h b/Marlin/src/pins/stm32f1/pins_MD_D301.h index bcede1d4be9c..9cc22dc5d4d4 100644 --- a/Marlin/src/pins/stm32f1/pins_MD_D301.h +++ b/Marlin/src/pins/stm32f1/pins_MD_D301.h @@ -42,18 +42,13 @@ * #define SERIAL_PORT 3 * #define BAUDRATE 115200 * #define SERIAL_PORT_2 -1 -*/ + */ // // Servos // #define SERVO0_PIN PB0 -// -// Z Probe must be this pin -// -#define Z_MIN_PROBE_PIN PB1 - // // Limit Switches // @@ -61,13 +56,20 @@ #define X_MAX_PIN PF11 #define Y_MIN_PIN PF14 #define Y_MAX_PIN PF13 -#ifdef Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN - #define Z_MIN_PIN PB1 -#else - #define Z_MIN_PIN PG0 -#endif +#define Z_MIN_PIN PG0 #define Z_MAX_PIN PF15 +// +// Z Probe must be this pin +// +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PB1 +#endif + +#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #error "It's physically impossible to connect the Z Probe to the Z Min Endstop pin on this board." +#endif + // // Filament Sensor // diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h index 8ce0f48839de..4424da3513da 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E2_V1_0.h @@ -192,7 +192,6 @@ // 2 +5V // 1 GND - #define LCDSCREEN_NAME "ZONESTAR LCD12864" #define LCD_PINS_RS EXP1_03_PIN #define LCD_PINS_EN EXP1_06_PIN #define LCD_PINS_D4 EXP1_04_PIN @@ -220,7 +219,6 @@ // 3 RX3 PB11 KNOB_ENB #define FORCE_SOFT_SPI - #define LCDSCREEN_NAME "ZONESTAR 12864OLED" #define LCD_PINS_RS EXP1_06_PIN // = LCD_RESET_PIN #define LCD_PINS_DC EXP1_04_PIN // DC #define DOGLCD_CS EXP1_03_PIN // CS diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h index c1e5a46f70db..398cd430a082 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E4_V1_0.h @@ -280,7 +280,6 @@ // #if ENABLED(ZONESTAR_12864LCD) - #define LCDSCREEN_NAME "ZONESTAR LCD12864" #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! #define LCD_PINS_EN EXP1_06_PIN // 6 DATA make sure for zonestar zm3e4! #define LCD_PINS_D4 EXP1_04_PIN // 8 SCK make sure for zonestar zm3e4! @@ -290,7 +289,6 @@ #define BTN_EN2 EXP1_08_PIN #define BTN_ENC EXP1_07_PIN #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define LCDSCREEN_NAME "REPRAPDISCOUNT LCD12864" #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! #define LCD_PINS_EN EXP1_04_PIN // 6 DATA make sure for zonestar zm3e4! #define LCD_PINS_D4 EXP1_06_PIN // 8 SCK make sure for zonestar zm3e4! @@ -301,7 +299,6 @@ #define BTN_ENC EXP1_01_PIN #elif ENABLED(ZONESTAR_DWIN_LCD) // Connect to EXP2 connector - #define LCDSCREEN_NAME "ZONESTAR DWIN LCD" #define BEEPER_PIN EXP2_05_PIN #define KILL_PIN PC0 #define BTN_EN1 EXP2_08_PIN @@ -310,7 +307,6 @@ #endif #if ENABLED(ZONESTAR_LCD2004_KNOB) - #define LCDSCREEN_NAME "LCD2004 KNOB" #define LCD_PINS_RS EXP1_03_PIN #define LCD_PINS_EN EXP1_04_PIN #define LCD_PINS_D4 EXP1_06_PIN @@ -323,7 +319,6 @@ #define BEEPER_PIN EXP1_02_PIN #define KILL_PIN EXP2_07_PIN #elif ENABLED(ZONESTAR_LCD2004_ADCKEY) - #define LCDSCREEN_NAME "LCD2004 5KEY" #define LCD_PINS_RS EXP1_03_PIN #define LCD_PINS_EN EXP1_04_PIN #define LCD_PINS_D4 EXP1_06_PIN diff --git a/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h b/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h index 24c7404360f0..7852570fbfc2 100644 --- a/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_ZM3E4_V2_0.h @@ -276,7 +276,6 @@ #define WIFI_EN PC14 #if ENABLED(ZONESTAR_12864LCD) - #define LCDSCREEN_NAME "ZONESTAR LCD12864" #define LCD_PINS_RS EXP1_03_PIN // 7 CS make sure for zonestar zm3e4! #define LCD_PINS_EN EXP1_06_PIN // 6 DATA make sure for zonestar zm3e4! #define LCD_PINS_D4 EXP1_04_PIN // 8 SCK make sure for zonestar zm3e4! @@ -286,7 +285,6 @@ #define BTN_EN2 EXP1_08_PIN #define BTN_ENC EXP1_07_PIN #elif ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) - #define LCDSCREEN_NAME "REPRAPDISCOUNT LCD12864" #define LCD_PINS_RS EXP2_03_PIN // 7 CS make sure for zonestar zm3e4! #define LCD_PINS_EN EXP2_06_PIN // 6 DATA make sure for zonestar zm3e4! #define LCD_PINS_D4 EXP2_04_PIN // 8 SCK make sure for zonestar zm3e4! @@ -297,7 +295,6 @@ #define BTN_ENC EXP2_07_PIN #elif ENABLED(ZONESTAR_DWIN_LCD) // Connect to EXP2 connector - #define LCDSCREEN_NAME "ZONESTAR DWIN LCD" #define BEEPER_PIN EXP2_05_PIN // PE11 #define KILL_PIN -1 // EXP1_01_PIN #define BTN_EN2 EXP2_07_PIN // PE8 diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V30.h b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V30.h index 70a9bf9de20d..029892e5c149 100644 --- a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V30.h +++ b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V30.h @@ -304,7 +304,7 @@ #endif // HAS_WIRED_LCD // Alter timing for graphical display -#if ENABLED(U8GLIB_ST7920) +#if IS_U8GLIB_ST7920 #define BOARD_ST7920_DELAY_1 96 #define BOARD_ST7920_DELAY_2 48 #define BOARD_ST7920_DELAY_3 600 diff --git a/buildroot/tests/STM32F103RE_btt b/buildroot/tests/STM32F103RE_btt index 197ca775989a..4cfbc3fbb2f5 100755 --- a/buildroot/tests/STM32F103RE_btt +++ b/buildroot/tests/STM32F103RE_btt @@ -10,6 +10,7 @@ set -e # Build with the default configurations # restore_configs +opt_enable ULTI_CONTROLLER opt_set MOTHERBOARD BOARD_BTT_SKR_E3_DIP \ SERIAL_PORT 1 SERIAL_PORT_2 -1 \ X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2130 diff --git a/ini/features.ini b/ini/features.ini index 4baa2566f04d..a47679963ba0 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -26,7 +26,7 @@ HAS_T(RINAMIC_CONFIG|MC_SPI) = build_src_filter=+ SR_LCD_3W_NL = SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/6f53c19a8a.zip HAS_MOTOR_CURRENT_(I2C|DAC|SPI|PWM) = build_src_filter=+ -HAS_MOTOR_CURRENT_I2C = SlowSoftI2CMaster +HAS_MOTOR_CURRENT_I2C = felias-fogg/SlowSoftI2CMaster@^1.0.0 build_src_filter=+ HAS_TMC26X = TMC26XStepper=https://github.com/MarlinFirmware/TMC26XStepper/archive/a7d7c92a13.zip build_src_filter=+ @@ -49,7 +49,8 @@ HAS_SPI_TFT = build_src_filter=+ + + TFT_TOUCH_DEVICE_GT911 = build_src_filter=+ I2C_EEPROM = build_src_filter=+ -SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/f34d777f39.zip +SOFT_I2C_EEPROM|U8G_USES_SW_I2C = felias-fogg/SlowSoftI2CMaster@^1.0.0 + SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/f34d777f39.zip SPI_EEPROM = build_src_filter=+ HAS_DWIN_E3V2|IS_DWIN_MARLINUI = build_src_filter=+ DWIN_CREALITY_LCD = build_src_filter=+