Extended library from C12832 Lib. by Peter Drescher, Chris Styles & Mihail Stoyanov. LCD in the market such as AQM1248A (Akizuki), AD-12864-SPI (antendo), NHD-C12832 (Newhaven), ST7565 (adafruit) and so on
Dependents: CW_Decoder_using_FFT_on_F446 LPC1114_SPI_LCD_ST7565family_test
Fork of C12832 by
ST7565 Class Reference
SPI LCD control library for ST7565 Controller http://www.ladyada.net/learn/lcd/st7565.html. More...
#include <ST7565_SPI_LCD.h>
Inherits GraphicsDisplay.
Public Types | |
enum | LCDType |
LCD panel format. More... | |
Public Member Functions | |
ST7565 (PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, LCDType type, const char *name="LCD") | |
Create a ST7565 object connected to SPI1. | |
virtual int | width () |
Get the width of the screen in pixel. | |
virtual int | height () |
Get the height of the screen in pixel. | |
virtual void | pixel (int x, int y, int colour) |
Draw a pixel at x,y black or white. | |
void | circle (int x, int y, int r, int colour) |
Draw a circle. | |
void | fillcircle (int x, int y, int r, int colour) |
Draw a filled circle. | |
void | line (int x0, int y0, int x1, int y1, int colour) |
Draw a 1 pixel line. | |
void | rect (int x0, int y0, int x1, int y1, int colour) |
Draw a rect. | |
void | fillrect (int x0, int y0, int x1, int y1, int colour) |
Draw a filled rect. | |
void | set_contrast (unsigned int o) |
set the contrast level | |
unsigned int | get_contrast (void) |
read the contrast level | |
void | invert (unsigned int o) |
Invert the screen. | |
virtual void | cls (void) |
Clear the screen. | |
void | setmode (int mode) |
Set the drawing mode. | |
virtual int | columns (void) |
Calculate the max number of columns. | |
virtual int | rows (void) |
calculate the max number of rows | |
virtual void | character (int x, int y, int c) |
Draw a character on given position out of the active font to the LCD. | |
virtual void | locate (int x, int y) |
Setup cursor position. | |
void | set_auto_up (unsigned int up) |
Setup auto update of screen. | |
unsigned int | get_auto_up (void) |
Get status of the auto update function. | |
void | set_font (unsigned char *f) |
Select the font to use. | |
void | print_bm (Bitmap bm, int x, int y) |
Print bitmap to buffer. | |
int | putc (int c) |
Write a character to the LCD. | |
int | printf (const char *format,...) |
Write a formated string to the LCD. | |
virtual bool | claim (FILE *stream) |
Redirect output from a stream (stoud, sterr) to display. | |
Protected Types | |
enum | |
Draw color. More... | |
enum | |
Draw mode NORMAl XOR set pixel by xor the screen. More... | |
Protected Attributes | |
SPI * | _spi_p |
Vars. |
Detailed Description
SPI LCD control library for ST7565 Controller http://www.ladyada.net/learn/lcd/st7565.html.
AD-12864-SPI http://www.aitendo.com/product/1622 AQM12848A http://akizukidenshi.com/catalog/g/gK-07007/
#include "mbed.h" #if 1 // mosi, sck, reset, a0, ncs ST7565 lcd(dp2, dp6, dp10, dp4, dp9, ST7565::AD12864SPI); #else SPI spi_lcd(dp2, dp1, dp6); // mosi, miso, sck // spi, reset, a0, ncs ST7565 lcd(spi_lcd, dp10, dp4, dp9, ST7565::AD12864SPI); #endif int main() { lcd.cls(); lcd.set_contrast(0x06); lcd.printf("123456789012345678901234567890\r\n"); lcd.rect(10,10,100,50,BLACK); lcd.circle(10,10,10,BLACK); lcd.fillcircle(50,40,10,BLACK); lcd.line(0,0,110,60,BLACK); while(1){;} }
Definition at line 75 of file ST7565_SPI_LCD.h.
Member Enumeration Documentation
anonymous enum [protected] |
Draw color.
Definition at line 306 of file ST7565_SPI_LCD.h.
anonymous enum [protected] |
Draw mode NORMAl XOR set pixel by xor the screen.
Definition at line 312 of file ST7565_SPI_LCD.h.
enum LCDType |
LCD panel format.
Definition at line 80 of file ST7565_SPI_LCD.h.
Constructor & Destructor Documentation
ST7565 | ( | PinName | mosi, |
PinName | sck, | ||
PinName | reset, | ||
PinName | a0, | ||
PinName | ncs, | ||
LCDType | type, | ||
const char * | name = "LCD" |
||
) |
Create a ST7565 object connected to SPI1.
Definition at line 50 of file ST7565_SPI_LCD.cpp.
Member Function Documentation
void character | ( | int | x, |
int | y, | ||
int | c | ||
) | [virtual] |
Draw a character on given position out of the active font to the LCD.
- Parameters:
-
x x-position of char (top left) y y-position c char to print
Implements TextDisplay.
Definition at line 576 of file ST7565_SPI_LCD.cpp.
void circle | ( | int | x, |
int | y, | ||
int | r, | ||
int | colour | ||
) |
Draw a circle.
- Parameters:
-
x0,y0 center r radius color - 1 set pixel, 0 erase pixel
Definition at line 411 of file ST7565_SPI_LCD.cpp.
bool claim | ( | FILE * | stream ) | [virtual, inherited] |
Redirect output from a stream (stoud, sterr) to display.
- Parameters:
-
stream stream that shall be redirected to the TextDisplay
Definition at line 65 of file TextDisplay.cpp.
void cls | ( | void | ) | [virtual] |
Clear the screen.
Reimplemented from TextDisplay.
Definition at line 289 of file ST7565_SPI_LCD.cpp.
int columns | ( | void | ) | [virtual] |
Calculate the max number of columns.
Depends on actual font size
- Returns:
- max column
Implements TextDisplay.
Definition at line 534 of file ST7565_SPI_LCD.cpp.
void fillcircle | ( | int | x, |
int | y, | ||
int | r, | ||
int | colour | ||
) |
Draw a filled circle.
- Parameters:
-
x0,y0 center r radius color - 1 set pixel, 0 erase pixel
Use circle with different radius, Can miss some pixels
Definition at line 508 of file ST7565_SPI_LCD.cpp.
void fillrect | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | colour | ||
) |
Draw a filled rect.
- Parameters:
-
x0,y0 top left corner x1,y1 down right corner color - 1 set pixel, 0 erase pixel
Definition at line 387 of file ST7565_SPI_LCD.cpp.
unsigned int get_auto_up | ( | void | ) |
Get status of the auto update function.
- Returns:
- if auto update is on
Definition at line 637 of file ST7565_SPI_LCD.cpp.
unsigned int get_contrast | ( | void | ) |
read the contrast level
Definition at line 138 of file ST7565_SPI_LCD.cpp.
int height | ( | ) | [virtual] |
Get the height of the screen in pixel.
- Returns:
- height of screen in pixel
Definition at line 115 of file ST7565_SPI_LCD.cpp.
void invert | ( | unsigned int | o ) |
Invert the screen.
- Parameters:
-
o = 0 normal, 1 invert
Definition at line 121 of file ST7565_SPI_LCD.cpp.
void line | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | colour | ||
) |
Draw a 1 pixel line.
- Parameters:
-
x0,y0 start point x1,y1 stop point color - 1 set pixel, 0 erase pixel
Definition at line 295 of file ST7565_SPI_LCD.cpp.
void locate | ( | int | x, |
int | y | ||
) | [virtual] |
Setup cursor position.
- Parameters:
-
x x-position (top left) y y-position
Reimplemented from TextDisplay.
Definition at line 528 of file ST7565_SPI_LCD.cpp.
void pixel | ( | int | x, |
int | y, | ||
int | colour | ||
) | [virtual] |
Draw a pixel at x,y black or white.
- Parameters:
-
x horizontal position y vertical position color - 1 set pixel, 0 erase pixel
Definition at line 198 of file ST7565_SPI_LCD.cpp.
void print_bm | ( | Bitmap | bm, |
int | x, | ||
int | y | ||
) |
Print bitmap to buffer.
- Parameters:
-
bm Bitmap in flash x x start y y start
Definition at line 642 of file ST7565_SPI_LCD.cpp.
int printf | ( | const char * | format, |
... | |||
) |
Write a formated string to the LCD.
- Parameters:
-
format A printf-style format string, followed by the variables to use in formating the string.
int putc | ( | int | c ) |
Write a character to the LCD.
- Parameters:
-
c The character to write to the display
void rect | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | colour | ||
) |
Draw a rect.
- Parameters:
-
x0,y0 top left corner x1,y1 down right corner color - 1 set pixel, 0 erase pixel
Definition at line 360 of file ST7565_SPI_LCD.cpp.
int rows | ( | void | ) | [virtual] |
calculate the max number of rows
- Returns:
- max rows depends on actual font size
Implements TextDisplay.
Definition at line 539 of file ST7565_SPI_LCD.cpp.
void set_auto_up | ( | unsigned int | up ) |
Setup auto update of screen.
- Parameters:
-
up 1 = on , 0 = off
if switched off the program has to call copy_to_lcd() to update screen from framebuffer
Definition at line 628 of file ST7565_SPI_LCD.cpp.
void set_contrast | ( | unsigned int | o ) |
set the contrast level
Definition at line 130 of file ST7565_SPI_LCD.cpp.
void set_font | ( | unsigned char * | f ) |
Select the font to use.
- Parameters:
-
f pointer to font array
font array can created with GLCD Font Creator from http://www.mikroe.com you have to add 4 parameter at the beginning of the font array to use:
- the number of byte / char
- the vertial size in pixel
- the horizontal size in pixel
- the number of byte per vertical line you also have to change the array to char[]
Definition at line 623 of file ST7565_SPI_LCD.cpp.
void setmode | ( | int | mode ) |
Set the drawing mode.
- Parameters:
-
mode NORMAl or XOR
Definition at line 523 of file ST7565_SPI_LCD.cpp.
int width | ( | ) | [virtual] |
Get the width of the screen in pixel.
- Returns:
- width of screen in pixel
Definition at line 109 of file ST7565_SPI_LCD.cpp.
Field Documentation
SPI* _spi_p [protected] |
Vars.
Definition at line 315 of file ST7565_SPI_LCD.h.
Generated on Tue Jul 12 2022 20:40:34 by 1.7.2