COSA
An Object-Oriented Platform for Arduino Programming
ST7565 Class Reference

#include <ST7565.hh>

Inheritance diagram for ST7565:
Inheritance graph
Collaboration diagram for ST7565:
Collaboration graph

Public Types

enum  TextMode { NORMAL_TEXT_MODE = 0x00, INVERTED_TEXT_MODE = 0xff }
 

Public Member Functions

 ST7565 (LCD::IO *io, Board::DigitalPin dc=Board::D8, Font *font=&system5x7)
 
virtual bool begin ()
 
virtual bool end ()
 
virtual void display_contrast (uint8_t level)
 
virtual void display_on ()
 
virtual void display_off ()
 
virtual void display_normal ()
 
virtual void display_inverse ()
 
virtual void display_clear ()
 
virtual void set_cursor (uint8_t x, uint8_t y)
 
Fontget_text_font () const
 
Fontset_text_font (Font *font)
 
void draw_icon (const uint8_t *bp)
 
void draw_bitmap (uint8_t *bp, uint8_t width, uint8_t height)
 
void draw_bar (uint8_t percent, uint8_t width, uint8_t pattern=0x55)
 
virtual int putchar (char c)
 
virtual void backlight_on ()
 
virtual void backlight_off ()
 
void get_cursor (uint8_t &x, uint8_t &y) const
 
uint8_t get_tab_step () const
 
void set_tab_step (uint8_t step)
 
TextMode text_mode (TextMode mode)
 
void non_blocking ()
 
void blocking ()
 
bool is_blocking () const
 
void eol (Mode mode)
 
Mode eol () const
 
virtual int available ()
 
virtual int room ()
 
virtual int puts (const char *s)
 
virtual int puts (str_P s)
 
virtual int write (const void *buf, size_t size)
 
virtual int write (const iovec_t *vec)
 
virtual int write_P (const void *buf, size_t size)
 
virtual int peekchar ()
 
virtual int peekchar (char c)
 
virtual int getchar ()
 
virtual char * gets (char *s, size_t count)
 
virtual int read (void *buf, size_t size)
 
virtual int read (iovec_t *vec)
 
virtual int flush ()
 
virtual void empty ()
 

Static Public Attributes

static const uint8_t WIDTH = 128
 
static const uint8_t HEIGHT = 64
 
static const uint8_t LINES = 8
 

Protected Types

enum  {
  DISPLAY_OFF = 0xAE, DISPLAY_ON = 0xAF, SET_DISPLAY_START = 0x40, DISPLAY_START_MASK = 0x3f,
  SET_Y_ADDR = 0xB0, Y_ADDR_MASK = 0x0f, SET_X_ADDR = 0x10, X_ADDR_MASK = 0x0f,
  ADC_NORMAL = 0xA0, ADC_REVERSE = 0xA1, DISPLAY_NORMAL = 0xA6, DISPLAY_REVERSE = 0xA7,
  DISPLAY_64X128_POINTS = 0xA4, DISPLAY_65X132_POINTS = 0xA5, LCD_BIAS_9 = 0xA2, LCD_BIAS_7 = 0xA3,
  X_ADDR_INC = 0xE0, X_ADDR_CLEAR = 0xEE, INTERNAL_RESET = 0xE2, COM_OUTPUT_NORMAL = 0xC0,
  COM_OUTPUT_REVERSE = 0xC8, SET_POWER_CONTROL = 0x28, POWER_MASK = 0x07, SET_RESISTOR_RATIO = 0x20,
  RESISTOR_MASK = 0x07, SET_CONSTRAST = 0x81, CONSTRAST_MASK = 0x3f, INDICATOR_OFF = 0xAC,
  INDICATOR_ON = 0xAD, FLASHING_OFF = 0x00, FLASHING_ON = 0x01, SET_BOOSTER_RATIO = 0xF8,
  BOOSTER_RATIO_234X = 0, BOOSTER_RATIO_5X = 1, BOOSTER_RATIO_6X = 3, NOP = 0xE3,
  SCRIPT_PAUSE = 0xF0, SCRIPT_END = 0xFF
}
 

Protected Member Functions

void set (uint8_t cmd)
 
void set (uint8_t x, uint8_t y)
 
void fill (uint8_t data, uint16_t count)
 

Protected Attributes

LCD::IOm_io
 Display adapter. More...
 
OutputPin m_dc
 Data(1) or command(0). More...
 
uint8_t m_line
 Display start line. More...
 
Fontm_font
 Font. More...
 
uint8_t m_x
 Cursor position x. More...
 
uint8_t m_y
 Cursor position y. More...
 
uint8_t m_tab
 Tab step. More...
 
uint8_t m_mode
 Text mode. More...
 
bool m_blocking
 
Mode m_eol
 

Static Protected Attributes

static const uint8_t script []
 

Detailed Description

ST7565 64x128 pixels matrix LCD controller/driver, device driver for IOStream/LCD access. Binding to trace, etc. Support natural text scroll, cursor, and handling of special characters such as carriage-return, form-feed, back-space, horizontal tab and new-line. Graphics should be performed with OffScreen Canvas and copied to the display with draw_bitmap().

Circuit

+------------+
1-|DB0 |
2-|DB1 |
3-|DB2 |
4-|DB3 |
5-|DB4 |
6-|DB5 |
(D7/D1)-------------7-|DB6(SCL) |
(D6/D0)-------------8-|DB7(SI) |
(VCC)---------------9-|VDD |
(GND)--------------10-|VSS |
(VCC)---[330]------11-|A |
(D9/D3)------------12-|CS |
(RST)--------------13-|RST |
(D8/D2)------------14-|DC |
15-|WR(R/W) |
16-|RD(E) |
+------------+
+------------+
1-|DB0 |
2-|DB1 |
3-|DB2 |
4-|DB3 |
5-|DB4 |
6-|DB5 |
(SCK/D13/D4)--------7-|DB6(SCL) |
(MOSI/D11/D5)-------8-|DB7(SI) |
(VCC)---------------9-|VDD |
(GND)--------------10-|VSS |
(VCC)---[330]------11-|A |
(D9/D3)------------12-|CS |
(RST)--------------13-|RST |
(D8/D2)------------14-|DC |
15-|WR(R/W) |
16-|RD(E) |
+------------+

References

  1. Sitronix 65x132 Dot Matrix LCD Controller/Driver, Ver 1.3, 2004 May 18.

Definition at line 85 of file ST7565.hh.

Member Enumeration Documentation

anonymous enum
protected

Instruction set (table 16, pp. 52).

Enumerator
DISPLAY_OFF 

Turn display off.

DISPLAY_ON 

Turn display on.

SET_DISPLAY_START 

Set start line address.

DISPLAY_START_MASK 
  • line address mask.
SET_Y_ADDR 

Set page address.

Y_ADDR_MASK 
  • page address mask.
SET_X_ADDR 

Set column address (2x4 bits).

X_ADDR_MASK 
  • colum address mask.
ADC_NORMAL 

Set normal address correspondence.

ADC_REVERSE 

Set reverse address correspondence.

DISPLAY_NORMAL 

Normal display mode.

DISPLAY_REVERSE 

Reverse display mode.

DISPLAY_64X128_POINTS 

Display normal.

DISPLAY_65X132_POINTS 

Display all points.

LCD_BIAS_9 

Voltage ratio 1/9 bias.

LCD_BIAS_7 

Voltage ratio 1/7 bias.

X_ADDR_INC 

Column address increment.

X_ADDR_CLEAR 

Clear read/modify/write.

INTERNAL_RESET 

Internal reset.

COM_OUTPUT_NORMAL 

Normal output scan direction.

COM_OUTPUT_REVERSE 
  • reverse direction.
SET_POWER_CONTROL 

Select internal power supply mode.

POWER_MASK 
  • operation mode mask.
SET_RESISTOR_RATIO 

Select internal resistor ratio.

RESISTOR_MASK 
  • resistor ratio mask.
SET_CONSTRAST 

Set output voltage volume register.

CONSTRAST_MASK 
  • electronic volume mask.
INDICATOR_OFF 

Static indicator off.

INDICATOR_ON 
  • on.
FLASHING_OFF 

Set indicator flashing mode off.

FLASHING_ON 
  • on.
SET_BOOSTER_RATIO 

Set booster ratio.

BOOSTER_RATIO_234X 
  • 2x, 3x, 4x.
BOOSTER_RATIO_5X 
  • 5x.
BOOSTER_RATIO_6X 
  • 6x.
NOP 

Non-operation.

SCRIPT_PAUSE 

Init script pause (ms).

SCRIPT_END 

Init script end.

Definition at line 227 of file ST7565.hh.

enum LCD::Device::TextMode
inherited

Text display mode.

Enumerator
NORMAL_TEXT_MODE 
INVERTED_TEXT_MODE 

Definition at line 45 of file LCD.hh.

Constructor & Destructor Documentation

ST7565::ST7565 ( LCD::IO io,
Board::DigitalPin  dc = Board::D8,
Font font = &system5x7 
)

Construct display device driver with given io adapter, chip select pin and font.

Parameters
[in]ioadapter;
[in]dcdata/command control pin (default D8/D2).
[in]fontbitmap (default System 5X7).

Definition at line 43 of file ST7565.cpp.

Member Function Documentation

int IOStream::Device::available ( )
virtualinherited

Number of bytes available (possible to read).

Returns
bytes.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, Soft::UART, UART, IOBuffer< SIZE >, and CC3000::Driver.

Definition at line 24 of file IOStream_Device.cpp.

virtual void LCD::Device::backlight_off ( )
inlinevirtualinherited

Turn display backlight off.

Reimplemented in HD44780, and VLCD.

Definition at line 86 of file LCD.hh.

virtual void LCD::Device::backlight_on ( )
inlinevirtualinherited

Turn display backlight on.

Reimplemented in HD44780, and VLCD.

Definition at line 80 of file LCD.hh.

bool ST7565::begin ( )
virtual

Start interaction with display.

Returns
true(1) if successful otherwise false(0)

Implements LCD::Device.

Definition at line 82 of file ST7565.cpp.

void IOStream::Device::blocking ( )
inlineinherited

Set blocking mode.

Definition at line 85 of file IOStream.hh.

void ST7565::display_clear ( )
virtual

Clear display and move cursor to home.

Implements LCD::Device.

Definition at line 144 of file ST7565.cpp.

void ST7565::display_contrast ( uint8_t  level)
virtual

Set display contrast (0..63).

Parameters
[in]level.

Reimplemented from LCD::Device.

Definition at line 109 of file ST7565.cpp.

void ST7565::display_inverse ( )
virtual

Display inverse mode.

Reimplemented from LCD::Device.

Definition at line 138 of file ST7565.cpp.

void ST7565::display_normal ( )
virtual

Display normal mode.

Reimplemented from LCD::Device.

Definition at line 132 of file ST7565.cpp.

void ST7565::display_off ( )
virtual

Turn display off.

Implements LCD::Device.

Definition at line 126 of file ST7565.cpp.

void ST7565::display_on ( )
virtual

Turn display on.

Implements LCD::Device.

Definition at line 120 of file ST7565.cpp.

void ST7565::draw_bar ( uint8_t  percent,
uint8_t  width,
uint8_t  pattern = 0x55 
)

Draw a bar at the current position with the given width. The bar is filled from left to right proportional to the given percent (0..100).

Parameters
[in]percentfilled from left to right.
[in]widthof bar.
[in]patternof filled section of bar.

Definition at line 197 of file ST7565.cpp.

void ST7565::draw_bitmap ( uint8_t *  bp,
uint8_t  width,
uint8_t  height 
)

Draw bitmap in the current mode.

Parameters
[in]bp.
[in]width.
[in]height.

Definition at line 182 of file ST7565.cpp.

void ST7565::draw_icon ( const uint8_t *  bp)

Draw icon in the current mode. The icon must be stored in program memory with width, height and data.

Parameters
[in]bp

Definition at line 165 of file ST7565.cpp.

void IOStream::Device::empty ( )
virtualinherited

Empty internal device buffers.

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 175 of file IOStream_Device.cpp.

bool ST7565::end ( )
virtual

Stop sequence of interaction with device.

Returns
true(1) if successful otherwise false(0)

Implements LCD::Device.

Definition at line 102 of file ST7565.cpp.

void IOStream::Device::eol ( Mode  mode)
inlineinherited

Set end of line mode.

Parameters
[in]modefor end of line.

Definition at line 103 of file IOStream.hh.

Mode IOStream::Device::eol ( ) const
inlineinherited

Get end of line mode.

Returns
mode.

Definition at line 112 of file IOStream.hh.

void ST7565::fill ( uint8_t  data,
uint16_t  count 
)
protected

Fill display with given data.

Parameters
[in]datato fill with.
[in]countnumber of bytes to fill.

Definition at line 74 of file ST7565.cpp.

int IOStream::Device::flush ( )
virtualinherited

Flush internal device buffers. Wait for device to become idle.

Returns
zero(0) or negative error code.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.

Definition at line 169 of file IOStream_Device.cpp.

void LCD::Device::get_cursor ( uint8_t &  x,
uint8_t &  y 
) const
inlineinherited

Get current cursor position.

Parameters
[out]x.
[out]y.

Definition at line 133 of file LCD.hh.

uint8_t LCD::Device::get_tab_step ( ) const
inlineinherited

Get tab step.

Returns
tab step.

Definition at line 152 of file LCD.hh.

Font* ST7565::get_text_font ( ) const
inline

Get current text font.

Returns
font setting.

Definition at line 170 of file ST7565.hh.

int IOStream::Device::getchar ( )
virtualinherited

Read character from device.

Returns
character or EOF(-1).

Reimplemented in FAT16::File, CFFS::File, Soft::UART, UART, IOBuffer< SIZE >, and Socket.

Definition at line 112 of file IOStream_Device.cpp.

char * IOStream::Device::gets ( char *  s,
size_t  count 
)
virtualinherited

Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.

Parameters
[in]sstring buffer to read into.
[in]countmax number of bytes to read.
Returns
string pointer or NULL.

Definition at line 118 of file IOStream_Device.cpp.

bool IOStream::Device::is_blocking ( ) const
inlineinherited

Is blocking mode?

Returns
bool.

Definition at line 94 of file IOStream.hh.

void IOStream::Device::non_blocking ( )
inlineinherited

Set non-blocking mode.

Definition at line 77 of file IOStream.hh.

int IOStream::Device::peekchar ( )
virtualinherited

Peek at the next character from device.

Returns
character or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 99 of file IOStream_Device.cpp.

int IOStream::Device::peekchar ( char  c)
virtualinherited

Peek for the given character in device buffer. Return number of characters or EOF(-1).

Parameters
[in]ccharacter to peek for.
Returns
available or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 105 of file IOStream_Device.cpp.

int ST7565::putchar ( char  c)
virtual

Write character to display. Handles carriage-return-line-feed, back- space, alert, horizontal tab and form-feed. Returns character or EOF on error.

Parameters
[in]ccharacter to write.
Returns
character written or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 220 of file ST7565.cpp.

int IOStream::Device::puts ( const char *  s)
virtualinherited

Write null terminated string to device. Terminating null is not written.

Parameters
[in]sstring to write.
Returns
zero(0) or negative error code.

Definition at line 43 of file IOStream_Device.cpp.

int IOStream::Device::puts ( str_P  s)
virtualinherited

Write null terminated string from program memory to device. Terminating null is not written.

Parameters
[in]sstring in program memory to write.
Returns
zero(0) or negative error code.

Definition at line 54 of file IOStream_Device.cpp.

int IOStream::Device::read ( void *  buf,
size_t  size 
)
virtualinherited

Read data to given buffer with given size from device.

Parameters
[in]bufbuffer to read into.
[in]sizenumber of bytes to read.
Returns
number of bytes read or EOF(-1).

Reimplemented in FAT16::File, W5200::Driver, W5500::Driver, W5100::Driver, CFFS::File, Socket, and CC3000::Driver.

Definition at line 144 of file IOStream_Device.cpp.

int IOStream::Device::read ( iovec_t vec)
virtualinherited

Read data to given buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to read into.
Returns
number of bytes read or EOF(-1).

Definition at line 157 of file IOStream_Device.cpp.

int IOStream::Device::room ( )
virtualinherited

Number of bytes room (write without blocking).

Returns
bytes.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.

Definition at line 30 of file IOStream_Device.cpp.

void ST7565::set ( uint8_t  cmd)
protected

Set the given command code.

Parameters
[in]cmdcommand code.

Definition at line 52 of file ST7565.cpp.

void ST7565::set ( uint8_t  x,
uint8_t  y 
)
protected

Set display address for next data block.

Parameters
[in]xposition (0..WIDTH-1).
[in]yposition (0..LINES-1).

Definition at line 62 of file ST7565.cpp.

void ST7565::set_cursor ( uint8_t  x,
uint8_t  y 
)
virtual

Set cursor to given position.

Parameters
[in]xpixel position (0..WIDTH-1).
[in]yline position (0..LINES-1).

Implements LCD::Device.

Definition at line 154 of file ST7565.cpp.

void LCD::Device::set_tab_step ( uint8_t  step)
inlineinherited

Set tab step to given value.

Parameters
[in]steptab.

Definition at line 161 of file LCD.hh.

Font* ST7565::set_text_font ( Font font)
inline

Set text font. Returns previous setting.

Parameters
[in]font.
Returns
previous font setting.

Definition at line 180 of file ST7565.hh.

TextMode LCD::Device::text_mode ( TextMode  mode)
inlineinherited

Set text mode. Return previous text mode.

Parameters
[in]modenew text mode.
Returns
previous text mode.

Definition at line 171 of file LCD.hh.

int IOStream::Device::write ( const void *  buf,
size_t  size 
)
virtualinherited

Write data from buffer with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented in FAT16::File, HD44780, CFFS::File, VLCD, Socket, and CC3000::Driver.

Definition at line 65 of file IOStream_Device.cpp.

int IOStream::Device::write ( const iovec_t vec)
virtualinherited

Write data from buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to write.
Returns
number of bytes written or EOF(-1).

Definition at line 87 of file IOStream_Device.cpp.

int IOStream::Device::write_P ( const void *  buf,
size_t  size 
)
virtualinherited

Write data from buffer in program memory with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented in CFFS::File, Socket, and CC3000::Driver.

Definition at line 76 of file IOStream_Device.cpp.

Member Data Documentation

const uint8_t ST7565::HEIGHT = 64
static

Definition at line 89 of file ST7565.hh.

const uint8_t ST7565::LINES = 8
static

Definition at line 90 of file ST7565.hh.

bool IOStream::Device::m_blocking
protectedinherited

Blocking state

Definition at line 248 of file IOStream.hh.

OutputPin ST7565::m_dc
protected

Data(1) or command(0).

Definition at line 273 of file ST7565.hh.

Mode IOStream::Device::m_eol
protectedinherited

End of line mode

Definition at line 251 of file IOStream.hh.

Font* ST7565::m_font
protected

Font.

Definition at line 275 of file ST7565.hh.

LCD::IO* ST7565::m_io
protected

Display adapter.

Display pins and state.

Definition at line 272 of file ST7565.hh.

uint8_t ST7565::m_line
protected

Display start line.

Definition at line 274 of file ST7565.hh.

uint8_t LCD::Device::m_mode
protectedinherited

Text mode.

Definition at line 183 of file LCD.hh.

uint8_t LCD::Device::m_tab
protectedinherited

Tab step.

Definition at line 182 of file LCD.hh.

uint8_t LCD::Device::m_x
protectedinherited

Cursor position x.

Definition at line 180 of file LCD.hh.

uint8_t LCD::Device::m_y
protectedinherited

Cursor position y.

Definition at line 181 of file LCD.hh.

const uint8_t ST7565::script[]
staticprotected

Initialization script to reduce memory footprint.

Definition at line 269 of file ST7565.hh.

const uint8_t ST7565::WIDTH = 128
static

Display width and height (in pixels).

Definition at line 88 of file ST7565.hh.


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