NOKIA5110_TEXT  2.4.0
Arduino Eco-system Library for Nokia 5110 LCD ( PCD8544 controller)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
NOKIA5110_TEXT Class Reference

Public Member Functions

 NOKIA5110_TEXT (uint8_t LCD_RST, uint8_t LCD_CE, uint8_t LCD_DC, int8_t LCD_DIN, int8_t LCD_CLK)
 Software SPI default. More...
 
 NOKIA5110_TEXT (uint8_t LCD_RST, uint8_t LCD_CE, uint8_t LCD_DC)
 Hardware SPI. More...
 
void LCDInit (bool Inverse=false, uint8_t Contrast=LCD_CONTRAST, uint8_t Bias=LCD_BIAS)
 LCDinit This sends the commands to the PCD8544 to init LCD. More...
 
void LCDsetContrast (uint8_t contrast)
 LCDSetContrast to set LCD contrast. More...
 
void LCDenableSleep (void)
 LCDenableSleep Put the LCD to Sleep function.
 
void LCDdisableSleep (void)
 LCDdisableSleep Wake the LCD up from Sleep.
 
void LCDSPIWrite (unsigned char DataOrCommand, unsigned char data)
 LCDSPIWrite write to display. More...
 
bool LCDIsSleeping (void)
 LCDisSleeping. More...
 
void LCDgotoXY (uint8_t x, uint8_t y)
 LCDgotoXY gotoXY routine to position cursor (x,y) More...
 
void LCDClear (uint8_t FillData=0x00)
 LCDClear Clears the LCD by writing zeros to the entire screen. More...
 
void LCDClearBlock (uint8_t RowBlockNum=0)
 LCDClearBlock Clears one of the 6 row blocks(one byte height) on LCD by writing zeros to the line. More efficient than clearing whole screen. More...
 
void LCDFillBlock (uint8_t FillData=0xFF, uint8_t RowBlockNum=0)
 LCDFillBlock Clears one of the 6 row blocks(one byte height) on LCD. More...
 
void LCDFont (LCDFontType_e FontNumber)
 LCDFont. More...
 
void LCDCharacter (char character)
 LCDCharacter print character Calls relevant method for the font set. More...
 
void LCDString (const char *characters)
 LCDString given a string of characters, one by one is passed to the LCD. More...
 
void LCDSetPixel (uint8_t col=0, uint8_t row=0)
 LCDSetPixel Method to set a individual pixel. More...
 
void LCDCustomChar (const unsigned char character[], uint16_t numChars, LCDPaddingType_e, bool ProgMemLocale)
 LCDCustomChar Write a custom character or bitmap to screen X by Y. More...
 
virtual void write (uint8_t)
 write is used by print super class simply wraps LCDCharacter when called by print
More...
 

Private Member Functions

void LCDdraw_fonts_1TO6 (char character)
 Draw font 1-6: 8 bit high fonts. More...
 
void LCDdraw_fonts_7 (char character)
 used to draw fonts 7 large More...
 
void LCDdraw_fonts_8TO9 (char character)
 used to draw fonts: huge and mega , 8 and 9 More...
 
bool isHardwareSPI (void)
 isHardwareSPI More...
 

Private Attributes

uint8_t _LCD_RST
 
uint8_t _LCD_CE
 
uint8_t _LCD_DC
 
int8_t _LCD_DIN
 
int8_t _LCD_CLK
 
uint8_t _contrast = LCD_CONTRAST
 
uint8_t _bias = LCD_BIAS
 
bool _inverse = false
 
bool _sleep = false
 
uint8_t _Block = 0
 
uint8_t _Col = 0
 
uint8_t _CurrentFontNumber = LCDFont_Default
 
uint8_t _CurrentFontWidth = 5
 
uint8_t _CurrentFontOffset = 0x20
 

Constructor & Destructor Documentation

◆ NOKIA5110_TEXT() [1/2]

NOKIA5110_TEXT::NOKIA5110_TEXT ( uint8_t  LCD_RST,
uint8_t  LCD_CE,
uint8_t  LCD_DC,
int8_t  LCD_DIN,
int8_t  LCD_CLK 
)

Software SPI default.

Constructor of the class object from left to right pin 1-5(LCD)

Parameters
LCD_RSTGPIO reset line
LCD_CEGPIO chip enable line
LCD_DCGPIO data or command line
LCD_DINGPIO data in , MOSI line
LCD_CLKGPIO clock line

◆ NOKIA5110_TEXT() [2/2]

NOKIA5110_TEXT::NOKIA5110_TEXT ( uint8_t  LCD_RST,
uint8_t  LCD_CE,
uint8_t  LCD_DC 
)

Hardware SPI.

Constructor of the class object from left to right pin 1-3(LCD)

Parameters
LCD_RSTGPIO reset line
LCD_CEGPIO chip enable line
LCD_DCGPIO data or command line

Member Function Documentation

◆ isHardwareSPI()

bool NOKIA5110_TEXT::isHardwareSPI ( void  )
private

isHardwareSPI

Checks if software SPI is on

Returns
true 1 if hardware SPi on , false 0 for software spi

◆ LCDCharacter()

void NOKIA5110_TEXT::LCDCharacter ( char  character)

LCDCharacter print character Calls relevant method for the font set.

Parameters
characterthe character to print

◆ LCDClear()

void NOKIA5110_TEXT::LCDClear ( uint8_t  FillData = 0x00)

LCDClear Clears the LCD by writing zeros to the entire screen.

Parameters
FillDataDefault is zero but can be passed a fill pattern eg 0xFF = all pixels on.

◆ LCDClearBlock()

void NOKIA5110_TEXT::LCDClearBlock ( uint8_t  RowBlockNum = 0)

LCDClearBlock Clears one of the 6 row blocks(one byte height) on LCD by writing zeros to the line. More efficient than clearing whole screen.

Parameters
RowBlockNumSend the row block number 0-5

◆ LCDCustomChar()

void NOKIA5110_TEXT::LCDCustomChar ( const unsigned char  character[],
uint16_t  numChars,
LCDPaddingType_e  padding,
bool  ProgMemLocale 
)

LCDCustomChar Write a custom character or bitmap to screen X by Y.

Parameters
characterExample: 5 by 8 = || || = Char array unsigned char power[5] = {0xFF, 0xFF, 0x00, 0xFF, 0xFF};
numCharsSize of array, sizeof(power) / sizeof(unsigned char)
paddingBlank vertical line padding padding 4 values
  1. 0 = no padding
  2. 1 = Left hand side padding only
  3. 2 = Right hand side padding only
  4. 3 = LHS + RHS
ProgMemLocaleIs the data of character[] in PROGMEM? true for PROGMEM , false for SRAM/data

◆ LCDdraw_fonts_1TO6()

void NOKIA5110_TEXT::LCDdraw_fonts_1TO6 ( char  character)
private

Draw font 1-6: 8 bit high fonts.

Parameters
characterthe character to print

◆ LCDdraw_fonts_7()

void NOKIA5110_TEXT::LCDdraw_fonts_7 ( char  character)
private

used to draw fonts 7 large

Parameters
characterpassed a char
Note
  1. data format of uint16_t fetched from font table
  2. 0xAABB font 7 16 bit high
  3. BB Upper byte top half of character
  4. AA lower byte bot half of character

◆ LCDdraw_fonts_8TO9()

void NOKIA5110_TEXT::LCDdraw_fonts_8TO9 ( char  character)
private

used to draw fonts: huge and mega , 8 and 9

Parameters
characterpassed a char
Note
  1. data format of uint32_t fetched from font file
  2. 0xAABBCCDD font 9 32 bit high
  3. 0x–BBCCDD font 8 24 bit high
    9 font 8 font data
    DD DD Upper byte
    CC CC upper middle byte
    BB BB lower middle byte
    AA lower byte , – = n/a for font 8

◆ LCDFillBlock()

void NOKIA5110_TEXT::LCDFillBlock ( uint8_t  FillData = 0xFF,
uint8_t  RowBlockNum = 0 
)

LCDFillBlock Clears one of the 6 row blocks(one byte height) on LCD.

Parameters
FillDatadata to write 0-0xFF
RowBlockNumrow block number 0-5
Note
The pattern of data can be reversed by changing filldata i.e 0x0F will half fill a block with ones.

◆ LCDFont()

void NOKIA5110_TEXT::LCDFont ( LCDFontType_e  FontNumber)

LCDFont.

Parameters
FontNumbera enum LCDFontType_e to set between fonts , 1-9

Enum to store current font width , Size width of fonts in pixels,

< tiny font

< seven segment font

< Default

< thick + homeSpun

< wide

< large , no lowercase letters

< mega and huge , numbers only

font offset in the ASCII table

< full ASCII

< Starts at Space

< ASCII code for . is 0X2E (. / 0 1 etc)

◆ LCDgotoXY()

void NOKIA5110_TEXT::LCDgotoXY ( uint8_t  x,
uint8_t  y 
)

LCDgotoXY gotoXY routine to position cursor (x,y)

Parameters
xrange: 0 to 83 (0 to 0x53)
yrange: 0 to 5 (6 blocks one byte each 6*8 = 48)

◆ LCDInit()

void NOKIA5110_TEXT::LCDInit ( bool  Inverse = false,
uint8_t  Contrast = LCD_CONTRAST,
uint8_t  Bias = LCD_BIAS 
)

LCDinit This sends the commands to the PCD8544 to init LCD.

Parameters
Inverseinverts the display.
ContrastThis value allows us to change LCD's contrast Try B0 to BF.
BiasValue is for system biasing, try 0x12<->0X14

◆ LCDIsSleeping()

bool NOKIA5110_TEXT::LCDIsSleeping ( void  )

LCDisSleeping.

Returns
value of _sleep, if true LCD is in sleep mode.

◆ LCDsetContrast()

void NOKIA5110_TEXT::LCDsetContrast ( uint8_t  contrast)

LCDSetContrast to set LCD contrast.

Parameters
contrastSet LCD VOP Contrast, range = ((0x00-0x7F) |0x80) 0xB5 = (0x35|0x80) try B1 - BF normally.

◆ LCDSetPixel()

void NOKIA5110_TEXT::LCDSetPixel ( uint8_t  col = 0,
uint8_t  row = 0 
)

LCDSetPixel Method to set a individual pixel.

Parameters
colcolumn position X = 0-83
rowrow position Y = 0-47

Can be used to create simple graphics.

◆ LCDSPIWrite()

void NOKIA5110_TEXT::LCDSPIWrite ( unsigned char  DataOrCommand,
unsigned char  data 
)

LCDSPIWrite write to display.

Parameters
datathe data byte to write
DataOrCommandone = data, zero = command
Note
There are two banks in the LCD, data and commands. This function sets the DC pin high or low depending, and then sends the data byte. The first byte is one(data) or zero(cmd), second byte data. Prints the byte down from current position, it is used internally to draw cols of characters it can be used to create vertical lines or patterns.

◆ LCDString()

void NOKIA5110_TEXT::LCDString ( const char *  characters)

LCDString given a string of characters, one by one is passed to the LCD.

Parameters
characterspointer to string array

◆ write()

void NOKIA5110_TEXT::write ( uint8_t  c)
virtual

write is used by print super class simply wraps LCDCharacter when called by print

Parameters
cThe character to print

Member Data Documentation

◆ _bias

uint8_t NOKIA5110_TEXT::_bias = LCD_BIAS
private

LCD Bias

◆ _Block

uint8_t NOKIA5110_TEXT::_Block = 0
private

LCD block 0-5, screen is heigh of 48 pixels is divided into 6 block's each a byte high

◆ _Col

uint8_t NOKIA5110_TEXT::_Col = 0
private

LCD Column 0-83

◆ _contrast

uint8_t NOKIA5110_TEXT::_contrast = LCD_CONTRAST
private

LCD Contrast

◆ _CurrentFontNumber

uint8_t NOKIA5110_TEXT::_CurrentFontNumber = LCDFont_Default
private

Stores Current font 1-9

◆ _CurrentFontOffset

uint8_t NOKIA5110_TEXT::_CurrentFontOffset = 0x20
private

Stores Current font offset in the ASCII table

◆ _CurrentFontWidth

uint8_t NOKIA5110_TEXT::_CurrentFontWidth = 5
private

Stores Current font width

◆ _inverse

bool NOKIA5110_TEXT::_inverse = false
private

LCD Inversion mode , Pixels black or white

◆ _LCD_CE

uint8_t NOKIA5110_TEXT::_LCD_CE
private

GPIO for Chip enable line

◆ _LCD_CLK

int8_t NOKIA5110_TEXT::_LCD_CLK
private

GPIO for SPI clock line, Software SPI only

◆ _LCD_DC

uint8_t NOKIA5110_TEXT::_LCD_DC
private

GPIO for Data or command line

◆ _LCD_DIN

int8_t NOKIA5110_TEXT::_LCD_DIN
private

GPIO for Data line (MOSI) , Software SPI only

◆ _LCD_RST

uint8_t NOKIA5110_TEXT::_LCD_RST
private

GPIO for reset line

◆ _sleep

bool NOKIA5110_TEXT::_sleep = false
private

LCD Sleep mode false awake , true LCD sleep


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