OULOUTECH / SSD1306

Dependents:   Affich_Lum_Moist

Fork of SSD1306 by Jonathan Gaul

Embed: (wiki syntax)

« Back to documentation index

SSD1306 Class Reference

SSD1306 Class Reference

SSD1306 Controller Driver. More...

#include <ssd1306.h>

Public Member Functions

 SSD1306 (PinName cs, PinName rs, PinName dc, PinName clk, PinName data)
 Construct a new SSD1306 object.
void initialise ()
 Initialise the display with defaults.
void update ()
 Force a refresh of the display.
void off ()
 Turn the whole display off.
void on ()
 Turn the whole display on.
void sleep ()
 Sends the display to sleep, but leaves RAM intact.
void wake ()
 Wakes up this display following a sleep() call.
void set_contrast (unsigned char value)
 Set the display contrast.
void set_inverse (unsigned char value)
 Set the display to normal or inverse.
void set_display_start_line (unsigned char value)
 Set the display start line.
void set_segment_remap (unsigned char value)
 Set the segment remap state.
void set_display_offset (unsigned char value)
 Set the vertical shift by COM.
void set_multiplex_ratio (unsigned char value)
 Set the multiplex ratio.
void set_com_output_scan_direction (unsigned char value)
 Set COM output scan direction.
void set_com_pins_hardware_configuration (unsigned char sequential, unsigned char lr_remap)
 Set COM pins hardware configuration.
void start_horizontal_scroll (unsigned char direction, unsigned char start, unsigned char end, unsigned char interval)
 Set up and start a continuous horizontal scroll.
void start_vertical_and_horizontal_scroll (unsigned char direction, unsigned char start, unsigned char end, unsigned char interval, unsigned char vertical_offset)
 Set up and start a continuous horizontal and vertical scroll.
void stop_scroll ()
 Deactivate the continuous scroll set up with start_horizontal_scroll() or start_vertical_and_horizontal_scroll().
void set_memory_addressing_mode (unsigned char mode)
 Set memory addressing mode to the given value.
void pam_set_start_address (unsigned char address)
 Page Addressing Mode: Set the column start address register for page addressing mode.
void pam_set_page_start (unsigned char address)
 Set the GDDRAM page start address for page addressing mode.
void hv_set_page_address (unsigned char start, unsigned char end)
 Set page start and end address for horizontal/vertical addressing mode.
void hv_set_column_address (unsigned char start, unsigned char end)
 Set column address range for horizontal/vertical addressing mode.
void set_display_clock_ratio_and_frequency (unsigned char ratio, unsigned char frequency)
 Set the display clock divide ratio and the oscillator frequency.
void set_precharge_period (unsigned char phase1, unsigned char phase2)
 Set the precharge period.
void set_vcomh_deselect_level (unsigned char level)
 Set the Vcomh deselect level.
void nop ()
 Perform a "no operation".
void set_charge_pump_enable (unsigned char enable)
 Enable/disable charge pump.
void set_font (unsigned char *font, unsigned int width)
 Set the current console font.
void set_double_height_text (unsigned int double_height)
 Set double height text output.
void putc (unsigned char c)
 Put a single character to the screen buffer.
void printf (const char *format,...)
 Print to the screen buffer.
void scroll_up ()
 Scroll the screen buffer up by one line.

Detailed Description

SSD1306 Controller Driver.

This class provides a buffered display for the SSD1306 OLED controller.

TODO:

  • At the moment, the driver assumes a 128x64 pixel display.
  • Only fonts of 8 pixel height are supported (different widths can be used).
  • Pretty much no drawing functions are provided as yet.
  • Possible "auto-update", automatically calling update() after a printf etc.

Information taken from the datasheet at: http://www.adafruit.com/datasheets/SSD1306.pdf

Definition at line 20 of file ssd1306.h.


Constructor & Destructor Documentation

SSD1306 ( PinName  cs,
PinName  rs,
PinName  dc,
PinName  clk,
PinName  data 
)

Construct a new SSD1306 object.

Parameters:
csThe connected C/S pin.
rsThe connected RS pin.
dcThe connected DC pin.
clkThe connected CLK pin.
dataThe connected Data pin.

Definition at line 6 of file ssd1306.cpp.


Member Function Documentation

void hv_set_column_address ( unsigned char  start,
unsigned char  end 
)

Set column address range for horizontal/vertical addressing mode.

Parameters:
startColumn start address, 0 - 127.
endColumn end address, 0 - 127.

Definition at line 152 of file ssd1306.cpp.

void hv_set_page_address ( unsigned char  start,
unsigned char  end 
)

Set page start and end address for horizontal/vertical addressing mode.

Parameters:
startThe start page, 0 - 7.
endThe end page, 0 - 7.

Definition at line 159 of file ssd1306.cpp.

void initialise (  )

Initialise the display with defaults.

Definition at line 200 of file ssd1306.cpp.

void nop (  )

Perform a "no operation".

Definition at line 189 of file ssd1306.cpp.

void off (  )

Turn the whole display off.

This will reset all configuration settings on the controller to their defaults.

Definition at line 16 of file ssd1306.cpp.

void on (  )

Turn the whole display on.

Used during initialisation.

Definition at line 21 of file ssd1306.cpp.

void pam_set_page_start ( unsigned char  address )

Set the GDDRAM page start address for page addressing mode.

Parameters:
addressThe start page, 0 - 7.

Definition at line 166 of file ssd1306.cpp.

void pam_set_start_address ( unsigned char  address )

Page Addressing Mode: Set the column start address register for page addressing mode.

Parameters:
addressThe address (full byte).

Definition at line 137 of file ssd1306.cpp.

void printf ( const char *  format,
  ... 
)

Print to the screen buffer.

printf() will wrap and scroll the screen as needed to display the text given.

Parameters:
formatFormat specifier, same as printf() in normal C.

Definition at line 366 of file ssd1306.cpp.

void putc ( unsigned char  c )

Put a single character to the screen buffer.

Repeated calls to putc() will cause the cursor to move across and then down as needed, with scrolling.

Parameters:
cThe character to write.

Definition at line 311 of file ssd1306.cpp.

void scroll_up (  )

Scroll the screen buffer up by one line.

Definition at line 348 of file ssd1306.cpp.

void set_charge_pump_enable ( unsigned char  enable )

Enable/disable charge pump.

Parameters:
enable0 to disable, 1 to enable the internal charge pump.

Definition at line 194 of file ssd1306.cpp.

void set_com_output_scan_direction ( unsigned char  value )

Set COM output scan direction.

If the display is active, this will immediately vertically flip the display.

Parameters:
value0 = Scan from COM0 (default), 1 = reversed (scan from COM[N-1]).

Definition at line 69 of file ssd1306.cpp.

void set_com_pins_hardware_configuration ( unsigned char  sequential,
unsigned char  lr_remap 
)

Set COM pins hardware configuration.

Parameters:
sequential0 = Sequental COM pin configuration, 1 = Alternative COM pin configuration (default).
lr_remap0 = Disable COM left/right remap (default), 1 = enable COM left/right remap.

Definition at line 74 of file ssd1306.cpp.

void set_contrast ( unsigned char  value )

Set the display contrast.

Parameters:
valueThe contrast, from 1 to 256.

Definition at line 47 of file ssd1306.cpp.

void set_display_clock_ratio_and_frequency ( unsigned char  ratio,
unsigned char  frequency 
)

Set the display clock divide ratio and the oscillator frequency.

Parameters:
ratioThe divide ratio, default is 0.
frequencyThe oscillator frequency, 0 - 127. Default is 8.

Definition at line 171 of file ssd1306.cpp.

void set_display_offset ( unsigned char  value )

Set the vertical shift by COM.

Parameters:
valueThe number of rows to shift, from 0 - 63.

Definition at line 41 of file ssd1306.cpp.

void set_display_start_line ( unsigned char  value )

Set the display start line.

This is the line at which the display will start rendering.

Parameters:
valueA value from 0 to 63 denoting the line to start at.

Definition at line 53 of file ssd1306.cpp.

void set_double_height_text ( unsigned int  double_height )

Set double height text output.

Parameters:
double_heightIf 1, calls to putc(), printf() etc will result in text taking up 2 lines instead of 1.

Definition at line 306 of file ssd1306.cpp.

void set_font ( unsigned char *  font,
unsigned int  width 
)

Set the current console font.

Parameters:
fontFont data, layed out vertically!
widthWidth of the font characters in pixels. Fonts are always (at present) 8 pixels in height.

Definition at line 300 of file ssd1306.cpp.

void set_inverse ( unsigned char  value )

Set the display to normal or inverse.

Parameters:
value0 for normal mode, or 1 for inverse mode.

Definition at line 36 of file ssd1306.cpp.

void set_memory_addressing_mode ( unsigned char  mode )

Set memory addressing mode to the given value.

Parameters:
mode0 for Horizontal addressing mode, 1 for Vertical addressing mode, or 2 for Page addressing mode (PAM). 2 is the default.

Definition at line 146 of file ssd1306.cpp.

void set_multiplex_ratio ( unsigned char  value )

Set the multiplex ratio.

Parameters:
valueMUX will be set to (value+1). Valid values range from 15 to 63 - MUX 16 to 64.

Definition at line 63 of file ssd1306.cpp.

void set_precharge_period ( unsigned char  phase1,
unsigned char  phase2 
)

Set the precharge period.

Parameters:
phase1Phase 1 period in DCLK clocks. 1 - 15, default is 2.
phase2Phase 2 period in DCLK clocks. 1 - 15, default is 2.

Definition at line 177 of file ssd1306.cpp.

void set_segment_remap ( unsigned char  value )

Set the segment remap state.

This allows the module to be addressed as if flipped horizontally. NOTE: Changing this setting has no effect on data already in the module's GDDRAM.

Parameters:
value0 = column address 0 = segment 0 (the default), 1 = column address 127 = segment 0 (flipped).

Definition at line 58 of file ssd1306.cpp.

void set_vcomh_deselect_level ( unsigned char  level )

Set the Vcomh deselect level.

Parameters:
level0 = 0.65 x Vcc, 1 = 0.77 x Vcc (default), 2 = 0.83 x Vcc.

Definition at line 183 of file ssd1306.cpp.

void sleep (  )

Sends the display to sleep, but leaves RAM intact.

Definition at line 26 of file ssd1306.cpp.

void start_horizontal_scroll ( unsigned char  direction,
unsigned char  start,
unsigned char  end,
unsigned char  interval 
)

Set up and start a continuous horizontal scroll.

Once you have set up the scrolling, you can deactivate it with stop_scroll().

Parameters:
direction0 for right, 1 for left.
startStart page address, 0 - 5.
endEnd page address, 0 - 5.
intervalInterval in frame frequency. Valid values are: 2, 3, 4, 5, 25, 64, 128, 256.
See also:
stop_scrol

Definition at line 80 of file ssd1306.cpp.

void start_vertical_and_horizontal_scroll ( unsigned char  direction,
unsigned char  start,
unsigned char  end,
unsigned char  interval,
unsigned char  vertical_offset 
)

Set up and start a continuous horizontal and vertical scroll.

NOTE: No continuous vertical scroll is available. Once you have set up the scrolling, you can deactivate it with stop_scroll().

Parameters:
direction0 for vertical and right horizontal scroll, 1 for vertical and left horizontal scroll.
startStart page address, 0 - 5.
endEnd page address, 0 - 5.
intervalInterval in frame frequency. Valid values are: 2, 3, 4, 5, 25, 64, 128, 256.
vertical_offsetOffset of vertical scroll, 1 - 63.
See also:
stop_scroll

Definition at line 106 of file ssd1306.cpp.

void stop_scroll (  )

Deactivate the continuous scroll set up with start_horizontal_scroll() or start_vertical_and_horizontal_scroll().

See also:
set_horizontal_scroll, set_vertical_and_horizontal_scroll

Definition at line 131 of file ssd1306.cpp.

void update (  )

Force a refresh of the display.

Copies the buffer to the controller.

Definition at line 236 of file ssd1306.cpp.

void wake (  )

Wakes up this display following a sleep() call.

See also:
sleep()

Definition at line 31 of file ssd1306.cpp.