PololuOLED library
|
Generic SH1106 class implemented using Arduino I/O functions. More...
#include <PololuSH1106.h>
Public Member Functions | |
PololuSH1106 (uint8_t clk, uint8_t mos, uint8_t res=255, uint8_t dc=255, uint8_t cs=255) | |
Creates a new instance of PololuSH1106. More... | |
void | init () |
Initializes the OLED if it has not already been initialized. More... | |
void | reinitialize () |
Reinitializes the OLED and its settings. More... | |
void | invert () |
Configures the OLED to invert all the pixels, resulting in black-on-white text. More... | |
void | noInvert () |
Configures the OLED to not invert its pixels (the default). More... | |
void | rotate180 () |
Configures the OLED to rotate its display 180 degrees from normal. More... | |
void | noRotate () |
Configures the OLED to use the default orientation. More... | |
void | setContrast (uint8_t contrast) |
Sets the contrast (i.e. brightness) of the OLED. More... | |
void | setLayout8x2 () |
Configures this library to use its default layout, which allows for 8 columns and 2 rows of text. More... | |
void | setLayout8x2WithGraphics (const uint8_t *graphics) |
Configures this library to use a layout with 8 columns and 2 rows of text, XORed with a graphics buffer. More... | |
void | setLayout11x4 () |
Configures this library to use a layout with 11 columns and 4 rows of text. More... | |
void | setLayout11x4WithGraphics (const uint8_t *graphics) |
Configures this library to use a layout with 11 columns and 4 rows of text, XORed with a graphics buffer. More... | |
void | setLayout21x8 () |
Configures this library to use a layout with 21 columns and 8 rows of text. More... | |
void | setLayout21x8WithGraphics (const uint8_t *graphics) |
Configures this library to use a layout with 21 columns and 8 rows of text, XORed with a graphics buffer. More... | |
void | display () |
Writes all of the text/graphics to the OLED. More... | |
void | displayPartial (uint8_t x, uint8_t y, uint8_t width) |
Writes a certain region of text/graphics to the OLED. More... | |
void | noAutoDisplay () |
Turns off auto display mode. More... | |
uint8_t * | getLinePointer (uint8_t line) |
Gets a pointer to a line of text in this library's text buffer. More... | |
void | gotoXY (uint8_t x, uint8_t y) |
Changes the location of the text cursor. More... | |
uint8_t | getX () |
Gets the X coordinate of the text cursor. More... | |
uint8_t | getY () |
Gets the Y coordinate of the text cursor. More... | |
void | scrollDisplayUp () |
Moves all the text up one row. (Does not change the cursor position.) More... | |
void | clear () |
Clears the text and resets the text cursor to the upper left. More... | |
size_t | write (const uint8_t *buffer, size_t size) override |
Writes a string of text. More... | |
size_t | write (uint8_t d) override |
Writes a single character of text. More... | |
void | loadCustomCharacterFromRam (const uint8_t *picture, uint8_t number) |
Defines a custom character from RAM. More... | |
void | loadCustomCharacter (const uint8_t *picture, uint8_t number) |
Defines a custom character. More... | |
void | loadCustomCharacter (const char *picture, uint8_t number) |
Defines a custom character. More... | |
Public Attributes | |
PololuSH1106Core | core |
This object handles all low-level communication with the SH1106. More... | |
Generic SH1106 class implemented using Arduino I/O functions.
Definition at line 149 of file PololuSH1106.h.
|
inline |
Creates a new instance of PololuSH1106.
clk | The pin to use to control the SH1106 CLK/SCL/D0 (clock input) pin. |
mos | The pin to use to control the SH1106 MOS/MOSI/SI/D1 (data input) pin. |
res | The pin to use to control the SH1106 RES (reset) pin. If you are not using the RES pin, you can pass 255. |
dc | The pin to use to control the SH1106 DC/A0 (data mode / not command mode) pin. If your display module uses 3-wire SPI mode so there is no DC pin to control, you should pass 255. |
cs | Sets the pin to use to control the SH1106 CS (chip select) pin. If you are not using the CS pin, you can pass 255. In that case, you should ensure the SH1106's CS pin is driven low when you are communicating with it. |
Definition at line 170 of file PololuSH1106.h.
|
inlineinherited |
Clears the text and resets the text cursor to the upper left.
After calling this function, the text buffer will consist entirely of space characters.
By default, this function also calls display() to write these changes to the OLED, but noAutoDisplay() disables that behavior.
Definition at line 901 of file PololuSH1106Main.h.
|
inlineinherited |
Writes all of the text/graphics to the OLED.
This also turns on auto display mode, undoing the effect of noAutoDisplay().
Note that this function does not always write to the entire display: for text-only modes, it will normally only write to the portion of the screen containing text.
Definition at line 794 of file PololuSH1106Main.h.
|
inlineinherited |
Writes a certain region of text/graphics to the OLED.
This function is like display(), but it only writes text/graphics to the OLED which are in a region corresponding to one or more consecutive characters in a line of text. This function cannot write arbitrary regions.
Most users will not need to call this because the clear(), write(), and print() functions automatically write to the display as needed. You can also use the display() function to write all of the text/graphics.
However, this function is useful to users who have disabled auto display mode, or are directly writing to the text buffer, and want an efficient way to update part of the screen.
x | The row number of the text to update (0 means top row). |
y | The column number of the first character to update (0 means left-most column). |
width | The number of characters to update. |
Definition at line 822 of file PololuSH1106Main.h.
|
inlineinherited |
Gets a pointer to a line of text in this library's text buffer.
This is for advanced users who want to use their own code to directly manipulate the text buffer.
The returned pointer will point to a region of memory at least 21 bytes long that holds the specified line of text. You can perform arbitrary operations on these bytes.
Note that you should not assume anything about where the lines are in relation to each other, and you should not assume it is safe to write beyond the 21st byte of a line.
Note that functions like snprintf will add a null (0) character at the end of their output. This is probably undesirable if you have configured character 0 to be a custom character using loadCustomCharacter(). Also, it means that the maximum content they can safely write to the text buffer is limited to 19 characters.
Definition at line 862 of file PololuSH1106Main.h.
|
inlineinherited |
Gets the X coordinate of the text cursor.
Definition at line 881 of file PololuSH1106Main.h.
|
inlineinherited |
Gets the Y coordinate of the text cursor.
Definition at line 884 of file PololuSH1106Main.h.
|
inlineinherited |
Changes the location of the text cursor.
This function changes the text cursor, which is the location of the text that will be overwritten by the next call to write() or print().
x | The column number (0 means left-most column). |
y | The row number (0 means top row). |
Definition at line 874 of file PololuSH1106Main.h.
|
inlineinherited |
Initializes the OLED if it has not already been initialized.
This resets the OLED, clears the contents of the OLED RAM, sets some default settings, and turns on the display.
Most users do not have to call this, because it is automatically called by any public function in this class that writes to the OLED.
Definition at line 176 of file PololuSH1106Main.h.
|
inlineinherited |
Configures the OLED to invert all the pixels, resulting in black-on-white text.
Definition at line 195 of file PololuSH1106Main.h.
|
inlineinherited |
Defines a custom character.
This overload is only provided for compatibility existing code that defines char arrays instead of uint8_t arrays.
Definition at line 1005 of file PololuSH1106Main.h.
|
inlineinherited |
Defines a custom character.
picture | A pointer to the character dot pattern, in program space. |
number | A character code between 0 and 7. |
Definition at line 991 of file PololuSH1106Main.h.
|
inlineinherited |
Defines a custom character from RAM.
picture | A pointer to the character dot pattern, in RAM. |
number | A character code between 0 and 7. |
Definition at line 969 of file PololuSH1106Main.h.
|
inlineinherited |
Turns off auto display mode.
This causes the clear(), write(), and print() functions to not perform any I/O or write any data to the OLED.
Calling display() will write to the display and turn auto display mode on again.
Definition at line 839 of file PololuSH1106Main.h.
|
inlineinherited |
Configures the OLED to not invert its pixels (the default).
Definition at line 205 of file PololuSH1106Main.h.
|
inlineinherited |
Configures the OLED to use the default orientation.
This is the orientation that results in the text shown on the Graphical OLED Display: 128x64, 1.3", White, SPI from Pololu being the same orientation as the pin labels.
Definition at line 232 of file PololuSH1106Main.h.
|
inlineinherited |
Reinitializes the OLED and its settings.
This redoes the initialization that is automatically done by init() the first time any function is called that writes to the OLED.
This can be useful if you want to plug the OLED into the robot after the library has already been initialized.
The screen will be blank after calling this, so you might want to call display() to show the graphics/text that you were shown before.
Definition at line 188 of file PololuSH1106Main.h.
|
inlineinherited |
Configures the OLED to rotate its display 180 degrees from normal.
Definition at line 215 of file PololuSH1106Main.h.
|
inlineinherited |
Moves all the text up one row. (Does not change the cursor position.)
Definition at line 887 of file PololuSH1106Main.h.
|
inlineinherited |
Sets the contrast (i.e. brightness) of the OLED.
contrast | A number between 0 (darkest, but still visible) and 255 (brightest, default). |
Definition at line 246 of file PololuSH1106Main.h.
|
inlineinherited |
Configures this library to use a layout with 11 columns and 4 rows of text.
Note that the last column of text will have one column of pixels cut off. You can choose not to use this column or only use it for narrow characters such as punctuation.
Definition at line 284 of file PololuSH1106Main.h.
|
inlineinherited |
Configures this library to use a layout with 11 columns and 4 rows of text, XORed with a graphics buffer.
graphics | A pointer to a 1024-byte graphics buffer. |
Note that the last column of text will have one column of pixels cut off. You can choose not to use this column or only use it for narrow characters such as punctuation.
Definition at line 300 of file PololuSH1106Main.h.
|
inlineinherited |
Configures this library to use a layout with 21 columns and 8 rows of text.
Definition at line 310 of file PololuSH1106Main.h.
|
inlineinherited |
Configures this library to use a layout with 21 columns and 8 rows of text, XORed with a graphics buffer.
graphics | A pointer to a 1024-byte graphics buffer. |
Definition at line 322 of file PololuSH1106Main.h.
|
inlineinherited |
Configures this library to use its default layout, which allows for 8 columns and 2 rows of text.
Definition at line 258 of file PololuSH1106Main.h.
|
inlineinherited |
Configures this library to use a layout with 8 columns and 2 rows of text, XORed with a graphics buffer.
graphics | A pointer to a 1024-byte graphics buffer. |
Definition at line 270 of file PololuSH1106Main.h.
|
inlineoverrideinherited |
Writes a string of text.
This function writes the specified string of text to the text buffer at the location specified by the text cursor (see gotoXY()), and moves the text cursor to the position immediately to the right of the string.
By default, this function also calls displayPartial() to write these changes to the OLED, but noAutoDisplay() disables that behavior.
There is no limit to how much text you can pass to this function, but the text will be discarded when you reach the end of the current line.
To advance to the next line, use gotoXY(). The newline and carriage return characters do not have any special effect on the text cursor position like they might have in a terminal emulator.
This function is called by (certain overloads of) the print() function provided by the Arduino print class.
Definition at line 926 of file PololuSH1106Main.h.
|
inlineoverrideinherited |
Writes a single character of text.
This is equivalent to writing a single character using write(const uint8_t *, size_t).
Definition at line 950 of file PololuSH1106Main.h.
|
inherited |
This object handles all low-level communication with the SH1106.
Definition at line 1012 of file PololuSH1106Main.h.