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.
UC1608.cpp
00001 /* mbed UniGraphic library - Device specific class 00002 * Copyright (c) 2015 Giuliano Dianda 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 */ 00005 #include "Protocols.h " 00006 #include "UC1608.h" 00007 00008 ////////////////////////////////////////////////////////////////////////////////// 00009 // display settings /////////////////////////////////////////////////////// 00010 ///////////////////////////////////////////////////////////////////////// 00011 #define IC_X_SEGS 240 // UC1608 SEG has range 0-239 (239-0 if MX=1), check your datasheet, important for the orientation 00012 #define IC_Y_COMS 128 // UC1608 COM has range 0-127 (127-0 if MY=1), check your datasheet, important for the orientation 00013 //#define LCDSIZE_X 240 // display X pixels 00014 //#define LCDSIZE_Y 120 // display Y pixels, UC1608 is advertised as 240x128 but display size could be smaller 00015 00016 00017 00018 UC1608::UC1608(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name , unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) 00019 : LCD(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name) 00020 { 00021 hw_reset(); 00022 BusEnable(true); 00023 init(); 00024 cls(); 00025 set_orientation(1); 00026 locate(0,0); 00027 } 00028 UC1608::UC1608(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name, unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) 00029 : LCD(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name) 00030 { 00031 hw_reset(); 00032 BusEnable(true); 00033 init(); 00034 cls(); 00035 set_orientation(1); 00036 locate(0,0); 00037 } 00038 // reset and init the lcd controller 00039 void UC1608::init() 00040 { 00041 /* Start Initial Sequence ----------------------------------------------------*/ 00042 00043 // wr_cmd8(0xE2); // sw reset 00044 wait_ms(15); 00045 00046 wr_cmd8(0x27); // Multiplex rate :128 set temperature consenpation 0% 00047 wr_cmd8(0xEA); //set bias:1/12bias 00048 00049 wr_cmd8(0xC4); // set mirror MX=1,MY=0 (controller->display SEGs wiring inverted) 00050 // wr_cmd8(0xA0); // ADC select seg0-seg223 00051 //wr_cmd8(0xA1); // ADC select seg223-seg0 00052 // wr_cmd8(0xC8); // SHL select com63-com0 00053 //wr_cmd8(0xC0); // SHL select com0-com63 00054 00055 wr_cmd8(0x2F); // //Power Control:internal, LCD capacitance 60nf-90nf 00056 wait_ms(10); 00057 00058 // wr_cmd8(0x81);//Set Gain and Potentiometer 00059 // wr_cmd8(0x40|26);//Set Gain and Potentiometer xx xxxxxx 00060 set_contrast(26); 00061 00062 wr_cmd8(0x88); //disable colum/page address wraparound 00063 wr_cmd8(0xA4); // LCD display ram (EntireDisplayOn disable) 00064 wr_cmd8(0x40); // start line = 0 00065 wr_cmd8(0xA6); // display normal (1 = illuminated) 00066 wr_cmd8(0xAF); // display ON 00067 00068 } 00069 //////////////////////////////////////////////////////////////////// 00070 // functions that overrides the standard ones implemented in LCD.cpp 00071 //////////////////////////////////////////////////////////////////// 00072 void UC1608::mirrorXY(mirror_t mode) 00073 { 00074 switch (mode) 00075 { 00076 case(NONE): 00077 wr_cmd8(0xC4); // this is in real X mirror command, but my display have SEGs wired inverted, so assume this is the default no-x-mirror 00078 break; 00079 case(X): 00080 wr_cmd8(0xC0); 00081 break; 00082 case(Y): 00083 wr_cmd8(0xCC); 00084 break; 00085 case(XY): 00086 wr_cmd8(0xC8); 00087 break; 00088 } 00089 } 00090 void UC1608::set_contrast(int o) 00091 { 00092 contrast = o; 00093 // wr_cmd8(0x81); // set volume 00094 // wr_cmd8(0x40|(o&0x3F)); 00095 wr_cmd16(0x8140|(o&0x3F)); 00096 } 00097 void UC1608::BusEnable(bool enable) 00098 { 00099 LCD::BusEnable(!enable); // crap IC has CS not inverted (active HIGH) 00100 }
Generated on Fri Jul 15 2022 13:58:04 by
