From bd36644d85bef0ff02f701203365ce16c5db3dc0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 26 Dec 2023 17:52:46 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Move=20U8G?= =?UTF-8?q?=20defines=20to=20HALs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/u8g/LCD_defines.h | 29 ++++ Marlin/src/HAL/DUE/u8g/LCD_defines.h | 34 +++++ .../u8g_com_HAL_DUE_shared_hw_spi.cpp | 0 .../u8g_com_HAL_DUE_st7920_sw_spi.cpp | 0 .../{dogm => u8g}/u8g_com_HAL_DUE_sw_spi.cpp | 0 .../u8g_com_HAL_DUE_sw_spi_shared.cpp | 0 .../u8g_com_HAL_DUE_sw_spi_shared.h | 0 Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h | 4 + Marlin/src/HAL/ESP32/u8g/LCD_defines.h | 29 ++++ Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp | 8 +- Marlin/src/HAL/HC32/u8g/LCD_defines.h | 26 ++++ Marlin/src/HAL/LINUX/u8g/LCD_defines.h | 26 ++++ Marlin/src/HAL/LPC1768/Servo.h | 1 - Marlin/src/HAL/LPC1768/u8g/LCD_defines.h | 33 ++--- .../u8g/u8g_com_HAL_LPC1768_hw_spi.cpp | 1 - .../u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp | 1 - .../u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp | 1 - .../u8g/u8g_com_HAL_LPC1768_sw_spi.cpp | 8 +- Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h | 22 +-- .../NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp | 4 +- Marlin/src/HAL/SAMD21/u8g/LCD_defines.h | 14 +- Marlin/src/HAL/SAMD51/u8g/LCD_defines.h | 29 ++++ Marlin/src/HAL/STM32/u8g/LCD_defines.h | 32 +++++ .../STM32F1/dogm/u8g_com_stm32duino_swspi.cpp | 8 +- Marlin/src/HAL/STM32F1/u8g/LCD_defines.h | 34 +++++ Marlin/src/HAL/TEENSY31_32/u8g/LCD_defines.h | 26 ++++ Marlin/src/HAL/TEENSY35_36/u8g/LCD_defines.h | 26 ++++ Marlin/src/HAL/TEENSY40_41/u8g/LCD_defines.h | 26 ++++ Marlin/src/lcd/dogm/HAL_LCD_com_defines.h | 132 ++++-------------- .../dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp | 8 +- 30 files changed, 387 insertions(+), 175 deletions(-) create mode 100644 Marlin/src/HAL/AVR/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/DUE/u8g/LCD_defines.h rename Marlin/src/HAL/DUE/{dogm => u8g}/u8g_com_HAL_DUE_shared_hw_spi.cpp (100%) rename Marlin/src/HAL/DUE/{dogm => u8g}/u8g_com_HAL_DUE_st7920_sw_spi.cpp (100%) rename Marlin/src/HAL/DUE/{dogm => u8g}/u8g_com_HAL_DUE_sw_spi.cpp (100%) rename Marlin/src/HAL/DUE/{dogm => u8g}/u8g_com_HAL_DUE_sw_spi_shared.cpp (100%) rename Marlin/src/HAL/DUE/{dogm => u8g}/u8g_com_HAL_DUE_sw_spi_shared.h (100%) create mode 100644 Marlin/src/HAL/ESP32/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/HC32/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/LINUX/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/SAMD51/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/STM32/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/STM32F1/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/TEENSY31_32/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/TEENSY35_36/u8g/LCD_defines.h create mode 100644 Marlin/src/HAL/TEENSY40_41/u8g/LCD_defines.h diff --git a/Marlin/src/HAL/AVR/u8g/LCD_defines.h b/Marlin/src/HAL/AVR/u8g/LCD_defines.h new file mode 100644 index 0000000000..91858c0dbf --- /dev/null +++ b/Marlin/src/HAL/AVR/u8g/LCD_defines.h @@ -0,0 +1,29 @@ +/** + * 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 + +/** + * AVR LCD-specific defines + */ + +uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_AVR_sw_sp_fn diff --git a/Marlin/src/HAL/DUE/u8g/LCD_defines.h b/Marlin/src/HAL/DUE/u8g/LCD_defines.h new file mode 100644 index 0000000000..e85f13514f --- /dev/null +++ b/Marlin/src/HAL/DUE/u8g/LCD_defines.h @@ -0,0 +1,34 @@ +/** + * 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 + +/** + * DUE (SAM3X8E) LCD-specific defines + */ + +uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + +#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_DUE_sw_spi_fn +#define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_DUE_shared_hw_spi_fn +#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_DUE_ST7920_sw_spi_fn diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp b/Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_shared_hw_spi.cpp similarity index 100% rename from Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp rename to Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_shared_hw_spi.cpp diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp b/Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_st7920_sw_spi.cpp similarity index 100% rename from Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_st7920_sw_spi.cpp rename to Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_st7920_sw_spi.cpp diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp b/Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_sw_spi.cpp similarity index 100% rename from Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi.cpp rename to Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_sw_spi.cpp diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp b/Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_sw_spi_shared.cpp similarity index 100% rename from Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.cpp rename to Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_sw_spi_shared.cpp diff --git a/Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h b/Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_sw_spi_shared.h similarity index 100% rename from Marlin/src/HAL/DUE/dogm/u8g_com_HAL_DUE_sw_spi_shared.h rename to Marlin/src/HAL/DUE/u8g/u8g_com_HAL_DUE_sw_spi_shared.h diff --git a/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h b/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h index 5f1c4b1601..07d2efe0bd 100644 --- a/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h +++ b/Marlin/src/HAL/ESP32/inc/Conditionals_LCD.h @@ -20,3 +20,7 @@ * */ #pragma once + +#if ANY(MKS_MINI_12864, FYSETC_MINI_12864_2_1) + #define U8G_HW_SPI_ESP32 1 +#endif diff --git a/Marlin/src/HAL/ESP32/u8g/LCD_defines.h b/Marlin/src/HAL/ESP32/u8g/LCD_defines.h new file mode 100644 index 0000000000..3696d60d7c --- /dev/null +++ b/Marlin/src/HAL/ESP32/u8g/LCD_defines.h @@ -0,0 +1,29 @@ +/** + * 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 + +/** + * ESP32 LCD-specific defines + */ + +uint8_t u8g_esp32_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +#define U8G_COM_HAL_HW_SPI_FN u8g_esp32_hw_spi_fn diff --git a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp index 012604dbfb..a4c1980adc 100644 --- a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp +++ b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp @@ -25,7 +25,7 @@ #include "../../inc/MarlinConfig.h" -#if ANY(MKS_MINI_12864, FYSETC_MINI_12864_2_1) +#if U8G_HW_SPI_ESP32 #include #include "../shared/HAL_SPI.h" @@ -41,7 +41,6 @@ static SPISettings spiConfig; - #ifndef LCD_SPI_SPEED #ifdef SD_SPI_SPEED #define LCD_SPI_SPEED SD_SPI_SPEED // Assume SPI speed shared with SD @@ -50,7 +49,7 @@ static SPISettings spiConfig; #endif #endif -uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { +uint8_t u8g_esp32_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT #if ENABLED(PAUSE_LCD_FOR_BUSY_SD) @@ -101,6 +100,5 @@ uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_pt return 1; } -#endif // MKS_MINI_12864 || FYSETC_MINI_12864_2_1 - +#endif // U8G_HW_SPI_ESP32 #endif // ARDUINO_ARCH_ESP32 diff --git a/Marlin/src/HAL/HC32/u8g/LCD_defines.h b/Marlin/src/HAL/HC32/u8g/LCD_defines.h new file mode 100644 index 0000000000..8dc94bca7f --- /dev/null +++ b/Marlin/src/HAL/HC32/u8g/LCD_defines.h @@ -0,0 +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 + +/** + * HC32 LCD-specific defines + */ diff --git a/Marlin/src/HAL/LINUX/u8g/LCD_defines.h b/Marlin/src/HAL/LINUX/u8g/LCD_defines.h new file mode 100644 index 0000000000..6caa0240ca --- /dev/null +++ b/Marlin/src/HAL/LINUX/u8g/LCD_defines.h @@ -0,0 +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 + +/** + * Linux LCD-specific defines + */ diff --git a/Marlin/src/HAL/LPC1768/Servo.h b/Marlin/src/HAL/LPC1768/Servo.h index f02f503a67..221001c948 100644 --- a/Marlin/src/HAL/LPC1768/Servo.h +++ b/Marlin/src/HAL/LPC1768/Servo.h @@ -39,7 +39,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#pragma once /** * Based on "servo.h - Interrupt driven Servo library for Arduino using 16 bit timers - diff --git a/Marlin/src/HAL/LPC1768/u8g/LCD_defines.h b/Marlin/src/HAL/LPC1768/u8g/LCD_defines.h index d2260037b6..5b58f1223a 100644 --- a/Marlin/src/HAL/LPC1768/u8g/LCD_defines.h +++ b/Marlin/src/HAL/LPC1768/u8g/LCD_defines.h @@ -25,25 +25,22 @@ * LPC1768 LCD-specific defines */ -// The following are optional depending on the platform. +#ifndef U8G_HAL_LINKS -// definitions of HAL specific com and device drivers. -uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); -uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); -uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); -uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); -uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + #define U8G_COM_SSD_I2C_HAL u8g_com_arduino_ssd_i2c_fn // See U8glib-HAL +#else -// connect U8g com generic com names to the desired driver -#define U8G_COM_HW_SPI u8g_com_HAL_LPC1768_hw_spi_fn // use LPC1768 specific hardware SPI routine -#define U8G_COM_SW_SPI u8g_com_HAL_LPC1768_sw_spi_fn // use LPC1768 specific software SPI routine -#define U8G_COM_ST7920_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn -#define U8G_COM_ST7920_SW_SPI u8g_com_HAL_LPC1768_ST7920_sw_spi_fn -#define U8G_COM_SSD_I2C u8g_com_HAL_LPC1768_ssd_hw_i2c_fn + uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); + uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); -// let these default for now -#define U8G_COM_PARALLEL u8g_com_null_fn -#define U8G_COM_T6963 u8g_com_null_fn -#define U8G_COM_FAST_PARALLEL u8g_com_null_fn -#define U8G_COM_UC_I2C u8g_com_null_fn + #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_LPC1768_sw_spi_fn + #define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_LPC1768_hw_spi_fn + #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_LPC1768_ST7920_sw_spi_fn + #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn + #define U8G_COM_SSD_I2C_HAL u8g_com_HAL_LPC1768_ssd_hw_i2c_fn + +#endif diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp index 0118f92847..406fc4840c 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_hw_spi.cpp @@ -125,5 +125,4 @@ uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, } #endif // HAS_MARLINUI_U8GLIB - #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp index bf76eaf0f4..3dea365ac7 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp @@ -194,5 +194,4 @@ uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_v } #endif // HAS_MARLINUI_U8GLIB - #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp index ce7b338019..c029dc0680 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_st7920_hw_spi.cpp @@ -134,5 +134,4 @@ uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t ar } #endif // HAS_MARLINUI_U8GLIB - #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp index f6ed7b0e7e..4edd0d3886 100644 --- a/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp +++ b/Marlin/src/HAL/LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp @@ -131,7 +131,7 @@ uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck static uint8_t SPI_speed = 0; -static void u8g_sw_spi_HAL_LPC1768_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) { +static void u8g_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) { #if ANY(FYSETC_MINI_12864, MKS_MINI_12864) swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin); #else @@ -176,13 +176,13 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, break; case U8G_COM_MSG_WRITE_BYTE: - u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val); + u8g_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val); break; case U8G_COM_MSG_WRITE_SEQ: { uint8_t *ptr = (uint8_t *)arg_ptr; while (arg_val > 0) { - u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++); + u8g_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++); arg_val--; } } @@ -191,7 +191,7 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, case U8G_COM_MSG_WRITE_SEQ_P: { uint8_t *ptr = (uint8_t *)arg_ptr; while (arg_val > 0) { - u8g_sw_spi_HAL_LPC1768_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr)); + u8g_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr)); ptr++; arg_val--; } diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h index 2a50eddcd4..63701ca334 100644 --- a/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/LCD_defines.h @@ -21,22 +21,14 @@ */ #pragma once -void usleep(uint64_t microsec); -// The following are optional depending on the platform. +/** + * Native/Simulator LCD-specific defines + */ + +void usleep(uint64_t microsec); -// definitions of HAL specific com and device drivers. uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); -// connect U8g com generic com names to the desired driver -#define U8G_COM_SW_SPI u8g_com_sw_spi_fn -#define U8G_COM_ST7920_SW_SPI u8g_com_ST7920_sw_spi_fn - -// let these default for now -#define U8G_COM_HW_SPI u8g_com_null_fn -#define U8G_COM_ST7920_HW_SPI u8g_com_null_fn -#define U8G_COM_SSD_I2C u8g_com_null_fn -#define U8G_COM_PARALLEL u8g_com_null_fn -#define U8G_COM_T6963 u8g_com_null_fn -#define U8G_COM_FAST_PARALLEL u8g_com_null_fn -#define U8G_COM_UC_I2C u8g_com_null_fn +#define U8G_COM_HAL_SW_SPI_FN u8g_com_sw_spi_fn +#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_ST7920_sw_spi_fn diff --git a/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp index a3254774bf..46f2798afa 100644 --- a/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp +++ b/Marlin/src/HAL/NATIVE_SIM/u8g/u8g_com_st7920_sw_spi.cpp @@ -100,6 +100,7 @@ static void u8g_com_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) { swSpiTransfer(val & 0x0F0, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL); swSpiTransfer(val << 4, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL); } + #ifdef __cplusplus extern "C" { #endif @@ -128,7 +129,7 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void break; case U8G_COM_MSG_RESET: - if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); + if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val); break; case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */ @@ -163,6 +164,7 @@ uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void } return 1; } + #ifdef __cplusplus } #endif diff --git a/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h b/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h index fa98725d22..d6fe93117b 100644 --- a/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h +++ b/Marlin/src/HAL/SAMD21/u8g/LCD_defines.h @@ -19,23 +19,11 @@ * along with this program. If not, see . * */ - -/** - * SAMD21 HAL developed by Bart Meijer (brupje) - * Based on SAMD51 HAL by Giuliano Zaro (AKA GMagician) - */ #pragma once /** * SAMD21 LCD-specific defines */ -// The following are optional depending on the platform. - -// definitions of HAL specific com and device drivers. -uint8_t u8g_com_samd21_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - -// connect U8g com generic com names to the desired driver -#define U8G_COM_HW_SPI u8g_com_samd21_st7920_hw_spi_fn // use SAMD21 specific hardware SPI routine -#define U8G_COM_ST7920_HW_SPI u8g_com_samd21_st7920_hw_spi_fn +#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd21_st7920_hw_spi_fn diff --git a/Marlin/src/HAL/SAMD51/u8g/LCD_defines.h b/Marlin/src/HAL/SAMD51/u8g/LCD_defines.h new file mode 100644 index 0000000000..658a2c0fc1 --- /dev/null +++ b/Marlin/src/HAL/SAMD51/u8g/LCD_defines.h @@ -0,0 +1,29 @@ +/** + * 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 + +/** + * SAMD51 LCD-specific defines + */ + +#define U8G_COM_HAL_HW_SPI_FN u8g_com_samd51_hw_spi_fn // See U8glib-HAL +#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd51_st7920_hw_spi_fn // See U8glib-HAL diff --git a/Marlin/src/HAL/STM32/u8g/LCD_defines.h b/Marlin/src/HAL/STM32/u8g/LCD_defines.h new file mode 100644 index 0000000000..35f1674d69 --- /dev/null +++ b/Marlin/src/HAL/STM32/u8g/LCD_defines.h @@ -0,0 +1,32 @@ +/** + * 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 + +/** + * STM32 LCD-specific defines + */ + +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 + +#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 diff --git a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp b/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp index c57350aa2e..fc421897c4 100644 --- a/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp +++ b/Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_swspi.cpp @@ -88,7 +88,7 @@ static inline uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, c return b; } -static void u8g_sw_spi_HAL_STM32F1_shift_out(uint8_t val) { +static void u8g_sw_spi_shift_out(uint8_t val) { #if ENABLED(FYSETC_MINI_12864) swSpiTransfer_mode_3(val, SPI_speed); #else @@ -139,13 +139,13 @@ uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, break; case U8G_COM_MSG_WRITE_BYTE: - u8g_sw_spi_HAL_STM32F1_shift_out(arg_val); + u8g_sw_spi_shift_out(arg_val); break; case U8G_COM_MSG_WRITE_SEQ: { uint8_t *ptr = (uint8_t *)arg_ptr; while (arg_val > 0) { - u8g_sw_spi_HAL_STM32F1_shift_out(*ptr++); + u8g_sw_spi_shift_out(*ptr++); arg_val--; } } break; @@ -153,7 +153,7 @@ uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, case U8G_COM_MSG_WRITE_SEQ_P: { uint8_t *ptr = (uint8_t *)arg_ptr; while (arg_val > 0) { - u8g_sw_spi_HAL_STM32F1_shift_out(u8g_pgm_read(ptr)); + u8g_sw_spi_shift_out(u8g_pgm_read(ptr)); ptr++; arg_val--; } diff --git a/Marlin/src/HAL/STM32F1/u8g/LCD_defines.h b/Marlin/src/HAL/STM32F1/u8g/LCD_defines.h new file mode 100644 index 0000000000..4bd461cb39 --- /dev/null +++ b/Marlin/src/HAL/STM32F1/u8g/LCD_defines.h @@ -0,0 +1,34 @@ +/** + * 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 + +/** + * STM32F1 (Maple) LCD-specific defines + */ + +uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); // See U8glib-HAL + +#define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32F1_sw_spi_fn +#define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn // See U8glib-HAL +#define U8G_COM_ST7920_HAL_SW_SPI u8g_com_std_sw_spi_fn // See U8glib-HAL +#define U8G_COM_ST7920_HAL_HW_SPI u8g_com_stm32duino_hw_spi_fn // See U8glib-HAL diff --git a/Marlin/src/HAL/TEENSY31_32/u8g/LCD_defines.h b/Marlin/src/HAL/TEENSY31_32/u8g/LCD_defines.h new file mode 100644 index 0000000000..a13e7e837f --- /dev/null +++ b/Marlin/src/HAL/TEENSY31_32/u8g/LCD_defines.h @@ -0,0 +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 + +/** + * Teensy 3.1/3.2 LCD-specific defines + */ diff --git a/Marlin/src/HAL/TEENSY35_36/u8g/LCD_defines.h b/Marlin/src/HAL/TEENSY35_36/u8g/LCD_defines.h new file mode 100644 index 0000000000..511085781c --- /dev/null +++ b/Marlin/src/HAL/TEENSY35_36/u8g/LCD_defines.h @@ -0,0 +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 + +/** + * Teensy 3.5/3.6 LCD-specific defines + */ diff --git a/Marlin/src/HAL/TEENSY40_41/u8g/LCD_defines.h b/Marlin/src/HAL/TEENSY40_41/u8g/LCD_defines.h new file mode 100644 index 0000000000..349f8c0399 --- /dev/null +++ b/Marlin/src/HAL/TEENSY40_41/u8g/LCD_defines.h @@ -0,0 +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 + +/** + * Teensy 4.0/4.1 LCD-specific defines + */ diff --git a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h index 6df6413158..a70e2b7b8b 100644 --- a/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h +++ b/Marlin/src/lcd/dogm/HAL_LCD_com_defines.h @@ -21,117 +21,35 @@ */ #pragma once -// Use this file to select the com driver for device drivers that are NOT in the U8G library +/** + * Assign custom or standard U8G device drivers + */ #include -#ifndef U8G_HAL_LINKS // Defined by LPC1768/9 environments in platform.ini +#include HAL_PATH(../.., u8g/LCD_defines.h) - #ifdef __SAM3X8E__ - - uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_DUE_sw_spi_fn - #define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_DUE_shared_hw_spi_fn - #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_DUE_ST7920_sw_spi_fn - - #elif defined(__SAMD51__) - - #define U8G_COM_HAL_HW_SPI_FN u8g_com_samd51_hw_spi_fn - #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd51_st7920_hw_spi_fn - - #elif defined(__SAMD21__) - - uint8_t u8g_com_samd21_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_samd21_st7920_hw_spi_fn - - #elif defined(__STM32F1__) - - uint8_t u8g_com_HAL_STM32F1_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_stm32duino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_STM32F1_sw_spi_fn - #define U8G_COM_HAL_HW_SPI_FN u8g_com_stm32duino_hw_spi_fn - #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_std_sw_spi_fn - #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_stm32duino_hw_spi_fn - - #elif defined(ARDUINO_ARCH_STM32) - - uint8_t u8g_com_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_stm32duino_hw_spi_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 - - #elif defined(ESP32) - - uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_HW_SPI_FN u8g_eps_hw_spi_fn - - #elif defined(__AVR__) - - uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_AVR_sw_sp_fn - - #endif - - #ifndef U8G_COM_HAL_SW_SPI_FN - #define U8G_COM_HAL_SW_SPI_FN u8g_com_arduino_std_sw_spi_fn - #endif - #ifndef U8G_COM_HAL_HW_SPI_FN - #define U8G_COM_HAL_HW_SPI_FN u8g_com_arduino_hw_spi_fn - #endif - #ifndef U8G_COM_ST7920_HAL_SW_SPI - #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_arduino_st7920_spi_fn - #endif - #ifndef U8G_COM_ST7920_HAL_HW_SPI - #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_arduino_st7920_hw_spi_fn - #endif - - // This can't be invoked from the current platformio.ini - #ifdef TARGET_LPC1768 - uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #endif - - #define U8G_COM_SSD_I2C_HAL u8g_com_arduino_ssd_i2c_fn - -#elif defined(TARGET_LPC1768) - - uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_SW_SPI_FN u8g_com_HAL_LPC1768_sw_spi_fn - #define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_LPC1768_hw_spi_fn - #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_LPC1768_ST7920_sw_spi_fn - #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn - #define U8G_COM_SSD_I2C_HAL u8g_com_HAL_LPC1768_ssd_hw_i2c_fn - -#elif defined(__PLAT_NATIVE_SIM__) - uint8_t u8g_com_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_SW_SPI_FN u8g_com_sw_spi_fn - #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_ST7920_sw_spi_fn -#endif - -#ifndef U8G_COM_HAL_SW_SPI_FN - #define U8G_COM_HAL_SW_SPI_FN u8g_com_null_fn -#endif -#ifndef U8G_COM_HAL_HW_SPI_FN - #define U8G_COM_HAL_HW_SPI_FN u8g_com_null_fn -#endif -#ifndef U8G_COM_ST7920_HAL_SW_SPI - #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_null_fn -#endif -#ifndef U8G_COM_ST7920_HAL_HW_SPI - #define U8G_COM_ST7920_HAL_HW_SPI u8g_com_null_fn -#endif -#ifndef U8G_COM_SSD_I2C_HAL - #define U8G_COM_SSD_I2C_HAL u8g_com_null_fn -#endif #if HAS_FSMC_GRAPHICAL_TFT || HAS_SPI_GRAPHICAL_TFT || HAS_LTDC_GRAPHICAL_TFT uint8_t u8g_com_hal_tft_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - #define U8G_COM_HAL_TFT_FN u8g_com_hal_tft_fn -#else - #define U8G_COM_HAL_TFT_FN u8g_com_null_fn + #define U8G_COM_HAL_TFT_FN u8g_com_hal_tft_fn +#endif + +// U8G_HAL_LINKS is defined for LPC1768/9 and Native envs by -DU8G_HAL_LINKS in platform.ini +#ifndef U8G_COM_HAL_SW_SPI_FN + #define U8G_COM_HAL_SW_SPI_FN TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_std_sw_spi_fn) +#endif +#ifndef U8G_COM_HAL_HW_SPI_FN + #define U8G_COM_HAL_HW_SPI_FN TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_hw_spi_fn) +#endif +#ifndef U8G_COM_ST7920_HAL_SW_SPI + #define U8G_COM_ST7920_HAL_SW_SPI TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_st7920_spi_fn) +#endif +#ifndef U8G_COM_ST7920_HAL_HW_SPI + #define U8G_COM_ST7920_HAL_HW_SPI TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_st7920_hw_spi_fn) +#endif +#ifndef U8G_COM_SSD_I2C_HAL + #define U8G_COM_SSD_I2C_HAL TERN(U8G_HAL_LINKS, u8g_com_null_fn, u8g_com_arduino_ssd_i2c_fn) +#endif +#ifndef U8G_COM_HAL_TFT_FN + #define U8G_COM_HAL_TFT_FN u8g_com_null_fn #endif 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 e844eee251..11cd7b14ba 100644 --- a/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp +++ b/Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp @@ -20,12 +20,12 @@ * */ -// NOTE - the HAL version of the rrd device uses a generic ST7920 device. See the -// file 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 for the HAL version. #include "../../inc/MarlinConfigPre.h" -#if !defined(U8G_HAL_LINKS) && ANY(__AVR__, ARDUINO_ARCH_STM32, ARDUINO_ARCH_ESP32) +#if ANY(__AVR__, ARDUINO_ARCH_STM32, ARDUINO_ARCH_ESP32) #include "../../inc/MarlinConfig.h" @@ -193,4 +193,4 @@ u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = { u8g_dev_rrd_st7920_128x64_fn, &u8 #endif #endif // IS_U8GLIB_ST7920 -#endif // !U8G_HAL_LINKS && (__AVR__ || ARDUINO_ARCH_STM32 || ARDUINO_ARCH_ESP32) +#endif // __AVR__ || ARDUINO_ARCH_STM32 || ARDUINO_ARCH_ESP32