Modified version of the DmTftLibrary, optimized for the LPC4088 Experiment Base Board
Dependents: lpc4088_ebb_dm_calc lpc4088_ebb_dm_bubbles
Fork of DmTftLibrary by
DmTftS6D0164.cpp
00001 /********************************************************************************************** 00002 Copyright (c) 2014 DisplayModule. All rights reserved. 00003 00004 Redistribution and use of this source code, part of this source code or any compiled binary 00005 based on this source code is permitted as long as the above copyright notice and following 00006 disclaimer is retained. 00007 00008 DISCLAIMER: 00009 THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES 00010 NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE. 00011 ********************************************************************************************/ 00012 00013 #include "DmTftS6D0164.h" 00014 00015 DmTftS6D0164::DmTftS6D0164(uint8_t wr, uint8_t cs, uint8_t dc, uint8_t rst) : DmTftBase(176, 220) { 00016 _wr = wr; 00017 _cs = cs; 00018 _dc = dc; 00019 _rst = rst; 00020 } 00021 00022 DmTftS6D0164::~DmTftS6D0164() { 00023 #if defined (DM_TOOLCHAIN_MBED) 00024 delete _pinRST; 00025 delete _pinCS; 00026 delete _pinWR; 00027 delete _pinDC; 00028 delete _virtualPortD; 00029 _pinRST = NULL; 00030 _pinCS = NULL; 00031 _pinWR = NULL; 00032 _pinDC = NULL; 00033 _virtualPortD = NULL; 00034 #endif 00035 } 00036 00037 void DmTftS6D0164::writeBus(uint8_t data) { 00038 #if defined (DM_TOOLCHAIN_ARDUINO) 00039 PORTD = data; 00040 #elif defined (DM_TOOLCHAIN_MBED) 00041 *_virtualPortD = data; 00042 #endif 00043 pulse_low(_pinWR, _bitmaskWR); 00044 } 00045 00046 void DmTftS6D0164::sendCommand(uint8_t index) { 00047 cbi(_pinDC, _bitmaskDC); 00048 writeBus(index); 00049 } 00050 00051 void DmTftS6D0164::sendData(uint16_t data) { 00052 sbi(_pinDC, _bitmaskDC); 00053 writeBus(data>>8); 00054 writeBus(data); 00055 } 00056 00057 void DmTftS6D0164::setAddress(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { 00058 sendCommand(0x37); // Set Column 00059 sendData(x0); 00060 sendCommand(0x36); 00061 sendData(x1); 00062 00063 00064 sendCommand(0x39); // Set Page 00065 sendData(y0); 00066 sendCommand(0x38); 00067 sendData(y1); 00068 00069 sendCommand(0x20); 00070 sendData(x0); 00071 sendCommand(0x21); 00072 sendData(y0); 00073 sendCommand(0x22); 00074 } 00075 00076 void DmTftS6D0164::init(void) { 00077 setTextColor(BLACK, WHITE); 00078 #if defined (DM_TOOLCHAIN_ARDUINO) 00079 /************************************** 00080 DM-DmTftS6D016422-102 Arduino UNO NUM 00081 00082 RST A2 16 00083 CS A3 17 00084 WR A4 18 00085 RS A5 19 00086 00087 DB8 0 0 00088 DB9 1 1 00089 DB10 2 2 00090 DB11 3 3 00091 DB12 4 4 00092 DB13 5 5 00093 DB14 6 6 00094 DB15 7 7 00095 00096 ***************************************/ 00097 DDRD = DDRD | B11111111; // SET PORT D AS OUTPUT 00098 00099 _pinRST = portOutputRegister(digitalPinToPort(_rst)); 00100 _bitmaskRST = digitalPinToBitMask(_rst); 00101 _pinCS = portOutputRegister(digitalPinToPort(_cs)); 00102 _bitmaskCS = digitalPinToBitMask(_cs); 00103 _pinWR = portOutputRegister(digitalPinToPort(_wr)); 00104 _bitmaskWR = digitalPinToBitMask(_wr); 00105 _pinDC = portOutputRegister(digitalPinToPort(_dc)); 00106 _bitmaskDC = digitalPinToBitMask(_dc); 00107 00108 pinMode(_rst, OUTPUT); 00109 pinMode(_cs, OUTPUT); 00110 pinMode(_wr, OUTPUT); 00111 pinMode(_dc,OUTPUT); 00112 #elif defined (DM_TOOLCHAIN_MBED) 00113 _pinRST = new DigitalOut((PinName)_rst); 00114 _pinCS = new DigitalOut((PinName)_cs); 00115 _pinWR = new DigitalOut((PinName)_wr); 00116 _pinDC = new DigitalOut((PinName)_dc); 00117 _virtualPortD = new BusOut(D0, D1, D2, D3, D4, SPECIAL_D5, D6, D7); 00118 #endif 00119 00120 sbi(_pinRST, _bitmaskRST); 00121 delay(5); 00122 cbi(_pinRST, _bitmaskRST); 00123 delay(15); 00124 sbi(_pinRST, _bitmaskRST); 00125 sbi(_pinCS, _bitmaskCS); 00126 sbi(_pinWR, _bitmaskWR); 00127 delay(15); 00128 cbi(_pinCS, _bitmaskCS); 00129 00130 // Power up sequence 00131 sendCommand(0x11); sendData(0x001A); // S6D0164 INIT 00132 sendCommand(0x12); sendData(0x3121); 00133 sendCommand(0x13); sendData(0x006C); 00134 sendCommand(0x14); sendData(0x4249); 00135 sendCommand(0x10); sendData(0x0800); 00136 delay(10); 00137 sendCommand(0x11); sendData(0x011A); 00138 delay(10); 00139 sendCommand(0x11); sendData(0x031A); 00140 delay(10); 00141 sendCommand(0x11); sendData(0x071A); 00142 delay(10); 00143 sendCommand(0x11); sendData(0x0F1A); 00144 delay(20); 00145 sendCommand(0x11); sendData(0x0F3A); 00146 delay(30); 00147 // Initialization set sequence 00148 sendCommand(0x01); sendData(0x011C); 00149 sendCommand(0x02); sendData(0x0100); 00150 sendCommand(0x03); sendData(0x1030); 00151 sendCommand(0x07); sendData(0x0000); 00152 sendCommand(0x08); sendData(0x0808); 00153 sendCommand(0x0B); sendData(0x1100); 00154 sendCommand(0x0C); sendData(0x0000); 00155 sendCommand(0x0F); sendData(0x1401); 00156 sendCommand(0x15); sendData(0x0000); 00157 sendCommand(0x20); sendData(0x0000); 00158 sendCommand(0x21); sendData(0x0000); 00159 00160 sendCommand(0x38); sendData(0x00DB); 00161 sendCommand(0x39); sendData(0x0000); 00162 sendCommand(0x50); sendData(0x0001); 00163 sendCommand(0x51); sendData(0x020B); 00164 sendCommand(0x52); sendData(0x0805); 00165 sendCommand(0x53); sendData(0x0404); 00166 sendCommand(0x54); sendData(0x0C0C); 00167 sendCommand(0x55); sendData(0x000C); 00168 sendCommand(0x56); sendData(0x0101); 00169 sendCommand(0x57); sendData(0x0400); 00170 sendCommand(0x58); sendData(0x1108); 00171 sendCommand(0x59); sendData(0x050C); 00172 sendCommand(0x36); sendData(0x00AF); 00173 sendCommand(0x37); sendData(0x0000); 00174 sendCommand(0x38); sendData(0x00DB); 00175 sendCommand(0x39); sendData(0x0000); 00176 sendCommand(0x0F); sendData(0x0B01); 00177 sendCommand(0x07); sendData(0x0016); 00178 delay(2); 00179 sendCommand(0x07); sendData(0x0017); 00180 sendCommand(0x22); 00181 delay(10); 00182 sbi(_pinCS, _bitmaskCS); 00183 00184 clearScreen(); 00185 } 00186 00187 /********************************************************************************************************* 00188 END FILE 00189 *********************************************************************************************************/ 00190 00191
Generated on Tue Jul 12 2022 19:30:31 by 1.7.2