Simple library for UC1701 based GLCD's
Dependents: Opensmart_LCD_UC1701
With lots of fonts! Will include more in the future. A couple bitmaps have also been added.
UC1701.h
- Committer:
- Anaesthetix
- Date:
- 2016-12-19
- Revision:
- 5:7494bdca926b
- Parent:
- 3:baaa16e24adc
File content as of revision 5:7494bdca926b:
/** * This is a simple library for UC1701 controlled graphic LCD's. * Written for a cheap OPEN-SMART 1.8" 128x64 display * See http://www.dx.com/p/open-smart-1-8-128-64-lcd-display-breakout-module-w-blue-backlit-444694 * * Written by: Erik van de Coevering * With thanks to Tim Barr from whom I've reused some code * Use this code in whatever way you like, as long as it stays free of charge! */ #ifndef UC1701_H #define UC1701_H #include "mbed.h" #include "font_4x5.h" #include "font_5x8.h" #include "font_6x6.h" #include "font_6x8.h" #include "font_7x7.h" #include "font_8x8.h" #include "font_8x8_1.h" #include "bold_font.h" #include "font2d_hunter.h" #include "font2d_formplex12.h" #include "biohazard.h" #include "highvoltage.h" #include "einstein.h" #include "test.h" #include "copter.h" #define LCDWIDTH 128 #define LCDHEIGHT 64 #define LCDPAGES 8 class UC1701 { public: // Constructor UC1701(SPI &spi, DigitalOut &lcd_cs, DigitalOut &cd); // Initialize LCD void init(void); // Set contrast (0 - 63), initialized to 40 void setContrast(char contrast); // Place cursor at position void setCursor(char column, char line); // Clear screen void clear(void); // Fill screen by writing each pixel -> used for optimizing. Use command 0xA5 void fill(void); // Write text to LCD where font format is a 2-dimensional array (only 96x8, 8x8 pixel fonts supported) void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size); // Write text to LCD where font format is a 1-dimensional array. Fonts bigger than 8 pix high should work but isn't tested void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size); // Draw a 128x64 pixel bitmap void drawBitmap(const char *data); // Draw a horizontal line, start positions / height / width in pixels void drawLineHor(char posx, char posy, char height, char width); // Draw a vertical line, start positions / height / width in pixels void drawLineVert(char posx, char posy, char height, char width); //----------------------------------------------------------------------------------------------------------------------------- // Functions below are buffered versions; possible to write things on top of each other without clearing pixels (ORs all data). // Use update() to write buffer to LCD. // Clear buffer before writing 1st time (initialize all values) // writetext / drawbitmap will be added soon //----------------------------------------------------------------------------------------------------------------------------- // Clear buffer void clearBuffer(void); // Write buffer to LCD void update(void); // Draw a horizontal line, start positions / height / width in pixels. Buffered version; possible to write things on top of each other // without clearing pixels (ORs all data). Use update() to write buffer to LCD void drawbufferLineHor(char posx, char posy, char height, char width); // Draw a vertical line, start positions / height / width in pixels. Buffered version. void drawbufferLineVert(char posx, char posy, char height, char width); private: SPI *_lcd; DigitalOut *_lcd_cs; DigitalOut *_lcd_cd; uint8_t _lcdbuffer[LCDWIDTH*LCDPAGES]; char buff[LCDWIDTH*LCDPAGES]; }; #endif