Simple library for interfacing to Nokia 5110 LCD display (as found on the SparkFun website). - koristen softverski SPI umjesto hardverskog
Fork of N5110 by
N5110 Class Reference
Simple library for interfacing with Nokia 5110 LCD display (https://www.sparkfun.com/products/10168) using the hardware SPI on the mbed. More...
#include <N5110.h>
Public Member Functions | |
N5110 (PinName pwrPin, PinName scePin, PinName rstPin, PinName dcPin, PinName mosiPin, PinName sclkPin, PinName ledPin) | |
Create a N5110 object connected to the specified pins. | |
void | init () |
Initialise display. | |
void | turnOff () |
Turn off. | |
void | clear () |
Clears. | |
void | normalMode () |
Turn on normal video mode (default) Black on white. | |
void | inverseMode () |
Turn on inverse video mode (default) White on black. | |
void | setBrightness (float brightness) |
Set Brightness. | |
void | setXYAddress (int x, int y) |
Set XY Address. | |
void | printString (const char *str, int x, int y) |
Print String. | |
void | printChar (char c) |
Print Character. | |
void | setPixel (int x, int y) |
Set a Pixel. | |
void | clearPixel (int x, int y) |
Clear a Pixel. | |
unsigned char | getPixel (int x, int y) |
Get a Pixel. | |
void | refresh () |
Refresh display. | |
void | randomiseBuffer () |
Randomise buffer. |
Detailed Description
Simple library for interfacing with Nokia 5110 LCD display (https://www.sparkfun.com/products/10168) using the hardware SPI on the mbed.
The display is powered from a GPIO pin meaning it can be controlled via software. The LED backlight is also software-controllable (via PWM pin). Can print characters and strings to the display using the included 5x7 font. The library also implements a screen buffer so that individual pixels on the display (84 x 48) can be set, cleared and read.
Acknowledgements to Chris Yan's Nokia_5110 Library.
Revision 1.0
- Date:
- January 2014
Example:
#include "mbed.h" #include "N5110.h" // VCC,SCE,RST,D/C,MOSI,SCLK,LED N5110 lcd(p7,p8,p9,p10,p11,p13,p26); int main() { // initialise display lcd.init(); // print a string in top-left corner lcd.printString("Hello, World!",0,0); // move cursor to 4th row lcd.setXYAddress(0,3); // print character lcd.printChar('X'); while(1); }
Definition at line 77 of file N5110.h.
Constructor & Destructor Documentation
N5110 | ( | PinName | pwrPin, |
PinName | scePin, | ||
PinName | rstPin, | ||
PinName | dcPin, | ||
PinName | mosiPin, | ||
PinName | sclkPin, | ||
PinName | ledPin | ||
) |
Create a N5110 object connected to the specified pins.
- Parameters:
-
pwr Pin connected to Vcc on the LCD display (pin 1) sce Pin connected to chip enable (pin 3) rst Pin connected to reset (pin 4) dc Pin connected to data/command select (pin 5) mosi Pin connected to data input (MOSI) (pin 6) sclk Pin connected to serial clock (SCLK) (pin 7) led Pin connected to LED backlight (must be PWM) (pin 8)
Member Function Documentation
void clearPixel | ( | int | x, |
int | y | ||
) |
unsigned char getPixel | ( | int | x, |
int | y | ||
) |
void init | ( | ) |
void inverseMode | ( | ) |
void normalMode | ( | ) |
void printChar | ( | char | c ) |
void printString | ( | const char * | str, |
int | x, | ||
int | y | ||
) |
void randomiseBuffer | ( | ) |
Randomise buffer.
This function fills the buffer with random data. Can be used to test the display. A call to refresh() must be made to update the display to reflect the change in pixels. The seed is not set and so the generated pattern will probably be the same each time. TODO: Randomise the seed - maybe using the noise on the AnalogIn pins.
void refresh | ( | ) |
void setBrightness | ( | float | brightness ) |
void setPixel | ( | int | x, |
int | y | ||
) |
void setXYAddress | ( | int | x, |
int | y | ||
) |
Set XY Address.
Sets the X and Y address of where the next data sent to the displa will be written in RAM.
- Parameters:
-
x - the column number (0 to 83) - is automatically incremented after data is written y - the row number (0 to 5) - the diplay is split into 6 banks - each bank can be considered a row
Generated on Wed Jul 20 2022 04:01:44 by 1.7.2