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

Files at this revision

API Documentation at this revision

Comitter:
Goji
Date:
Mon Sep 08 16:07:05 2014 +0000
Commit message:
Music Player for ARCH-PRO

Changed in this revision

GSDPlayer.cpp Show annotated file Show diff for this revision Revisions of this file
GT20L16J1Y_font.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
TinyJpgDec.lib Show annotated file Show diff for this revision Revisions of this file
mGTFT/FONT/font8x12A.h Show annotated file Show diff for this revision Revisions of this file
mGTFT/mGTFT.cpp Show annotated file Show diff for this revision Revisions of this file
mGTFT/mGTFT.h Show annotated file Show diff for this revision Revisions of this file
mGTFT/mGTFTdev.h Show annotated file Show diff for this revision Revisions of this file
mGTFT/mGTFTini.h Show annotated file Show diff for this revision Revisions of this file
mGTP/DEV/aitend26.cpp Show annotated file Show diff for this revision Revisions of this file
mGTP/DEV/aitend26.h Show annotated file Show diff for this revision Revisions of this file
mGTP/DEV/mcuf24.cpp Show annotated file Show diff for this revision Revisions of this file
mGTP/DEV/mcuf24.h Show annotated file Show diff for this revision Revisions of this file
mGTP/mGTP.h Show annotated file Show diff for this revision Revisions of this file
mGTP/mGTPlib.cpp Show annotated file Show diff for this revision Revisions of this file
mainconf.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GSDPlayer.cpp	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,746 @@
+// --------------------------------------------------------
+//  GSDPlayer (c) CopYright 2013-2014 Goji.   goji2100.com
+// --------------------------------------------------------
+
+#include "mbed.h"
+#include "mainconf.h"
+
+#include "SDFileSystem.h"
+#include "TinyJpgDec.h"
+
+#include "mGTFT.h"
+#include "mGTP.h"
+#include "GT20L16J1Y_font.h"
+
+
+/* SDFileSystem.cpp change
+ -----------------------------------------------------------------------
+144:    _spi.frequency(16000000);
+210:    _spi.frequency(24000000); // Set to 1MHz for data transfer
+*/
+
+
+//#define Level_Indicator 4000  // for Level Indicator
+//#define Test                  // for Simple Player
+
+#define FILESYS "sd"
+#if defined(_ARCH_PRO)
+  SDFileSystem sd(P0_9,  P0_8,  P0_7,  P0_6,  FILESYS); // Arch Pro SPI1SD
+  #define BUFF_SIZE (512 * 4)               // WAV file buffer size
+  #define LLow    1
+  #define LHigh   0
+  PwmOut  Line_R(P2_0), Line_L(P2_1);       // PWM_1, PWM_2
+  BusOut  TFTBus(D8, D9, D2, D3, D4, D5, D6, D7);
+#else
+#endif
+
+Serial pc(USBTX, USBRX);
+DigitalOut statLED1(LED1), statLED2(LED2), statLED3(LED3), statLED4(LED4);
+
+#define PWM_CLKMHZ  24  // 24MHz
+Ticker Tick_Timer;
+
+volatile uint16_t ps_stat = 0;      // Player status
+uint16_t tp_stat = 0, tp_statN = 0;
+#define PS_PLAY     BIT1(15)
+#define PS_PAUSE    BIT1(14)
+#define PS_FFR      BIT1(13)
+#define PS_FFF      BIT1(12)
+#define PS_SEEK     BIT1(11)
+#define PS_FR       BIT1(10)
+#define PS_FF       BIT1( 9)
+#define PS_VDOWN    BIT1( 8)
+#define PS_VUP      BIT1( 7)
+#define PS_EOR      BIT1( 6)   // End of Root
+#define PS_EOD      BIT1( 5)   // End of DIR
+#define PS_EOF      BIT1( 4)   // Eod of File
+
+#define SWBuff()    { if (buffNX==0) { buffNW=0,buffNX=1; } else { buffNW=1,buffNX=0; } buffLN[buffNX]=buffGP=0; }
+volatile int32_t buffNW, buffNX, buffLN[2], buffGP;
+unsigned char Wave_buff[2][BUFF_SIZE];
+#define _WS16(n,v)  *(short*         )&Wave_buff[n][v]
+#define _WU16(n,v)  *(unsigned short*)&Wave_buff[n][v]
+#define _WU32(n,v)  *(unsigned long* )&Wave_buff[n][v]
+uint8_t  Wave_CHs, Wave_Bits;
+uint32_t Wave_BPS, Wave_Size, Wave_Rlen, Wave_Play, Wave_FPos;
+uint16_t Wave_Prid;
+
+volatile uint16_t Pwm_Ratio, Line_Vols = 16, Line_Vol = 160;
+
+#if defined(Level_Indicator)
+volatile uint32_t Pwm_cnt = 0;
+volatile uint16_t Pwm_aveL = 0, Pwm_aveR = 0;
+#endif
+
+void PwmLR_Out16(int16_t lv, int16_t rv)
+{
+    int16_t lw = ((lv + 32768) / Pwm_Ratio);
+    int16_t rw = ((rv + 32768) / Pwm_Ratio);
+//  if (lw >= LPC_PWM1->MR0) lw = LPC_PWM1->MR0;
+//  if (rw >= LPC_PWM1->MR0) rw = LPC_PWM1->MR0;
+  #if defined(_ARCH_PRO)
+    LPC_PWM1->MR1 = lw;
+    LPC_PWM1->MR2 = rw;
+    if (Line_Vols)
+        LPC_PWM1->LER |= ((1 << 1) | (1 << 2));
+  #else
+    LPC_PWM1->MR6 = lw;
+    LPC_PWM1->MR5 = rw;
+    if (Line_Vols)
+        LPC_PWM1->LER |= ((1 << 6) | (1 << 5));
+  #endif
+  #if defined(Level_Indicator)
+    Pwm_cnt++;
+    Pwm_aveL = (Pwm_aveL + ((uint16_t)(lv) + 32768) >> 8) / 2;
+    Pwm_aveR = (Pwm_aveR + ((uint16_t)(rv) + 32768) >> 8) / 2;
+  #endif
+}
+
+
+void ISR_Tick(void)
+{
+    if (!(ps_stat & PS_PAUSE) && (buffGP < buffLN[buffNW])) {
+        statLED2 = LHigh;
+        PwmLR_Out16(_WS16(buffNW, buffGP), _WS16(buffNW, buffGP + 2));
+        buffGP += 4;
+        if ((buffGP >= buffLN[buffNW]) && (buffNX != -1)) SWBuff();
+        statLED2 = LLow;
+    }
+}
+
+
+extern TFT_INFO TFT_info;
+int32_t Last_Err;
+
+GT20L16J1Y_FONT font(p11, p12, p13, P0_16);
+void draw_kanji(int x1, int y1, uint16_t c1, uint16_t c2)
+{
+    for (int x = 0; x < 32; x++)
+        for (int y = 0, m = 0x01; y < 8; y++, m <<= 1)
+            TFT_setPixel(x1 + x%16,  y1 + y + (8 * (x >> 4)), ((font.bitmap[x] & m) ? c1 : c2));
+}
+
+
+uint16_t bmpXsize, bmpYsize;
+
+void BMP24Bits(int16_t x1, int16_t y1, char *fn)
+{
+    uint8_t rbuff[64];
+
+    FILE *fp = fopen(fn, "rb");
+    if (!fp) {
+        pc.printf("open error\n");
+        return;
+    }
+
+    fread(rbuff, 1, (14 + 40), fp);
+    bmpXsize = *(uint16_t*)&rbuff[18];
+    bmpYsize = *(uint16_t*)&rbuff[22];
+
+    if ((bmpXsize > TFT_MAX_X) ||
+        (bmpYsize > TFT_MAX_Y) ||
+        (rbuff[28] != 24)) {
+        pc.printf("format error\n");
+        return;
+    }
+
+    int dummy = (bmpXsize * 3) % 4;
+    for (int z = 0, y = y1; z < bmpYsize; z++, y--) {
+        TFT_setXY(x1, y);
+        for (int i = 0; i < bmpXsize; i++) {
+            fread(rbuff, 1, 3, fp);
+            TFT_wr_data((uint16_t)(
+                ((rbuff[2] & 0xF8) << 8) |      // R
+                ((rbuff[1] & 0xFC) << 3) |      // G
+                ((rbuff[0]       ) >> 3) ));    // B
+        }
+        if (dummy) fread(rbuff, 1, dummy, fp);
+    }
+    fclose(fp);
+}
+
+
+FILE *jfp;
+UINT jpeg_input(JDEC *jd, BYTE *buff, UINT ndata)
+{
+    if (buff) {
+        int n = fread(buff, 1, ndata, jfp);
+        return(n == -1 ? 0 : n);
+    }
+    return(fseek(jfp, ndata, SEEK_CUR) == -1 ? 0 : ndata);
+}
+
+int16_t Cover_tlx, Cover_tly;
+
+UINT jpeg_output(JDEC *jd, void *bitmap, JRECT *rect)
+{
+    WORD *src = (WORD *)bitmap;
+
+    int x0 = rect->left;
+    int x1 = rect->right;
+    int y0 = rect->top;
+    int y1 = rect->bottom;
+    int w = x1 - x0 + 1;
+
+    if (x0 >= TFT_MAX_X || y0 >= TFT_MAX_Y) return 1;
+    if (x1 >= TFT_MAX_X) x1 = TFT_MAX_X - 1;
+    if (y1 >= TFT_MAX_Y) y1 = TFT_MAX_Y - 1;
+
+    for (int y = y0; y <= y1; y++) {
+        TFT_setXY(Cover_tlx + x0, Cover_tly + y);
+        WORD *p = src + w * (y - y0);
+        for (int x = x0; x <= x1; x++)
+            TFT_wr_data(*p++);
+    }
+    return 1;
+}
+
+
+#define MM_TLX      0
+#define MM_TLY      (TFT_MAX_Y - bmpYsize)
+#define MM_YH       bmpYsize
+
+#define MM_FR       80
+#define MM_PLAY     (MM_FR   + 50)
+#define MM_FF       (MM_PLAY + 54)
+#define MM_FFE      (MM_FF   + 50)
+#define MM_VUPD     (TFT_MAX_X - 58)
+
+#define MM_VUP      (TFT_MAX_Y - bmpYsize)
+#define MM_VDWN     (TFT_MAX_Y - (bmpYsize / 2))
+
+uint16_t tp_menu()
+{
+    int16_t wposX, wposY;
+
+    if (TPC_getXY(&wposX, &wposY) == 2) {
+        if (wposY < MM_TLY) return(PS_SEEK);
+        if (wposX < MM_FR ) return(0);
+        if      (wposX < MM_PLAY) return(PS_FFR);
+        else if (wposX < MM_FF  ) return(PS_PAUSE);
+        else if (wposX < MM_FFE ) return(PS_FFF);
+        else if (wposY < MM_VDWN) return(PS_VUP);
+        else if (wposY > MM_VDWN) return(PS_VDOWN);
+    }
+    return(0);
+}
+
+//#define SEEK_Dump() 
+#define SEEK_Dump() pc.printf("%d - (%8d - %d = %8d) = %8d(%8d)\n", Wave_Size,Wave_FPos,Wave_Play,Wave_FPos-Wave_Play,Wave_Rlen,Wave_Rlen-(Wave_Size-(Wave_FPos-Wave_Play)))
+
+uint16_t event_chk()
+{
+    static uint16_t stepS  = 0, timep, barp, bcp;
+    static int16_t  tp_cnt = 0;
+
+    int16_t px, py;
+    uint16_t statN = 0, tw, barl, bc;
+    char times[8];
+
+    while (1) {
+        switch (stepS) {
+            case  0:
+            case 50:
+                tw = (Wave_FPos - Wave_Play) / (Wave_BPS * 4);   // (Wave_FPos * 8) / (Wave_BPS * 16 * 4)
+                if (tw != timep) {
+                    timep = tw;
+                    sprintf(times, "%02d:%02d", (timep / 60), (timep % 60));
+                    TFT_drawText( 28, (TFT_MAX_Y - 1) - 6 - (bmpYsize / 2), (uint8_t*)times, WHITE, BLACK);
+                    barp = 0;
+                }
+                stepS += 10;
+                break;
+
+            case 10:
+            case 60:
+                barl = (((Wave_FPos - Wave_Play) / 1000) * TFT_MAX_X) / (Wave_Size / 1000);
+                bc = (ps_stat & PS_PAUSE) ? YELLOW : BLUE;
+                if ((stepS >= 50) || (barp != barl) || (bcp != bc)) {
+                    TFT_fillRectangle(  0, (TFT_MAX_Y - 1) - bmpYsize - 2, barl, (TFT_MAX_Y - 1) - bmpYsize, bc, bc);
+                    if (barl < (TFT_MAX_X - 1))
+                        TFT_fillRectangle(barl, (TFT_MAX_Y - 1) - bmpYsize - 2, (TFT_MAX_X - 1), (TFT_MAX_Y - 1) - bmpYsize, BLACK, BLACK);
+                    barp = barl;
+                    bcp = bc;
+                }
+                if (stepS > 50) stepS += 10;
+                else stepS = 20;
+                break;
+
+            case 70:
+                if (TPC_getXY(&px, &py) == 2) {
+                    if (px < ((320 * 1) / 10)) px = ((320 * 1) / 10);
+                    if (px > ((320 * 9) / 10)) px = ((320 * 9) / 10);
+                    if (px < ((320 * 1) / 7)) {
+                        if (Wave_FPos < (Wave_BPS * 2 * 2 * 2)) {
+                            SEEK_Dump();
+                            statN = PS_FFR;
+                            tp_cnt = 0;
+                            stepS = 0;
+                            break;
+                        }
+                        Wave_FPos = Wave_Play;
+                        Wave_Rlen = Wave_Size;
+                    } else if (px >= ((320 * 9) / 10)) {
+                        Wave_FPos = Wave_Play + Wave_Size;
+                        Wave_Rlen = 0;
+                    } else {
+                        uint64_t pr = (px - ((320 * 1) / 10)) * 1000 / (((320 * 8) / 10));
+                        Wave_FPos = ((Wave_Size * pr) / 1000);
+                        if (Wave_FPos > (Wave_Play + Wave_Size)) Wave_FPos = Wave_Size + Wave_Play;
+                        if (Wave_FPos < Wave_Play) Wave_FPos = Wave_Play;
+                        Wave_Rlen = Wave_Size - (Wave_FPos - Wave_Play);
+                    }
+                } else {
+                    tp_cnt++;
+                    if (tp_cnt > 100) {
+                        if (Wave_FPos < Wave_Size + Wave_Play) {
+                            Wave_FPos &= (uint64_t)-BUFF_SIZE;
+                            if (Wave_FPos < Wave_Play) Wave_FPos = Wave_Play;
+                            Wave_Rlen = Wave_Size - (Wave_FPos - Wave_Play);
+                        }
+                        SEEK_Dump();
+                        statN = PS_SEEK;
+                        tp_cnt = 0;
+                        stepS = 0;
+                        break;
+                    }
+                }
+                stepS = 50;
+                break;
+
+            case 20:
+                if (tp_stat != 0) {
+                    stepS = 22;
+                    break;
+                }
+                tp_stat = tp_menu();
+                tp_cnt = 0;
+                if (tp_stat & PS_SEEK) {
+                    ps_stat |= PS_PAUSE;
+                    stepS = 50;
+                    SEEK_Dump();
+                    break;
+                }
+                if (tp_stat == 0) stepS = 0;
+                else stepS = 22;
+                break;
+
+            case 22:
+                tp_statN = tp_menu();
+                if (tp_statN == 0) {
+                    tp_cnt = 0;
+                    tp_stat = 0;
+                    stepS = 0;
+                    break;
+                }
+                if (tp_stat == tp_statN) {
+                    if (tp_cnt != -1) tp_cnt++;
+                    stepS = 24;
+                    break;
+                }
+                tp_cnt = 0;
+                tp_stat = tp_statN;
+                stepS = 22;
+                break;
+
+            case 24:
+                if (tp_cnt > 1) {
+                    if (tp_stat & PS_VUP) {
+                        if (tp_cnt == 3) statN = tp_stat;
+                        if (tp_cnt >= 5) tp_cnt = 0;
+                    } else if (tp_stat & PS_VDOWN) {
+                        if (tp_cnt == 2) statN = tp_stat;
+                        if (tp_cnt >= 3) tp_cnt = 0;
+                    } else {
+                        statN = tp_stat;
+                        tp_cnt = -1;
+                    }
+                }
+                stepS = 0;
+                break;
+
+            default:
+                stepS = 0;
+                break;
+        }
+        if (stepS < 50) break;
+    }
+    return(statN);
+}
+
+
+void poll()
+{
+    uint16_t statN;
+    char stext[8];
+
+    if ((statN = event_chk()) == 0) return;
+    if (statN & PS_PAUSE) { ps_stat ^= PS_PAUSE; return; }
+    if (statN & (PS_FFR | PS_FFF | PS_SEEK)) { ps_stat |= statN; return; }
+    if (statN & (PS_VUP | PS_VDOWN)) {
+        if (statN & PS_VUP) {
+            if (Line_Vols < 32) { Line_Vol -= (Line_Vols >= 16 ? 10 : 40); Line_Vols++; }
+        } else {
+            if (Line_Vols >  0) { Line_Vol += (Line_Vols >  16 ? 10 : 40); Line_Vols--; }
+        }
+        sprintf(stext, "%2d", Line_Vols);
+        TFT_drawText((TFT_MAX_X - 76), (TFT_MAX_Y - 1) - 6 - (bmpYsize / 2), (uint8_t*)stext, WHITE, BLACK);
+        Pwm_Ratio = ((65536 / PWM_CLKMHZ) / Wave_Prid) + Line_Vol;
+    }
+    return;
+}
+
+
+DIR  *dp;
+FILE *fp;
+struct dirent *p;
+
+int Open_Wave(char *path)
+{
+    fp = fopen(path, "rb");
+    if (fp == NULL)  return (Last_Err = -3);    // can't open
+
+    buffLN[0] = fread(Wave_buff[0], 1, BUFF_SIZE, fp);
+    if (buffLN[0] < 46) return (Last_Err = -4); // invalid file
+
+    // "RIFF", (long)File size, "WAVE"
+    if ((_WU32(0, 0) != 0x46464952) ||
+        (_WU32(0, 8) != 0x45564157))
+        return (Last_Err = -5);  // invalid file
+
+    buffGP = 12;
+    while (buffGP < BUFF_SIZE) {
+        unsigned long tagn = _WU32(0, buffGP);
+        unsigned long tagl = _WU32(0, buffGP + 4);
+        buffGP += 8;
+
+        if (tagn == 0x20746D66) {   // "fmt "
+            Wave_CHs  = _WU16(0, buffGP + 2);
+            Wave_BPS  = _WU32(0, buffGP + 4);
+            Wave_Bits = _WU32(0, buffGP +14);
+            Wave_Prid = 2000000 / Wave_BPS;
+            if (Wave_Prid & 1) Wave_Prid++;
+            Wave_Prid >>= 1;
+        }
+
+        // "fact" 0x74636166)
+        // "LIST" 0x74636166)
+        if (tagn != 0x61746164) {   // !"data"
+            buffGP += tagl;
+            continue;
+        }
+
+        if ((Wave_BPS == 24000) ||
+            (Wave_BPS == 32000) ||
+            (Wave_BPS == 44100) ||
+            (Wave_BPS == 48000)) {
+            Wave_Size = tagl;
+            return 0;
+        }
+        break;
+    }
+    return (Last_Err = -6);  // invalid file
+}
+
+
+int music_nw, music_nx;
+
+int Play_Wave()
+{
+    int32_t getln;
+
+    if (((buffNX != -1) && (buffLN[buffNX] == 0)) ||(ps_stat & (PS_SEEK | PS_FFR))) {
+        statLED1 = LHigh;
+        if (ps_stat & (PS_SEEK | PS_FFR)) {
+            if (fseek(fp, Wave_FPos, SEEK_SET) == -1) {
+                ps_stat |= PS_EOF;
+                buffNX = -1;
+                return (Last_Err = -7); // read error
+            }
+            Wave_Rlen = Wave_Size - (Wave_FPos - Wave_Play);
+            ps_stat &= ~PS_FFR;
+        }
+
+        if (Wave_FPos <= Wave_Play)
+            getln = ((BUFF_SIZE - Wave_Play) > Wave_Rlen) ? Wave_Rlen : (BUFF_SIZE - Wave_Play);
+        else
+            getln = (Wave_Rlen > BUFF_SIZE) ? BUFF_SIZE : Wave_Rlen;
+        if (getln && (buffNX != -1)) {
+            if (fread(Wave_buff[buffNX], 1, getln, fp) != getln) {
+                ps_stat |= PS_EOF;
+                buffNX = -1;
+                return (Last_Err = -7); // read error
+            }
+            buffLN[buffNX] = getln & -4;
+            Wave_FPos += getln;
+            if (Wave_Rlen > getln) Wave_Rlen -= getln; else Wave_Rlen = 0;
+
+            if (ps_stat & PS_SEEK) {
+                buffLN[buffNW] = buffLN[buffNX];
+                SWBuff();
+                ps_stat &= ~(PS_SEEK | PS_PAUSE);
+            }
+        }
+        statLED1 = LLow;
+
+        if (Wave_Rlen == 0) {
+            buffNX = -1;
+            ps_stat |= PS_EOF;
+            wait_ms(50);
+            return(0);
+        }
+        return getln;
+    }
+
+    if (ps_stat & PS_PAUSE) return(1);
+    return 0;
+}
+
+
+#if defined(Test)
+int main()
+{
+    if (Open_Wave("/" FILESYS "/music/01.wav")) error("open error\n");
+
+    Pwm_Ratio = ((65535 / PWM_CLKMHZ) / Wave_Prid) + Line_Vol;
+    buffNW = 0, buffNX = 1;
+    buffLN[buffNX] = 0;
+
+    Line_R.period_us(Wave_Prid);
+    Line_L.period_us(Wave_Prid);
+    Tick_Timer.attach_us(&ISR_Tick, Wave_Prid);
+
+    pc.printf("start\n");
+    while (1) {
+        if (buffLN[buffNX] == 0) {
+            if (fread(Wave_buff[buffNX], 1, BUFF_SIZE, fp) != BUFF_SIZE) break;
+            if (Wave_Size >= BUFF_SIZE) Wave_Size -= BUFF_SIZE; else break;
+            buffLN[buffNX] = BUFF_SIZE;
+        }
+    }
+    Tick_Timer.detach();
+    fclose(fp);
+    pc.printf("stop\n");
+}
+
+#else
+
+int main()
+{
+    char path[256], msc_file[256], stext[20];
+
+    pc.baud(115200);
+    TFT_init();
+    TPC_Init();
+    TFT_clearScreen(GRAY);
+
+    while (1) {
+
+        // Open Music Directory
+        // ---------------------
+        if (sd.disk_initialize()) return -1;
+
+        BMP24Bits(0, (TFT_MAX_Y - 1), "/" FILESYS "/images/Play.bmp");
+        dp = 0, music_nw = 1, music_nx = 1;
+
+        while (1) {
+
+            // Get Music file(.wav)
+            // ---------------------
+            {
+                int i;
+
+                if (music_nw >= music_nx) {
+                    if (dp) closedir(dp);
+                    dp = opendir("/" FILESYS "/music");
+                    if (dp == NULL) {
+                        pc.printf("\n" "/" FILESYS "/music/ open error.\n");
+                        return 0;
+                    }
+                    music_nw = 0;
+                }
+
+                if ((p = readdir(dp)) == NULL) break;
+                for (i = 0; p->d_name[i]; i++)
+                    msc_file[i] = p->d_name[i];
+                msc_file[i] = '\0';
+
+                if (msc_file[i - 4] == '.') msc_file[i - 4] = '\0';
+                if (strcmp(p->d_name + (i - 3), "wav") != 0) {
+                    pc.printf("Skip - music/%s\n", p->d_name);
+                    continue;
+                }
+
+                if (++music_nw < music_nx) continue;
+                music_nx++;
+            }
+
+            // View Navigate(Play time, Sound volume)
+            // ---------------------------------------
+            {
+                snprintf(path, sizeof path, "/" FILESYS "/music/%s", msc_file);
+                pc.printf("Play - %s\n", path);
+
+                TFT_fillRectangle(  0,   0, 319, 239 - bmpYsize, GRAY,  GRAY);
+                TFT_drawText( 28, 239 - 6 - (bmpYsize / 2), (uint8_t*)"00:00", WHITE, BLACK);
+                sprintf(stext, "%2d", Line_Vols);
+                TFT_drawText(244, 239 - 6 - (bmpYsize / 2), (uint8_t*)stext, WHITE, BLACK);
+                TFT_fillRectangle(  0, 239 - bmpYsize - 2, 319, 239 - bmpYsize, BLACK, BLACK);
+            }
+
+            // View Image
+            // -----------
+            {
+                JDEC jdec;
+                WORD work[4000/sizeof(WORD)];
+
+                snprintf(path, sizeof path, "/" FILESYS "/music/%s" ".jpg", msc_file);
+                pc.printf("jpg - %s\n", path);
+                jfp = fopen(path, "rb");
+                if (!jfp) jfp = fopen("/" FILESYS "/images/NoImage.jpg", "rb");
+                if (jfp) {
+                    JRESULT r = jd_prepare(&jdec, jpeg_input, work, sizeof(work), jfp);
+                    if (r == JDR_OK) {
+                        uint16_t ww = jdec.width & 0x3FF;   // struct jdec ???
+                        uint16_t wh = jdec.width >> 16;     // ..
+                        Cover_tlx = (ww < 170) ? ((176 - ww) / 2) : 4;
+                        Cover_tly = (wh < 180) ? ((188 - wh) / 2) : 4;
+                        r = jd_decomp(&jdec, jpeg_output, 0);
+                      #if (0)
+                        TFT_drawLine(Cover_tlx + 1, Cover_tly + wh, Cover_tlx + ww, Cover_tly + wh, WHITE);
+                        TFT_drawLine(Cover_tlx + ww, Cover_tly + 1, Cover_tlx + ww, Cover_tly + wh, WHITE);
+                      #endif
+                    }
+                    fclose(jfp);
+                }
+            }
+
+            // View Song title
+            // ----------------
+            {
+                int l = 0;
+                char msc_Text[256];
+
+                snprintf(path, sizeof path, "/" FILESYS "/music/%s" ".txt", msc_file);
+                pc.printf("txt - %s\n", path);
+
+                fp = fopen(path, "r");
+                if (fp) {
+                    l = fread(msc_Text, 1, 256, fp);
+                    fclose(fp);
+                }
+
+                if (l > 4)
+                     msc_Text[l] = '\0';
+                else snprintf(msc_Text, sizeof(msc_Text), "||%s||", msc_file);
+                pc.printf("%02d - %s\n\n", music_nw, msc_Text);
+
+                int  ps, pl = 0;
+                int  px = 176, py = Cover_tly + 2;
+                uint8_t ws[2];
+                ws[1] = '\0';
+
+                for (ps = 0; ps < 256; ps++) {
+                    if (msc_Text[ps] == '|') {
+                        if (++pl > 2) break;
+                        py += 20;
+                        px = 176;
+                        continue;
+                    }
+                    if (msc_Text[ps] & 0x80) {  // KANJI ?
+                        font.read((msc_Text[ps] << 8)| msc_Text[ps + 1]);
+                        draw_kanji(px, py, ((pl == 2) ? WHITE : DWHITE), GRAY);
+                        px += 16;
+                        ps++;
+                    } else {
+                        ws[0] = msc_Text[ps];
+                        TFT_drawText(px, py + 2, ws, ((pl == 2) ? WHITE : DWHITE), GRAY);
+                        px += 8;
+                    }
+                }
+            }
+
+            // Play Music
+            // -----------
+            {
+                snprintf(path, sizeof path, "/" FILESYS "/music/%s" ".wav", msc_file);
+                int rc = Open_Wave(path);
+                if (rc) {
+                    if (fp != NULL) fclose(fp);
+                    pc.printf(" rc=%d, Last_Err=%d\n", rc, Last_Err);
+                    Last_Err = 0;
+                    continue;
+                }
+
+                uint16_t tw = Wave_Size / (Wave_BPS * 4);
+                sprintf(stext, "%02d %2dks %02d:%02d", music_nw, (Wave_BPS / 1000), (tw / 60), (tw % 60));
+                TFT_drawText(214, (222 - bmpYsize), (uint8_t*)stext, BLACK, GRAY);
+
+                Wave_Play = buffGP;
+                Wave_FPos = BUFF_SIZE;
+                Wave_Rlen = Wave_Size - (Wave_FPos - Wave_Play);
+                buffNW = 0, buffNX = 1;
+                buffLN[buffNX] = 0;
+
+                Last_Err = 0;
+                ps_stat  = PS_PLAY;
+
+                Pwm_Ratio = ((65535 / PWM_CLKMHZ) / Wave_Prid) + Line_Vol;
+                Line_R.period_us(Wave_Prid);
+                Line_L.period_us(Wave_Prid);
+                Tick_Timer.attach_us(&ISR_Tick, Wave_Prid); // Play!
+ 
+                while (!(ps_stat & PS_EOF) && (ps_stat & PS_PLAY) && (Last_Err == 0)) {
+
+                  #if defined(Level_Indicator)
+                    uint16_t yl0 = 0, yr0 = 0, yl, yr;
+                    if (Pwm_cnt > Level_Indicator) {
+                        yl = 238 - (((Pwm_aveL - 64) * (bmpYsize - 2)) / 200);
+                        yr = 238 - (((Pwm_aveR - 64) * (bmpYsize - 2)) / 200);
+                        Pwm_cnt = 0;
+                        if (yl > 237) yl = 238;
+                        if (yr > 237) yr = 238;
+                        yl0 = (yl > yl0) ? yl : ((yl0 + yl) / 2);
+                        yr0 = (yr > yr0) ? yr : ((yr0 + yl) / 2);
+                        TFT_fillRectangle(MM_VUPD + 5, MM_VUP + 1, MM_VUPD +  7, yl0, BLACK, BLACK);
+                        TFT_fillRectangle(MM_VUPD + 9, MM_VUP + 1, MM_VUPD + 11, yr0, BLACK, BLACK);
+                        if (yl0 < 238) TFT_fillRectangle(MM_VUPD + 5, yl0, MM_VUPD +  7, 238, YELLOW, YELLOW);
+                        if (yr0 < 238) TFT_fillRectangle(MM_VUPD + 9, yr0, MM_VUPD + 11, 238, YELLOW, YELLOW);
+                    }
+                  #endif
+
+                    if (Play_Wave()) {
+
+                        statLED4 = LHigh;
+                        if (ps_stat & PS_PAUSE) wait_ms(5);
+                        poll();
+                        statLED4 = LLow;
+
+                        if (ps_stat & PS_FFF) {
+                            buffNX = -1;
+                            break;
+                        }
+
+                        if (ps_stat & PS_FFR) {
+                            if (Wave_FPos < (Wave_BPS * 2 * 2 * 2)) {
+                                buffNX = -1;
+                                if (music_nx > music_nw)
+                                    music_nx = (music_nw > 1) ? music_nw - 1 : 1;
+                                break;
+                            } else
+                                Wave_FPos = Wave_Play;
+                        }
+                    }
+                }
+
+                Tick_Timer.detach();
+                fclose(fp);
+                pc.printf("Close stat=%04X, %d - %d\n", ps_stat, Wave_Rlen, Last_Err);
+                ps_stat  = 0;
+                Last_Err = 0;
+            }
+        }
+        closedir(dp);
+    }
+}
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GT20L16J1Y_font.lib	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/MACRUM/code/GT20L16J1Y_font/#aed20a7685b9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Goji/code/SDFileSystem/#b7ee2068b3b1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TinyJpgDec.lib	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/humlet/code/TinyJpgDec/#b6f284347a66
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTFT/FONT/font8x12A.h	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,1799 @@
+// --------------------------------------------------------
+// font8x12A.h (c) CopYright 2013-2014 Goji.
+// --------------------------------------------------------
+
+const uint8_t font8x12A[][12] = {
+    {   // 0x0
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {   // 0x0001
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x30,
+        0x78,
+        0xFC,
+        0x78,
+        0x30,
+        0x00,
+        0x00,
+        0x00
+    },
+    {   // 0x0002
+        0x00,
+        0x4A,
+        0xB4,
+        0x4A,
+        0xB4,
+        0x4A,
+        0xB4,
+        0x4A,
+        0xB4,
+        0x4A,
+        0xB4,
+        0x4A
+    },
+    {   // 0x0003
+        0x00,
+        0xCC,
+        0xCC,
+        0xFC,
+        0xCC,
+        0xCC,
+        0x00,
+        0xFE,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x0004
+        0x00,
+        0xFC,
+        0xC0,
+        0xFC,
+        0xC0,
+        0xC0,
+        0x00,
+        0xFC,
+        0xC0,
+        0xFC,
+        0xC0,
+        0xC0
+    },
+    {   // 0x0005
+        0x00,
+        0xFC,
+        0xCC,
+        0xC0,
+        0xC0,
+        0xFC,
+        0x00,
+        0xFC,
+        0xCC,
+        0xF8,
+        0xCC,
+        0xCC
+    },
+    {   // 0x0006
+        0x00,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xFC,
+        0x00,
+        0xFC,
+        0xC0,
+        0xFC,
+        0xC0,
+        0xC0
+    },
+    {   // 0x0007
+        0x00,
+        0x78,
+        0xCC,
+        0xCC,
+        0x78,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {   // 0x0008
+        0x00,
+        0x00,
+        0x00,
+        0x70,
+        0x70,
+        0xFC,
+        0x70,
+        0x70,
+        0x00,
+        0x00,
+        0xFC,
+        0x00
+    },
+    {   // 0x0009
+        0x00,
+        0xCC,
+        0xCC,
+        0xFC,
+        0xCC,
+        0xCC,
+        0x00,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xFC
+    },
+    {   // 0x000A
+        0x00,
+        0xCC,
+        0xCC,
+        0xCC,
+        0xF8,
+        0xF0,
+        0x00,
+        0xFE,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x000B
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0xF8,
+        0xF8,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {   // 0x000C
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xF8,
+        0xF8,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x000D
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x3E,
+        0x3E,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x000E
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x3E,
+        0x3E,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {   // 0x000F
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0xFE,
+        0xFE,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x0010
+        0x00,
+        0xFE,
+        0xFE,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {   // 0x0011
+        0x00,
+        0x10,
+        0x38,
+        0x38,
+        0x7C,
+        0x7C,
+        0xFE,
+        0x00,
+        0xFF,
+        0xFF,
+        0x00,
+        0x00
+    },
+    {   // 0x0012
+        0x00,
+        0xFF,
+        0xFF,
+        0x00,
+        0x10,
+        0x38,
+        0x38,
+        0x7C,
+        0x7C,
+        0xFE,
+        0x00,
+        0x00
+    },
+    {   // 0x0013
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x7F,
+        0x7F,
+        0x00,
+        0x00
+    },
+    {   // 0x0014
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFE,
+        0xFE
+    },
+    {   // 0x0015
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x3E,
+        0x3E,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x0016
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0xF8,
+        0xF8,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x0017
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0xFE,
+        0xFE,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {   // 0x0018
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFE,
+        0xFE,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x0019
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38,
+        0x38
+    },
+    {   // 0x001A
+        0x00,
+        0x00,
+        0x18,
+        0x30,
+        0x60,
+        0xC0,
+        0x60,
+        0x30,
+        0x18,
+        0x00,
+        0xFC,
+        0x00
+    },
+    {   // 0x001B
+        0x00,
+        0x00,
+        0x60,
+        0x30,
+        0x18,
+        0x0C,
+        0x18,
+        0x30,
+        0x60,
+        0x00,
+        0xFC,
+        0x00
+    },
+    {   // 0x001C
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFC,
+        0x4C,
+        0x4C,
+        0x4C,
+        0x8C,
+        0x8C,
+        0x00
+    },
+    {   // 0x001D
+        0x00,
+        0x00,
+        0x00,
+        0x38,
+        0x38,
+        0xFC,
+        0x78,
+        0xFC,
+        0x70,
+        0x70,
+        0x00,
+        0x00
+    },
+    {   // 0x001E
+        0x80,
+        0xC0,
+        0xE0,
+        0xF0,
+        0xF8,
+        0xFC,
+        0xFC,
+        0xF8,
+        0xF0,
+        0xE0,
+        0xC0,
+        0x80
+    },
+    {   // 0x001F
+        0x00,
+        0x7F,
+        0x7F,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x0020
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x0021
+        0x00,
+        0x00,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x00,
+        0x30,
+        0x30,
+        0x00
+    },
+    {    // 0x0022
+        0x00,
+        0xCC,
+        0xCC,
+        0xCC,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x0023
+        0x00,
+        0x00,
+        0x4C,
+        0x4C,
+        0xFE,
+        0x4C,
+        0x4C,
+        0x4C,
+        0xFE,
+        0x4C,
+        0x4C,
+        0x00
+    },
+    {    // 0x0024
+        0x00,
+        0x00,
+        0x08,
+        0x7C,
+        0xC8,
+        0xF8,
+        0x78,
+        0x7C,
+        0x4C,
+        0xF8,
+        0x40,
+        0x00
+    },
+    {    // 0x0025
+        0x00,
+        0x00,
+        0x60,
+        0x94,
+        0x6C,
+        0x38,
+        0x30,
+        0x70,
+        0xCC,
+        0x92,
+        0x0C,
+        0x00
+    },
+    {    // 0x0026
+        0x00,
+        0x00,
+        0x78,
+        0xCC,
+        0xCC,
+        0x78,
+        0x70,
+        0xCC,
+        0xCC,
+        0xCC,
+        0x76,
+        0x00
+    },
+    {    // 0x0027
+        0x00,
+        0x70,
+        0x70,
+        0x70,
+        0x70,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x0028
+        0x00,
+        0x04,
+        0x18,
+        0x18,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x18,
+        0x18,
+        0x04
+    },
+    {    // 0x0029
+        0x00,
+        0x80,
+        0x60,
+        0x60,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x60,
+        0x60,
+        0x80
+    },
+    {    // 0x002A
+        0x00,
+        0x00,
+        0x00,
+        0x30,
+        0xB4,
+        0xFC,
+        0x78,
+        0xFC,
+        0xB4,
+        0x30,
+        0x00,
+        0x00
+    },
+    {    // 0x002B
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x30,
+        0x30,
+        0xFC,
+        0x30,
+        0x30,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x002C
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x70,
+        0x70,
+        0xC0
+    },
+    {    // 0x002D
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFE,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x002E
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x70,
+        0x70,
+        0x00
+    },
+    {    // 0x002F
+        0x00,
+        0x01,
+        0x03,
+        0x06,
+        0x0C,
+        0x18,
+        0x30,
+        0x60,
+        0xC0,
+        0x80,
+        0x00,
+        0x00
+    },
+    {    // 0x0030
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0xCE,
+        0xD6,
+        0xE6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0031
+        0x00,
+        0x00,
+        0x18,
+        0x38,
+        0x78,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0x00
+    },
+    {    // 0x0032
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0x06,
+        0x3C,
+        0x78,
+        0xC0,
+        0xC0,
+        0xFE,
+        0x00
+    },
+    {    // 0x0033
+        0x00,
+        0x00,
+        0xFE,
+        0x06,
+        0x0C,
+        0x78,
+        0x0C,
+        0x06,
+        0xC6,
+        0xC6,
+        0x78,
+        0x00
+    },
+    {    // 0x0034
+        0x00,
+        0x00,
+        0x3C,
+        0x3C,
+        0x4C,
+        0x4C,
+        0xCC,
+        0xCC,
+        0xFE,
+        0x0C,
+        0x0C,
+        0x00
+    },
+    {    // 0x0035
+        0x00,
+        0x00,
+        0xFE,
+        0xC0,
+        0xC0,
+        0xFC,
+        0x06,
+        0x06,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0036
+        0x00,
+        0x00,
+        0x3C,
+        0x70,
+        0xC0,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0037
+        0x00,
+        0x00,
+        0xFE,
+        0x06,
+        0x06,
+        0x18,
+        0x18,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x00
+    },
+    {    // 0x0038
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0039
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7E,
+        0x06,
+        0x0C,
+        0x78,
+        0x00
+    },
+    {    // 0x003A
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x70,
+        0x70,
+        0x00,
+        0x00,
+        0x70,
+        0x70,
+        0x00,
+        0x00
+    },
+    {    // 0x003B
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x70,
+        0x70,
+        0x00,
+        0x00,
+        0x70,
+        0x70,
+        0xC0,
+        0x00
+    },
+    {    // 0x003C
+        0x00,
+        0x00,
+        0x0C,
+        0x18,
+        0x30,
+        0x60,
+        0xC0,
+        0x60,
+        0x30,
+        0x18,
+        0x0C,
+        0x00
+    },
+    {    // 0x003D
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFE,
+        0x00,
+        0xFE,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x003E
+        0x00,
+        0x00,
+        0x60,
+        0x30,
+        0x18,
+        0x0C,
+        0x06,
+        0x0C,
+        0x18,
+        0x30,
+        0x60,
+        0x00
+    },
+    {    // 0x003F
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0x06,
+        0x18,
+        0x30,
+        0x30,
+        0x00,
+        0x30,
+        0x00
+    },
+    {    // 0x0040
+        0x00,
+        0x00,
+        0x7C,
+        0xC2,
+        0xC6,
+        0xDE,
+        0xE6,
+        0xE6,
+        0xDE,
+        0xC4,
+        0x7A,
+        0x00
+    },
+    {    // 0x0041
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFE,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x0042
+        0x00,
+        0x00,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFC,
+        0x00
+    },
+    {    // 0x0043
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0044
+        0x00,
+        0x00,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFC,
+        0x00
+    },
+    {    // 0x0045
+        0x00,
+        0x00,
+        0xFE,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xFC,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xFE,
+        0x00
+    },
+    {    // 0x0046
+        0x00,
+        0x00,
+        0xFE,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xFC,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0x00
+    },
+    {    // 0x0047
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC0,
+        0xC0,
+        0xDE,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0048
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFE,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x0049
+        0x00,
+        0x00,
+        0xFC,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0xFC,
+        0x00
+    },
+    {    // 0x004A
+        0x00,
+        0x00,
+        0x06,
+        0x06,
+        0x06,
+        0x06,
+        0x06,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x004B
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xCC,
+        0xF8,
+        0xF8,
+        0xD8,
+        0xCC,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x004C
+        0x00,
+        0x00,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xFE,
+        0x00
+    },
+    {    // 0x004D
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xEE,
+        0xFE,
+        0xFE,
+        0xD6,
+        0xD6,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x004E
+        0x00,
+        0x00,
+        0x86,
+        0xC6,
+        0xE6,
+        0xF6,
+        0xFE,
+        0xDE,
+        0xCE,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x004F
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0050
+        0x00,
+        0x00,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFC,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0x00
+    },
+    {    // 0x0051
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xCE,
+        0x7C,
+        0x06
+    },
+    {    // 0x0052
+        0x00,
+        0x00,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x0053
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC0,
+        0xE0,
+        0x1C,
+        0x06,
+        0x06,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0054
+        0x00,
+        0x00,
+        0xFE,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x00
+    },
+    {    // 0x0055
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0056
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x6C,
+        0x38,
+        0x00
+    },
+    {    // 0x0057
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xD6,
+        0xD6,
+        0xFE,
+        0xEE,
+        0xC6,
+        0xC2,
+        0x00
+    },
+    {    // 0x0058
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x6C,
+        0x38,
+        0x30,
+        0x6C,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x0059
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x18,
+        0x18,
+        0x18,
+        0x00
+    },
+    {    // 0x005A
+        0x00,
+        0x00,
+        0xFE,
+        0x06,
+        0x06,
+        0x0C,
+        0x18,
+        0x30,
+        0xC0,
+        0xC0,
+        0xFE,
+        0x00
+    },
+    {    // 0x005B
+        0x00,
+        0x3E,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x3E
+    },
+    {    // 0x005C
+        0x00,
+        0x80,
+        0xC0,
+        0x60,
+        0x30,
+        0x18,
+        0x0C,
+        0x06,
+        0x03,
+        0x01,
+        0x00,
+        0x00
+    },
+    {    // 0x005D
+        0x00,
+        0x3C,
+        0x0C,
+        0x0C,
+        0x0C,
+        0x0C,
+        0x0C,
+        0x0C,
+        0x0C,
+        0x0C,
+        0x0C,
+        0x3C
+    },
+    {    // 0x005E
+        0x00,
+        0x38,
+        0x6C,
+        0xC6,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x005F
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFE,
+        0xFE,
+        0x00
+    },
+    {    // 0x0060
+        0x00,
+        0x78,
+        0x78,
+        0x3C,
+        0x3C,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x0061
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x7C,
+        0x06,
+        0x7E,
+        0xC6,
+        0xC6,
+        0x7E,
+        0x00
+    },
+    {    // 0x0062
+        0x00,
+        0x00,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFC,
+        0x00
+    },
+    {    // 0x0063
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC0,
+        0xC0,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0064
+        0x00,
+        0x00,
+        0x06,
+        0x06,
+        0x06,
+        0x7E,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7E,
+        0x00
+    },
+    {    // 0x0065
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xFE,
+        0xC0,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0066
+        0x00,
+        0x00,
+        0x1E,
+        0x30,
+        0x30,
+        0x30,
+        0xFE,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x00
+    },
+    {    // 0x0067
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x7E,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7E,
+        0x06,
+        0xC6,
+        0x7C
+    },
+    {    // 0x0068
+        0x00,
+        0x00,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x0069
+        0x00,
+        0x00,
+        0x18,
+        0x18,
+        0x00,
+        0x78,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0x7E,
+        0x00
+    },
+    {    // 0x006A
+        0x00,
+        0x18,
+        0x18,
+        0x00,
+        0x78,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0xF8
+    },
+    {    // 0x006B
+        0x00,
+        0x00,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC6,
+        0xCC,
+        0xF0,
+        0xF8,
+        0xCC,
+        0xC6,
+        0x00
+    },
+    {    // 0x006C
+        0x00,
+        0x00,
+        0x70,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x38,
+        0x00
+    },
+    {    // 0x006D
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xE4,
+        0xFE,
+        0xD6,
+        0xD6,
+        0xD6,
+        0xD6,
+        0x00
+    },
+    {    // 0x006E
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x006F
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x7C,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7C,
+        0x00
+    },
+    {    // 0x0070
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFC,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFC,
+        0xC0,
+        0xC0,
+        0xC0
+    },
+    {    // 0x0071
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x7E,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7E,
+        0x06,
+        0x06,
+        0x06
+    },
+    {    // 0x0072
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xDC,
+        0xE6,
+        0xC0,
+        0xC0,
+        0xC0,
+        0xC0,
+        0x00
+    },
+    {    // 0x0073
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x7E,
+        0xC0,
+        0x70,
+        0x0C,
+        0x06,
+        0xFC,
+        0x00
+    },
+    {    // 0x0074
+        0x00,
+        0x00,
+        0x30,
+        0x30,
+        0x30,
+        0xFE,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x1E,
+        0x00
+    },
+    {    // 0x0075
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7E,
+        0x00
+    },
+    {    // 0x0076
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xFC,
+        0x78,
+        0x00
+    },
+    {    // 0x0077
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xD6,
+        0xD6,
+        0xFE,
+        0xFE,
+        0xD6,
+        0xC6,
+        0x00
+    },
+    {    // 0x0078
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0x38,
+        0x38,
+        0xC6,
+        0xC6,
+        0x00
+    },
+    {    // 0x0079
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xC6,
+        0xC6,
+        0xC6,
+        0xC6,
+        0x7E,
+        0x06,
+        0xC6,
+        0x7C
+    },
+    {    // 0x007A
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0xFE,
+        0x06,
+        0x18,
+        0x30,
+        0xC0,
+        0xFE,
+        0x00
+    },
+    {    // 0x007B
+        0x00,
+        0x0C,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0xE0,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x0C
+    },
+    {    // 0x007C
+        0x00,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30,
+        0x30
+    },
+    {    // 0x007D
+        0x00,
+        0x30,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0x0E,
+        0x18,
+        0x18,
+        0x18,
+        0x18,
+        0x30
+    },
+    {    // 0x007E
+        0x00,
+        0x00,
+        0x74,
+        0xFC,
+        0xB8,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00,
+        0x00
+    },
+    {    // 0x007F
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF,
+        0xFF
+    }
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTFT/mGTFT.cpp	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,287 @@
+// --------------------------------------------------------
+// mGTFT.c (c) CopYright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#include "mbed.h"
+#include "mainconf.h"
+
+#include "mGTFT.h"
+#include "mGTP.h"
+#include "font8x12A.h"
+
+#define  WW   1234
+#include "mGTFTini.h"
+
+
+void TFT_wr_reg(uint16_t regv)
+{
+    TFT_WR_0;
+    TFT_wr_regs(regv >> 8);
+    TFT_WR_1;
+    TFT_WR_0;
+    TFT_wr_regs(regv);
+    TFT_WR_1;
+}
+
+
+void TFT_wr_index(uint16_t index)
+{
+//  TFT_CS_0;
+    TFT_RS_0;
+    TFT_wr_reg(index);
+    TFT_RS_1;
+//  TFT_CS_1;
+}
+
+
+void TFT_wr_data(uint16_t data)
+{
+//  TFT_CS_0;
+//  TFT_RS_1;
+    TFT_wr_reg(data);
+//  TFT_CS_1;
+}
+
+
+void TFT_wr_index_data(uint16_t index, uint16_t data)
+{
+//  TFT_CS_0;
+    TFT_RS_0;
+    TFT_wr_reg(index);
+    TFT_RS_1;
+    TFT_wr_reg(data);
+//  TFT_CS_1;
+}
+
+void TFT_setOrientation(uint16_t am)
+{
+    mTFT_SET_ORENTATION(am);
+}
+
+
+void TFT_setWindow(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
+{
+    TFT_wr_index_data(0x50, y1);
+    TFT_wr_index_data(0x51, y2 - 1);
+    TFT_wr_index_data(0x52, x1);
+    TFT_wr_index_data(0x53, x2 - 1);
+    TFT_setOrientation(TFT_HV_HORZ);
+    TFT_setXY(x1, y1);
+}
+
+
+void TFT_setXY(int16_t x1, int16_t y1)
+{
+    TFT_wr_index_data(0x20, y1);
+    TFT_wr_index_data(0x21, x1);
+    TFT_wr_index(0x22);
+}
+
+
+void TFT_clearScreen(uint16_t ccode)
+{
+    TFT_setXY(0, 0);
+    for (int y = 0; y < TFT_info.yMAX; y++)
+        for (int x = 0; x < TFT_info.xMAX; x++)
+            TFT_wr_reg(ccode);
+}
+
+
+void TFT_setPixels(int16_t x1, int16_t y1, uint16_t ccode)
+{
+    if ((x1 >= TFT_info.xMIN) && (x1 < TFT_info.xMAX) &&
+        (y1 >= TFT_info.yMIN) && (y1 < TFT_info.yMAX)) {
+        TFT_setPixel(x1, y1, ccode);
+    }
+}
+
+
+void TFT_setPixel(int16_t x1, int16_t y1, uint16_t ccode)
+{
+    TFT_setXY(x1, y1);
+    TFT_wr_data(ccode);
+}
+
+void TFT_drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t ccode)
+{
+    if (x1 == x2) {
+        TFT_drawVerticalLine  (x1, y1, y2, ccode);
+    } else
+    if (y1 == y2) {
+        TFT_drawHorizontalLine(x1, y1, x2, ccode);
+    } else {
+        int16_t dx = TFT_abs(x1, x2);
+        int16_t dy = TFT_abs(y1, y2);
+        int16_t sx = (x1 < x2) ? 1 : -1;
+        int16_t sy = (y1 < y2) ? 1 : -1;
+        int16_t er = dx - dy, e2;
+
+        while (1) {
+            TFT_setPixels(x1, y1, ccode);
+            if ((x1 == x2) && (y1 == y2)) break;
+            e2 = er * 2;
+            if (e2 > -dx) { er -= dy; x1 += sx; }
+            if (e2 <  dx) { er += dx; y1 += sy; }
+        }
+    }
+}
+
+
+void TFT_drawVerticalLine(int16_t x1, int16_t y1, int16_t y2, uint16_t ccode)
+{
+    if ((x1 <  TFT_info.xMIN) ||
+        (x1 >= TFT_info.xMAX)) return;
+
+    if (y1 > y2) TFT_swap(y1, y2);
+
+    if (y1 <  TFT_info.yMIN) y1 = TFT_info.yMIN;
+    if (y1 >= TFT_info.yMAX) y1 = TFT_info.yMAX - 1;
+    if (y2 <  TFT_info.yMIN) y2 = TFT_info.yMIN;
+    if (y2 >= TFT_info.yMAX) y2 = TFT_info.yMAX - 1;
+
+    mTFT_SET_ORENTATION(TFT_HV_VERT);
+    TFT_setXY(x1, y1);
+    while (y1++ <= y2)
+        TFT_wr_data(ccode);
+    mTFT_SET_ORENTATION(TFT_HV_HORZ);
+}
+
+
+void TFT_drawHorizontalLine(int16_t x1, int16_t y1, int16_t x2, uint16_t ccode)
+{
+    if ((y1 <  TFT_info.yMIN) ||
+        (y1 >= TFT_info.yMAX)) return;
+
+    if (x1 > x2) TFT_swap(x1, x2);
+
+    if (x1 <  TFT_info.xMIN) x1 = TFT_info.xMIN;
+    if (x1 >= TFT_info.xMAX) x1 = TFT_info.xMAX - 1;
+    if (x2 <  TFT_info.xMIN) x2 = TFT_info.xMIN;
+    if (x2 >= TFT_info.xMAX) x2 = TFT_info.xMAX - 1;
+
+    TFT_setXY(x1, y1);
+    while (x1++ <= x2)
+        TFT_wr_data(ccode);
+}
+
+
+void TFT_drawRectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t ccode)
+{
+    TFT_drawLine(x1, y1, x1, y2, ccode);
+    TFT_drawLine(x1, y1, x2, y1, ccode);
+    TFT_drawLine(x1, y2, x2, y2, ccode);
+    TFT_drawLine(x2, y1, x2, y2, ccode);
+}
+
+
+void TFT_fillRectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t lccode, uint16_t fccode)
+{
+    if (y1 > y2) TFT_swap(y1, y2);
+
+    TFT_drawRectangle(x1++, y1++, x2--, y2--, lccode);
+  #if (1)
+    while (y1 <= y2)
+        TFT_drawHorizontalLine(x1, y1++, x2, fccode);
+  #else
+    if (x1 <  TFT_info.xMIN) x1 = TFT_info.xMIN;
+    if (x1 >= TFT_info.xMAX) x1 = TFT_info.xMAX - 1;
+    if (x2 <  TFT_info.xMIN) x2 = TFT_info.xMIN;
+    if (x2 >= TFT_info.xMAX) x2 = TFT_info.xMAX - 1;
+
+    while (y1 <= y2) {
+        TFT_setXY(x1, y1++);
+        for (int wx = x1; wx < x2; wx++)
+            wr_data(fccode);
+    }
+  #endif
+}
+
+
+void TFT_drawCircle(int16_t x1, int16_t y1, int16_t r, uint16_t lccode, uint16_t fccode)
+{
+    //  http://fussy.web.fc2.com/algo/algo2-1.htm
+    int32_t wx = r, wy = 0, lx = r, fx, fy;
+    int32_t xy = (r * -2) + 3;
+
+    if (r < 1) return;
+    while (wx >= wy) {
+        TFT_setPixels(x1 - wx, y1 + wy, lccode);
+        TFT_setPixels(x1 + wx, y1 + wy, lccode); 
+        TFT_setPixels(x1 - wx, y1 - wy, lccode);
+        TFT_setPixels(x1 + wx, y1 - wy, lccode);
+        TFT_setPixels(x1 - wy, y1 + wx, lccode);
+        TFT_setPixels(x1 + wy, y1 + wx, lccode);
+        TFT_setPixels(x1 - wy, y1 - wx, lccode);
+        TFT_setPixels(x1 + wy, y1 - wx, lccode);
+        if (fccode != BLACK1) {
+            fx = wx + wx - 1;
+            fy = wy + wy - 1;
+            TFT_drawHorizontalLine((x1 - wx) + 1, y1 + wy, (x1 - wx) + 1 + fx, fccode);
+            TFT_drawHorizontalLine((x1 - wx) + 1, y1 - wy, (x1 - wx) + 1 + fx, fccode);
+            if (lx != wx) {
+                lx = wx;
+                TFT_drawHorizontalLine((x1 - wy) + 1, y1 + wx, (x1 - wy) + 1 + fy, fccode);
+                TFT_drawHorizontalLine((x1 - wy) + 1, y1 - wx, (x1 - wy) + 1 + fy, fccode);
+            }
+        }
+        if (xy >= 0) {
+            wx--;
+            xy -= wx << 2;
+        }
+        wy++;
+        xy += ((wy << 2) + 2);
+    }
+}
+
+
+uint32_t TFT_getFont(uint8_t *font, int16_t width, int16_t line)
+{
+    if (width <= 8) {
+        return (*(font + line) << (32 - 8));
+    } else {
+        if (width <= 12) {
+            uint16_t n = line + (line >> 1);    // n = line * 1.5
+            if (line & 1) {
+                return ((*(font + n) << (32 - 12)) | (*(font + n + 1) << (32 - 4)));
+            } else {
+                return ((*(font + n) << (32 - 16)) | (*(font + n + 1) << (32 - 8)));
+            }
+        } else {
+            return (*(uint32_t *)((uint8_t *)font + ((width / 8) * line)));
+        }
+    }
+}
+
+
+void TFT_drawFont(int16_t x1, int16_t y1, int16_t width, int16_t line, uint8_t *font, uint16_t fccode, uint16_t bccode)
+{
+    int j;
+    uint32_t k;
+
+    if (((x1 + width) < TFT_info.xMIN) || (x1 >= TFT_info.xMAX) ||
+        ((y1 + line ) < TFT_info.yMIN) || (y1 >= TFT_info.yMAX)) return;
+
+    for (int i = 0; i < line; i++) {
+        uint32_t p = TFT_getFont(font, width, i);
+        for (j = 0, k = 0x80000000; j < width; j++, k >>= 1) {
+            if (p & k)
+                TFT_setPixels(x1 + j, y1 + i, fccode);
+            else
+                if (bccode != BLACK1)
+                    TFT_setPixels(x1 + j, y1 + i, bccode);
+        }
+    }
+}
+
+
+int16_t TFT_drawText(int16_t x1, int16_t y1, uint8_t *s, uint16_t fccode, uint16_t bccode)
+{
+    uint8_t cc;
+
+    while ((cc = *s++) != '\0') {
+        if (cc > 0x7F) cc = ' ';
+        TFT_drawFont(x1, y1, 8, 12, (uint8_t*)&font8x12A[cc][0], fccode, bccode);
+        x1 += 8;
+    }
+    return x1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTFT/mGTFT.h	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,51 @@
+// --------------------------------------------------------
+//  mGTFT.h (c) CopYright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#include "mGTFTdev.h"
+
+#define __RGB(r,g,b)    (uint16_t)((r<<11)|(g<<6)|b)
+#define WHITE           (__RGB(31, 31, 31))
+#define DWHITE          (__RGB(27, 27, 27))
+#define RED             (__RGB(31,  0,  0))
+#define GREEN           (__RGB( 0, 31,  0))
+#define BLUE            (__RGB( 0,  0, 31))
+#define BLACK           (__RGB( 0,  0,  0))
+#define YELLOW          (__RGB(31, 31,  0))
+#define MAGENTA         (__RGB(31,  0, 31))
+#define CYAN            (__RGB( 0, 31, 31))
+#define GRAY            (__RGB(11, 11, 11))
+#define GRAY1           (__RGB(10, 10,  8))
+#define GRAY2           (__RGB(16, 16, 14))
+#define BLACK1          (__RGB( 0,  0,  1))
+
+#define TFT_STOP()      // { TFT_CS_1; LCDTFT::wr_data(0); }
+#define TFT_RUN()       // TFT_CS_0
+
+//#define delay_ms(ms)    wait_ms(ms)
+#define TFT_abs(a, b)   ((a > b) ? (a - b) : (b - a))
+#define TFT_swap(a, b)  { uint16_t w = a; a = b; b = w; }
+
+void TFT_wr_regs(uint8_t regv);
+void TFT_wr_reg(uint16_t regv);
+void TFT_wr_index(uint16_t index);
+void TFT_wr_data(uint16_t data);
+void TFT_wr_index_data(uint16_t index, uint16_t data);
+
+void TFT_init(void);
+void TFT_setOrientation(uint16_t am);
+void TFT_setWindow(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
+void TFT_clearScreen(uint16_t ccolor);
+void TFT_setXY(int16_t x1, int16_t y1);
+void TFT_setPixel(int16_t x1, int16_t y1, uint16_t ccode);
+void TFT_setPixels(int16_t x1, int16_t y1, uint16_t ccode);
+void TFT_drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t ccolor);
+void TFT_drawVerticalLine(int16_t x1, int16_t y1, int16_t y2, uint16_t ccode);
+void TFT_drawHorizontalLine(int16_t x1, int16_t y1, int16_t x2, uint16_t ccode);
+void TFT_drawRectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t ccode);
+void TFT_fillRectangle(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t lccode, uint16_t fccode);
+void TFT_drawCircle(int16_t x1, int16_t y1, int16_t r, uint16_t lccode, uint16_t fccode);
+void TFT_drawFont(int16_t x1, int16_t y1, int16_t width, int16_t line, uint8_t *font, uint16_t fccode, uint16_t bccode);
+void TFT_drawICON(int16_t x1, int16_t y1, int16_t width, int16_t line, uint16_t *icon, uint16_t fccode, uint16_t bccode);
+uint32_t TFT_getFont(uint8_t *font, int16_t width, int16_t line);
+int16_t  TFT_drawText(int16_t x1, int16_t y1, uint8_t *s, uint16_t fccode, uint16_t bccode);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTFT/mGTFTdev.h	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,45 @@
+// --------------------------------------------------------
+//  mGTFTdev.h (c) CopYright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#if defined(aitendo26)
+
+  #define ST7783
+
+  #define TFT_DEVID		0x7783
+  #define TFT_MIN_X     0
+  #define TFT_MIN_Y     0
+  #define TFT_MAX_X     320
+  #define TFT_MAX_Y     240
+
+  #define TFT_HV_VERT   0x0000
+  #define TFT_HV_HORZ   0x0008
+  #define mTFT_SET_ORENTATION(am) TFT_wr_index_data(0x03, 0x1030 | am)
+
+  #define TFT_pin_RD	A0
+  #define TFT_pin_WR	A1	
+  #define TFT_pin_RS	A2	
+  #define TFT_pin_CS	A3	
+  #define TFT_pin_RESET	A4
+
+#elif defined(mcufriend24)
+
+  #define ILI9325
+
+  #define TFT_DEVID		0x9325
+  #define TFT_MIN_X     0
+  #define TFT_MIN_Y     0
+  #define TFT_MAX_X     320
+  #define TFT_MAX_Y     240
+
+  #define TFT_HV_VERT   0x0000
+  #define TFT_HV_HORZ   0x0008
+  #define mTFT_SET_ORENTATION(am) TFT_wr_index_data(0x03, 0x1030 | am)
+
+  #define TFT_pin_RD	A0
+  #define TFT_pin_WR	A1	
+  #define TFT_pin_RS	A2	
+  #define TFT_pin_CS	A3	
+  #define TFT_pin_RESET	A4
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTFT/mGTFTini.h	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,233 @@
+// --------------------------------------------------------
+//  mGTFTini.h (c) CopYright 2013-2014 Goji.
+// --------------------------------------------------------
+
+DigitalOut TFT_RD(TFT_pin_RD);
+DigitalOut TFT_WR(TFT_pin_WR);
+DigitalOut TFT_CS(TFT_pin_CS);
+DigitalOut TFT_RS(TFT_pin_RS);
+DigitalOut TFT_RESET(TFT_pin_RESET);
+
+#define TFT_RESET_0     TFT_RESET = 0
+#define TFT_RESET_1     TFT_RESET = 1
+#define TFT_RS_0        TFT_RS = 0
+#define TFT_RS_1        TFT_RS = 1
+#define TFT_WR_0        TFT_WR = 0
+#define TFT_WR_1        TFT_WR = 1
+#define TFT_CS_0        TFT_CS = 0
+#define TFT_CS_1        TFT_CS = 1
+#define TFT_RD_0        TFT_RD = 0
+#define TFT_RD_1        TFT_RD = 1
+
+TFT_INFO TFT_info = {
+    TFT_MIN_X,
+    TFT_MAX_X,
+    TFT_MIN_Y,
+    TFT_MAX_Y,
+    TPC_XNON,
+    TPC_XMIN,
+    TPC_XMAX,
+    TPC_YNON,
+    TPC_YMIN,
+    TPC_YMAX
+};
+
+
+//---------------------------------------------------------------------
+#if defined(ILI9325)
+//---------------------------------------------------------------------
+uint16_t TFT_Init_table[] = {
+    // http://www.ilitek.com ILI9325 Application Notes
+    // - Set internal timing ------------ //
+    0xE3, 0x3008,    // Set internal timing
+    0xE7, 0x0012,
+    0xEF, 0x1231,
+
+    // - Start Initial Sequence --------- //
+    0x01, 0x0100,    // set SS and SM bit
+    0x02, 0x0700,    // set 1 line inversion
+    0x03, 0x1038,    // set GRAM write direction and BGR=1.
+    0x04, 0x0000,    // Resize register
+    0x08, 0x0207,    // set the back porch and front porch
+    0x09, 0x0000,    // set non-display area refresh cycle ISC[3:0]
+    0x0A, 0x0000,    // FMARK function
+    0x0C, 0x0000,    // RGB interface setting
+    0x0D, 0x0000,    // Frame marker Position
+    0x0F, 0x0000,    // RGB interface polarity
+
+    // - Power On sequence -------------- //
+    0x10, 0x0000,    // SAP, BT[3:0], AP, DSTB, SLP, STB
+    0x11, 0x0007,    // DC1[2:0], DC0[2:0], VC[2:0]
+    0x12, 0x0000,    // VREG1OUT voltage
+    0x13, 0x0000,    // VDV[4:0] for VCOM amplitude
+      WW,    200,
+
+    0x10, 0x1490,    // SAP, BT[3:0], AP, DSTB, SLP, STB
+    0x11, 0x0227,    // DC1[2:0], DC0[2:0], VC[2:0]
+      WW,     50,
+
+    0x12, 0x001C,    // External reference voltage Vci, Vci x 1.80
+    0x07, 0x0001,
+      WW,     50,
+
+    0x13, 0x1A00,    // Power Control 4: VREG1OUT x 1.14
+    0x29, 0x0025,    // Power Control 7: VREG1OUT x 0.870
+    0x2B, 0x000D,    // Frame Rate Control: 8 fps
+      WW,     50,
+
+    0x20, 0x0000,
+    0x21, 0x013F,
+
+    // - Adjust the Gamma Curve --------- //
+    0x30, 0x0000,
+    0x31, 0x0506,
+    0x32, 0x0104,
+    0x35, 0x0207,
+    0x36, 0x000F,
+    0x37, 0x0306,
+    0x38, 0x0102,
+    0x39, 0x0707,
+    0x3C, 0x0702,
+    0x3D, 0x1604,
+
+    // - Set GRAM area ------------------ //
+    0x50, 0x0000,           // Horizontal GRAM Start Address
+    0x51, TFT_MAX_Y - 1,    // Horizontal GRAM End Address
+    0x52, 0x0000,           // Vertical GRAM Start Address
+    0x53, TFT_MAX_X - 1,    // Vertical GRAM Start Address
+
+    0x60, 0xA700,           // Gate Scan Line
+    0x61, 0x0001,           // NDL,VLE, REV
+    0x6A, 0x0000,           // set scrolling line
+
+    // - Partial Display Control ---------//
+    0x80, 0x0000,
+    0x81, 0x0000,
+    0x82, 0x0000,
+    0x83, 0x0000,
+    0x84, 0x0000,
+    0x85, 0x0000,
+
+    // - Panel Control -------------------//
+    0x90, 0x0010,
+    0x92, 0x0600,
+    0x93, 0x0003,
+    0x95, 0x0110,
+    0x97, 0x0000,
+    0x98, 0x0000,
+
+    // - 262K ccode and display ON ------ //
+    0x07, 0x0133,
+      WW,      0
+};
+
+//---------------------------------------------------------------------
+#elif defined(ST7783)
+//---------------------------------------------------------------------
+uint16_t TFT_Init_table[] = {
+    0x01, 0x0100,
+    0x02, 0x0700,
+    0x03, 0x1038,
+    0x04, 0x0000,
+
+    0x08, 0x0302,
+    0x09, 0x0008,
+    0x0A, 0x0008,
+
+    0x10, 0x0790,
+    0x11, 0x0005,
+    0x12, 0x0000,
+    0x13, 0x0000,
+      WW,    100,
+
+    0x10, 0x12B0,
+    0x11, 0x0007,
+      WW,    100,
+
+    0x12, 0x008C,
+    0x13, 0x1700,
+      WW,    100,
+
+    0x29, 0x0222,
+      WW,    100,
+
+    0x30, 0x0000,
+    0x31, 0x0405,
+    0x32, 0x0203,
+    0x35, 0x0004,
+    0x36, 0x0B07,
+    0x37, 0x0000,
+    0x38, 0x0405,
+    0x39, 0x0203,
+    0x3C, 0x0004,
+    0x3D, 0x0B07,
+
+    0x50, 0x0000,           // Horizontal GRAM Start Address
+    0x51, TFT_MAX_Y - 1,    // Horizontal GRAM End Address
+    0x52, 0x0000,           // Vertical GRAM Start Address
+    0x53, TFT_MAX_X - 1,    // Vertical GRAM Start Address
+
+    0x60, 0x2700,
+    0x61, 0x0001,
+    0x6A, 0x0033,
+    0x90, 0x0033,
+    0x07, 0x0133,
+      WW,      0
+};
+
+#else
+  #error "TFT Hardware not defined."
+#endif
+
+
+#define BIT1(n)         (1ul<<n)
+#define BIT3(n)         (3ul<<n)
+#define BIT7(n)         (7ul<<n)
+
+void TFT_init()
+{
+//  mTFT_SETUP_IO();
+
+    TFT_CS_1;
+    TFT_RD_1;
+    TFT_WR_1;
+
+    TFT_RESET_0; wait_ms(20);
+    TFT_RESET_1; wait_ms(50);
+    
+    TFT_CS_0;
+    for (int i = 0; ; i += 2) {
+        if (TFT_Init_table[i] == WW) {          // Delay or Exit
+            if (TFT_Init_table[i + 1] == 0)     // Exit(End of Init Table)
+                break;                          // ..
+            else
+                wait_ms(TFT_Init_table[i + 1]);// Delay
+        } else
+            TFT_wr_index_data(TFT_Init_table[i], TFT_Init_table[i + 1]);
+    }
+    TFT_setOrientation(TFT_HV_HORZ);
+    TFT_setWindow(TFT_info.xMIN, TFT_info.yMIN, TFT_info.xMAX, TFT_info.yMAX);
+}
+
+
+#if defined(_ARCH_PRO)
+void TFT_wr_regs(uint8_t regv)
+{
+  #if defined(aitendo26) || defined(mcufriend24)
+    // dbit  76543210 - data bit
+    // pin#  76543298 - Digital pin# in Arduino
+    // port# 22220000 - Port# in ARCH Pro
+    // bit#  54325410 - Bit#  in ARCH Pro
+    LPC_GPIO0->FIOCLR = BIT1( 1)|BIT1( 0)|BIT1( 5)|BIT1( 4);    // All low
+    LPC_GPIO2->FIOCLR = BIT1( 5)|BIT1( 4)|BIT1( 3)|BIT1( 2);    // ..    
+    LPC_GPIO0->FIOSET = (regv & (BIT1( 3)|BIT1( 2))) << 2 | (regv & (BIT1( 1)|BIT1( 0)));
+    LPC_GPIO2->FIOSET = (regv & (BIT1( 7)|BIT1( 6)|BIT1( 5)|BIT1( 4))) >> 2;
+  #endif
+}
+#else
+
+// Can't use too slow
+BusOut  TFTBus(D8, D9, D2, D3, D4, D5, D6, D7);
+#define TFT_wr_regs(regv)   TFTBus = (regv)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTP/DEV/aitend26.cpp	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,162 @@
+// --------------------------------------------------------
+//  aitend26.c (c) Copyright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#include "mbed.h"
+#include "mainconf.h"
+
+#include "mGTP.h"
+
+#if defined(aitendo26)
+//====================
+void TPC_Init(void)
+{
+    // ADC settings
+    LPC_SC->PCONP        |=  (BIT1(12));    // PCADC: A/D converter (ADC) power/clock enable
+    LPC_SC->PCLKSEL0     &= ~(BIT3(24));    // PCLK_ADC: PCLK_peripheral 00 = CCLK/4
+    LPC_ADC->ADCR         =  ( 0 <<  0)     // SEL: Channels select 0 = No selected 
+                           | (50 <<  8)     // CLKDIV: PCLK max ~= 25MHz, /50 = 500KHz
+                           | ( 0 << 16)     // BURST: 0 = software control 
+                           | ( 0 << 17)     // CLKS: not applicable
+                           | ( 1 << 21)     // PDN: 1 = operational
+                           | ( 0 << 24)     // START: 0 = no start
+                           | ( 0 << 27);    // EDGE: not applicable
+}
+
+
+/*
+    DigitalInOut U_D6(p22);     // X+ (D6)  p22 = P2.4
+    DigitalInOut U_D7(p21);     // Y- (D7)  p21 = P2.5
+    AnalogIn     U_A1(p16);     // Y+ (A1)  p16 = P0.24 TFT_WR
+    AnalogIn     U_A2(p17);     // X- (A2)  p17 = P0.25 TFT_RS
+ */
+
+int16_t get_pX(void)
+{
+    int16_t adcv;
+
+    TFT_STOP();
+
+    // Y+ P0.24 Output High
+//  LPC_PINCON->PINSEL1  &= ~(BIT3(16));    // Set pin Function P0.24 for GPIO(00)
+//  LPC_GPIO0->FIODIR    |=  (BIT1(24));    // Set pin Direction P0.24 for Output(1)
+    LPC_GPIO0->FIOSET     =  (BIT1(24));    // Set pin High(1)
+
+    // Y- P2.5 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3(10));    // Set pin Function P2.5 for GPIO(00)
+//  LPC_GPIO2->FIODIR    |=  (BIT1( 5));    // Set pin Direction P2.5 for Output(1)
+    LPC_GPIO2->FIOCLR     =  (BIT1( 5));    // Set pin Low(0)
+
+    // X+ P2.4 Input mode
+//  LPC_PINCON->PINSEL4  &= ~(BIT3( 8));    // Set pin Function P2.4 for GPIO(00)
+    LPC_GPIO2->FIODIR    &= ~(BIT1( 4));    // Set pin Direction P2.4 for Input(0)
+//  LPC_PINCON->PINMODE4 &= ~(BIT3( 8));    // P2.4 pull-down(11)
+    LPC_PINCON->PINMODE4 |=  (BIT3( 8));    // ..
+
+    // X- P0.25 ADC mode
+    LPC_PINCON->PINSEL1  &= ~(BIT3(18));    // Set pin function P0.25 for AD0.2(01)
+    LPC_PINCON->PINSEL1  |=  (BIT1(18));    // ..
+//  LPC_PINCON->PINMODE1 &= ~(BIT3(18));    // P0.25 pull-down(11)
+    LPC_PINCON->PINMODE1 |=  (BIT3(18));    // ..
+
+    LPC_ADC->ADCR        &= ~(0xFF);        // ADC Channel Clear
+    LPC_ADC->ADCR        |=  (BIT1( 2));    // ADC Channel AD0.2[P0.25]
+    for (int w = 0; w < 100; ) w++;         // Wait for stable
+    LPC_ADC->ADCR        |=  (BIT1(24));    // ADC Start
+    while (!(LPC_ADC->ADGDR & BIT1(31)));   // Wait DONE bit
+    LPC_ADC->ADCR        &= ~(BIT7(24));    // ADC Stop
+
+    adcv = (LPC_ADC->ADGDR >> 4) & 0x0FFF;
+
+    // X+ P2.4 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3( 8));    // Set pin Function P2.4 for GPIO(00)
+    LPC_GPIO2->FIODIR    |=  (BIT1( 4));    // Set pin Direction P2.4 for Output(1)
+//  LPC_GPIO2->FIOSET     =  (BIT1( 4));    // Set pin Low(0)
+
+    // X- P0.25 Output Low
+    LPC_PINCON->PINSEL1  &= ~(BIT3(18));    // Set pin function P0.25 for GPIO(00)
+    LPC_GPIO0->FIODIR    |=  (BIT1(25));    // Set pin Direction P0.25 for Output(1)
+//  LPC_GPIO0->FIOCLR     =  (BIT1(25));    // Set pin Low(0)
+
+    // Y+ P0.24 Output Low
+//  LPC_PINCON->PINSEL1  &= ~(BIT3(16));    // Set pin Function P0.24 for GPIO(00)
+//  LPC_GPIO0->FIODIR    |=  (BIT1(24));    // Set pin Direction P0.24 for Output(1)
+//  LPC_GPIO0->FIOCLR     =  (BIT1(24));    // Set pin Low(0)
+
+    // Y- P2.5 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3(10));    // Set pin Function P2.5 for GPIO(00)
+//  LPC_GPIO2->FIODIR    |=  (BIT1( 5));    // Set pin Direction P2.5 for Output(1)
+//  LPC_GPIO2->FIOCLR     =  (BIT1( 5));    // Set pin Low(0)
+
+    TFT_RUN();
+    return(adcv);
+}
+
+int16_t get_pY(void)
+{
+    uint16_t adcv;
+
+    TFT_STOP();
+
+    // X+ P2.4 Output High
+//  LPC_PINCON->PINSEL4  &= ~(BIT3( 8));    // Set pin Function P2.4 for GPIO(00)
+//  LPC_GPIO2->FIODIR    |=  (BIT1( 4));    // Set pin Direction P2.4 for Output(1)
+    LPC_GPIO2->FIOSET     =  (BIT1( 4));    // Set pin zHigh(1)
+
+    // X- P0.25 Output Low
+//  LPC_PINCON->PINSEL1  &= ~(BIT3(18));    // Set pin Function P0.25 for GPIO(00)
+//  LPC_GPIO0->FIODIR    |=  (BIT1(25));    // Set pin Direction P0.25 for Output(1)
+    LPC_GPIO0->FIOCLR     =  (BIT1(25));    // Set pin Low(0)
+
+    // Y- P2.5 Input
+//  LPC_PINCON->PINSEL4  &= ~(BIT3(10));    // Set pin Function P2.5 for GPIO(00)
+    LPC_GPIO2->FIODIR    &= ~(BIT1( 5));    // Set pin Direction P2.5 for input(0)
+//  LPC_PINCON->PINMODE4 &= ~(BIT3(10));    // P2.5 pull-down(11)
+    LPC_PINCON->PINMODE4 |=  (BIT3(10));    // ..
+
+    // Y+ P0.24 ADC mode
+    LPC_PINCON->PINSEL1  &= ~(BIT3(16));    // Set pin function P0.24 for AD0.1(01)
+    LPC_PINCON->PINSEL1  |=  (BIT1(16));    // ..
+//  LPC_PINCON->PINMODE1 &= ~(BIT3(16));    // P0.24 pull-down(11)
+    LPC_PINCON->PINMODE1 |=  (BIT3(16));    // ..
+
+    LPC_ADC->ADCR        &= ~(0xFF);        // ADC Channel Clear
+    LPC_ADC->ADCR        |=  (BIT1( 1));    // ADC Channel AD0.1[P0.24]
+    for (int w = 0; w < 100; ) w++;         // Wait for stable
+    LPC_ADC->ADCR        |=  (BIT1(24));    // ADC Start
+    while (!(LPC_ADC->ADGDR & BIT1(31)));   // Wait DONE bit
+    LPC_ADC->ADCR        &= ~(BIT7(24));    // ADC Stop
+
+  #if defined(MCUFRIEND)
+    // mcufriend
+    adcv = 0x1000 - ((LPC_ADC->ADGDR >> 4) & 0x0FFF);
+  #else
+    adcv = (LPC_ADC->ADGDR >> 4) & 0x0FFF;
+  #endif
+
+    // X+ P2.4 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3( 8));    // Set pin Function P2.4 for GPIO(00)
+//  LPC_GPIO2->FIODIR    |=  (BIT1( 4));    // Set pin Direction P2.4 for Output(1)
+//  LPC_GPIO2->FIOSET     =  (BIT1( 4));    // Set pin Low(0)
+
+    // X- P0.25 Output Low
+//  LPC_PINCON->PINSEL1  &= ~(BIT3(18));    // Set pin function P0.25 for GPIO(00)
+//  LPC_GPIO0->FIODIR    |=  (BIT1(25));    // Set pin Direction P0.25 for Output(1)
+//  LPC_GPIO0->FIOCLR     =  (BIT1(25));    // Set pin Low(0)
+
+    // Y+ P0.24 Output Low
+    LPC_PINCON->PINSEL1  &= ~(BIT3(16));    // Set pin Function P0.24 for GPIO(00)
+    LPC_GPIO0->FIODIR    |=  (BIT1(24));    // Set pin Direction P0.24 for Output(1)
+//  LPC_GPIO0->FIOCLR     =  (BIT1(24));    // Set pin Low(0)
+
+    // Y- P2.5 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3(10));    // Set pin Function P2.5 for GPIO(00)
+    LPC_GPIO2->FIODIR    |=  (BIT1( 5));    // Set pin Direction P2.5 for Output(1)
+//  LPC_GPIO2->FIOCLR     =  (BIT1( 5));    // Set pin Low(0)
+
+    TFT_RUN();
+    return((int16_t)adcv);
+}
+
+//====================
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTP/DEV/aitend26.h	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,34 @@
+// --------------------------------------------------------
+//  aitend26.h (c) Copyright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#if defined(aitendo26)
+//====================
+
+// aitendo 2.6" for Arduino UNO[UNO026LCD7781TP]
+// ST7783
+// --------------------------------------------------------
+
+/*
+DigitalInOut U_A0(p15);     // Y- (A0)  p15 = P0.23
+AnalogIn     U_A1(p16);     // X- (A1)  p16 = P0.24
+AnalogIn     U_A2(p17);     // Y+ (A2)  p17 = P0.25
+DigitalInOut U_A3(p18);     // X+ (A3)  p18 = P0.26
+*/
+
+#define TPC_XNON    ( 511)
+#define TPC_XMIN    ( 602)
+#define TPC_XMAX    (2940)
+#define TPC_YNON    ( 471)
+#define TPC_YMIN    ( 584)
+#define TPC_YMAX    (2709)
+
+#define TFT_RUN()   
+#define TFT_STOP()  
+
+void    TPC_Init(void);
+int16_t get_pX(void);
+int16_t get_pY(void);
+
+//====================
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTP/DEV/mcuf24.cpp	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,158 @@
+// --------------------------------------------------------
+//  mcuf24.c (c) Copyright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#include "mbed.h"
+#include "mainconf.h"
+
+#include "mGTP.h"
+
+#if defined(mcufriend24)
+//======================
+void TPC_Init(void)
+{
+    // ADC settings
+    LPC_SC->PCONP        |=  (BIT1(12));    // PCADC: A/D converter (ADC) power/clock enable
+    LPC_SC->PCLKSEL0     &= ~(BIT3(24));    // PCLK_ADC: PCLK_peripheral 00 = CCLK/4
+    LPC_ADC->ADCR         =  ( 0 <<  0)     // SEL: Channels select 0 = No selected 
+                           | (50 <<  8)     // CLKDIV: PCLK max ~= 25MHz, /50 = 500KHz
+                           | ( 0 << 16)     // BURST: 0 = software control 
+                           | ( 0 << 17)     // CLKS: not applicable
+                           | ( 1 << 21)     // PDN: 1 = operational
+                           | ( 0 << 24)     // START: 0 = no start
+                           | ( 0 << 27);    // EDGE: not applicable
+}
+
+
+/*
+    DigitalInOut U_D6(p22);     // X+ (D6)  p22 = P2.4
+    DigitalInOut U_D7(p21);     // Y- (D7)  p21 = P2.5
+    AnalogIn     U_A1(p16);     // Y+ (A1)  p16 = P0.24 TFT_WR
+    AnalogIn     U_A2(p17);     // X- (A2)  p17 = P0.25 TFT_RS
+ */
+
+int16_t get_pX(void)
+{
+    int16_t adcv;
+
+    TFT_STOP();
+
+    // Y+ P0.24 Output High
+//  LPC_PINCON->PINSEL1  &= ~(BIT3(16));    // Set pin Function P0.24 for GPIO(00)
+//  LPC_GPIO0->FIODIR    |=  (BIT1(24));    // Set pin Direction P0.24 for Output(1)
+    LPC_GPIO0->FIOSET     =  (BIT1(24));    // Set pin High(1)
+
+    // Y- P2.5 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3(10));    // Set pin Function P2.5 for GPIO(00)
+//  LPC_GPIO2->FIODIR    |=  (BIT1( 5));    // Set pin Direction P2.5 for Output(1)
+    LPC_GPIO2->FIOCLR     =  (BIT1( 5));    // Set pin Low(0)
+
+    // X+ P2.4 Input mode
+//  LPC_PINCON->PINSEL4  &= ~(BIT3( 8));    // Set pin Function P2.4 for GPIO(00)
+    LPC_GPIO2->FIODIR    &= ~(BIT1( 4));    // Set pin Direction P2.4 for Input(0)
+//  LPC_PINCON->PINMODE4 &= ~(BIT3( 8));    // P2.4 pull-down(11)
+    LPC_PINCON->PINMODE4 |=  (BIT3( 8));    // ..
+
+    // X- P0.25 ADC mode
+    LPC_PINCON->PINSEL1  &= ~(BIT3(18));    // Set pin function P0.25 for AD0.2(01)
+    LPC_PINCON->PINSEL1  |=  (BIT1(18));    // ..
+//  LPC_PINCON->PINMODE1 &= ~(BIT3(18));    // P0.25 pull-down(11)
+    LPC_PINCON->PINMODE1 |=  (BIT3(18));    // ..
+
+    LPC_ADC->ADCR        &= ~(0xFF);        // ADC Channel Clear
+    LPC_ADC->ADCR        |=  (BIT1( 2));    // ADC Channel AD0.2[P0.25]
+    for (int w = 0; w < 100; ) w++;         // Wait for stable
+    LPC_ADC->ADCR        |=  (BIT1(24));    // ADC Start
+    while (!(LPC_ADC->ADGDR & BIT1(31)));   // Wait DONE bit
+    LPC_ADC->ADCR        &= ~(BIT7(24));    // ADC Stop
+
+    adcv = (LPC_ADC->ADGDR >> 4) & 0x0FFF;
+
+    // X+ P2.4 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3( 8));    // Set pin Function P2.4 for GPIO(00)
+    LPC_GPIO2->FIODIR    |=  (BIT1( 4));    // Set pin Direction P2.4 for Output(1)
+//  LPC_GPIO2->FIOSET     =  (BIT1( 4));    // Set pin Low(0)
+
+    // X- P0.25 Output Low
+    LPC_PINCON->PINSEL1  &= ~(BIT3(18));    // Set pin function P0.25 for GPIO(00)
+    LPC_GPIO0->FIODIR    |=  (BIT1(25));    // Set pin Direction P0.25 for Output(1)
+//  LPC_GPIO0->FIOCLR     =  (BIT1(25));    // Set pin Low(0)
+
+    // Y+ P0.24 Output Low
+//  LPC_PINCON->PINSEL1  &= ~(BIT3(16));    // Set pin Function P0.24 for GPIO(00)
+//  LPC_GPIO0->FIODIR    |=  (BIT1(24));    // Set pin Direction P0.24 for Output(1)
+//  LPC_GPIO0->FIOCLR     =  (BIT1(24));    // Set pin Low(0)
+
+    // Y- P2.5 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3(10));    // Set pin Function P2.5 for GPIO(00)
+//  LPC_GPIO2->FIODIR    |=  (BIT1( 5));    // Set pin Direction P2.5 for Output(1)
+//  LPC_GPIO2->FIOCLR     =  (BIT1( 5));    // Set pin Low(0)
+
+    TFT_RUN();
+    return(adcv);
+}
+
+int16_t get_pY(void)
+{
+    uint16_t adcv;
+
+    TFT_STOP();
+
+    // X+ P2.4 Output High
+//  LPC_PINCON->PINSEL4  &= ~(BIT3( 8));    // Set pin Function P2.4 for GPIO(00)
+//  LPC_GPIO2->FIODIR    |=  (BIT1( 4));    // Set pin Direction P2.4 for Output(1)
+    LPC_GPIO2->FIOSET     =  (BIT1( 4));    // Set pin zHigh(1)
+
+    // X- P0.25 Output Low
+//  LPC_PINCON->PINSEL1  &= ~(BIT3(18));    // Set pin Function P0.25 for GPIO(00)
+//  LPC_GPIO0->FIODIR    |=  (BIT1(25));    // Set pin Direction P0.25 for Output(1)
+    LPC_GPIO0->FIOCLR     =  (BIT1(25));    // Set pin Low(0)
+
+    // Y- P2.5 Input
+//  LPC_PINCON->PINSEL4  &= ~(BIT3(10));    // Set pin Function P2.5 for GPIO(00)
+    LPC_GPIO2->FIODIR    &= ~(BIT1( 5));    // Set pin Direction P2.5 for input(0)
+//  LPC_PINCON->PINMODE4 &= ~(BIT3(10));    // P2.5 pull-down(11)
+    LPC_PINCON->PINMODE4 |=  (BIT3(10));    // ..
+
+    // Y+ P0.24 ADC mode
+    LPC_PINCON->PINSEL1  &= ~(BIT3(16));    // Set pin function P0.24 for AD0.1(01)
+    LPC_PINCON->PINSEL1  |=  (BIT1(16));    // ..
+//  LPC_PINCON->PINMODE1 &= ~(BIT3(16));    // P0.24 pull-down(11)
+    LPC_PINCON->PINMODE1 |=  (BIT3(16));    // ..
+
+    LPC_ADC->ADCR        &= ~(0xFF);        // ADC Channel Clear
+    LPC_ADC->ADCR        |=  (BIT1( 1));    // ADC Channel AD0.1[P0.24]
+    for (int w = 0; w < 100; ) w++;         // Wait for stable
+    LPC_ADC->ADCR        |=  (BIT1(24));    // ADC Start
+    while (!(LPC_ADC->ADGDR & BIT1(31)));   // Wait DONE bit
+    LPC_ADC->ADCR        &= ~(BIT7(24));    // ADC Stop
+
+    // mcufriend
+    adcv = 0x1000 - ((LPC_ADC->ADGDR >> 4) & 0x0FFF);
+
+    // X+ P2.4 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3( 8));    // Set pin Function P2.4 for GPIO(00)
+//  LPC_GPIO2->FIODIR    |=  (BIT1( 4));    // Set pin Direction P2.4 for Output(1)
+//  LPC_GPIO2->FIOSET     =  (BIT1( 4));    // Set pin Low(0)
+
+    // X- P0.25 Output Low
+//  LPC_PINCON->PINSEL1  &= ~(BIT3(18));    // Set pin function P0.25 for GPIO(00)
+//  LPC_GPIO0->FIODIR    |=  (BIT1(25));    // Set pin Direction P0.25 for Output(1)
+//  LPC_GPIO0->FIOCLR     =  (BIT1(25));    // Set pin Low(0)
+
+    // Y+ P0.24 Output Low
+    LPC_PINCON->PINSEL1  &= ~(BIT3(16));    // Set pin Function P0.24 for GPIO(00)
+    LPC_GPIO0->FIODIR    |=  (BIT1(24));    // Set pin Direction P0.24 for Output(1)
+//  LPC_GPIO0->FIOCLR     =  (BIT1(24));    // Set pin Low(0)
+
+    // Y- P2.5 Output Low
+//  LPC_PINCON->PINSEL4  &= ~(BIT3(10));    // Set pin Function P2.5 for GPIO(00)
+    LPC_GPIO2->FIODIR    |=  (BIT1( 5));    // Set pin Direction P2.5 for Output(1)
+//  LPC_GPIO2->FIOCLR     =  (BIT1( 5));    // Set pin Low(0)
+
+    TFT_RUN();
+    return((int16_t)adcv);
+}
+
+//====================
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTP/DEV/mcuf24.h	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,34 @@
+// --------------------------------------------------------
+//  MCUF24.h (c) Copyright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#if defined(mcufriend24)
+//======================
+
+// www.mcufriend.com 2.4" TFT LCD Shield
+// ILI9325
+// --------------------------------------------------------
+
+/*
+DigitalInOut U_A0(p15);     // Y- (A0)  p15 = P0.23
+AnalogIn     U_A1(p16);     // X- (A1)  p16 = P0.24
+AnalogIn     U_A2(p17);     // Y+ (A2)  p17 = P0.25
+DigitalInOut U_A3(p18);     // X+ (A3)  p18 = P0.26
+*/
+
+#define TPC_XNON    ( 713)
+#define TPC_XMIN    ( 798)
+#define TPC_XMAX    (2730)
+#define TPC_YNON    ( 632)
+#define TPC_YMIN    ( 741)
+#define TPC_YMAX    (2637)
+
+#define TFT_RUN()   
+#define TFT_STOP()  
+
+void    TPC_Init(void);
+int16_t get_pX(void);
+int16_t get_pY(void);
+
+//====================
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTP/mGTP.h	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,18 @@
+// --------------------------------------------------------
+//  mGTP.h (c) CopYright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#define BIT1(n)     (1ul<<n)
+#define BIT3(n)     (3ul<<n)
+#define BIT7(n)     (7ul<<n)
+
+int16_t TPC_getXYO(int16_t*, int16_t*);
+int16_t TPC_getXY (int16_t*, int16_t*);
+
+#if defined(aitendo26)
+  #include "aitend26.h"
+  
+#elif defined(mcufriend24)
+  #include "mcuf24.h"
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mGTP/mGTPlib.cpp	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,46 @@
+// --------------------------------------------------------
+//  mGTPlib.c (c) Copyright 2013-2014 Goji.
+// --------------------------------------------------------
+
+#include "mbed.h"
+#include "mainconf.h"
+
+#include "mGTP.h"
+
+extern  TFT_INFO TFT_info;
+
+#define TPC_ABS(a,b)    ((a>b)?(a-b):(b-a))
+
+int16_t TPC_getXYO(int16_t *dx, int16_t *dy)
+{
+    int16_t wx1, wx2, wy1, wy2;
+
+    if ((wx1 = get_pX()) < TFT_info.TPC_xNon) return(0);
+    if ((wy1 = get_pY()) < TFT_info.TPC_yNon) return(0);
+    wait_us(300);
+    if ((wx2 = get_pX()) < TFT_info.TPC_xNon) return(0);
+    if ((wy2 = get_pY()) < TFT_info.TPC_yNon) return(0);
+    if ((TPC_ABS(wx1, wx2) > 20) || (TPC_ABS(wy1, wy2) > 20)) return(1);
+
+    *dx = (wx1 + wx2) / 2;
+    *dy = (wy1 + wy2) / 2;
+
+    return(2);
+}
+
+int16_t TPC_getXY(int16_t *dx, int16_t *dy)
+{
+    int16_t rc;
+
+    if ((rc = TPC_getXYO(dx, dy)) != 2) return(rc);
+
+    *dx = (*dx > TFT_info.TPC_xMin) ? (*dx - TFT_info.TPC_xMin) : 0;
+    *dy = (*dy > TFT_info.TPC_yMin) ? (*dy - TFT_info.TPC_yMin) : 0;
+    if (*dx > TFT_info.TPC_xMax) *dx = TFT_info.TPC_xMax;
+    if (*dy > TFT_info.TPC_yMax) *dy = TFT_info.TPC_yMax;
+
+    *dx = ((((*dx * 1000) / TFT_info.TPC_xMax) * (TFT_info.xMAX - 1)) / 1000);
+    *dy = ((((*dy * 1000) / TFT_info.TPC_yMax) * (TFT_info.yMAX - 1)) / 1000);
+
+    return(2);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mainconf.h	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,24 @@
+// -- Board Select -----------------------------------
+  #define _ARCH_PRO
+// ---------------------------------------------------
+
+// -- TFT LCD / Touch Panel --------------------------
+  #define aitendo26
+//#define mcufriend24
+// ---------------------------------------------------
+
+typedef struct TFT_INFO TFT_INFO;
+struct TFT_INFO {
+    int xMIN;
+    int xMAX;
+    int yMIN;
+    int yMAX;
+    int TPC_xNon;
+    int TPC_xMin;
+    int TPC_xMax;
+    int TPC_yNon;
+    int TPC_yMin;
+    int TPC_yMax;
+    int TFT_devid;
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 08 16:07:05 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013
\ No newline at end of file