Added a light-weight status screen for the ST7920

- The status screen uses the ST7920 character generator to greatly
  reduce SPI traffic and MCU load when updating the status screen.

- Has been tested with the RepRapDiscount Full Graphics Smart Controller
  but should work with any LCD that uses an ST7920 or fully compatible
  controller.
2.0.x
Marcio Teixeira
parent d741bcf8a9
commit 4880ac6533

@ -1510,7 +1510,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1510,7 +1510,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1510,7 +1510,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1658,9 +1658,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// Note: Details on connecting to the Anet V1.0 controller are in the file pins_ANET_10.h
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1513,6 +1513,7 @@
//
//#define G3D_PANEL
//
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
@ -1521,6 +1522,18 @@
//
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic
// controller and SD support - http://reprap.org/wiki/Mini_panel

@ -1510,7 +1510,18 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1510,7 +1510,18 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1516,7 +1516,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1514,7 +1514,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1521,7 +1521,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1512,6 +1512,18 @@
//
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic
// controller and SD support - http://reprap.org/wiki/Mini_panel

@ -1513,7 +1513,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1541,7 +1541,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1495,7 +1495,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1510,7 +1510,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1543,7 +1543,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1510,7 +1510,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1504,7 +1504,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1634,7 +1634,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1524,7 +1524,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -1513,7 +1513,18 @@
// RepRapDiscount FULL GRAPHIC Smart Controller
// http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller
//
// If USE_ST7920_LIGHTWEIGHT_UI is uncommented, then an alternative
// light-weight status screen will be used that takes advantage of
// the ST7920 character-generator to conserve MCU resources.
//
// Since the lightweight status screen can only show a status
// message or the position, but not both, set DELAY_TO_SHOW_POSITION
// to the number of seconds until the position is revealed after a new
// status message is drawn.
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//#define USE_ST7920_LIGHTWEIGHT_UI
//#define DELAY_TO_SHOW_POSITION 20
//
// MakerLab Mini Panel with graphic

@ -119,10 +119,12 @@ uint8_t u8g_dev_rrd_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, vo
ST7920_CS();
u8g_Delay(120); //initial delay for boot up
ST7920_SET_CMD();
ST7920_WRITE_NIBBLES(0x20); //non-extended mode
ST7920_WRITE_NIBBLES(0x08); //display off, cursor+blink off
ST7920_WRITE_NIBBLES(0x01); //clear CGRAM ram
u8g_Delay(15); //delay for CGRAM clear
ST7920_WRITE_NIBBLES(0x3E); //extended mode + GDRAM active
ST7920_WRITE_NIBBLES(0x01); //clear DDRAM ram
u8g_Delay(15); //delay for DDRAM clear
ST7920_WRITE_NIBBLES(0x24); //extended mode
ST7920_WRITE_NIBBLES(0x26); //extended mode + GDRAM active
for (y = 0; y < (LCD_PIXEL_HEIGHT) / 2; y++) { //clear GDRAM
ST7920_WRITE_NIBBLES(0x80 | y); //set y
ST7920_WRITE_NIBBLES(0x80); //set x = 0
@ -178,6 +180,14 @@ 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(USE_ST7920_LIGHTWEIGHT_UI)
typedef const __FlashStringHelper *progmem_str;
// We have to include the code for the lightweight UI here
// as it relies on macros that are only defined in this file.
#include "ultralcd_impl_st7920_lite_status_screen_impl_spi.h"
#endif
#pragma GCC reset_options
#endif // U8G_HAL_LINKS

@ -5113,6 +5113,23 @@ void lcd_update() {
#endif
#if ENABLED(DOGLCD)
#if defined(USE_ST7920_LIGHTWEIGHT_UI)
#if ENABLED(ULTIPANEL)
bool do_U8G_loop = true;
lcd_in_status(currentScreen == lcd_status_screen);
if(currentScreen == lcd_status_screen) {
lcd_status_screen();
do_U8G_loop = false;
}
#else
const bool do_U8G_loop = false;
lcd_in_status(true);
lcd_status_screen();
#endif
#else
const bool do_U8G_loop = true;
#endif
if(do_U8G_loop) {
if (!drawing_screen) { // If not already drawing pages
u8g.firstPage(); // Start the first page
drawing_screen = 1; // Flag as drawing pages
@ -5128,6 +5145,7 @@ void lcd_update() {
NOLESS(max_display_update_time, millis() - ms);
return;
}
}
#else
CURRENTSCREEN();
#endif

@ -54,6 +54,11 @@
#include "dogm/dogm_bitmaps.h"
#if ENABLED(USE_ST7920_LIGHTWEIGHT_UI)
typedef const __FlashStringHelper *progmem_str;
#include "dogm/ultralcd_impl_st7920_lite_status_screen_impl.h"
#endif
#if ENABLED(SDSUPPORT)
#include "../libs/duration_t.h"
#endif
@ -373,6 +378,9 @@ static void lcd_implementation_init() {
// The kill screen is displayed for unrecoverable conditions
void lcd_kill_screen() {
#if ENABLED(USE_ST7920_LIGHTWEIGHT_UI)
ST7920_Lite_Status_Screen::clear_text_buffer();
#endif
const uint8_t h4 = u8g.getHeight() / 4;
u8g.firstPage();
do {
@ -498,6 +506,7 @@ inline void lcd_implementation_status_message(const bool blink) {
#endif
}
#if !ENABLED(USE_ST7920_LIGHTWEIGHT_UI)
static void lcd_implementation_status_screen() {
const bool blink = lcd_blink();
@ -803,6 +812,7 @@ static void lcd_implementation_status_screen() {
#endif
}
}
#endif
#if ENABLED(ULTIPANEL)

Loading…
Cancel
Save