Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
Display Class Reference

A class for the SSD1306 OLED display, uses the ssd1306 library for low-level operations. More...

#include <Display.h>

Public Member Functions

void begin ()
 Initialize the display.
void clear ()
 Clear the display.
 Display ()
 Construct a new Display object.
void drawCircle (int16_t x0, int16_t y0, int16_t r, bool fill)
 Draw a circle.
void drawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1)
 Draw a line between two points.
void drawSquare (uint32_t x, uint32_t y, uint32_t w, uint32_t h, bool fill)
 Draw a square.
void stopDisplay ()
 Stop the display (power off).
void writeText (const char *text)
 Write text to the display with a scale of 2 at center (8,24).
void writeTextPositioned (int16_t x, int16_t y, const char *text, uint8_t scale=1)
 Write text to the display with a specified scale and position.

Detailed Description

A class for the SSD1306 OLED display, uses the ssd1306 library for low-level operations.

Display is connected to the I2C bus using address SSD1306_I2C_ADDRESS (0x3C). Functions are based on TKJHAT C SDK with minimal modifications to fit Arduino style and the class structure.

Default connections:

Signal I2C Macro GPIO Description
SDA DEFAULT_I2C_SDA_PIN 12 I2C data
SCL DEFAULT_I2C_SCL_PIN 13 I2C clock
Address SSD1306_I2C_ADDRESS 0x3C OLED I2C address
Precondition
The I2C interface must be initialized (use TKJHAT::begin()).
See also
SSD1306 datasheet: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
pico-ssd1306 library used: https://github.com/daschr/pico-ssd1306

Member Function Documentation

◆ drawCircle()

void Display::drawCircle ( int16_t x0,
int16_t y0,
int16_t r,
bool fill )

Draw a circle.

Parameters
x0The x-coordinate of the center
y0The y-coordinate of the center
rThe radius of the circle
fillWhether to fill the circle

◆ drawLine()

void Display::drawLine ( int16_t x0,
int16_t y0,
int16_t x1,
int16_t y1 )

Draw a line between two points.

Parameters
x0The x-coordinate of the first point
y0The y-coordinate of the first point
x1The x-coordinate of the second point
y1The y-coordinate of the second point

◆ drawSquare()

void Display::drawSquare ( uint32_t x,
uint32_t y,
uint32_t w,
uint32_t h,
bool fill )

Draw a square.

Parameters
xThe x-coordinate of the top-left corner
yThe y-coordinate of the top-left corner
wThe width of the square
hThe height of the square
fillWhether to fill the square

◆ writeText()

void Display::writeText ( const char * text)

Write text to the display with a scale of 2 at center (8,24).

Parameters
textThe text to display

◆ writeTextPositioned()

void Display::writeTextPositioned ( int16_t x,
int16_t y,
const char * text,
uint8_t scale = 1 )

Write text to the display with a specified scale and position.

Parameters
textThe text to display
xThe x-coordinate of the text
yThe y-coordinate of the text
scaleOptional, change the scale of text (default is 1)

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