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

#include <MAX72XX.hh>

Inheritance diagram for MAX72XX:
Inheritance graph
Collaboration diagram for MAX72XX:
Collaboration graph

Public Types

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

Public Member Functions

 MAX72XX (LCD::IO *io, const uint8_t *font=NULL)
 
virtual bool begin ()
 
virtual bool end ()
 
virtual void display_contrast (uint8_t level)
 
virtual void display_on ()
 
virtual void display_off ()
 
virtual void display_clear ()
 
virtual void set_cursor (uint8_t x, uint8_t y)
 
virtual int putchar (char c)
 
virtual void backlight_on ()
 
virtual void backlight_off ()
 
virtual void display_normal ()
 
virtual void display_inverse ()
 
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 = 8
 
static const uint8_t HEIGHT = 1
 
static const uint8_t LINES = 1
 

Protected Types

enum  Register {
  NOP = 0x00, DIGIT0 = 0x01, DIGIT1 = 0x02, DIGIT2 = 0x03,
  DIGIT3 = 0x04, DIGIT4 = 0x05, DIGIT5 = 0x06, DIGIT6 = 0x07,
  DIGIT7 = 0x08, DECODE_MODE = 0x09, INTENSITY = 0x0a, SCAN_LIMIT = 0x0b,
  DISPLAY_MODE = 0x0c, DISPLAY_TEST = 0x0f
}
 
enum  { SHUTDOWN_MODE = 0x00, NORMAL_OPERATION = 0x01 }
 
enum  { NO_DECODE = 0x00, ALL_DECODE = 0xff }
 

Protected Member Functions

void set (Register reg, uint8_t value)
 

Protected Attributes

LCD::IOm_io
 Display adapter. More...
 
const uint8_t * m_font
 Font in program memory. More...
 
char m_latest
 Latest character code. 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 font []
 

Detailed Description

MAX72XX Serially Interfaced, 8-Digit LED Display Drivers, device driver for IOStream access.

The MAX7219/MAX7221 are compact, serial input/output common-cathode display drivers that interface microprocessors (μPs) to 7-segment numeric LED displays of up to 8 digits, bar-graph displays, or 64 individual LEDs. Included on-chip are a BCD code-B decoder, multiplex scan circuitry, segment and digit drivers, and an 8x8 static RAM that stores each digit.

Circuit

+------------+
(D6/D0)-------------1-|DIN |
(GND)---------------4-|GND |
(GND)---------------9-|GND |
(D9/D3)------------12-|CS |
(D7/D1)------------13-|CLK |
(VCC)--------------19-|VCC |
+------------+
+------------+
(MOSI/D11/D5)-------1-|DIN |
(GND)---------------4-|GND |
(GND)---------------9-|GND |
(D9/D3)------------12-|CS |
(SCK/D13/D4)-------13-|CLK |
(VCC)--------------19-|VCC |
+------------+

References

  1. Product Specification, MAXIM, MAX7219/7221, 19-5542, Rev.4, 7/03. http://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf

Definition at line 64 of file MAX72XX.hh.

Member Enumeration Documentation

anonymous enum
protected

Shutdown Register Format (Table 3, pp. 7).

Enumerator
SHUTDOWN_MODE 

Shutdown mode.

NORMAL_OPERATION 

Normal operation.

Definition at line 163 of file MAX72XX.hh.

anonymous enum
protected

Decode-Mode Register (Table 4, pp. 7).

Enumerator
NO_DECODE 

No decode for digits 7-0.

ALL_DECODE 

Code B decode for digits 7-0.

Definition at line 171 of file MAX72XX.hh.

enum MAX72XX::Register
protected

Register Address Map (Table 2, pp 7).

Enumerator
NOP 

No-operation.

DIGIT0 

Digit 0 (encode or segment data).

DIGIT1 

Digit 1 (encode or segment data).

DIGIT2 

Digit 2 (encode or segment data).

DIGIT3 

Digit 3 (encode or segment data).

DIGIT4 

Digit 4 (encode or segment data).

DIGIT5 

Digit 5 (encode or segment data).

DIGIT6 

Digit 6 (encode or segment data).

DIGIT7 

Digit 7 (encode or segment data).

DECODE_MODE 

Decode Mode (0..255, digit bitset).

INTENSITY 

Intensity (0..15, level).

SCAN_LIMIT 

Scan Limit (0..7, digits 1..8).

DISPLAY_MODE 

Display Mode (shutdown, normal).

DISPLAY_TEST 

Display Test (0..1, on/off).

Definition at line 143 of file MAX72XX.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

MAX72XX::MAX72XX ( LCD::IO io,
const uint8_t *  font = NULL 
)

Construct display device driver with given io adapter and font. The font should be a character to segment mapping table in program memory for character codes SPACE(0x20) to DEL(0x7f).

Parameters
[in]ioadapter, SPI or in/output pin based.
[in]fontprogram memory (Default NULL).

Definition at line 137 of file MAX72XX.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 MAX72XX::begin ( )
virtual

Start interaction with display. Turns display on, clears and sets the contrast/intensity to mid-level(7).

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

Implements LCD::Device.

Definition at line 154 of file MAX72XX.cpp.

void IOStream::Device::blocking ( )
inlineinherited

Set blocking mode.

Definition at line 85 of file IOStream.hh.

void MAX72XX::display_clear ( )
virtual

Clear display and move cursor to home (0, 0).

Implements LCD::Device.

Definition at line 184 of file MAX72XX.cpp.

void MAX72XX::display_contrast ( uint8_t  level)
virtual

Set display contrast/intensity level (0..15).

Parameters
[in]contrastlevel.

Reimplemented from LCD::Device.

Definition at line 192 of file MAX72XX.cpp.

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

Display inverse mode.

Reimplemented in ST7565, and PCD8544.

Definition at line 120 of file LCD.hh.

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

Display normal mode.

Reimplemented in ST7565, and PCD8544.

Definition at line 114 of file LCD.hh.

void MAX72XX::display_off ( )
virtual

Turn display off.

Implements LCD::Device.

Definition at line 178 of file MAX72XX.cpp.

void MAX72XX::display_on ( )
virtual

Turn display on.

Implements LCD::Device.

Definition at line 172 of file MAX72XX.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 MAX72XX::end ( )
virtual

Stop sequence of interaction with device.

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

Implements LCD::Device.

Definition at line 165 of file MAX72XX.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.

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.

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 MAX72XX::putchar ( char  c)
virtual

Write character to display. Handles carriage-return-line-feed, backspace, alert, horizontal tab and form-feed. The period character is translated to the 7-segment LED decimal point of the previous written character. Returns character or EOF on error.

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

Reimplemented from IOStream::Device.

Definition at line 205 of file MAX72XX.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 MAX72XX::set ( Register  reg,
uint8_t  value 
)
protected

Set register to the given value.

Parameters
[in]regregister address.
[in]value.

Definition at line 145 of file MAX72XX.cpp.

void MAX72XX::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 198 of file MAX72XX.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.

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 MAX72XX::font[]
staticprotected

Default font.

Definition at line 177 of file MAX72XX.hh.

const uint8_t MAX72XX::HEIGHT = 1
static

Definition at line 68 of file MAX72XX.hh.

const uint8_t MAX72XX::LINES = 1
static

Definition at line 69 of file MAX72XX.hh.

bool IOStream::Device::m_blocking
protectedinherited

Blocking state

Definition at line 248 of file IOStream.hh.

Mode IOStream::Device::m_eol
protectedinherited

End of line mode

Definition at line 251 of file IOStream.hh.

const uint8_t* MAX72XX::m_font
protected

Font in program memory.

Definition at line 181 of file MAX72XX.hh.

LCD::IO* MAX72XX::m_io
protected

Display adapter.

Display pins and state.

Definition at line 180 of file MAX72XX.hh.

char MAX72XX::m_latest
protected

Latest character code.

Definition at line 182 of file MAX72XX.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 MAX72XX::WIDTH = 8
static

Display size.

Definition at line 67 of file MAX72XX.hh.


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