Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Opensmart_LCD_UC1701
UC1701.h
00001 /** 00002 * This is a simple library for UC1701 controlled graphic LCD's. 00003 * Written for a cheap OPEN-SMART 1.8" 128x64 display 00004 * See http://www.dx.com/p/open-smart-1-8-128-64-lcd-display-breakout-module-w-blue-backlit-444694 00005 * 00006 * Written by: Erik van de Coevering 00007 * With thanks to Tim Barr from whom I've reused some code 00008 * Use this code in whatever way you like, as long as it stays free of charge! 00009 */ 00010 00011 #ifndef UC1701_H 00012 #define UC1701_H 00013 00014 #include "mbed.h" 00015 #include "font_4x5.h" 00016 #include "font_5x8.h" 00017 #include "font_6x6.h" 00018 #include "font_6x8.h" 00019 #include "font_7x7.h" 00020 #include "font_8x8.h" 00021 #include "font_8x8_1.h" 00022 #include "bold_font.h" 00023 #include "font2d_hunter.h" 00024 #include "font2d_formplex12.h" 00025 #include "biohazard.h" 00026 #include "highvoltage.h" 00027 #include "einstein.h" 00028 #include "test.h" 00029 #include "copter.h" 00030 00031 #define LCDWIDTH 128 00032 #define LCDHEIGHT 64 00033 #define LCDPAGES 8 00034 00035 class UC1701 00036 { 00037 public: 00038 00039 // Constructor 00040 UC1701(SPI &spi, DigitalOut &lcd_cs, DigitalOut &cd); 00041 00042 // Initialize LCD 00043 void init(void); 00044 00045 // Set contrast (0 - 63), initialized to 40 00046 void setContrast(char contrast); 00047 00048 // Place cursor at position 00049 void setCursor(char column, char line); 00050 00051 // Clear screen 00052 void clear(void); 00053 00054 // Fill screen by writing each pixel -> used for optimizing. Use command 0xA5 00055 void fill(void); 00056 00057 // Write text to LCD where font format is a 2-dimensional array (only 96x8, 8x8 pixel fonts supported) 00058 void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size); 00059 00060 // Write text to LCD where font format is a 1-dimensional array. Fonts bigger than 8 pix high should work but isn't tested 00061 void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size); 00062 00063 // Draw a 128x64 pixel bitmap 00064 void drawBitmap(const char *data); 00065 00066 // Draw a horizontal line, start positions / height / width in pixels 00067 void drawLineHor(char posx, char posy, char height, char width); 00068 00069 // Draw a vertical line, start positions / height / width in pixels 00070 void drawLineVert(char posx, char posy, char height, char width); 00071 00072 //----------------------------------------------------------------------------------------------------------------------------- 00073 // Functions below are buffered versions; possible to write things on top of each other without clearing pixels (ORs all data). 00074 // Use update() to write buffer to LCD. 00075 // Clear buffer before writing 1st time (initialize all values) 00076 // writetext / drawbitmap will be added soon 00077 //----------------------------------------------------------------------------------------------------------------------------- 00078 00079 // Clear buffer 00080 void clearBuffer(void); 00081 00082 // Write buffer to LCD 00083 void update(void); 00084 00085 // Draw a horizontal line, start positions / height / width in pixels. Buffered version; possible to write things on top of each other 00086 // without clearing pixels (ORs all data). Use update() to write buffer to LCD 00087 void drawbufferLineHor(char posx, char posy, char height, char width); 00088 00089 // Draw a vertical line, start positions / height / width in pixels. Buffered version. 00090 void drawbufferLineVert(char posx, char posy, char height, char width); 00091 00092 private: 00093 00094 SPI *_lcd; 00095 DigitalOut *_lcd_cs; 00096 DigitalOut *_lcd_cd; 00097 uint8_t _lcdbuffer[LCDWIDTH*LCDPAGES]; 00098 char buff[LCDWIDTH*LCDPAGES]; 00099 00100 }; 00101 00102 #endif
Generated on Thu Jul 14 2022 15:48:05 by
