Music Player for ARCH-PRO

Dependencies:   GT20L16J1Y_font TinyJpgDec mbed

SeeedStudio Arch Pro + aitendo TFT-LCD w/Touch panel => .wav File Player
LPC1768 + aitendo TFT-LCD w/Touch panel => .wav File Player
http://goji2100.com/
/media/uploads/Goji/017s.png

Committer:
Goji
Date:
Mon Sep 08 16:07:05 2014 +0000
Revision:
0:6fa19738f62e
Music Player for ARCH-PRO

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Goji 0:6fa19738f62e 1 // --------------------------------------------------------
Goji 0:6fa19738f62e 2 // mGTFTini.h (c) CopYright 2013-2014 Goji.
Goji 0:6fa19738f62e 3 // --------------------------------------------------------
Goji 0:6fa19738f62e 4
Goji 0:6fa19738f62e 5 DigitalOut TFT_RD(TFT_pin_RD);
Goji 0:6fa19738f62e 6 DigitalOut TFT_WR(TFT_pin_WR);
Goji 0:6fa19738f62e 7 DigitalOut TFT_CS(TFT_pin_CS);
Goji 0:6fa19738f62e 8 DigitalOut TFT_RS(TFT_pin_RS);
Goji 0:6fa19738f62e 9 DigitalOut TFT_RESET(TFT_pin_RESET);
Goji 0:6fa19738f62e 10
Goji 0:6fa19738f62e 11 #define TFT_RESET_0 TFT_RESET = 0
Goji 0:6fa19738f62e 12 #define TFT_RESET_1 TFT_RESET = 1
Goji 0:6fa19738f62e 13 #define TFT_RS_0 TFT_RS = 0
Goji 0:6fa19738f62e 14 #define TFT_RS_1 TFT_RS = 1
Goji 0:6fa19738f62e 15 #define TFT_WR_0 TFT_WR = 0
Goji 0:6fa19738f62e 16 #define TFT_WR_1 TFT_WR = 1
Goji 0:6fa19738f62e 17 #define TFT_CS_0 TFT_CS = 0
Goji 0:6fa19738f62e 18 #define TFT_CS_1 TFT_CS = 1
Goji 0:6fa19738f62e 19 #define TFT_RD_0 TFT_RD = 0
Goji 0:6fa19738f62e 20 #define TFT_RD_1 TFT_RD = 1
Goji 0:6fa19738f62e 21
Goji 0:6fa19738f62e 22 TFT_INFO TFT_info = {
Goji 0:6fa19738f62e 23 TFT_MIN_X,
Goji 0:6fa19738f62e 24 TFT_MAX_X,
Goji 0:6fa19738f62e 25 TFT_MIN_Y,
Goji 0:6fa19738f62e 26 TFT_MAX_Y,
Goji 0:6fa19738f62e 27 TPC_XNON,
Goji 0:6fa19738f62e 28 TPC_XMIN,
Goji 0:6fa19738f62e 29 TPC_XMAX,
Goji 0:6fa19738f62e 30 TPC_YNON,
Goji 0:6fa19738f62e 31 TPC_YMIN,
Goji 0:6fa19738f62e 32 TPC_YMAX
Goji 0:6fa19738f62e 33 };
Goji 0:6fa19738f62e 34
Goji 0:6fa19738f62e 35
Goji 0:6fa19738f62e 36 //---------------------------------------------------------------------
Goji 0:6fa19738f62e 37 #if defined(ILI9325)
Goji 0:6fa19738f62e 38 //---------------------------------------------------------------------
Goji 0:6fa19738f62e 39 uint16_t TFT_Init_table[] = {
Goji 0:6fa19738f62e 40 // http://www.ilitek.com ILI9325 Application Notes
Goji 0:6fa19738f62e 41 // - Set internal timing ------------ //
Goji 0:6fa19738f62e 42 0xE3, 0x3008, // Set internal timing
Goji 0:6fa19738f62e 43 0xE7, 0x0012,
Goji 0:6fa19738f62e 44 0xEF, 0x1231,
Goji 0:6fa19738f62e 45
Goji 0:6fa19738f62e 46 // - Start Initial Sequence --------- //
Goji 0:6fa19738f62e 47 0x01, 0x0100, // set SS and SM bit
Goji 0:6fa19738f62e 48 0x02, 0x0700, // set 1 line inversion
Goji 0:6fa19738f62e 49 0x03, 0x1038, // set GRAM write direction and BGR=1.
Goji 0:6fa19738f62e 50 0x04, 0x0000, // Resize register
Goji 0:6fa19738f62e 51 0x08, 0x0207, // set the back porch and front porch
Goji 0:6fa19738f62e 52 0x09, 0x0000, // set non-display area refresh cycle ISC[3:0]
Goji 0:6fa19738f62e 53 0x0A, 0x0000, // FMARK function
Goji 0:6fa19738f62e 54 0x0C, 0x0000, // RGB interface setting
Goji 0:6fa19738f62e 55 0x0D, 0x0000, // Frame marker Position
Goji 0:6fa19738f62e 56 0x0F, 0x0000, // RGB interface polarity
Goji 0:6fa19738f62e 57
Goji 0:6fa19738f62e 58 // - Power On sequence -------------- //
Goji 0:6fa19738f62e 59 0x10, 0x0000, // SAP, BT[3:0], AP, DSTB, SLP, STB
Goji 0:6fa19738f62e 60 0x11, 0x0007, // DC1[2:0], DC0[2:0], VC[2:0]
Goji 0:6fa19738f62e 61 0x12, 0x0000, // VREG1OUT voltage
Goji 0:6fa19738f62e 62 0x13, 0x0000, // VDV[4:0] for VCOM amplitude
Goji 0:6fa19738f62e 63 WW, 200,
Goji 0:6fa19738f62e 64
Goji 0:6fa19738f62e 65 0x10, 0x1490, // SAP, BT[3:0], AP, DSTB, SLP, STB
Goji 0:6fa19738f62e 66 0x11, 0x0227, // DC1[2:0], DC0[2:0], VC[2:0]
Goji 0:6fa19738f62e 67 WW, 50,
Goji 0:6fa19738f62e 68
Goji 0:6fa19738f62e 69 0x12, 0x001C, // External reference voltage Vci, Vci x 1.80
Goji 0:6fa19738f62e 70 0x07, 0x0001,
Goji 0:6fa19738f62e 71 WW, 50,
Goji 0:6fa19738f62e 72
Goji 0:6fa19738f62e 73 0x13, 0x1A00, // Power Control 4: VREG1OUT x 1.14
Goji 0:6fa19738f62e 74 0x29, 0x0025, // Power Control 7: VREG1OUT x 0.870
Goji 0:6fa19738f62e 75 0x2B, 0x000D, // Frame Rate Control: 8 fps
Goji 0:6fa19738f62e 76 WW, 50,
Goji 0:6fa19738f62e 77
Goji 0:6fa19738f62e 78 0x20, 0x0000,
Goji 0:6fa19738f62e 79 0x21, 0x013F,
Goji 0:6fa19738f62e 80
Goji 0:6fa19738f62e 81 // - Adjust the Gamma Curve --------- //
Goji 0:6fa19738f62e 82 0x30, 0x0000,
Goji 0:6fa19738f62e 83 0x31, 0x0506,
Goji 0:6fa19738f62e 84 0x32, 0x0104,
Goji 0:6fa19738f62e 85 0x35, 0x0207,
Goji 0:6fa19738f62e 86 0x36, 0x000F,
Goji 0:6fa19738f62e 87 0x37, 0x0306,
Goji 0:6fa19738f62e 88 0x38, 0x0102,
Goji 0:6fa19738f62e 89 0x39, 0x0707,
Goji 0:6fa19738f62e 90 0x3C, 0x0702,
Goji 0:6fa19738f62e 91 0x3D, 0x1604,
Goji 0:6fa19738f62e 92
Goji 0:6fa19738f62e 93 // - Set GRAM area ------------------ //
Goji 0:6fa19738f62e 94 0x50, 0x0000, // Horizontal GRAM Start Address
Goji 0:6fa19738f62e 95 0x51, TFT_MAX_Y - 1, // Horizontal GRAM End Address
Goji 0:6fa19738f62e 96 0x52, 0x0000, // Vertical GRAM Start Address
Goji 0:6fa19738f62e 97 0x53, TFT_MAX_X - 1, // Vertical GRAM Start Address
Goji 0:6fa19738f62e 98
Goji 0:6fa19738f62e 99 0x60, 0xA700, // Gate Scan Line
Goji 0:6fa19738f62e 100 0x61, 0x0001, // NDL,VLE, REV
Goji 0:6fa19738f62e 101 0x6A, 0x0000, // set scrolling line
Goji 0:6fa19738f62e 102
Goji 0:6fa19738f62e 103 // - Partial Display Control ---------//
Goji 0:6fa19738f62e 104 0x80, 0x0000,
Goji 0:6fa19738f62e 105 0x81, 0x0000,
Goji 0:6fa19738f62e 106 0x82, 0x0000,
Goji 0:6fa19738f62e 107 0x83, 0x0000,
Goji 0:6fa19738f62e 108 0x84, 0x0000,
Goji 0:6fa19738f62e 109 0x85, 0x0000,
Goji 0:6fa19738f62e 110
Goji 0:6fa19738f62e 111 // - Panel Control -------------------//
Goji 0:6fa19738f62e 112 0x90, 0x0010,
Goji 0:6fa19738f62e 113 0x92, 0x0600,
Goji 0:6fa19738f62e 114 0x93, 0x0003,
Goji 0:6fa19738f62e 115 0x95, 0x0110,
Goji 0:6fa19738f62e 116 0x97, 0x0000,
Goji 0:6fa19738f62e 117 0x98, 0x0000,
Goji 0:6fa19738f62e 118
Goji 0:6fa19738f62e 119 // - 262K ccode and display ON ------ //
Goji 0:6fa19738f62e 120 0x07, 0x0133,
Goji 0:6fa19738f62e 121 WW, 0
Goji 0:6fa19738f62e 122 };
Goji 0:6fa19738f62e 123
Goji 0:6fa19738f62e 124 //---------------------------------------------------------------------
Goji 0:6fa19738f62e 125 #elif defined(ST7783)
Goji 0:6fa19738f62e 126 //---------------------------------------------------------------------
Goji 0:6fa19738f62e 127 uint16_t TFT_Init_table[] = {
Goji 0:6fa19738f62e 128 0x01, 0x0100,
Goji 0:6fa19738f62e 129 0x02, 0x0700,
Goji 0:6fa19738f62e 130 0x03, 0x1038,
Goji 0:6fa19738f62e 131 0x04, 0x0000,
Goji 0:6fa19738f62e 132
Goji 0:6fa19738f62e 133 0x08, 0x0302,
Goji 0:6fa19738f62e 134 0x09, 0x0008,
Goji 0:6fa19738f62e 135 0x0A, 0x0008,
Goji 0:6fa19738f62e 136
Goji 0:6fa19738f62e 137 0x10, 0x0790,
Goji 0:6fa19738f62e 138 0x11, 0x0005,
Goji 0:6fa19738f62e 139 0x12, 0x0000,
Goji 0:6fa19738f62e 140 0x13, 0x0000,
Goji 0:6fa19738f62e 141 WW, 100,
Goji 0:6fa19738f62e 142
Goji 0:6fa19738f62e 143 0x10, 0x12B0,
Goji 0:6fa19738f62e 144 0x11, 0x0007,
Goji 0:6fa19738f62e 145 WW, 100,
Goji 0:6fa19738f62e 146
Goji 0:6fa19738f62e 147 0x12, 0x008C,
Goji 0:6fa19738f62e 148 0x13, 0x1700,
Goji 0:6fa19738f62e 149 WW, 100,
Goji 0:6fa19738f62e 150
Goji 0:6fa19738f62e 151 0x29, 0x0222,
Goji 0:6fa19738f62e 152 WW, 100,
Goji 0:6fa19738f62e 153
Goji 0:6fa19738f62e 154 0x30, 0x0000,
Goji 0:6fa19738f62e 155 0x31, 0x0405,
Goji 0:6fa19738f62e 156 0x32, 0x0203,
Goji 0:6fa19738f62e 157 0x35, 0x0004,
Goji 0:6fa19738f62e 158 0x36, 0x0B07,
Goji 0:6fa19738f62e 159 0x37, 0x0000,
Goji 0:6fa19738f62e 160 0x38, 0x0405,
Goji 0:6fa19738f62e 161 0x39, 0x0203,
Goji 0:6fa19738f62e 162 0x3C, 0x0004,
Goji 0:6fa19738f62e 163 0x3D, 0x0B07,
Goji 0:6fa19738f62e 164
Goji 0:6fa19738f62e 165 0x50, 0x0000, // Horizontal GRAM Start Address
Goji 0:6fa19738f62e 166 0x51, TFT_MAX_Y - 1, // Horizontal GRAM End Address
Goji 0:6fa19738f62e 167 0x52, 0x0000, // Vertical GRAM Start Address
Goji 0:6fa19738f62e 168 0x53, TFT_MAX_X - 1, // Vertical GRAM Start Address
Goji 0:6fa19738f62e 169
Goji 0:6fa19738f62e 170 0x60, 0x2700,
Goji 0:6fa19738f62e 171 0x61, 0x0001,
Goji 0:6fa19738f62e 172 0x6A, 0x0033,
Goji 0:6fa19738f62e 173 0x90, 0x0033,
Goji 0:6fa19738f62e 174 0x07, 0x0133,
Goji 0:6fa19738f62e 175 WW, 0
Goji 0:6fa19738f62e 176 };
Goji 0:6fa19738f62e 177
Goji 0:6fa19738f62e 178 #else
Goji 0:6fa19738f62e 179 #error "TFT Hardware not defined."
Goji 0:6fa19738f62e 180 #endif
Goji 0:6fa19738f62e 181
Goji 0:6fa19738f62e 182
Goji 0:6fa19738f62e 183 #define BIT1(n) (1ul<<n)
Goji 0:6fa19738f62e 184 #define BIT3(n) (3ul<<n)
Goji 0:6fa19738f62e 185 #define BIT7(n) (7ul<<n)
Goji 0:6fa19738f62e 186
Goji 0:6fa19738f62e 187 void TFT_init()
Goji 0:6fa19738f62e 188 {
Goji 0:6fa19738f62e 189 // mTFT_SETUP_IO();
Goji 0:6fa19738f62e 190
Goji 0:6fa19738f62e 191 TFT_CS_1;
Goji 0:6fa19738f62e 192 TFT_RD_1;
Goji 0:6fa19738f62e 193 TFT_WR_1;
Goji 0:6fa19738f62e 194
Goji 0:6fa19738f62e 195 TFT_RESET_0; wait_ms(20);
Goji 0:6fa19738f62e 196 TFT_RESET_1; wait_ms(50);
Goji 0:6fa19738f62e 197
Goji 0:6fa19738f62e 198 TFT_CS_0;
Goji 0:6fa19738f62e 199 for (int i = 0; ; i += 2) {
Goji 0:6fa19738f62e 200 if (TFT_Init_table[i] == WW) { // Delay or Exit
Goji 0:6fa19738f62e 201 if (TFT_Init_table[i + 1] == 0) // Exit(End of Init Table)
Goji 0:6fa19738f62e 202 break; // ..
Goji 0:6fa19738f62e 203 else
Goji 0:6fa19738f62e 204 wait_ms(TFT_Init_table[i + 1]);// Delay
Goji 0:6fa19738f62e 205 } else
Goji 0:6fa19738f62e 206 TFT_wr_index_data(TFT_Init_table[i], TFT_Init_table[i + 1]);
Goji 0:6fa19738f62e 207 }
Goji 0:6fa19738f62e 208 TFT_setOrientation(TFT_HV_HORZ);
Goji 0:6fa19738f62e 209 TFT_setWindow(TFT_info.xMIN, TFT_info.yMIN, TFT_info.xMAX, TFT_info.yMAX);
Goji 0:6fa19738f62e 210 }
Goji 0:6fa19738f62e 211
Goji 0:6fa19738f62e 212
Goji 0:6fa19738f62e 213 #if defined(_ARCH_PRO)
Goji 0:6fa19738f62e 214 void TFT_wr_regs(uint8_t regv)
Goji 0:6fa19738f62e 215 {
Goji 0:6fa19738f62e 216 #if defined(aitendo26) || defined(mcufriend24)
Goji 0:6fa19738f62e 217 // dbit 76543210 - data bit
Goji 0:6fa19738f62e 218 // pin# 76543298 - Digital pin# in Arduino
Goji 0:6fa19738f62e 219 // port# 22220000 - Port# in ARCH Pro
Goji 0:6fa19738f62e 220 // bit# 54325410 - Bit# in ARCH Pro
Goji 0:6fa19738f62e 221 LPC_GPIO0->FIOCLR = BIT1( 1)|BIT1( 0)|BIT1( 5)|BIT1( 4); // All low
Goji 0:6fa19738f62e 222 LPC_GPIO2->FIOCLR = BIT1( 5)|BIT1( 4)|BIT1( 3)|BIT1( 2); // ..
Goji 0:6fa19738f62e 223 LPC_GPIO0->FIOSET = (regv & (BIT1( 3)|BIT1( 2))) << 2 | (regv & (BIT1( 1)|BIT1( 0)));
Goji 0:6fa19738f62e 224 LPC_GPIO2->FIOSET = (regv & (BIT1( 7)|BIT1( 6)|BIT1( 5)|BIT1( 4))) >> 2;
Goji 0:6fa19738f62e 225 #endif
Goji 0:6fa19738f62e 226 }
Goji 0:6fa19738f62e 227 #else
Goji 0:6fa19738f62e 228
Goji 0:6fa19738f62e 229 // Can't use too slow
Goji 0:6fa19738f62e 230 BusOut TFTBus(D8, D9, D2, D3, D4, D5, D6, D7);
Goji 0:6fa19738f62e 231 #define TFT_wr_regs(regv) TFTBus = (regv)
Goji 0:6fa19738f62e 232
Goji 0:6fa19738f62e 233 #endif