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 Display Module

Committer:
embeddedartists
Date:
Thu Sep 11 14:28:32 2014 +0000
Revision:
12:eb97ccfe7c3f
Parent:
4:92d019216e28
Tweaked to get better/stable touch events

Who changed what in which revision?

UserRevisionLine numberNew contents of line
displaymodule 0:d6ff5fa503e8 1 /**********************************************************************************************
displaymodule 0:d6ff5fa503e8 2 Copyright (c) 2014 DisplayModule. All rights reserved.
displaymodule 0:d6ff5fa503e8 3
displaymodule 0:d6ff5fa503e8 4 Redistribution and use of this source code, part of this source code or any compiled binary
displaymodule 0:d6ff5fa503e8 5 based on this source code is permitted as long as the above copyright notice and following
displaymodule 0:d6ff5fa503e8 6 disclaimer is retained.
displaymodule 0:d6ff5fa503e8 7
displaymodule 0:d6ff5fa503e8 8 DISCLAIMER:
displaymodule 0:d6ff5fa503e8 9 THIS SOFTWARE IS SUPPLIED "AS IS" WITHOUT ANY WARRANTIES AND SUPPORT. DISPLAYMODULE ASSUMES
displaymodule 0:d6ff5fa503e8 10 NO RESPONSIBILITY OR LIABILITY FOR THE USE OF THE SOFTWARE.
displaymodule 0:d6ff5fa503e8 11 ********************************************************************************************/
displaymodule 0:d6ff5fa503e8 12
displaymodule 0:d6ff5fa503e8 13 #include "DmTftS6D0164.h"
displaymodule 0:d6ff5fa503e8 14
displaymodule 0:d6ff5fa503e8 15 DmTftS6D0164::DmTftS6D0164(uint8_t wr, uint8_t cs, uint8_t dc, uint8_t rst) : DmTftBase(176, 220) {
displaymodule 0:d6ff5fa503e8 16 _wr = wr;
displaymodule 0:d6ff5fa503e8 17 _cs = cs;
displaymodule 0:d6ff5fa503e8 18 _dc = dc;
displaymodule 0:d6ff5fa503e8 19 _rst = rst;
displaymodule 0:d6ff5fa503e8 20 }
displaymodule 0:d6ff5fa503e8 21
displaymodule 0:d6ff5fa503e8 22 DmTftS6D0164::~DmTftS6D0164() {
displaymodule 0:d6ff5fa503e8 23 #if defined (DM_TOOLCHAIN_MBED)
displaymodule 0:d6ff5fa503e8 24 delete _pinRST;
displaymodule 0:d6ff5fa503e8 25 delete _pinCS;
displaymodule 0:d6ff5fa503e8 26 delete _pinWR;
displaymodule 0:d6ff5fa503e8 27 delete _pinDC;
displaymodule 0:d6ff5fa503e8 28 delete _virtualPortD;
displaymodule 0:d6ff5fa503e8 29 _pinRST = NULL;
displaymodule 0:d6ff5fa503e8 30 _pinCS = NULL;
displaymodule 0:d6ff5fa503e8 31 _pinWR = NULL;
displaymodule 0:d6ff5fa503e8 32 _pinDC = NULL;
displaymodule 0:d6ff5fa503e8 33 _virtualPortD = NULL;
displaymodule 0:d6ff5fa503e8 34 #endif
displaymodule 0:d6ff5fa503e8 35 }
displaymodule 0:d6ff5fa503e8 36
displaymodule 0:d6ff5fa503e8 37 void DmTftS6D0164::writeBus(uint8_t data) {
displaymodule 0:d6ff5fa503e8 38 #if defined (DM_TOOLCHAIN_ARDUINO)
displaymodule 0:d6ff5fa503e8 39 PORTD = data;
displaymodule 0:d6ff5fa503e8 40 #elif defined (DM_TOOLCHAIN_MBED)
displaymodule 0:d6ff5fa503e8 41 *_virtualPortD = data;
displaymodule 0:d6ff5fa503e8 42 #endif
displaymodule 0:d6ff5fa503e8 43 pulse_low(_pinWR, _bitmaskWR);
displaymodule 0:d6ff5fa503e8 44 }
displaymodule 0:d6ff5fa503e8 45
displaymodule 0:d6ff5fa503e8 46 void DmTftS6D0164::sendCommand(uint8_t index) {
displaymodule 0:d6ff5fa503e8 47 cbi(_pinDC, _bitmaskDC);
displaymodule 0:d6ff5fa503e8 48 writeBus(index);
displaymodule 0:d6ff5fa503e8 49 }
displaymodule 0:d6ff5fa503e8 50
displaymodule 0:d6ff5fa503e8 51 void DmTftS6D0164::sendData(uint16_t data) {
displaymodule 0:d6ff5fa503e8 52 sbi(_pinDC, _bitmaskDC);
displaymodule 0:d6ff5fa503e8 53 writeBus(data>>8);
displaymodule 0:d6ff5fa503e8 54 writeBus(data);
displaymodule 0:d6ff5fa503e8 55 }
displaymodule 0:d6ff5fa503e8 56
displaymodule 0:d6ff5fa503e8 57 void DmTftS6D0164::setAddress(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
displaymodule 0:d6ff5fa503e8 58 sendCommand(0x37); // Set Column
displaymodule 0:d6ff5fa503e8 59 sendData(x0);
displaymodule 0:d6ff5fa503e8 60 sendCommand(0x36);
displaymodule 0:d6ff5fa503e8 61 sendData(x1);
displaymodule 0:d6ff5fa503e8 62
displaymodule 0:d6ff5fa503e8 63
displaymodule 0:d6ff5fa503e8 64 sendCommand(0x39); // Set Page
displaymodule 0:d6ff5fa503e8 65 sendData(y0);
displaymodule 0:d6ff5fa503e8 66 sendCommand(0x38);
displaymodule 0:d6ff5fa503e8 67 sendData(y1);
displaymodule 0:d6ff5fa503e8 68
displaymodule 0:d6ff5fa503e8 69 sendCommand(0x20);
displaymodule 0:d6ff5fa503e8 70 sendData(x0);
displaymodule 0:d6ff5fa503e8 71 sendCommand(0x21);
displaymodule 0:d6ff5fa503e8 72 sendData(y0);
displaymodule 0:d6ff5fa503e8 73 sendCommand(0x22);
displaymodule 0:d6ff5fa503e8 74 }
displaymodule 0:d6ff5fa503e8 75
displaymodule 0:d6ff5fa503e8 76 void DmTftS6D0164::init(void) {
displaymodule 0:d6ff5fa503e8 77 setTextColor(BLACK, WHITE);
displaymodule 0:d6ff5fa503e8 78 #if defined (DM_TOOLCHAIN_ARDUINO)
displaymodule 0:d6ff5fa503e8 79 /**************************************
displaymodule 0:d6ff5fa503e8 80 DM-DmTftS6D016422-102 Arduino UNO NUM
displaymodule 0:d6ff5fa503e8 81
displaymodule 0:d6ff5fa503e8 82 RST A2 16
displaymodule 0:d6ff5fa503e8 83 CS A3 17
displaymodule 0:d6ff5fa503e8 84 WR A4 18
displaymodule 0:d6ff5fa503e8 85 RS A5 19
displaymodule 0:d6ff5fa503e8 86
displaymodule 0:d6ff5fa503e8 87 DB8 0 0
displaymodule 0:d6ff5fa503e8 88 DB9 1 1
displaymodule 0:d6ff5fa503e8 89 DB10 2 2
displaymodule 0:d6ff5fa503e8 90 DB11 3 3
displaymodule 0:d6ff5fa503e8 91 DB12 4 4
displaymodule 0:d6ff5fa503e8 92 DB13 5 5
displaymodule 0:d6ff5fa503e8 93 DB14 6 6
displaymodule 0:d6ff5fa503e8 94 DB15 7 7
displaymodule 0:d6ff5fa503e8 95
displaymodule 0:d6ff5fa503e8 96 ***************************************/
displaymodule 0:d6ff5fa503e8 97 DDRD = DDRD | B11111111; // SET PORT D AS OUTPUT
displaymodule 0:d6ff5fa503e8 98
displaymodule 0:d6ff5fa503e8 99 _pinRST = portOutputRegister(digitalPinToPort(_rst));
displaymodule 0:d6ff5fa503e8 100 _bitmaskRST = digitalPinToBitMask(_rst);
displaymodule 0:d6ff5fa503e8 101 _pinCS = portOutputRegister(digitalPinToPort(_cs));
displaymodule 0:d6ff5fa503e8 102 _bitmaskCS = digitalPinToBitMask(_cs);
displaymodule 0:d6ff5fa503e8 103 _pinWR = portOutputRegister(digitalPinToPort(_wr));
displaymodule 0:d6ff5fa503e8 104 _bitmaskWR = digitalPinToBitMask(_wr);
displaymodule 0:d6ff5fa503e8 105 _pinDC = portOutputRegister(digitalPinToPort(_dc));
displaymodule 0:d6ff5fa503e8 106 _bitmaskDC = digitalPinToBitMask(_dc);
displaymodule 0:d6ff5fa503e8 107
displaymodule 0:d6ff5fa503e8 108 pinMode(_rst, OUTPUT);
displaymodule 0:d6ff5fa503e8 109 pinMode(_cs, OUTPUT);
displaymodule 0:d6ff5fa503e8 110 pinMode(_wr, OUTPUT);
displaymodule 0:d6ff5fa503e8 111 pinMode(_dc,OUTPUT);
displaymodule 0:d6ff5fa503e8 112 #elif defined (DM_TOOLCHAIN_MBED)
displaymodule 0:d6ff5fa503e8 113 _pinRST = new DigitalOut((PinName)_rst);
displaymodule 0:d6ff5fa503e8 114 _pinCS = new DigitalOut((PinName)_cs);
displaymodule 0:d6ff5fa503e8 115 _pinWR = new DigitalOut((PinName)_wr);
displaymodule 0:d6ff5fa503e8 116 _pinDC = new DigitalOut((PinName)_dc);
displaymodule 4:92d019216e28 117 _virtualPortD = new BusOut(D0, D1, D2, D3, D4, SPECIAL_D5, D6, D7);
displaymodule 0:d6ff5fa503e8 118 #endif
displaymodule 0:d6ff5fa503e8 119
displaymodule 0:d6ff5fa503e8 120 sbi(_pinRST, _bitmaskRST);
displaymodule 0:d6ff5fa503e8 121 delay(5);
displaymodule 0:d6ff5fa503e8 122 cbi(_pinRST, _bitmaskRST);
displaymodule 0:d6ff5fa503e8 123 delay(15);
displaymodule 0:d6ff5fa503e8 124 sbi(_pinRST, _bitmaskRST);
displaymodule 0:d6ff5fa503e8 125 sbi(_pinCS, _bitmaskCS);
displaymodule 0:d6ff5fa503e8 126 sbi(_pinWR, _bitmaskWR);
displaymodule 0:d6ff5fa503e8 127 delay(15);
displaymodule 0:d6ff5fa503e8 128 cbi(_pinCS, _bitmaskCS);
displaymodule 0:d6ff5fa503e8 129
displaymodule 0:d6ff5fa503e8 130 // Power up sequence
displaymodule 0:d6ff5fa503e8 131 sendCommand(0x11); sendData(0x001A); // S6D0164 INIT
displaymodule 0:d6ff5fa503e8 132 sendCommand(0x12); sendData(0x3121);
displaymodule 0:d6ff5fa503e8 133 sendCommand(0x13); sendData(0x006C);
displaymodule 0:d6ff5fa503e8 134 sendCommand(0x14); sendData(0x4249);
displaymodule 0:d6ff5fa503e8 135 sendCommand(0x10); sendData(0x0800);
displaymodule 0:d6ff5fa503e8 136 delay(10);
displaymodule 0:d6ff5fa503e8 137 sendCommand(0x11); sendData(0x011A);
displaymodule 0:d6ff5fa503e8 138 delay(10);
displaymodule 0:d6ff5fa503e8 139 sendCommand(0x11); sendData(0x031A);
displaymodule 0:d6ff5fa503e8 140 delay(10);
displaymodule 0:d6ff5fa503e8 141 sendCommand(0x11); sendData(0x071A);
displaymodule 0:d6ff5fa503e8 142 delay(10);
displaymodule 0:d6ff5fa503e8 143 sendCommand(0x11); sendData(0x0F1A);
displaymodule 0:d6ff5fa503e8 144 delay(20);
displaymodule 0:d6ff5fa503e8 145 sendCommand(0x11); sendData(0x0F3A);
displaymodule 0:d6ff5fa503e8 146 delay(30);
displaymodule 0:d6ff5fa503e8 147 // Initialization set sequence
displaymodule 0:d6ff5fa503e8 148 sendCommand(0x01); sendData(0x011C);
displaymodule 0:d6ff5fa503e8 149 sendCommand(0x02); sendData(0x0100);
displaymodule 0:d6ff5fa503e8 150 sendCommand(0x03); sendData(0x1030);
displaymodule 0:d6ff5fa503e8 151 sendCommand(0x07); sendData(0x0000);
displaymodule 0:d6ff5fa503e8 152 sendCommand(0x08); sendData(0x0808);
displaymodule 0:d6ff5fa503e8 153 sendCommand(0x0B); sendData(0x1100);
displaymodule 0:d6ff5fa503e8 154 sendCommand(0x0C); sendData(0x0000);
displaymodule 0:d6ff5fa503e8 155 sendCommand(0x0F); sendData(0x1401);
displaymodule 0:d6ff5fa503e8 156 sendCommand(0x15); sendData(0x0000);
displaymodule 0:d6ff5fa503e8 157 sendCommand(0x20); sendData(0x0000);
displaymodule 0:d6ff5fa503e8 158 sendCommand(0x21); sendData(0x0000);
displaymodule 0:d6ff5fa503e8 159
displaymodule 0:d6ff5fa503e8 160 sendCommand(0x38); sendData(0x00DB);
displaymodule 0:d6ff5fa503e8 161 sendCommand(0x39); sendData(0x0000);
displaymodule 0:d6ff5fa503e8 162 sendCommand(0x50); sendData(0x0001);
displaymodule 0:d6ff5fa503e8 163 sendCommand(0x51); sendData(0x020B);
displaymodule 0:d6ff5fa503e8 164 sendCommand(0x52); sendData(0x0805);
displaymodule 0:d6ff5fa503e8 165 sendCommand(0x53); sendData(0x0404);
displaymodule 0:d6ff5fa503e8 166 sendCommand(0x54); sendData(0x0C0C);
displaymodule 0:d6ff5fa503e8 167 sendCommand(0x55); sendData(0x000C);
displaymodule 0:d6ff5fa503e8 168 sendCommand(0x56); sendData(0x0101);
displaymodule 0:d6ff5fa503e8 169 sendCommand(0x57); sendData(0x0400);
displaymodule 0:d6ff5fa503e8 170 sendCommand(0x58); sendData(0x1108);
displaymodule 0:d6ff5fa503e8 171 sendCommand(0x59); sendData(0x050C);
displaymodule 0:d6ff5fa503e8 172 sendCommand(0x36); sendData(0x00AF);
displaymodule 0:d6ff5fa503e8 173 sendCommand(0x37); sendData(0x0000);
displaymodule 0:d6ff5fa503e8 174 sendCommand(0x38); sendData(0x00DB);
displaymodule 0:d6ff5fa503e8 175 sendCommand(0x39); sendData(0x0000);
displaymodule 0:d6ff5fa503e8 176 sendCommand(0x0F); sendData(0x0B01);
displaymodule 0:d6ff5fa503e8 177 sendCommand(0x07); sendData(0x0016);
displaymodule 0:d6ff5fa503e8 178 delay(2);
displaymodule 0:d6ff5fa503e8 179 sendCommand(0x07); sendData(0x0017);
displaymodule 0:d6ff5fa503e8 180 sendCommand(0x22);
displaymodule 0:d6ff5fa503e8 181 delay(10);
displaymodule 0:d6ff5fa503e8 182 sbi(_pinCS, _bitmaskCS);
displaymodule 0:d6ff5fa503e8 183
displaymodule 0:d6ff5fa503e8 184 clearScreen();
displaymodule 0:d6ff5fa503e8 185 }
displaymodule 0:d6ff5fa503e8 186
displaymodule 0:d6ff5fa503e8 187 /*********************************************************************************************************
displaymodule 0:d6ff5fa503e8 188 END FILE
displaymodule 0:d6ff5fa503e8 189 *********************************************************************************************************/
displaymodule 0:d6ff5fa503e8 190
displaymodule 0:d6ff5fa503e8 191