|
|
@ -23,9 +23,13 @@
|
|
|
|
// NOTE - the HAL version of the rrd device uses a generic ST7920 device. See the
|
|
|
|
// 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.
|
|
|
|
// file u8g_dev_st7920_128x64_HAL.cpp for the HAL version.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DOGLCD)
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef U8G_HAL_LINKS
|
|
|
|
#ifndef U8G_HAL_LINKS
|
|
|
|
|
|
|
|
|
|
|
|
#include "../../Marlin.h"
|
|
|
|
//#include "../../Marlin.h"
|
|
|
|
|
|
|
|
|
|
|
|
//#if ENABLED(U8GLIB_ST7920)
|
|
|
|
//#if ENABLED(U8GLIB_ST7920)
|
|
|
|
//#if ( ENABLED(SHARED_SPI) || !ENABLED(SHARED_SPI) && (defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0) && (defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0))
|
|
|
|
//#if ( ENABLED(SHARED_SPI) || !ENABLED(SHARED_SPI) && (defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0) && (defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0))
|
|
|
@ -97,18 +101,15 @@
|
|
|
|
#define U8G_DELAY() u8g_10MicroDelay()
|
|
|
|
#define U8G_DELAY() u8g_10MicroDelay()
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void ST7920_WRITE_BYTE(uint8_t val) {
|
|
|
|
static void ST7920_WRITE_BYTE(uint8_t val) {
|
|
|
|
for (uint8_t i = 0; i < 8; i++) {
|
|
|
|
for (uint8_t i = 0; i < 8; i++) {
|
|
|
|
WRITE(ST7920_DAT_PIN, val & 0x80);
|
|
|
|
WRITE(ST7920_DAT_PIN, val & 0x80);
|
|
|
|
WRITE(ST7920_CLK_PIN, HIGH);
|
|
|
|
WRITE(ST7920_CLK_PIN, HIGH);
|
|
|
|
WRITE(ST7920_CLK_PIN, LOW);
|
|
|
|
WRITE(ST7920_CLK_PIN, LOW);
|
|
|
|
val = val << 1;
|
|
|
|
val <<= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define ST7920_SET_CMD() { ST7920_WRITE_BYTE(0xF8); U8G_DELAY(); }
|
|
|
|
#define ST7920_SET_CMD() { ST7920_WRITE_BYTE(0xF8); U8G_DELAY(); }
|
|
|
|
#define ST7920_SET_DAT() { ST7920_WRITE_BYTE(0xFA); U8G_DELAY(); }
|
|
|
|
#define ST7920_SET_DAT() { ST7920_WRITE_BYTE(0xFA); U8G_DELAY(); }
|
|
|
|
#define ST7920_WRITE_NIBBLES(a) { ST7920_WRITE_BYTE((uint8_t)((a)&0xF0u)); ST7920_WRITE_BYTE((uint8_t)((a)<<4u)); U8G_DELAY(); }
|
|
|
|
#define ST7920_WRITE_NIBBLES(a) { ST7920_WRITE_BYTE((uint8_t)((a)&0xF0u)); ST7920_WRITE_BYTE((uint8_t)((a)<<4u)); U8G_DELAY(); }
|
|
|
@ -118,17 +119,13 @@ static void ST7920_WRITE_BYTE(uint8_t val) {
|
|
|
|
#define ST7920_CS() { WRITE(ST7920_CS_PIN,1); U8G_DELAY(); }
|
|
|
|
#define ST7920_CS() { WRITE(ST7920_CS_PIN,1); U8G_DELAY(); }
|
|
|
|
#define ST7920_NCS() { WRITE(ST7920_CS_PIN,0); }
|
|
|
|
#define ST7920_NCS() { WRITE(ST7920_CS_PIN,0); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
|
|
|
|
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
|
|
|
|
uint8_t i, y;
|
|
|
|
uint8_t i, y;
|
|
|
|
switch (msg) {
|
|
|
|
switch (msg) {
|
|
|
|
case U8G_DEV_MSG_INIT: {
|
|
|
|
case U8G_DEV_MSG_INIT: {
|
|
|
|
OUT_WRITE(ST7920_CS_PIN, LOW);
|
|
|
|
OUT_WRITE(ST7920_CS_PIN, LOW);
|
|
|
|
|
|
|
|
OUT_WRITE(ST7920_DAT_PIN, LOW);
|
|
|
|
|
|
|
|
OUT_WRITE(ST7920_CLK_PIN, LOW);
|
|
|
|
OUT_WRITE(ST7920_DAT_PIN, LOW);
|
|
|
|
|
|
|
|
OUT_WRITE(ST7920_CLK_PIN, LOW);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ST7920_CS();
|
|
|
|
ST7920_CS();
|
|
|
|
u8g_Delay(120); //initial delay for boot up
|
|
|
|
u8g_Delay(120); //initial delay for boot up
|
|
|
@ -197,4 +194,7 @@ u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g
|
|
|
|
|
|
|
|
|
|
|
|
//#endif //( ENABLED(SHARED_SPI) || !ENABLED(SHARED_SPI) && (defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0) && (defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0))
|
|
|
|
//#endif //( ENABLED(SHARED_SPI) || !ENABLED(SHARED_SPI) && (defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0) && (defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0))
|
|
|
|
//#endif // U8GLIB_ST7920
|
|
|
|
//#endif // U8GLIB_ST7920
|
|
|
|
#endif // AVR
|
|
|
|
|
|
|
|
|
|
|
|
#endif // U8G_HAL_LINKS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // DOGLCD
|
|
|
|