Group status methods, share reset_status with Extensible UI (#12414)
* Group status methods, share reset_status with Extensible UI * Move common DOGM code to headers
This commit is contained in:
@@ -27,60 +27,7 @@
|
||||
|
||||
#if ENABLED(U8GLIB_ST7920) && !defined(U8G_HAL_LINKS) && !defined(__SAM3X8E__)
|
||||
|
||||
#include "../../HAL/shared/Delay.h"
|
||||
|
||||
#define ST7920_CLK_PIN LCD_PINS_D4
|
||||
#define ST7920_DAT_PIN LCD_PINS_ENABLE
|
||||
#define ST7920_CS_PIN LCD_PINS_RS
|
||||
|
||||
//#define PAGE_HEIGHT 8 //128 byte framebuffer
|
||||
#define PAGE_HEIGHT 16 //256 byte framebuffer
|
||||
//#define PAGE_HEIGHT 32 //512 byte framebuffer
|
||||
|
||||
#define LCD_PIXEL_WIDTH 128
|
||||
#define LCD_PIXEL_HEIGHT 64
|
||||
|
||||
#include <U8glib.h>
|
||||
|
||||
//set optimization so ARDUINO optimizes this file
|
||||
#pragma GCC optimize (3)
|
||||
|
||||
// If you want you can define your own set of delays in Configuration.h
|
||||
//#define ST7920_DELAY_1 DELAY_NS(0)
|
||||
//#define ST7920_DELAY_2 DELAY_NS(0)
|
||||
//#define ST7920_DELAY_3 DELAY_NS(0)
|
||||
|
||||
#if F_CPU >= 20000000
|
||||
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_3 DELAY_NS(50)
|
||||
#elif MB(3DRAG) || MB(K8200) || MB(K8400) || MB(SILVER_GATE)
|
||||
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_2 DELAY_NS(188)
|
||||
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
|
||||
#elif MB(MINIRAMBO) || MB(EINSY_RAMBO) || MB(EINSY_RETRO)
|
||||
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_2 DELAY_NS(250)
|
||||
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
|
||||
#elif MB(RAMBO)
|
||||
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_3 DELAY_NS(0)
|
||||
#elif MB(BQ_ZUM_MEGA_3D)
|
||||
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_3 DELAY_NS(189)
|
||||
#elif defined(ARDUINO_ARCH_STM32)
|
||||
#define CPU_ST7920_DELAY_1 DELAY_NS(300)
|
||||
#define CPU_ST7920_DELAY_2 DELAY_NS(40)
|
||||
#define CPU_ST7920_DELAY_3 DELAY_NS(340)
|
||||
#elif F_CPU == 16000000
|
||||
#define CPU_ST7920_DELAY_1 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_2 DELAY_NS(0)
|
||||
#define CPU_ST7920_DELAY_3 DELAY_NS(63)
|
||||
#else
|
||||
#error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'"
|
||||
#endif
|
||||
#include "ultralcd_st7920_u8glib_rrd_AVR.h"
|
||||
|
||||
#ifndef ST7920_DELAY_1
|
||||
#define ST7920_DELAY_1 CPU_ST7920_DELAY_1
|
||||
@@ -92,13 +39,19 @@
|
||||
#define ST7920_DELAY_3 CPU_ST7920_DELAY_3
|
||||
#endif
|
||||
|
||||
// Optimize this code with -O3
|
||||
#pragma GCC optimize (3)
|
||||
|
||||
#define ST7920_SND_BIT \
|
||||
WRITE(ST7920_CLK_PIN, LOW); ST7920_DELAY_1; \
|
||||
WRITE(ST7920_DAT_PIN, val & 0x80); ST7920_DELAY_2; \
|
||||
WRITE(ST7920_CLK_PIN, HIGH); ST7920_DELAY_3; \
|
||||
val <<= 1
|
||||
|
||||
static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
|
||||
// Optimize this code with -O3
|
||||
#pragma GCC optimize (3)
|
||||
|
||||
void ST7920_SWSPI_SND_8BIT(uint8_t val) {
|
||||
ST7920_SND_BIT; // 1
|
||||
ST7920_SND_BIT; // 2
|
||||
ST7920_SND_BIT; // 3
|
||||
@@ -109,19 +62,6 @@ static void ST7920_SWSPI_SND_8BIT(uint8_t val) {
|
||||
ST7920_SND_BIT; // 8
|
||||
}
|
||||
|
||||
#if DOGM_SPI_DELAY_US > 0
|
||||
#define U8G_DELAY() DELAY_US(DOGM_SPI_DELAY_US)
|
||||
#else
|
||||
#define U8G_DELAY() DELAY_US(10)
|
||||
#endif
|
||||
|
||||
#define ST7920_CS() { WRITE(ST7920_CS_PIN,1); U8G_DELAY(); }
|
||||
#define ST7920_NCS() { WRITE(ST7920_CS_PIN,0); }
|
||||
#define ST7920_SET_CMD() { ST7920_SWSPI_SND_8BIT(0xF8); U8G_DELAY(); }
|
||||
#define ST7920_SET_DAT() { ST7920_SWSPI_SND_8BIT(0xFA); U8G_DELAY(); }
|
||||
#define ST7920_WRITE_BYTE(a) { ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xF0u)); ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4u)); U8G_DELAY(); }
|
||||
#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(); }
|
||||
|
||||
uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
|
||||
uint8_t i, y;
|
||||
switch (msg) {
|
||||
@@ -192,12 +132,6 @@ uint8_t u8g_dev_st7920_128x64_rrd_buf[(LCD_PIXEL_WIDTH) * (PAGE_HEIGHT) / 8] U
|
||||
u8g_pb_t u8g_dev_st7920_128x64_rrd_pb = {{PAGE_HEIGHT, LCD_PIXEL_HEIGHT, 0, 0, 0}, LCD_PIXEL_WIDTH, u8g_dev_st7920_128x64_rrd_buf};
|
||||
u8g_dev_t u8g_dev_st7920_128x64_rrd_sw_spi = {u8g_dev_rrd_st7920_128x64_fn, &u8g_dev_st7920_128x64_rrd_pb, &u8g_com_null_fn};
|
||||
|
||||
#if ENABLED(LIGHTWEIGHT_UI)
|
||||
// We have to include the code for the lightweight UI here
|
||||
// as it relies on macros that are only defined in this file.
|
||||
#include "status_screen_lite_ST7920_spi.h"
|
||||
#endif
|
||||
|
||||
#pragma GCC reset_options
|
||||
|
||||
#endif // U8GLIB_ST7920 && !U8G_HAL_LINKS && !__SAM3X8E__
|
||||
|
||||
Reference in New Issue
Block a user