Byggern
OLED Class Reference

An interface to communicate with the OLED display. More...

#include <oled.h>

Inheritance diagram for OLED:
Stream OLED_memory OLED_SCP

Public Member Functions

void Init (uint8_t width, uint8_t height)
 
void GoToLine (uint8_t line)
 
void Clear ()
 
void ClearLine ()
 
void WriteByte (uint8_t page, uint8_t column, uint8_t byte)
 
void WriteByteArray (uint8_t page, uint8_t column, uint8_t *byte_array, uint8_t length)
 
void Repaint ()
 
void SetNumberOfLines (uint8_t number_of_lines)
 
void WriteBitmap (uint8_t **pixels, uint8_t bitmap_width, uint8_t bitmap_height, uint8_t x, uint8_t y, bool is_progmem)
 
void SetFont (uint8_t *font, uint8_t width, uint8_t height)
 
void WriteLine (char *string, uint8_t length, uint8_t line, uint8_t offset)
 
uint8_t GetYCoordinateFromLineNumber (uint8_t line)
 
uint8_t GetMaxLineCharacters ()
 
- Public Member Functions inherited from Stream
 Stream (uint16_t input_stream_size, uint16_t output_stream_size)
 
virtual void Write (uint8_t *string, uint16_t size)
 
virtual uint16_t Read (uint8_t *string, uint16_t size)
 
virtual bool ReadByte (uint8_t &byte)
 
virtual void WriteByte (uint8_t byte)
 
virtual uint8_t GetAvailableWriteBytes ()
 
virtual uint8_t GetAvailableReadBytes ()
 
virtual bool CheckInputOverflowFlag ()
 
virtual bool CheckOutputOverflowFlag ()
 
virtual uint16_t GetInputBufferLength ()
 
virtual uint16_t GetOutputBufferLength ()
 
virtual void FlushInputBuffer ()
 
virtual void FlushOutputBuffer ()
 

Protected Member Functions

 OLED ()
 
virtual void WriteByteToOLED (volatile uint8_t *address, uint8_t data)
 
void GetBitmapForCharacter (char character, uint8_t *&character_bitmap)
 
- Protected Member Functions inherited from Stream
virtual uint16_t ReadFromBuffer (uint8_t *buffer, uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty, uint8_t *string, uint16_t &string_size)
 
virtual void WriteToBuffer (uint8_t *buffer, uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty, bool &overflow_flag, uint8_t *string, uint16_t &string_size, void(*cb)(Stream *stream))
 
virtual bool ReadByteFromBuffer (uint8_t &byte, uint8_t *buffer, uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty)
 
virtual void WriteByteToBuffer (uint8_t *buffer, uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty, bool &overflow_flag, uint8_t &byte, void(*cb)(Stream *stream))
 
virtual void WriteByteToInputStream (uint8_t &byte)
 
virtual bool ReadByteFromOutputStream (uint8_t &byte)
 
virtual void WriteToInputStream (uint8_t *string, uint16_t size)
 
virtual uint16_t ReadFromOutputStream (uint8_t *string, uint16_t size)
 
virtual uint16_t CalculateLength (uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty)
 
virtual void FlushStream (uint16_t &start_index, uint16_t &stop_index, uint16_t &buffer_size, bool &empty)
 

Protected Attributes

uint8_t current_line = 0
 
uint8_t display_width = 0
 
uint8_t display_height = 0
 
uint8_t number_of_pages = 0
 
uint8_t number_of_lines = 0
 
volatile uint8_t * oled_command = (volatile uint8_t*)0x8000
 
volatile uint8_t * oled_data = (volatile uint8_t*)0x8100
 
uint8_t ** matrix
 
uint8_t pixels_per_line
 
uint8_t * font = nullptr
 
uint8_t font_width
 
uint8_t font_height
 
- Protected Attributes inherited from Stream
uint8_t * input_buffer
 
uint8_t * output_buffer
 
uint16_t input_buffer_start_index = 0
 
uint16_t output_buffer_start_index = 0
 
uint16_t input_buffer_stop_index
 
uint16_t output_buffer_stop_index
 
uint16_t input_buffer_size
 
uint16_t output_buffer_size
 
void(* event_input_buffer_not_empty )(Stream *stream) = nullptr
 
void(* event_output_buffer_not_empty )(Stream *stream) = nullptr
 
bool input_buffer_empty = true
 
bool output_buffer_empty = true
 
bool input_buffer_overflowed = false
 
bool output_buffer_overflowed = false
 

Detailed Description

An interface to communicate with the OLED display.

Constructor & Destructor Documentation

§ OLED()

OLED::OLED ( )
protected

Singleton constructor.

Member Function Documentation

§ Clear()

void OLED::Clear ( )

Clears the whole screen.

§ ClearLine()

void OLED::ClearLine ( )

Clears the current line.

§ GetBitmapForCharacter()

void OLED::GetBitmapForCharacter ( char  character,
uint8_t *&  character_bitmap 
)
protected

Fetches a pointer to PROGMEM for the bitmap for the given font and character. Emphasis on that it points to PROGMEM.

§ GetMaxLineCharacters()

uint8_t OLED::GetMaxLineCharacters ( )

Returns how wide a line is in characters.

Returns
How wide a line is in characters.

§ GetYCoordinateFromLineNumber()

uint8_t OLED::GetYCoordinateFromLineNumber ( uint8_t  line)

Returns the y coordinate of the line.

Parameters
lineThe line to find the y coordinate of.
Returns
The y coordinate of the line.

§ GoToLine()

void OLED::GoToLine ( uint8_t  line)

Sets the line pointer.

Parameters
lineWhich line to go to.

§ Init()

void OLED::Init ( uint8_t  width,
uint8_t  height 
)

Initializes the whole screen.

Parameters
widthThe width of the screen in pixels.
heightThe height of the screen in pixels.

§ Repaint()

void OLED::Repaint ( )

Repaints the OLED

§ SetFont()

void OLED::SetFont ( uint8_t *  font,
uint8_t  width,
uint8_t  height 
)

Sets the font to be used when writing to the screen.

Parameters
fontA pointer to the font. Put this on the PROGMEM only if possible to save RAM space.
widthThe width of the font in pixels.
heightThe height of the font in pixels.

§ SetNumberOfLines()

void OLED::SetNumberOfLines ( uint8_t  number_of_lines)

Sets the number of lines. Not to be confused with number of pages.

Parameters
number_of_linesThe number of lines.

§ WriteBitmap()

void OLED::WriteBitmap ( uint8_t **  pixels,
uint8_t  bitmap_width,
uint8_t  bitmap_height,
uint8_t  x,
uint8_t  y,
bool  is_progmem 
)

Writes a pixel matrix to the given x and y position on the display.

Parameters
pixelsA double pointer to the matrix.
bitmap_widthThe width of the bitmap in pixels.
bitmap_heightThe height of the bitmap in pixels.
xThe starting position, x direction.
yThe starting position, y direction.
is_progmemA bool that indicates where the pixel array is located.

§ WriteByte()

void OLED::WriteByte ( uint8_t  page,
uint8_t  column,
uint8_t  byte 
)

Writes a byte to the given page and column. This is a helper function mainly used for debugging.

Parameters
pageWhich page to be written to.
pageWhich column to be written to.
byteThe byte to be written.

§ WriteByteArray()

void OLED::WriteByteArray ( uint8_t  page,
uint8_t  column,
uint8_t *  byte_array,
uint8_t  length 
)

Writes a byte array starting at the given page and column. This is a helper function mainly used for debugging.

Parameters
pageWhich page to be written to.
pageWhich column to be written to first.
byte_arrayBytes to be written.
lengthThe length of the byte array (number of columns).

§ WriteByteToOLED()

virtual void OLED::WriteByteToOLED ( volatile uint8_t *  address,
uint8_t  data 
)
inlineprotectedvirtual

Writes a single byte to the OLED. This can be implemented using the external memory interface or using whatever other technology like for instance the SCP.

Parameters
addressThe address to write to.
dataThe data to write.

Reimplemented in OLED_SCP, and OLED_memory.

§ WriteLine()

void OLED::WriteLine ( char *  string,
uint8_t  length,
uint8_t  line,
uint8_t  offset 
)

Writes a string to the given line.

Parameters
stringThe string to be written.
lengthLength of the string.
lineThe line to write to.
offsetThe offset from the left, in characters.

Member Data Documentation

§ current_line

uint8_t OLED::current_line = 0
protected

The current line to write to.

§ display_height

uint8_t OLED::display_height = 0
protected

Height of display in pixels.

§ display_width

uint8_t OLED::display_width = 0
protected

Width of the display in pixels.

§ font

uint8_t* OLED::font = nullptr
protected

The font to use for writing.

§ font_height

uint8_t OLED::font_height
protected

Height of the font in pixels.

§ font_width

uint8_t OLED::font_width
protected

Width of the font in pixels.

§ matrix

uint8_t** OLED::matrix
protected

The display buffer. There is also a buffer on the OLED controller, such that this implements a dual buffer.

§ number_of_lines

uint8_t OLED::number_of_lines = 0
protected

Number of lines. Not to be confused with number of pages.

§ number_of_pages

uint8_t OLED::number_of_pages = 0
protected

Number of pages

§ oled_command

volatile uint8_t* OLED::oled_command = (volatile uint8_t*)0x8000
protected

A pointer to where the OLED_COMMAND address space starts.

§ oled_data

volatile uint8_t* OLED::oled_data = (volatile uint8_t*)0x8100
protected

A pointer to where the OLED_DATA address space starts.

§ pixels_per_line

uint8_t OLED::pixels_per_line
protected

The number of pixels per line.


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