My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ultralcd_st7920_u8glib_rrd_AVR.h 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. // NOTE - the HAL version of the rrd device uses a generic ST7920 device. See the
  24. // file u8g_dev_st7920_128x64_HAL.cpp for the HAL version.
  25. #include "../../inc/MarlinConfig.h"
  26. #include "../../HAL/shared/Delay.h"
  27. #define ST7920_CLK_PIN LCD_PINS_D4
  28. #define ST7920_DAT_PIN LCD_PINS_ENABLE
  29. #define ST7920_CS_PIN LCD_PINS_RS
  30. //#define PAGE_HEIGHT 8 // 128 byte framebuffer
  31. #define PAGE_HEIGHT 16 // 256 byte framebuffer
  32. //#define PAGE_HEIGHT 32 // 512 byte framebuffer
  33. #include <U8glib.h>
  34. // If you want you can define your own set of delays in Configuration.h
  35. //#define ST7920_DELAY_1 DELAY_NS(0)
  36. //#define ST7920_DELAY_2 DELAY_NS(0)
  37. //#define ST7920_DELAY_3 DELAY_NS(0)
  38. #if F_CPU >= 20000000
  39. #define CPU_ST7920_DELAY_1 DELAY_NS(0)
  40. #define CPU_ST7920_DELAY_2 DELAY_NS(0)
  41. #define CPU_ST7920_DELAY_3 DELAY_NS(50)
  42. #elif MB(3DRAG, K8200, K8400, SILVER_GATE)
  43. #define CPU_ST7920_DELAY_1 DELAY_NS(0)
  44. #define CPU_ST7920_DELAY_2 DELAY_NS(188)
  45. #define CPU_ST7920_DELAY_3 DELAY_NS(0)
  46. #elif MB(MINIRAMBO, EINSY_RAMBO, EINSY_RETRO)
  47. #define CPU_ST7920_DELAY_1 DELAY_NS(0)
  48. #define CPU_ST7920_DELAY_2 DELAY_NS(250)
  49. #define CPU_ST7920_DELAY_3 DELAY_NS(0)
  50. #elif MB(RAMBO)
  51. #define CPU_ST7920_DELAY_1 DELAY_NS(0)
  52. #define CPU_ST7920_DELAY_2 DELAY_NS(0)
  53. #define CPU_ST7920_DELAY_3 DELAY_NS(0)
  54. #elif MB(BQ_ZUM_MEGA_3D)
  55. #define CPU_ST7920_DELAY_1 DELAY_NS(0)
  56. #define CPU_ST7920_DELAY_2 DELAY_NS(0)
  57. #define CPU_ST7920_DELAY_3 DELAY_NS(189)
  58. #elif defined(ARDUINO_ARCH_STM32)
  59. #define CPU_ST7920_DELAY_1 DELAY_NS(300)
  60. #define CPU_ST7920_DELAY_2 DELAY_NS(40)
  61. #define CPU_ST7920_DELAY_3 DELAY_NS(340)
  62. #elif F_CPU == 16000000
  63. #define CPU_ST7920_DELAY_1 DELAY_NS(0)
  64. #define CPU_ST7920_DELAY_2 DELAY_NS(0)
  65. #define CPU_ST7920_DELAY_3 DELAY_NS(63)
  66. #else
  67. #error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'"
  68. #endif
  69. void ST7920_SWSPI_SND_8BIT(uint8_t val);
  70. #if DOGM_SPI_DELAY_US > 0
  71. #define U8G_DELAY() DELAY_US(DOGM_SPI_DELAY_US)
  72. #else
  73. #define U8G_DELAY() DELAY_US(10)
  74. #endif
  75. #define ST7920_CS() { WRITE(ST7920_CS_PIN,1); U8G_DELAY(); }
  76. #define ST7920_NCS() { WRITE(ST7920_CS_PIN,0); }
  77. #define ST7920_SET_CMD() { ST7920_SWSPI_SND_8BIT(0xF8); U8G_DELAY(); }
  78. #define ST7920_SET_DAT() { ST7920_SWSPI_SND_8BIT(0xFA); U8G_DELAY(); }
  79. #define ST7920_WRITE_BYTE(a) { ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xF0u)); ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u)); U8G_DELAY(); }
  80. #define ST7920_WRITE_BYTES(p,l) { for (uint8_t i = l + 1; --i;) { ST7920_SWSPI_SND_8BIT(*p&0xF0); ST7920_SWSPI_SND_8BIT(*p<<4); p++; } U8G_DELAY(); }