Nol.A SDK Library 26.11.2
For IoT System Software Development
Loading...
Searching...
No Matches
ST7920 Class Reference

Buffered monochrome ST7920 SPI display. Call begin(), clearDisplay(), draw with Adafruit_GFX methods, then invalidate() to update the panel. More...

#include <ST7920.hpp>

Inheritance diagram for ST7920:
Adafruit_GFX Print KXM12864M_3

Public Member Functions

 ST7920 (uint16_t width, uint16_t height, SPI &, int8_t CS)
 Allocate a framebuffer and bind SPI/chip select.
bool begin (void)
 Configure SPI and GPIO.
void clearDisplay (void)
 Clear the framebuffer without sending it to the panel.
void invertDisplay (void)
 Toggle inversion and invert the framebuffer; call invalidate() to display it.
bool isInverted ()
 Return the current software inversion flag.
virtual void invalidate ()
 Send the entire framebuffer to the panel synchronously.
void drawPixel (int16_t x, int16_t y, uint16_t color)
 Set a buffered pixel at x/y; color 1 is black, 0 is white. Invalid coordinates and other color values are ignored.
void backlight ()
 Compatibility no-op; backlight control is not implemented.
void noBacklight ()
 Compatibility no-op; backlight control is not implemented.
void cursor ()
 Compatibility no-op; cursor control is not implemented.
void blink ()
 Compatibility no-op; blink control is not implemented.
Public Member Functions inherited from Adafruit_GFX
 Adafruit_GFX (int16_t w, int16_t h)
 Construct a graphics surface with native width w and height h in pixels. Coordinates use pixels from the upper-left corner; colors are interpreted by the concrete display. Subclasses must implement drawPixel().
virtual void writeFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 Write a vertical line of h pixels at x/y using color.
virtual void writeFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 Write a horizontal line of w pixels at x/y using color.
virtual void writeLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 Write a line between the inclusive endpoints (x0,y0) and (x1,y1).
virtual void setRotation (uint8_t r)
 Select orientation using the low two bits of r (0, 90, 180, or 270 degrees).
virtual void invertDisplay (boolean i)
 Request device inversion when i is true; the base implementation is a no-op.
virtual void drawFastVLine (int16_t x, int16_t y, int16_t h, uint16_t color)
 Draw a vertical line of h pixels at x/y with the current display orientation.
virtual void drawFastHLine (int16_t x, int16_t y, int16_t w, uint16_t color)
 Draw a horizontal line of w pixels at x/y with the current display orientation.
virtual void fillRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 Fill a rectangle at x/y of width w and height h in pixels.
virtual void fillScreen (uint16_t color)
 Fill the entire graphics surface with color.
virtual void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 Draw a line between the inclusive endpoints (x0,y0) and (x1,y1).
virtual void drawRect (int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 Draw the outline of a rectangle at x/y of width w and height h in pixels.
virtual size_t write (uint8_t)
 Render one character at the text cursor, honoring font, scale, wrapping, and colors.
void drawCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 Draw a circle outline centered at x0/y0 with radius r in pixels.
void drawCircleHelper (int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color)
 Draw selected circle quadrants; cornername is the four-bit quadrant mask.
void fillCircle (int16_t x0, int16_t y0, int16_t r, uint16_t color)
 Fill a circle centered at x0/y0 with radius r in pixels.
void fillCircleHelper (int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color)
 Fill selected circle sides; cornername selects sides and delta extends vertical spans.
void drawTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Draw a triangle outline through the three supplied pixel-coordinate vertices.
void fillTriangle (int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color)
 Fill a triangle through the three supplied pixel-coordinate vertices.
void drawRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
 Draw a rectangle outline at x0/y0 with pixel dimensions w/h and corner radius.
void fillRoundRect (int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color)
 Fill a rectangle at x0/y0 with pixel dimensions w/h and corner radius.
void drawBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)
 Draw a row-padded, MSB-first 1-bit bitmap of w by h pixels at x/y. Set bits use color; clear bits are transparent unless the bg overload is used.
void drawBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color, uint16_t bg)
 Draw a row-padded, MSB-first 1-bit bitmap of w by h pixels at x/y. Set bits use color; clear bits are transparent unless the bg overload is used.
void drawBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color)
 Draw a row-padded, MSB-first 1-bit bitmap of w by h pixels at x/y. Set bits use color; clear bits are transparent unless the bg overload is used.
void drawBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg)
 Draw a row-padded, MSB-first 1-bit bitmap of w by h pixels at x/y. Set bits use color; clear bits are transparent unless the bg overload is used.
void drawXBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h, uint16_t color)
 Draw an LSB-first XBM image of w by h pixels; zero bits are transparent.
void drawGrayscaleBitmap (int16_t x, int16_t y, const uint8_t bitmap[], int16_t w, int16_t h)
 Draw w by h bytes of grayscale pixels at x/y. Mask overloads use an MSB-first 1-bit mask; zero mask bits are transparent.
void drawGrayscaleBitmap (int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h)
 Draw w by h bytes of grayscale pixels at x/y. Mask overloads use an MSB-first 1-bit mask; zero mask bits are transparent.
void drawGrayscaleBitmap (int16_t x, int16_t y, const uint8_t bitmap[], const uint8_t mask[], int16_t w, int16_t h)
 Draw w by h bytes of grayscale pixels at x/y. Mask overloads use an MSB-first 1-bit mask; zero mask bits are transparent.
void drawGrayscaleBitmap (int16_t x, int16_t y, uint8_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
 Draw w by h bytes of grayscale pixels at x/y. Mask overloads use an MSB-first 1-bit mask; zero mask bits are transparent.
void drawRGBBitmap (int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h)
 Draw w by h RGB565 pixels at x/y. Mask overloads use an MSB-first 1-bit mask; zero mask bits are transparent.
void drawRGBBitmap (int16_t x, int16_t y, uint16_t *bitmap, int16_t w, int16_t h)
 Draw w by h RGB565 pixels at x/y. Mask overloads use an MSB-first 1-bit mask; zero mask bits are transparent.
void drawRGBBitmap (int16_t x, int16_t y, const uint16_t bitmap[], const uint8_t mask[], int16_t w, int16_t h)
 Draw w by h RGB565 pixels at x/y. Mask overloads use an MSB-first 1-bit mask; zero mask bits are transparent.
void drawRGBBitmap (int16_t x, int16_t y, uint16_t *bitmap, uint8_t *mask, int16_t w, int16_t h)
 Draw w by h RGB565 pixels at x/y. Mask overloads use an MSB-first 1-bit mask; zero mask bits are transparent.
void drawChar (int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
 Draw character c at x/y with foreground/background colors and integer pixel scale.
void setCursor (int16_t x, int16_t y)
 Set the text cursor in pixels; custom-font y coordinates refer to the baseline.
void setTextColor (uint16_t c)
 Set text foreground color; the two-argument overload also sets background. The one-argument overload uses transparent background for the classic font.
void setTextColor (uint16_t c, uint16_t bg)
 Set text foreground color; the two-argument overload also sets background. The one-argument overload uses transparent background for the classic font.
void setTextSize (uint8_t s)
 Set integer text magnification; zero is treated as one.
void setTextWrap (boolean w)
 Enable or disable automatic text wrapping at the right edge.
void cp437 (boolean x=true)
 Enable corrected CP437 character mapping; false retains the legacy mapping.
void setFont (const GFXfont *f=NULL)
 Select a borrowed GFXfont; nullptr restores the built-in fixed-width font.
int16_t height (void) const
 Return the surface height in pixels after rotation.
int16_t width (void) const
 Return the surface width in pixels after rotation.
uint8_t getRotation (void) const
 Return the current rotation index, 0 through 3.
int16_t getCursorX (void) const
 Return the text cursor X coordinate in pixels.
int16_t getCursorY (void) const
 Return the text cursor Y coordinate in pixels.
Public Member Functions inherited from Print
int getWriteError ()
void clearWriteError ()
size_t write (const char *str)
 문자열을 출력합니다.
virtual size_t write (const uint8_t *buffer, size_t size)
 데이터 배열을 출력합니다.
size_t write (const char *buffer, size_t size)
 데이터 배열을 출력합니다.
virtual int availableForWrite ()
size_t print (const __FlashStringHelper *)
 프로그램 메모리(읽기 전용 플래시) 영역에 저장된 문자열을 출력합니다.
size_t print (const std::string &)
 문자열을 출력합니다.
size_t print (const char[])
 NULL로 종료되는 문자열을 출력합니다.
size_t print (char)
 문자 하나를 출력합니다.
size_t print (unsigned char, int=DEC)
 부호가 없는(unsigned) 8-byte 정수를 지정한 진수 형태로 출력합니다.
size_t print (int, int=DEC)
 int 형 정수를 지정한 진수 형태로 출력합니다.
size_t print (unsigned int, int=DEC)
 unsigned int 형 정수를 지정한 진수 형태로 출력합니다.
size_t print (long, int=DEC)
 long 형 정수를 지정한 진수 형태로 출력합니다.
size_t print (unsigned long, int=DEC)
 unsigned long 형 정수를 지정한 진수 형태로 출력합니다.
size_t print (double, int=2)
 double 형 실수를 지정한 소수점 이하 출력 개수로 출력합니다.
size_t print (const Printable &)
 Printable을 구현한 클래스를 출력합니다.
size_t println (const __FlashStringHelper *)
 프로그램 메모리(읽기 전용 플래시) 영역에 저장된 문자열과 개행문자(CR+LF)를 출력합니다.
size_t println (const std::string &s)
 문자열과 개행문자(CR+LF)를 출력합니다.
size_t println (const char[])
 NULL로 종료되는 문자열과 개행문자(CR+LF)를 출력합니다.
size_t println (char)
 문자 하나와 개행문자(CR+LF)를 출력합니다.
size_t println (unsigned char, int=DEC)
 부호가 없는(unsigned) 8-byte 정수를 지정한 진수 형태로, 개행문자(CR+LF)와 함께 출력합니다.
size_t println (int, int=DEC)
 int 형 정수를 지정한 진수 형태로, 개행문자(CR+LF)와 함께 출력합니다.
size_t println (unsigned int, int=DEC)
 unsigned int 형 정수를 지정한 진수 형태로, 개행문자(CR+LF)와 함께 출력합니다.
size_t println (long, int=DEC)
 long 형 정수를 지정한 진수 형태로, 개행문자(CR+LF)와 함께 출력합니다.
size_t println (unsigned long, int=DEC)
 unsigned long 형 정수를 지정한 진수 형태로, 개행문자(CR+LF)와 함께 출력합니다.
size_t println (double, int=2)
 double 형 실수를 지정한 소수점 이하 출력 개수로, 개행문자(CR+LF)와 함께 출력합니다.
size_t println (const Printable &)
 Printable을 구현한 클래스를, 개행문자(CR+LF)와 함께 출력합니다.
size_t println (void)
 개행문자(CR+LF)를 출력합니다.
virtual int printf (const char *,...)
 printf 출력을 내보냅니다.
virtual void flush ()

Protected Member Functions

void ST7920Data (uint8_t data)
void ST7920Command (uint8_t data)
Protected Member Functions inherited from Adafruit_GFX
void charBounds (char c, int16_t *x, int16_t *y, int16_t *minx, int16_t *miny, int16_t *maxx, int16_t *maxy)
Protected Member Functions inherited from Print
void setWriteError (int err=1)

Protected Attributes

SPI & spi
int8_t cs
uint16_t * buff = nullptr
Protected Attributes inherited from Adafruit_GFX
const int16_t WIDTH
const int16_t HEIGHT
int16_t _width
int16_t _height
int16_t cursor_x
int16_t cursor_y
uint16_t textcolor
uint16_t textbgcolor
uint8_t textsize
uint8_t rotation
boolean wrap
boolean _cp437
const GFXfont * gfxFont

Detailed Description

Buffered monochrome ST7920 SPI display. Call begin(), clearDisplay(), draw with Adafruit_GFX methods, then invalidate() to update the panel.

Constructor & Destructor Documentation

◆ ST7920()

ST7920::ST7920 ( uint16_t width,
uint16_t height,
SPI & ,
int8_t CS )

Allocate a framebuffer and bind SPI/chip select.

Parameters
widthWidth in pixels; must be a multiple of 16.
heightHeight in pixels.
sSPI bus that must outlive the display.
CSActive-high chip-select GPIO.

Member Function Documentation

◆ begin()

bool ST7920::begin ( void )

Configure SPI and GPIO.

Returns
False if framebuffer allocation failed; true otherwise.

◆ drawPixel()

void ST7920::drawPixel ( int16_t x,
int16_t y,
uint16_t color )
virtual

Set a buffered pixel at x/y; color 1 is black, 0 is white. Invalid coordinates and other color values are ignored.

Implements Adafruit_GFX.

◆ invalidate()

virtual void ST7920::invalidate ( )
virtual

Send the entire framebuffer to the panel synchronously.

Reimplemented in KXM12864M_3.


The documentation for this class was generated from the following file: