Hexiwear OLED Display Driver

Dependents:   Hexi_OLED_TextImage_Example Hexi_OLED_Text_Example Hexi_OLED_Image_Example security-console-app ... more

Embed: (wiki syntax)

« Back to documentation index

SSD1351 Class Reference

SSD1351 Class Reference

OLED Display Driver for Hexiwear. More...

#include <Hexi_OLED_SSD1351.h>

Public Member Functions

 SSD1351 (PinName mosiPin, PinName sclkPin, PinName pwrPin, PinName csPin, PinName rstPin, PinName dcPin)
 Create a Hexiwear OLED Driver connected to the specified pins.
 ~SSD1351 ()
 Destroy the Hexiwear instance.
void SendCmd (uint32_t cmd, uint8_t isFirst)
 Send the command to OLED.
void SendData (const uint8_t *dataToSend, uint32_t dataSize)
 Send data to OLED.
oled_status_t DrawBox (int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height, uint16_t color)
 draw box on OLED
void FillScreen (uint16_t color)
 Fill the entire screen with specified color.
oled_status_t DrawPixel (int8_t xCrd, int8_t yCrd, uint16_t color)
 Draw a single pixel.
oled_status_t DrawScreen (const uint8_t *image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height, oled_transition_t transition)
 Draw the whole screen.
oled_status_t SetFont (const uint8_t *newFont, uint16_t newColor)
 Set the font to use.
void SetDynamicArea (oled_dynamic_area_t *dynamic_area)
 Set OLED dynamic area.
void DestroyDynamicArea ()
 Destroy current OLED dynamic area.
void SetTextProperties (oled_text_properties_t *textProperties)
 Set OLED class text properties from parameter.
void GetTextProperties (oled_text_properties_t *textProperties)
 Copy OLED class text properties to parameter.
uint8_t GetTextWidth (const uint8_t *text)
 Return the width in [px] required for the given string to be displayed.
uint8_t CharCount (uint8_t width, const uint8_t *font, const uint8_t *text, uint8_t length)
 Count the characters.
oled_status_t AddText (const uint8_t *text, int8_t xCrd, int8_t yCrd)
 Add text to the main screen buffer at position x,y.
oled_status_t AddText (const uint8_t *text)
 Add text to the main screen buffer.
oled_status_t DrawText (const uint8_t *text)
 Write text on OLED at position set in Dynamic Area Field.
void GetImageDimensions (uint8_t *width, uint8_t *height, const uint8_t *image)
 Return the dimensions of image.
oled_status_t AddImage (const uint8_t *image)
 Add image to the main screen buffer.Used with SetDynamicArea() Function.
oled_status_t AddImage (const uint8_t *image, int8_t xCrd, int8_t yCrd)
 Add image to the main screen buffer at position x,y.
oled_status_t DrawImage (const uint8_t *image)
 Send image to OLED GRAM.Used with SetDynamicArea() Function for positioning image.
oled_status_t DrawImage (const uint8_t *image, int8_t xCrd, int8_t yCrd)
 Send image to OLED GRAM at position x,y.
void DimScreenON ()
 Dim OLED screen on.
void DimScreenOFF ()
 Return OLED back to full contrast.
void Swap (oled_pixel_t imgDst, const uint8_t *imgSrc, uint16_t imgSize)
 Swap image's bytes per pixel to obtain the correct color format.
void PowerON ()
 Turn on Power for OLED Display.
void PowerOFF ()
 Turn off Power for OLED Display.
void UpdateBuffer (int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height, const uint8_t *image)
 update the main screen buffer with the given image
oled_status_t Label (const uint8_t *text, int8_t xCrd, int8_t yCrd)
 Write text on OLED at position x,y.
oled_status_t TextBox (const uint8_t *text, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height)
 Create a text box of width,height at position x,y.

Detailed Description

OLED Display Driver for Hexiwear.

Definition at line 46 of file Hexi_OLED_SSD1351.h.


Constructor & Destructor Documentation

SSD1351 ( PinName  mosiPin,
PinName  sclkPin,
PinName  pwrPin,
PinName  csPin,
PinName  rstPin,
PinName  dcPin 
)

Create a Hexiwear OLED Driver connected to the specified pins.

Parameters:
mosiPinSPI Master Out, Slave In Pin
sclkPinSPI CLock Pin
pwrPinOLED Power Pin
csPinOLED Chip Select Pin
rstPinOLED Reset Pin
dcPinOLED DC Pin
Note:
Default TextProperties

.font = OpenSans_10x15_Regular, .fontColor = COLOR_WHITE, .alignParam = OLED_TEXT_ALIGN_CENTER, .background = NULL

Definition at line 86 of file Hexi_OLED_SSD1351.cpp.

~SSD1351 ( void   )

Destroy the Hexiwear instance.

Definition at line 128 of file Hexi_OLED_SSD1351.cpp.


Member Function Documentation

oled_status_t AddImage ( const uint8_t *  image )

Add image to the main screen buffer.Used with SetDynamicArea() Function.

Parameters:
imagedesired image
Returns:
status flag

Definition at line 763 of file Hexi_OLED_SSD1351.cpp.

oled_status_t AddImage ( const uint8_t *  image,
int8_t  xCrd,
int8_t  yCrd 
)

Add image to the main screen buffer at position x,y.

Parameters:
imagedesired image
xCrdimage x-coordinate
yCrdimage y-coordinate
Returns:
status flag

Definition at line 786 of file Hexi_OLED_SSD1351.cpp.

oled_status_t AddText ( const uint8_t *  text,
int8_t  xCrd,
int8_t  yCrd 
)

Add text to the main screen buffer at position x,y.

Parameters:
texttext to add
xCrdx-coordinate for the given text
yCrdy-coordinate for the given text
Returns:
status flag

Definition at line 498 of file Hexi_OLED_SSD1351.cpp.

oled_status_t AddText ( const uint8_t *  text )

Add text to the main screen buffer.

Used with SetDynamicArea() Function.

Parameters:
texttext to add
Returns:
status flag

set default values, if necessary

write the characters into designated space, one by one

Definition at line 615 of file Hexi_OLED_SSD1351.cpp.

uint8_t CharCount ( uint8_t  width,
const uint8_t *  font,
const uint8_t *  text,
uint8_t  length 
)

Count the characters.

Parameters:
widthtext width
fonttext font
textgiven text string
lengthtext length
Returns:
character count

Definition at line 472 of file Hexi_OLED_SSD1351.cpp.

void DestroyDynamicArea (  )

Destroy current OLED dynamic area.

Definition at line 425 of file Hexi_OLED_SSD1351.cpp.

void DimScreenOFF (  )

Return OLED back to full contrast.

Definition at line 868 of file Hexi_OLED_SSD1351.cpp.

void DimScreenON (  )

Dim OLED screen on.

Definition at line 856 of file Hexi_OLED_SSD1351.cpp.

oled_status_t DrawBox ( int8_t  xCrd,
int8_t  yCrd,
uint8_t  width,
uint8_t  height,
uint16_t  color 
)

draw box on OLED

Parameters:
xCrdx-coordinate for box's uper left corner
yCrdy-coordinate for box's uper left corner
widthbox's width
heightbox's height
colorcolor of the box
Returns:
status flag

Definition at line 203 of file Hexi_OLED_SSD1351.cpp.

oled_status_t DrawImage ( const uint8_t *  image,
int8_t  xCrd,
int8_t  yCrd 
)

Send image to OLED GRAM at position x,y.

Parameters:
imagedesired image
xCrdimage x-coordinate
yCrdimage y-coordinate
Returns:
status flag

Definition at line 836 of file Hexi_OLED_SSD1351.cpp.

oled_status_t DrawImage ( const uint8_t *  image )

Send image to OLED GRAM.Used with SetDynamicArea() Function for positioning image.

Parameters:
imagedesired image
Returns:
status flag

Definition at line 818 of file Hexi_OLED_SSD1351.cpp.

oled_status_t DrawPixel ( int8_t  xCrd,
int8_t  yCrd,
uint16_t  color 
)

Draw a single pixel.

Parameters:
xCrdpixel's x coordinate
yCrdpixel's y coordinate
colorpixel's color
Returns:
status flag

Definition at line 297 of file Hexi_OLED_SSD1351.cpp.

oled_status_t DrawScreen ( const uint8_t *  image,
int8_t  xCrd,
int8_t  yCrd,
uint8_t  width,
uint8_t  height,
oled_transition_t  transition 
)

Draw the whole screen.

Parameters:
imageimage to draw
xCrdimage x-coordinate
yCrdimage y-coordinate
widthimage width
heightimage height
transitiontransition style for the new image arrival
Returns:
status flag

Definition at line 328 of file Hexi_OLED_SSD1351.cpp.

oled_status_t DrawText ( const uint8_t *  text )

Write text on OLED at position set in Dynamic Area Field.

Used with SetDynamicArea() Function.

Parameters:
textdesired text

Definition at line 737 of file Hexi_OLED_SSD1351.cpp.

void FillScreen ( uint16_t  color )

Fill the entire screen with specified color.

fill the entire screen

Parameters:
colorcolor to fill with
colorcolor to fill with
Returns:
status flag

Definition at line 278 of file Hexi_OLED_SSD1351.cpp.

void GetImageDimensions ( uint8_t *  width,
uint8_t *  height,
const uint8_t *  image 
)

Return the dimensions of image.

Parameters:
widthgiven image's width
heightgiven image's height
imagedesired image

Definition at line 756 of file Hexi_OLED_SSD1351.cpp.

void GetTextProperties ( oled_text_properties_t *  textProperties )

Copy OLED class text properties to parameter.

Parameters:
textPropertiesdestination data-structure

Definition at line 445 of file Hexi_OLED_SSD1351.cpp.

uint8_t GetTextWidth ( const uint8_t *  text )

Return the width in [px] required for the given string to be displayed.

Parameters:
textdesired string
Returns:
required text width in [px]

Definition at line 453 of file Hexi_OLED_SSD1351.cpp.

oled_status_t Label ( const uint8_t *  text,
int8_t  xCrd,
int8_t  yCrd 
)

Write text on OLED at position x,y.

Recommended for Static Text.

Parameters:
textdesired text
xCrdx-coordinate for the given text
yCrdy-coordinate for the given text

Definition at line 927 of file Hexi_OLED_SSD1351.cpp.

void PowerOFF (  )

Turn off Power for OLED Display.

Definition at line 898 of file Hexi_OLED_SSD1351.cpp.

void PowerON (  )

Turn on Power for OLED Display.

Definition at line 893 of file Hexi_OLED_SSD1351.cpp.

void SendCmd ( uint32_t  cmd,
uint8_t  isFirst 
)

Send the command to OLED.

Parameters:
cmdOLED command from the datasheet
isFirstdesignate if this is the first byte in the command

Definition at line 138 of file Hexi_OLED_SSD1351.cpp.

void SendData ( const uint8_t *  dataToSend,
uint32_t  dataSize 
)

Send data to OLED.

Parameters:
dataToSenddata to send to OLED
dataSizedata-size

Definition at line 167 of file Hexi_OLED_SSD1351.cpp.

void SetDynamicArea ( oled_dynamic_area_t *  dynamic_area )

Set OLED dynamic area.

Parameters:
dynamic_areadata-structure with desired values

Definition at line 402 of file Hexi_OLED_SSD1351.cpp.

oled_status_t SetFont ( const uint8_t *  newFont,
uint16_t  newColor 
)

Set the font to use.

Parameters:
newFontdesired font
newColordesired color
Returns:
status flag

Definition at line 383 of file Hexi_OLED_SSD1351.cpp.

void SetTextProperties ( oled_text_properties_t *  textProperties )

Set OLED class text properties from parameter.

Parameters:
textPropertiesdata-structure with desired properties

Definition at line 435 of file Hexi_OLED_SSD1351.cpp.

void Swap ( oled_pixel_t  imgDst,
const uint8_t *  imgSrc,
uint16_t  imgSize 
)

Swap image's bytes per pixel to obtain the correct color format.

Parameters:
imgDstdesired image
imgSrcoriginal image
imgSizeimage's size

Definition at line 876 of file Hexi_OLED_SSD1351.cpp.

oled_status_t TextBox ( const uint8_t *  text,
int8_t  xCrd,
int8_t  yCrd,
uint8_t  width,
uint8_t  height 
)

Create a text box of width,height at position x,y.

Recommended for Dynamic Text. Text is aligned in textbox accordingly to the align parameter set by SetTextProperties().

Parameters:
textdesired text
xCrdx-coordinate for the textbox
yCrdy-coordinate for the textbox
widthwidth of the textbox
heightheight of the textbox

Definition at line 948 of file Hexi_OLED_SSD1351.cpp.

void UpdateBuffer ( int8_t  xCrd,
int8_t  yCrd,
uint8_t  width,
uint8_t  height,
const uint8_t *  image 
)

update the main screen buffer with the given image

Parameters:
xCrdimage x-coordinate
yCrdimage y-coordinate
widthimage width
heightimage height
imageimage for buffer

Definition at line 906 of file Hexi_OLED_SSD1351.cpp.