displaylib_1bit_PICO 2.0.0
1-bit colour graphic display library, Rpi PICO RP2040 library
Loading...
Searching...
No Matches
nokia5110.hpp
Go to the documentation of this file.
1
7#pragma once
8
9// libraries
10#include <cstdint>
11#include <cstdbool>
12#include <cstdio>
13#include "hardware/spi.h"
14#include "pico/stdlib.h"
15#include "display_graphics.hpp"
16
21{
22
23public:
24
25 NOKIA_5110(int16_t width, int16_t height);
26 ~NOKIA_5110(){};
27
28 virtual void drawPixel(int16_t x, int16_t y, uint8_t color) override;
29
30 DisplayRet::Ret_Codes_e LCDSPISetup(spi_inst_t *spi, uint32_t spiBaudRate, int8_t cd, int8_t rst, int8_t cs, int8_t sclk, int8_t din);
31 void LCDInit(bool Inverse, uint8_t Contrast,uint8_t Bias);
32 DisplayRet::Ret_Codes_e LCDSetBufferPtr(uint8_t width, uint8_t height, std::span<uint8_t> buffer);
33
36 void LCDBuffer(std::span<uint8_t> data);
37
38 void LCDenableSleep(void);
39 void LCDdisableSleep(void);
40 bool LCDIsSleeping(void);
41
42 void LCDSPIoff(void);
43 void LCDPowerDown(void);
44
45 void LCDSetContrast(uint8_t con);
46 void LCDfillScreen(uint8_t fill = 0xFF);
47 void LCDinvertDisplay(bool inv);
48 void LCDgotoXY(uint8_t x, uint8_t y);
49 void LCDfillBlock(uint8_t FillData = 0xFF , uint8_t RowBlockNum = 0);
50
51private:
52
53 void LCDWriteData(uint8_t data);
54 void LCDWriteCommand(uint8_t command);
55
56 // LCD Commands & registers list
57 static constexpr uint8_t LCD_FUNCTIONSET = 0x20;
58 static constexpr uint8_t LCD_POWERDOWN = 0x04;
59 static constexpr uint8_t LCD_ENTRYMODE = 0x02;
60 static constexpr uint8_t LCD_EXTENDEDINSTRUCTION = 0x01;
62 static constexpr uint8_t LCD_DISPLAYCONTROL = 0x08;
63 static constexpr uint8_t LCD_DISPLAYBLANK = 0x00;
64 static constexpr uint8_t LCD_DISPLAYNORMAL = 0x04;
65 static constexpr uint8_t LCD_DISPLAYALLON = 0x01;
66 static constexpr uint8_t LCD_DISPLAYINVERTED = 0x05;
68 static constexpr uint8_t LCD_SETYADDR = 0x40;
69 static constexpr uint8_t LCD_SETXADDR = 0x80;
71 static constexpr uint8_t LCD_SETTEMP = 0x04;
72 static constexpr uint8_t LCD_CONTRAST = 0xB0;
73 static constexpr uint8_t LCD_BIAS = 0x13;
75 // SPI
76 int8_t _display_CS;
77 int8_t _display_CD;
78 int8_t _display_RST;
80 int8_t _display_DIN;
81 spi_inst_t *_spiInterface;
83 // Display
84 uint8_t _contrast;
85 uint8_t _bias;
86 bool _inverse = false;
87 bool _sleep;
89// Screen related
90 int16_t _LCD_WIDTH = 84;
91 int16_t _LCD_HEIGHT = 48;
92 int8_t _LCD_PAGE_NUM = (_LCD_HEIGHT / 8);
94 std::span<uint8_t> _LCDbuffer;
95}; //end of class
96
97
Class Controls SPI comms and LCD functionality.
Definition nokia5110.hpp:21
static constexpr uint8_t LCD_SETYADDR
Definition nokia5110.hpp:68
static constexpr uint8_t LCD_DISPLAYBLANK
Definition nokia5110.hpp:63
void LCDBuffer(std::span< uint8_t > data)
Draw an array to the screen.
Definition nokia5110.cpp:307
int8_t _display_DIN
Definition nokia5110.hpp:80
spi_inst_t * _spiInterface
Definition nokia5110.hpp:81
void LCDenableSleep(void)
Turn on sleep mode.
Definition nokia5110.cpp:234
DisplayRet::Ret_Codes_e LCDSetBufferPtr(uint8_t width, uint8_t height, std::span< uint8_t > buffer)
sets the buffer pointer to the users screen data buffer
Definition nokia5110.cpp:330
bool _inverse
Definition nokia5110.hpp:86
uint8_t _contrast
Definition nokia5110.hpp:84
DisplayRet::Ret_Codes_e LCDclearBuffer(void)
clears the buffer of the active screen pointed to by ActiveBuffer
Definition nokia5110.cpp:290
static constexpr uint8_t LCD_POWERDOWN
Definition nokia5110.hpp:58
static constexpr uint8_t LCD_DISPLAYALLON
Definition nokia5110.hpp:65
int16_t _LCD_Display_size
Definition nokia5110.hpp:93
void LCDgotoXY(uint8_t x, uint8_t y)
LCDgotoXY gotoXY routine to position cursor (x,y)
Definition nokia5110.cpp:353
DisplayRet::Ret_Codes_e LCDSPISetup(spi_inst_t *spi, uint32_t spiBaudRate, int8_t cd, int8_t rst, int8_t cs, int8_t sclk, int8_t din)
initialise LCD pinmodes and SPI setup
Definition nokia5110.cpp:32
virtual void drawPixel(int16_t x, int16_t y, uint8_t color) override
Set a single pixel in the buffer.
Definition nokia5110.cpp:162
static constexpr uint8_t LCD_SETTEMP
Definition nokia5110.hpp:71
int8_t _display_CD
Definition nokia5110.hpp:77
void LCDInit(bool Inverse, uint8_t Contrast, uint8_t Bias)
Init the LCD command sequence, called from begin This sends the commands to the PCD8544 to init LCD.
Definition nokia5110.cpp:79
void LCDSetContrast(uint8_t con)
Function to set contrast passed a byte.
Definition nokia5110.cpp:148
static constexpr uint8_t LCD_DISPLAYNORMAL
Definition nokia5110.hpp:64
bool LCDIsSleeping(void)
LCDisSleeping.
Definition nokia5110.cpp:263
void LCDinvertDisplay(bool inv)
inverts color on display
Definition nokia5110.cpp:219
bool _sleep
Definition nokia5110.hpp:87
int16_t _LCD_WIDTH
Definition nokia5110.hpp:90
int16_t _LCD_HEIGHT
Definition nokia5110.hpp:91
int8_t _display_RST
Definition nokia5110.hpp:78
static constexpr uint8_t LCD_ENTRYMODE
Definition nokia5110.hpp:59
void LCDWriteData(uint8_t data)
Writes a byte to the PCD8544.
Definition nokia5110.cpp:127
int8_t _display_SCLK
Definition nokia5110.hpp:79
uint8_t _bias
Definition nokia5110.hpp:85
void LCDfillScreen(uint8_t fill=0xFF)
Writes the buffer (with pattern) to the LCD.
Definition nokia5110.cpp:201
void LCDdisableSleep(void)
Turn off sleep mode.
Definition nokia5110.cpp:243
static constexpr uint8_t LCD_CONTRAST
Definition nokia5110.hpp:72
int8_t _display_CS
Definition nokia5110.hpp:76
int8_t _LCD_PAGE_NUM
Definition nokia5110.hpp:92
static constexpr uint8_t LCD_DISPLAYINVERTED
Definition nokia5110.hpp:66
void LCDSPIoff(void)
End SPI operations.
Definition nokia5110.cpp:105
std::span< uint8_t > _LCDbuffer
Definition nokia5110.hpp:94
static constexpr uint8_t LCD_SETXADDR
Definition nokia5110.hpp:69
static constexpr uint8_t LCD_DISPLAYCONTROL
Definition nokia5110.hpp:62
static constexpr uint8_t LCD_EXTENDEDINSTRUCTION
Definition nokia5110.hpp:60
static constexpr uint8_t LCD_FUNCTIONSET
Definition nokia5110.hpp:57
DisplayRet::Ret_Codes_e LCDupdate(void)
updates the LCD i.e. writes the shared buffer to the active screen pointed to by ActiveBuffer
Definition nokia5110.cpp:272
void LCDWriteCommand(uint8_t command)
Writes a command byte to the PCD8544.
Definition nokia5110.cpp:136
void LCDfillBlock(uint8_t FillData=0xFF, uint8_t RowBlockNum=0)
LCDFillBlock Clears one of the 6 row blocks(one byte height) on LCD.
Definition nokia5110.cpp:367
void LCDPowerDown(void)
Powerdown procedure for LCD see datasheet P40.
Definition nokia5110.cpp:113
static constexpr uint8_t LCD_BIAS
Definition nokia5110.hpp:73
Graphics class to hold graphic related functions.
Definition display_graphics.hpp:22
int16_t height(void) const
Gets the height of the display (per current _rotation)
Definition display_graphics.cpp:677
int16_t width(void) const
Gets the width of the display (per current _rotation)
Definition display_graphics.cpp:668
header file for the graphics based functions, 1-bit color displays.
Ret_Codes_e
Definition display_data.hpp:32