diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 54f7cdbd4adbb..fbc33e1e49a40 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -270,10 +270,6 @@ #endif -#if ANY(FYSETC_MINI_12864, MKS_MINI_12864, ENDER2_STOCKDISPLAY) - #define IS_U8GLIB_MINI12864 1 -#endif - // ST7920-based graphical displays #if ANY(IS_RRD_FG_SC, LCD_FOR_MELZI, SILVER_GATE_GLCD_CONTROLLER) #define DOGLCD diff --git a/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h new file mode 100644 index 0000000000000..dc40aba046281 --- /dev/null +++ b/Marlin/src/lcd/dogm/HAL_LCD_class_defines.h @@ -0,0 +1,136 @@ +/** + * 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 + +#include "../../inc/MarlinConfig.h" + +// use this file to create the public interface for device drivers that are NOT in the U8G library + +extern u8g_dev_t u8g_dev_st7565_64128n_HAL_2x_sw_spi; +extern u8g_dev_t u8g_dev_st7565_64128n_HAL_2x_hw_spi; + +class U8GLIB_64128N_2X_HAL : public U8GLIB { +public: + U8GLIB_64128N_2X_HAL() : U8GLIB() { } + U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); + } + void init(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); + } +}; + +extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi; +extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_hw_spi; + +class U8GLIB_ST7920_128X64_4X_HAL : public U8GLIB { +public: + U8GLIB_ST7920_128X64_4X_HAL() : U8GLIB() { } + U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, reset); } + U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset=U8G_PIN_NONE) { init(cs, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE + } + void init(pin_t cs, pin_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_hw_spi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE + } +}; + +// +// AVR version uses ultralcd_st7920_u8glib_rrd_AVR.cpp +// HAL version uses u8g_dev_st7920_128x64_HAL.cpp +// +extern u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi; + +class U8GLIB_ST7920_128X64_RRD : public U8GLIB { +public: + U8GLIB_ST7920_128X64_RRD() : U8GLIB() { } + U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_st7920_128x64_rrd_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE + } +}; + +extern u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c_2_wire; + +class U8GLIB_SH1106_128X64_2X_I2C_2_WIRE : public U8GLIB { +public: + U8GLIB_SH1106_128X64_2X_I2C_2_WIRE() : U8GLIB() { } + U8GLIB_SH1106_128X64_2X_I2C_2_WIRE(uint8_t options) { init(options); } + void init(uint8_t options = U8G_I2C_OPT_NONE) { U8GLIB::init(&u8g_dev_sh1106_128x64_2x_i2c_2_wire, options); } +}; + +extern u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire; + +class U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE : public U8GLIB { +public: + U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE() : U8GLIB() { } + U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE(uint8_t options) { init(options); } + void init(uint8_t options = U8G_I2C_OPT_NONE) { U8GLIB::init(&u8g_dev_ssd1306_128x64_2x_i2c_2_wire, options); } +}; + +// +// Very basic support for 320x240 TFT screen +// Tested on MKS Robin TFT_V2.0 with ST7789V controller +// +extern u8g_dev_t u8g_dev_tft_320x240_upscale_from_128x64; + +class U8GLIB_TFT_320X240_UPSCALE_FROM_128X64 : public U8GLIB { +public: + U8GLIB_TFT_320X240_UPSCALE_FROM_128X64() : U8GLIB() { } + U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset=U8G_PIN_NONE) { init(cs, rs, reset); } + void init(uint8_t cs, uint8_t rs, uint8_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset); } +}; + + +extern u8g_dev_t u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, u8g_dev_uc1701_mini12864_HAL_2x_hw_spi; + +class U8GLIB_MINI12864_2X_HAL : public U8GLIB { +public: + U8GLIB_MINI12864_2X_HAL() : U8GLIB() { } + U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } + void init(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, sck, mosi, cs, a0, reset); + } + void init(uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset); + } +}; + +extern u8g_dev_t u8g_dev_ssd1309_sw_spi; +extern u8g_dev_t u8g_dev_ssd1309_hw_spi; + +class U8GLIB_SSD1309_128X64_HAL : public U8GLIB { +public: + U8GLIB_SSD1309_128X64_HAL() : U8GLIB() { } + U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } + U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } + void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); + } + void init(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { + U8GLIB::init(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); + } +}; diff --git a/Marlin/src/lcd/dogm/u8g/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h similarity index 100% rename from Marlin/src/lcd/dogm/u8g/HAL_LCD_com_defines.h rename to Marlin/src/lcd/dogm/HAL_LCD_com_defines.h diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.h b/Marlin/src/lcd/dogm/marlinui_DOGM.h index aca104460cf10..2af27d8de9c9e 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.h +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.h @@ -27,7 +27,8 @@ #include "../../inc/MarlinConfigPre.h" -#include "u8g/HAL_LCD_class_defines.h" +#include +#include "HAL_LCD_class_defines.h" //#define ALTERNATIVE_LCD diff --git a/Marlin/src/lcd/dogm/u8g/HAL_LCD_class_defines.h b/Marlin/src/lcd/dogm/u8g/HAL_LCD_class_defines.h deleted file mode 100644 index 967ce744e0321..0000000000000 --- a/Marlin/src/lcd/dogm/u8g/HAL_LCD_class_defines.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - * 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 - -#include "../../../inc/MarlinConfig.h" - -#include - -// Use this file to create the public interface for device drivers that are NOT in the U8G library - -#if IS_U8GLIB_ST7565_64128N - - extern u8g_dev_t u8g_dev_st7565_64128n_HAL_2x_sw_spi, u8g_dev_st7565_64128n_HAL_2x_hw_spi; - - class U8GLIB_64128N_2X_HAL : public U8GLIB { - public: - U8GLIB_64128N_2X_HAL() : U8GLIB() { } - U8GLIB_64128N_2X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } - U8GLIB_64128N_2X_HAL(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } - void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); - } - void init(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_st7565_64128n_HAL_2x_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); - } - }; - -#elif IS_U8GLIB_ST7920 - - extern u8g_dev_t u8g_dev_st7920_128x64_HAL_4x_sw_spi, u8g_dev_st7920_128x64_HAL_4x_hw_spi; - - class U8GLIB_ST7920_128X64_4X_HAL : public U8GLIB { - public: - U8GLIB_ST7920_128X64_4X_HAL() : U8GLIB() { } - U8GLIB_ST7920_128X64_4X_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, reset); } - U8GLIB_ST7920_128X64_4X_HAL(pin_t cs, pin_t reset=U8G_PIN_NONE) { init(cs, reset); } - void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE - } - void init(pin_t cs, pin_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_st7920_128x64_HAL_4x_hw_spi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE - } - }; - - // - // AVR version uses ultralcd_st7920_u8glib_rrd_AVR.cpp - // HAL version uses u8g_dev_st7920_128x64_HAL.cpp - // - extern u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi; - - class U8GLIB_ST7920_128X64_RRD : public U8GLIB { - public: - U8GLIB_ST7920_128X64_RRD() : U8GLIB() { } - U8GLIB_ST7920_128X64_RRD(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, reset); } - void init(pin_t sck, pin_t mosi, pin_t cs, pin_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_st7920_128x64_rrd_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, U8G_PIN_NONE, (uint8_t)reset); // a0 = U8G_PIN_NONE - } - }; - -#elif ENABLED(U8GLIB_SH1106) - - extern u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c_2_wire; - - class U8GLIB_SH1106_128X64_2X_I2C_2_WIRE : public U8GLIB { - public: - U8GLIB_SH1106_128X64_2X_I2C_2_WIRE() : U8GLIB() { } - U8GLIB_SH1106_128X64_2X_I2C_2_WIRE(uint8_t options) { init(options); } - void init(uint8_t options = U8G_I2C_OPT_NONE) { U8GLIB::init(&u8g_dev_sh1106_128x64_2x_i2c_2_wire, options); } - }; - -#elif ENABLED(U8GLIB_SSD1306) - - extern u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c_2_wire; - - class U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE : public U8GLIB { - public: - U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE() : U8GLIB() { } - U8GLIB_SSD1306_128X64_2X_I2C_2_WIRE(uint8_t options) { init(options); } - void init(uint8_t options = U8G_I2C_OPT_NONE) { U8GLIB::init(&u8g_dev_ssd1306_128x64_2x_i2c_2_wire, options); } - }; - -#elif TFT_SCALED_DOGLCD - - // - // Very basic support for 320x240 TFT screen - // Tested on MKS Robin TFT_V2.0 with ST7789V controller - // - extern u8g_dev_t u8g_dev_tft_320x240_upscale_from_128x64; - - class U8GLIB_TFT_320X240_UPSCALE_FROM_128X64 : public U8GLIB { - public: - U8GLIB_TFT_320X240_UPSCALE_FROM_128X64() : U8GLIB() { } - U8GLIB_TFT_320X240_UPSCALE_FROM_128X64(uint8_t cs, uint8_t rs, uint8_t reset=U8G_PIN_NONE) { init(cs, rs, reset); } - void init(uint8_t cs, uint8_t rs, uint8_t reset=U8G_PIN_NONE) { U8GLIB::init(&u8g_dev_tft_320x240_upscale_from_128x64, cs, rs, reset); } - }; - -#elif IS_U8GLIB_MINI12864 - - extern u8g_dev_t u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, u8g_dev_uc1701_mini12864_HAL_2x_hw_spi; - - class U8GLIB_MINI12864_2X_HAL : public U8GLIB { - public: - U8GLIB_MINI12864_2X_HAL() : U8GLIB() { } - U8GLIB_MINI12864_2X_HAL(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } - U8GLIB_MINI12864_2X_HAL(uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } - void init(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_sw_spi, sck, mosi, cs, a0, reset); - } - void init(uint8_t cs, uint8_t a0, uint8_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_uc1701_mini12864_HAL_2x_hw_spi, cs, a0, reset); - } - }; - -#elif ENABLED(U8GLIB_SSD1309) - - extern u8g_dev_t u8g_dev_ssd1309_sw_spi, u8g_dev_ssd1309_hw_spi; - - class U8GLIB_SSD1309_128X64_HAL : public U8GLIB { - public: - U8GLIB_SSD1309_128X64_HAL() : U8GLIB() { } - U8GLIB_SSD1309_128X64_HAL(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(sck, mosi, cs, a0, reset); } - U8GLIB_SSD1309_128X64_HAL(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { init(cs, a0, reset); } - void init(pin_t sck, pin_t mosi, pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_ssd1309_sw_spi, (uint8_t)sck, (uint8_t)mosi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); - } - void init(pin_t cs, pin_t a0, pin_t reset=U8G_PIN_NONE) { - U8GLIB::init(&u8g_dev_ssd1309_hw_spi, (uint8_t)cs, (uint8_t)a0, (uint8_t)reset); - } - }; - -#endif diff --git a/Marlin/src/lcd/dogm/u8g/u8g_dev_12864_i2c_util.cpp b/Marlin/src/lcd/dogm/u8g/u8g_dev_12864_i2c_util.cpp deleted file mode 100644 index bfab03bbef254..0000000000000 --- a/Marlin/src/lcd/dogm/u8g/u8g_dev_12864_i2c_util.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/** - * 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 . - * - */ - -/** - * For two wire I2C interfaces. - * - * Three and four wire I2C interfaces have an A0 line. That line is - * used to switch between command and data modes. - * - * The two wire LCDs use an instruction byte to signal if data or - * command info is to follow. The command stream needs the instruction - * byte between eack command byte. The data stream needs one at the - * beginning. - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if ANY(U8GLIB_SH1106, U8GLIB_SSD1306) - -#include "HAL_LCD_com_defines.h" - -// This routine adds the instruction byte between the command -// bytes to make the init sequences easier to read. - -#define I2C_CMD_MODE 0x80 - -uint8_t u8g_WriteEscSeqP_2_wire(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq) { - bool is_escape = false; - for (;;) { - uint8_t value = u8g_pgm_read(esc_seq); - if (!is_escape) { - if (value != 255) { - if (u8g_WriteByte(u8g, dev, value) == 0) return 0; - if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0) return 0; - } - else { - is_escape = true; - } - } - else { - if (value == 255) { - if (u8g_WriteByte(u8g, dev, value) == 0) return 0; - if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0) return 0; - } - else if (value == 0xFE) { - break; - } - else if (value >= 0xF0) { - // Not yet used, do nothing - } - else if (value >= 0xE0) { - u8g_SetAddress(u8g, dev, value & 0x0F); - } - else if (value >= 0xD0) { - u8g_SetChipSelect(u8g, dev, value & 0x0F); - } - else if (value >= 0xC0) { - u8g_SetResetLow(u8g, dev); - value &= 0x0F; - value <<= 4; - value+=2; - u8g_Delay(value); - u8g_SetResetHigh(u8g, dev); - u8g_Delay(value); - } - else if (value >= 0xBE) { // not yet implemented - //u8g_SetVCC(u8g, dev, value & 0x01); - } - else if (value <= 0x7F) { - u8g_Delay(value); - } - is_escape = false; - } - esc_seq++; - } - return 1; -} - -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 // U8GLIB_SH1106 || U8GLIB_SSD1306 diff --git a/Marlin/src/lcd/dogm/u8g/u8g_dev_sh1106_12864_i2c.cpp b/Marlin/src/lcd/dogm/u8g/u8g_dev_sh1106_12864_i2c.cpp deleted file mode 100644 index a29858ef6797d..0000000000000 --- a/Marlin/src/lcd/dogm/u8g/u8g_dev_sh1106_12864_i2c.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/** - * 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 . - * - */ - -/** - * Based on u8g_dev_ssd1306_128x64.c - * - * Universal 8bit Graphics Library - * - * Copyright (c) 2015, olikraus@gmail.com - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * For two wire I2C interfaces. - * - * Three and four wire I2C interfaces have an A0 line. That line is - * used to switch between command and data modes. - * - * The two wire LCDs use an instruction byte to signal if data or - * command info is to follow. The command stream needs the instruction - * byte between eack command byte. The data stream needs one at the - * beginning. - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if ENABLED(U8GLIB_SH1106) - -#include "HAL_LCD_com_defines.h" - -#define WIDTH 128 -#define HEIGHT 64 -#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); - -// SH1106 is compatible with SSD1306, but is 132x64, so -// the 128x64 display area is centered within the 132x64. - -#define SH1106_COL_ADR(N) (0x10 | ((N)>>4)), ((N) & 0x0F) -#define SH1106_PAGE_ADR(N) (0x20), (N) -#define SH1106_COLUMN_RANGE(N,O) (0x21), (N), (O) -#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_NOP() (0xE3) - -static const uint8_t u8g_dev_sh1106_128x64_data_start_2_wire[] PROGMEM = { - SH1106_COL_ADR(2), // Start at column 2 - U8G_ESC_END // End of sequence -}; - -static const uint8_t u8g_dev_sh1106_128x64_init_seq_2_wire[] PROGMEM = { - 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), // Page addressing mode - SH1106_COLUMN_RANGE(2, 129), // Set column range from 2 through 129 - 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), // Deactivate scroll - SH1106_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_Write_Init_Sequence_2_wire(u8g, dev, COUNT(u8g_dev_sh1106_128x64_init_seq_2_wire), u8g_dev_sh1106_128x64_init_seq_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_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_sh1106_128x64_data_start_2_wire); - u8g_WriteByte(u8g, dev, 0xB0 | (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_WriteEscSeqP_2_wire(u8g, dev, u8g_dev_sh1106_128x64_data_start_2_wire); - u8g_WriteByte(u8g, dev, 0xB0 | (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: - 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 }; -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 }; - -#endif // U8GLIB_SH1106 diff --git a/Marlin/src/lcd/dogm/u8g/u8g_dev_ssd1306_12864_i2c.cpp b/Marlin/src/lcd/dogm/u8g/u8g_dev_ssd1306_12864_i2c.cpp deleted file mode 100644 index 48eaa6a981487..0000000000000 --- a/Marlin/src/lcd/dogm/u8g/u8g_dev_ssd1306_12864_i2c.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/** - * 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 . - * - */ - -/** - * Based on u8g_dev_ssd1306_128x64.c - * - * Universal 8bit Graphics Library - * - * Copyright (c) 2015, olikraus@gmail.com - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, this - * list of conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * For two wire I2C interfaces. - * - * Three and four wire I2C interfaces have an A0 line. That line is - * used to switch between command and data modes. - * - * The two wire LCDs use an instruction byte to signal if data or - * command info is to follow. The command stream needs the instruction - * byte between eack command byte. The data stream needs one at the - * beginning. - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if ENABLED(U8GLIB_SSD1306) - -#include "HAL_LCD_com_defines.h" - -#define WIDTH 128 -#define HEIGHT 64 -#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); - -#define SSD1306_COL_ADR(N) (0x10 | ((N)>>4)), ((N) & 0x0F) -#define SSD1306_ADDR_MODE(N) (0x20), (N) -#define SSD1306_COLUMN_RANGE(N,O) (0x21), (N), (O) -#define SSD1306_PAGE_RANGE(N,O) (0x22), (N), (O) -#define SSD1306_SCROLL(N) ((N) ? 0x2F : 0x2E) -#define SSD1306_START_LINE(N) (0x40 | (N)) -#define SSD1306_CONTRAST(N) (0x81), (N) -#define SSD1306_CHARGE_PUMP(N) (0x8D), ((N) ? 0x14 : 0x10) -#define SSD1306_SEG_REMAP(N) ((N) ? 0xA1 : 0xA0) -#define SSD1306_ALL_PIX(N) ((N) ? 0xA5 : 0xA4) -#define SSD1306_INVERTED(N) ((N) ? 0xA7 : 0xA6) -#define SSD1306_MUX_RATIO(N) (0xA8), (N) -#define SSD1306_ON(N) ((N) ? 0xAF : 0xAE) -#define SSD1306_OUT_MODE(N) ((N) ? 0xC8 : 0xC0) -#define SSD1306_DISP_OFFS(N) (0xD3), (N) -#define SSD1306_OSC_FREQ(R,F) (0xD5), ((F) << 4 | (R)) -#define SSD1306_CHARGE_PER(P,D) (0xD9), ((D) << 4 | (P)) -#define SSD1306_COM_CONFIG(N) (0xDA), ((N) ? 0x12 : 0x02) -#define SSD1306_VCOM_DESEL(N) (0xDB), (N) -#define SSD1306_NOP() (0xE3) - -static const uint8_t u8g_dev_ssd1306_128x64_data_start_2_wire[] PROGMEM = { - SSD1306_COL_ADR(0), // Set the col adr to 0 - U8G_ESC_END // End of sequence -}; - -static const uint8_t u8g_dev_ssd1306_128x64_init_seq_2_wire[] PROGMEM = { - SSD1306_ON(0), // Display OFF, sleep mode - SSD1306_MUX_RATIO(0x3F), // Mux ratio - SSD1306_DISP_OFFS(0), // Display offset - SSD1306_START_LINE(0), // Start line - SSD1306_SEG_REMAP(1), // Segment remap A0/A1 - SSD1306_OUT_MODE(1), // C0: scan dir normal, C8: reverse - SSD1306_COM_CONFIG(1), // Com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) - SSD1306_CONTRAST(0xCF), // [2] Set contrast control - SSD1306_ADDR_MODE(2), // Page addressing mode - SSD1306_COLUMN_RANGE(0, 127), // Column range from 0 through 127 - SSD1306_PAGE_RANGE(0, 7), // Set page range from 0 through 7 - SSD1306_CHARGE_PER(0x1, 0xF), // [2] Pre-charge period 0x22/F1 - SSD1306_VCOM_DESEL(0x40), // Vcomh deselect level - SSD1306_ALL_PIX(0), // Output RAM to display - SSD1306_INVERTED(0), // None inverted normal display mode - SSD1306_OSC_FREQ(0, 8), // Clock divide ratio (0:1) and oscillator frequency (8) - SSD1306_CHARGE_PUMP(1), // [2] Charge pump setting (p62): 0x14 enable, 0x10 disable - SSD1306_SCROLL(0), // Deactivate scroll - SSD1306_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_Write_Init_Sequence_2_wire(u8g, dev, COUNT(u8g_dev_ssd1306_128x64_init_seq_2_wire), u8g_dev_ssd1306_128x64_init_seq_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_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_SetChipSelect(u8g, dev, 0); - 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_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width); - u8g_SetChipSelect(u8g, dev, 0); - } - break; - case U8G_DEV_MSG_SLEEP_ON: - 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 }; -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 }; - -#endif // U8GLIB_SSD1306 diff --git a/Marlin/src/lcd/dogm/u8g/u8g_dev_ssd1309_12864.cpp b/Marlin/src/lcd/dogm/u8g/u8g_dev_ssd1309_12864.cpp deleted file mode 100644 index 091a603244664..0000000000000 --- a/Marlin/src/lcd/dogm/u8g/u8g_dev_ssd1309_12864.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/** - * 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 . - * - */ - -#include "../../../inc/MarlinConfigPre.h" - -#if ENABLED(U8GLIB_SSD1309) - -#include "HAL_LCD_com_defines.h" -#include - -#define WIDTH 128 -#define HEIGHT 64 -#define PAGE_HEIGHT 8 - -#define SSD1309_COL_ADR(N) (0x10 | ((N)>>4)), ((N) & 0x0F) -#define SSD1309_ADDR_MODE(N) (0x20), (N) -#define SSD1309_COLUMN_RANGE(N,O) (0x21), (N), (O) -#define SSD1309_PAGE_RANGE(N,O) (0x22), (N), (O) -#define SSD1309_SCROLL(N) ((N) ? 0x2F : 0x2E) -#define SSD1309_START_LINE(N) (0x40 | (N)) -#define SSD1309_CONTRAST(N) (0x81), (N) -#define SSD1309_SEG_REMAP(N) ((N) ? 0xA1 : 0xA0) -#define SSD1309_ALL_PIX(N) ((N) ? 0xA5 : 0xA4) -#define SSD1309_INVERTED(N) ((N) ? 0xA7 : 0xA6) -#define SSD1309_MUX_RATIO(N) (0xA8), (N) -#define SSD1309_ON(N) ((N) ? 0xAF : 0xAE) -#define SSD1309_OUT_MODE(N) ((N) ? 0xC8 : 0xC0) -#define SSD1309_DISP_OFFS(N) (0xD3), (N) -#define SSD1309_OSC_FREQ(R,F) (0xD5), ((F) << 4 | (R)) -#define SSD1309_CHARGE_PER(P,D) (0xD9), ((D) << 4 | (P)) -#define SSD1309_COMMAND_LOCK() (0xFD), (0x12) -#define SSD1309_COM_CONFIG(N) (0xDA), ((N) ? 0x12 : 0x02) -#define SSD1309_VCOM_DESEL(N) (0xDB), (N) -#define SSD1309_NOP() (0xE3) - -// SSD1309 init sequence -static const uint8_t u8g_dev_ssd1309_128x64_init_seq[] PROGMEM = { - U8G_ESC_CS(0), // Disable chip - U8G_ESC_ADR(0), // Instruction mode - U8G_ESC_RST(1), // Do reset low pulse with (1*16)+2 milliseconds - U8G_ESC_CS(1), // Enable chip - - SSD1309_COMMAND_LOCK(), // Command Lock - SSD1309_ON(0), // Display OFF - SSD1309_OSC_FREQ(0, 10), // Clock divide ratio (0:1) and oscillator frequency (10) - SSD1309_MUX_RATIO(0x3F), // Multiplex Ratio - SSD1309_DISP_OFFS(0), // Display Offset - SSD1309_START_LINE(0), // Display Start Line - SSD1309_SEG_REMAP(1), // Segment Re-Map - SSD1309_OUT_MODE(1), // COM Output Scan Direction - SSD1309_COM_CONFIG(1), // COM Pins Hardware Configuration - SSD1309_CONTRAST(0xDF), // Current Control - SSD1309_CHARGE_PER(2, 8), // Pre-Charge Period - SSD1309_VCOM_DESEL(0x34), // VCOMH Deselect Level - SSD1309_ALL_PIX(0), // Entire Display On/Off - SSD1309_INVERTED(0), // Normal/Inverse Display - U8G_ESC_VCC(1), // Power up VCC & Stabilized - U8G_ESC_DLY(50), // Wait 50ms - SSD1309_ON(1), // Display ON - U8G_ESC_DLY(50), // Wait 50ms - U8G_ESC_CS(0), // Disable chip - U8G_ESC_END // End of sequence -}; - -static const uint8_t u8g_dev_ssd1309_128x64_data_start[] PROGMEM = { - U8G_ESC_ADR(0), // Instruction mode - U8G_ESC_CS(1), // Enable chip - SSD1309_COL_ADR(0), // Set the col adr to 0 - U8G_ESC_END // End of sequence -}; - -static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = { - U8G_ESC_ADR(0), // Instruction mode - U8G_ESC_CS(1), // Enable chip - SSD1309_ON(0), // Display OFF - U8G_ESC_CS(0), // Disable chip - U8G_ESC_END // End of sequence -}; - -static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = { - U8G_ESC_ADR(0), // Instruction mode - U8G_ESC_CS(1), // Enable chip - SSD1309_ON(1), // Display ON - U8G_ESC_DLY(50), // Delay 50 ms - U8G_ESC_CS(0), // Disable chip - U8G_ESC_END // End of sequence -}; - -uint8_t u8g_dev_ssd1309_128x64_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(u8g, dev, u8g_dev_ssd1309_128x64_init_seq); - break; - case U8G_DEV_MSG_STOP: - break; - case U8G_DEV_MSG_PAGE_NEXT: { - u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); - u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_data_start); - u8g_WriteByte(u8g, dev, 0xB0 | pb->p.page); // Select current page (SSD1309) - u8g_SetAddress(u8g, dev, 1); // Data mode - if (u8g_pb_WriteBuffer(pb, u8g, dev) == 0) return 0; - u8g_SetChipSelect(u8g, dev, 0); - } - break; - case U8G_DEV_MSG_CONTRAST: - u8g_SetChipSelect(u8g, dev, 1); - u8g_SetAddress(u8g, dev, 0); // Instruction mode - u8g_WriteByte(u8g, dev, 0x81); - u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); // 11 Jul 2015: fixed contrast calculation - u8g_SetChipSelect(u8g, dev, 0); - return 1; - case U8G_DEV_MSG_SLEEP_ON: - u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on); - return 1; - case U8G_DEV_MSG_SLEEP_OFF: - u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); - return 1; - } - return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); -} - -uint8_t u8g_dev_ssd1309_buf[WIDTH * 2] U8G_NOCOMMON; -u8g_pb_t u8g_dev_ssd1309_pb = { { 8, HEIGHT, 0, 0, 0 }, WIDTH, u8g_dev_ssd1309_buf }; -u8g_dev_t u8g_dev_ssd1309_sw_spi = { u8g_dev_ssd1309_128x64_fn, &u8g_dev_ssd1309_pb, U8G_COM_HAL_SW_SPI_FN }; - -#endif // U8GLIB_SSD1309 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 new file mode 100644 index 0000000000000..57336acca813d --- /dev/null +++ b/Marlin/src/lcd/dogm/u8g_dev_ssd1306_sh1106_128x64_I2C.cpp @@ -0,0 +1,299 @@ +/** + * 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 . + * + */ + +/** + * Based on u8g_dev_ssd1306_128x64.c + * + * Universal 8bit Graphics Library + * + * Copyright (c) 2015, olikraus@gmail.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list + * of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, this + * list of conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * These routines are meant for two wire I2C interfaces. + * + * Three and four wire I2C interfaces have an A0 line. That line is + * used to switch between command and data modes. + * + * The two wire LCDs use an instruction byte to signal if data or + * command info is to follow. The command stream needs the instruction + * byte between eack command byte. The data stream needs one at the + * beginning. + */ + +#include "../../inc/MarlinConfigPre.h" + +#if HAS_U8GLIB_I2C_OLED + +#include "HAL_LCD_com_defines.h" + +#define WIDTH 128 +#define HEIGHT 64 +#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. + +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 +}; + +#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) + +static const uint8_t u8g_dev_sh1106_128x64_init_sequence_2_wire[] PROGMEM = { + 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), // 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), // Deactivate scroll + SH1106_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_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_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_WriteSequence(u8g, dev, pb->width, (uint8_t *) pb->buf); + u8g_SetChipSelect(u8g, dev, 0); + 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_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width); + u8g_SetChipSelect(u8g, dev, 0); + } + break; + case U8G_DEV_MSG_SLEEP_ON: + 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 }; +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 = { + 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_sequence_2_wire[] PROGMEM = { + 0xAE, // Display OFF, sleep mode + 0xA8, 0x3F, // Mux ratio + 0xD3, 0x00, // Display offset + 0x40, // Start line + 0xA1, // Segment remap a0/a1 + 0xC8, // C0: scan dir normal, c8: reverse + 0xDA, 0x12, // Com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) + 0x81, 0x80, // [2] set contrast control + 0x20, 0x02, // Page addressing mode + 0x21, 0, 127, // Set column range from 0 through 127 + 0x22, 0, 7, // Set page range from 0 through 7 + 0xD9, 0xF1, // [2] pre-charge period 0x22/f1 + 0xDB, 0x40, // Vcomh deselect level + 0xA4, // Output ram to display + 0xA6, // None inverted normal display mode + 0xD5, 0x80, // Clock divide ratio (0x00=1) and oscillator frequency (0x08) + 0x8D, 0x14, // [2] charge pump setting (p62): 0x14 enable, 0x10 disable + 0x2E, // Deactivate scroll + 0xAF, // Display ON +}; + +#define LENGTH_SSD1306_SEQ_TOTAL sizeof(u8g_dev_ssd1306_128x64_init_sequence_2_wire) +#define LENGTH_SSD1306_SEQ_ELEMENT sizeof(u8g_dev_ssd1306_128x64_init_sequence_2_wire[0]) +#define LENGTH_SSD1306_SEQ LENGTH_SSD1306_SEQ_TOTAL/LENGTH_SSD1306_SEQ_ELEMENT // compile errors if combine these three into one line + +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_Write_Init_Sequence_2_wire(u8g, dev, LENGTH_SSD1306_SEQ, 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_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_SetChipSelect(u8g, dev, 0); + 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_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width); + u8g_SetChipSelect(u8g, dev, 0); + } + break; + case U8G_DEV_MSG_SLEEP_ON: + 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}; +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. + +#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 != 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 == 0xFF) { + if (u8g_WriteByte(u8g, dev, value) == 0) return 0; + if (u8g_WriteByte(u8g, dev, I2C_CMD_MODE) == 0) return 0; + } + else if (value == 0xFE) { + break; + } + else if (value >= 0xF0) { + // Not yet used, do nothing + } + else if (value >= 0xE0) { + u8g_SetAddress(u8g, dev, value & 0x0F); + } + else if (value >= 0xD0) { + u8g_SetChipSelect(u8g, dev, value & 0x0F); + } + else if (value >= 0xC0) { + u8g_SetResetLow(u8g, dev); + value &= 0x0F; + value <<= 4; + value+=2; + u8g_Delay(value); + u8g_SetResetHigh(u8g, dev); + u8g_Delay(value); + } + else if (value >= 0xBE) { // not yet implemented + //u8g_SetVCC(u8g, dev, value & 0x01); + } + else if (value <= 0x7F) { + u8g_Delay(value); + } + is_escape = 0; + } + esc_seq++; + } + return 1; +} + +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_dev_ssd1309_12864.cpp b/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp new file mode 100644 index 0000000000000..6d40ea0d4b477 --- /dev/null +++ b/Marlin/src/lcd/dogm/u8g_dev_ssd1309_12864.cpp @@ -0,0 +1,129 @@ +/** + * 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 . + * + */ + +#include "../../inc/MarlinConfigPre.h" + +#if HAS_MARLINUI_U8GLIB + +#include "HAL_LCD_com_defines.h" +#include + +#define WIDTH 128 +#define HEIGHT 64 +#define PAGE_HEIGHT 8 + +// SSD1309 init sequence +static const uint8_t u8g_dev_ssd1309_128x64_init_seq[] PROGMEM = { + U8G_ESC_CS(0), // Disable chip + U8G_ESC_ADR(0), // Instruction mode + U8G_ESC_RST(1), // Do reset low pulse with (1*16)+2 milliseconds + U8G_ESC_CS(1), // Enable chip + + 0xFD,0x12, // Command Lock + 0xAE, // Set Display Off + 0xD5,0xA0, // Set Display Clock Divide Ratio/Oscillator Frequency + 0xA8,0x3F, // Set Multiplex Ratio + 0x3D,0x00, // Set Display Offset + 0x40, // Set Display Start Line + 0xA1, // Set Segment Re-Map + 0xC8, // Set COM Output Scan Direction + 0xDA,0x12, // Set COM Pins Hardware Configuration + 0x81,0xDF, // Set Current Control + 0xD9,0x82, // Set Pre-Charge Period + 0xDB,0x34, // Set VCOMH Deselect Level + 0xA4, // Set Entire Display On/Off + 0xA6, // Set Normal/Inverse Display + U8G_ESC_VCC(1), // Power up VCC & Stabilized + U8G_ESC_DLY(50), + 0xAF, // Set Display On + U8G_ESC_DLY(50), + U8G_ESC_CS(0), // Disable chip + U8G_ESC_END // End of sequence +}; + +// Select one init sequence here +#define u8g_dev_ssd1309_128x64_init_seq u8g_dev_ssd1309_128x64_init_seq + +static const uint8_t u8g_dev_ssd1309_128x64_data_start[] PROGMEM = { + U8G_ESC_ADR(0), // Instruction mode + U8G_ESC_CS(1), // Enable chip + 0x010, // Set upper 4 bit of the col adr to 0 + 0x000, // Set lower 4 bit of the col adr to 4 + U8G_ESC_END // End of sequence +}; + +static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = { + U8G_ESC_ADR(0), // Instruction mode + U8G_ESC_CS(1), // Enable chip + 0x0AE, // Display off + U8G_ESC_CS(0), // Disable chip + U8G_ESC_END // End of sequence +}; + +static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = { + U8G_ESC_ADR(0), // Instruction mode + U8G_ESC_CS(1), // Enable chip + 0x0AF, // Display on + U8G_ESC_DLY(50), // Delay 50 ms + U8G_ESC_CS(0), // Disable chip + U8G_ESC_END // End of sequence +}; + +uint8_t u8g_dev_ssd1309_128x64_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(u8g, dev, u8g_dev_ssd1309_128x64_init_seq); + break; + case U8G_DEV_MSG_STOP: + break; + case U8G_DEV_MSG_PAGE_NEXT: { + u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem); + u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_data_start); + u8g_WriteByte(u8g, dev, 0x0B0 | pb->p.page); // Select current page (SSD1306) + u8g_SetAddress(u8g, dev, 1); // Data mode + if (u8g_pb_WriteBuffer(pb, u8g, dev) == 0) return 0; + u8g_SetChipSelect(u8g, dev, 0); + } + break; + case U8G_DEV_MSG_CONTRAST: + u8g_SetChipSelect(u8g, dev, 1); + u8g_SetAddress(u8g, dev, 0); // Instruction mode + u8g_WriteByte(u8g, dev, 0x081); + u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); // 11 Jul 2015: fixed contrast calculation + u8g_SetChipSelect(u8g, dev, 0); + return 1; + case U8G_DEV_MSG_SLEEP_ON: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on); + return 1; + case U8G_DEV_MSG_SLEEP_OFF: + u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off); + return 1; + } + return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg); +} + +uint8_t u8g_dev_ssd1309_buf[WIDTH*2] U8G_NOCOMMON ; +u8g_pb_t u8g_dev_ssd1309_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1309_buf}; +u8g_dev_t u8g_dev_ssd1309_sw_spi = { u8g_dev_ssd1309_128x64_fn, &u8g_dev_ssd1309_pb, U8G_COM_HAL_SW_SPI_FN }; + +#endif // HAS_MARLINUI_U8GLIB diff --git a/Marlin/src/lcd/dogm/u8g/u8g_dev_st7565_64128n_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp similarity index 99% rename from Marlin/src/lcd/dogm/u8g/u8g_dev_st7565_64128n_HAL.cpp rename to Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp index b95da2f3c433b..63e7b2e2b8b55 100644 --- a/Marlin/src/lcd/dogm/u8g/u8g_dev_st7565_64128n_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_st7565_64128n_HAL.cpp @@ -53,7 +53,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "../../../inc/MarlinConfig.h" +#include "../../inc/MarlinConfig.h" #if HAS_MARLINUI_U8GLIB diff --git a/Marlin/src/lcd/dogm/u8g/u8g_dev_st7920_128x64_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp similarity index 99% rename from Marlin/src/lcd/dogm/u8g/u8g_dev_st7920_128x64_HAL.cpp rename to Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp index d2cb2a5708462..ae1531e9f8df0 100644 --- a/Marlin/src/lcd/dogm/u8g/u8g_dev_st7920_128x64_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp @@ -53,7 +53,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "../../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfigPre.h" #if HAS_MARLINUI_U8GLIB && DISABLED(TFT_CLASSIC_UI) diff --git a/Marlin/src/lcd/dogm/u8g/u8g_dev_tft_upscale_from_128x64.cpp b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp similarity index 98% rename from Marlin/src/lcd/dogm/u8g/u8g_dev_tft_upscale_from_128x64.cpp rename to Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp index ae1b34092e376..c6aff38dc9b5d 100644 --- a/Marlin/src/lcd/dogm/u8g/u8g_dev_tft_upscale_from_128x64.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp @@ -53,12 +53,12 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "../../../inc/MarlinConfig.h" +#include "../../inc/MarlinConfig.h" #if HAS_MARLINUI_U8GLIB && (PIN_EXISTS(FSMC_CS) || HAS_SPI_GRAPHICAL_TFT || HAS_LTDC_GRAPHICAL_TFT) #include "HAL_LCD_com_defines.h" -#include "../marlinui_DOGM.h" +#include "marlinui_DOGM.h" #include @@ -66,7 +66,7 @@ #define HAS_LCD_IO 1 #endif -#include "../../tft_io/tft_io.h" +#include "../tft_io/tft_io.h" TFT_IO tftio; #define WIDTH LCD_PIXEL_WIDTH @@ -74,16 +74,16 @@ TFT_IO tftio; #define PAGE_HEIGHT 8 #if ENABLED(TOUCH_SCREEN_CALIBRATION) - #include "../../tft_io/touch_calibration.h" - #include "../../marlinui.h" + #include "../tft_io/touch_calibration.h" + #include "../marlinui.h" #endif #if HAS_TOUCH_BUTTONS && HAS_TOUCH_SLEEP #define HAS_TOUCH_BUTTONS_SLEEP 1 #endif -#include "../../touch/touch_buttons.h" -#include "../../scaled_tft.h" +#include "../touch/touch_buttons.h" +#include "../scaled_tft.h" #define X_HI (UPSCALE(TFT_PIXEL_OFFSET_X, WIDTH) - 1) #define Y_HI (UPSCALE(TFT_PIXEL_OFFSET_Y, HEIGHT) - 1) diff --git a/Marlin/src/lcd/dogm/u8g/u8g_dev_uc1701_mini12864_HAL.cpp b/Marlin/src/lcd/dogm/u8g_dev_uc1701_mini12864_HAL.cpp similarity index 99% rename from Marlin/src/lcd/dogm/u8g/u8g_dev_uc1701_mini12864_HAL.cpp rename to Marlin/src/lcd/dogm/u8g_dev_uc1701_mini12864_HAL.cpp index 95ae2810f2561..172afbd76647b 100644 --- a/Marlin/src/lcd/dogm/u8g/u8g_dev_uc1701_mini12864_HAL.cpp +++ b/Marlin/src/lcd/dogm/u8g_dev_uc1701_mini12864_HAL.cpp @@ -53,7 +53,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "../../../inc/MarlinConfigPre.h" +#include "../../inc/MarlinConfigPre.h" #if HAS_MARLINUI_U8GLIB diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 648941c23e398..49b6f25a47e6e 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, IS_U8GLIB_ST7920) + #if ANY(FYSETC_MINI_12864, U8GLIB_ST7920) #define FORCE_SOFT_SPI #endif //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 diff --git a/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V30.h b/Marlin/src/pins/stm32f4/pins_FYSETC_CHEETAH_V30.h index 029892e5c149d..70a9bf9de20dd 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 IS_U8GLIB_ST7920 +#if ENABLED(U8GLIB_ST7920) #define BOARD_ST7920_DELAY_1 96 #define BOARD_ST7920_DELAY_2 48 #define BOARD_ST7920_DELAY_3 600