JUTF43 Initial Version

Dependencies:   mbed

1. LCD 세팅

USER DEFINE모드로 사용을 해야 내가 UART로 전송한 데이터를 사용합니다.

참고로!! MASS STORAGE 모드로 선택을 할 경우에는 Boot모드이다. ICBanq의 로고의 BMP파일을 볼수 있습니다.

/media/uploads/eunkyoungkim/20150826_102033_-1-.jpg

2. LCD와 TEST board연결

TFTLCD에서는 5V/TX1/RX1/GND만 연결하면 사용할수 있습니다. /media/uploads/eunkyoungkim/20150826_101936_-1-.jpg

PC에서 바로 시리얼로 보내려면 컨버터가 있어야해서 나의 경우는 MCU borad(WIZwiki-W7500)를 사용합니다.

WIZwiki-W7500의 Datasheet는 아래의 링크를 가서 확인 하면됩니다.

http://wizwiki.net/wiki/doku.php?id=products:w7500:documents

Test board와 연결은 다음과 같습니다.

/media/uploads/eunkyoungkim/20150826_102012_-1-.jpg

3. 코드

Command설명입니다

ex ) $l,1,10,10,100,100,#

Cmddescription
$(0x24)START
l(L의 소문자),1Line 그리기
1,1시작 x,y 좌표
100,100끝 x,y좌표
#(0x63)STOP

mbed코드

mbed가 궁금하다면?

4. 결과

484 x 272인 TFT LCD에 (10,10) -> (100,100)까지만 선을 그어봤습니다.

/media/uploads/eunkyoungkim/20150826_102350_-1-.jpg

Files at this revision

API Documentation at this revision

Comitter:
eunkyoungkim
Date:
Wed Aug 26 04:38:43 2015 +0000
Commit message:
JUTF43 Initial Version;

Changed in this revision

JUTF43/lcd_cmd.cpp Show annotated file Show diff for this revision Revisions of this file
JUTF43/lcd_cmd.h Show annotated file Show diff for this revision Revisions of this file
main.cpp 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
diff -r 000000000000 -r e4340e1e2d7f JUTF43/lcd_cmd.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JUTF43/lcd_cmd.cpp	Wed Aug 26 04:38:43 2015 +0000
@@ -0,0 +1,271 @@
+//#include <stdio.h>
+//
+//#include "lcd_cmd.h"
+//#define MAX_PACKET 1024
+//static char cmd_buf[MAX_PACKET];
+//
+//bool lcd_connect(int portnum)
+//{
+//    TCHAR portname[128];
+//    wsprintf(portname, _T("\\\\.\\COM%d"),portnum);
+//    serial.OpenCom(portname, 115200, 8,0,1);
+//    if(serial.IsActive())
+//    {
+//        serial.ClearCommBlock();
+//        serial.ThreadReceiveSet();
+//    }
+//    else
+//    {
+//        TCHAR msg[128];
+//        wsprintf(msg, _T("Failed to open Serial Port(%d)"), portnum);
+//        OutputDebugString(msg);
+//        return false;
+//    }
+//
+//    lcd_connect_check();
+//
+//    return true;
+//}
+//void lcd_disconnect()
+//{
+//    serial.ThreadReceiveRelease();
+//    serial.CloseCom();
+//}
+//bool lcd_is_open()
+//{
+//    if(serial.IsActive()) return true;
+//    else return false;
+//}
+//void set_receive_window(HWND h, UINT msg)
+//{
+//    serial.SetReceiveWindow(h, msg);
+//}
+//
+//bool send_command(char* str)
+//{
+//    char ch = '-';
+//    if(serial.IsActive())
+//    {
+//        unsigned char sop = '$';
+//        unsigned char eop = '#';
+//
+//        //start of packet
+//        serial.WriteCommBlock(&sop, 1);
+//
+//        //command body
+//        serial.WriteCommBlock((unsigned char*) str, strlen(str));
+//
+//        ///end of packet
+//        serial.WriteCommBlock(&eop, 1);
+//        return true;
+//    }
+//    return false;
+//}
+//
+//bool lcd_connect_check()
+//{
+//    return send_command("s,0");
+//}
+//bool lcd_set_double_buffer_mode()
+//{
+//    return send_command("s,3");
+//}
+//bool lcd_set_single_buffer_mode()
+//{
+//    return send_command("s,4");
+//}
+//bool lcd_brightness(int val)
+//{
+//    if (val > 99)
+//        val = 99;
+//    else if (val < 0)
+//        val = 0;
+//    sprintf_s(cmd_buf,MAX_PACKET, "s,5,%d", val);
+//    return send_command(cmd_buf);
+//}
+//bool lcd_flip()
+//{
+//    return send_command("s,6");
+//}
+//bool lcd_usb_mass_storage()
+//{
+//    return send_command("s,7");
+//}
+//bool lcd_reset()
+//{
+//    return send_command("s,9");
+//}
+//
+//
+//bool lcd_set_color(unsigned char r, unsigned char g, unsigned char b)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "l,0,%d,%d,%d", r, g, b);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_draw_line(int x, int y, int endx, int endy)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "l,1,%d,%d,%d,%d", x, y, endx, endy);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_draw_rect(int x, int y, int w, int h, bool bfill)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "l,2,%d,%d,%d,%d,%d", x, y, w, h, bfill == true ? 1 : 0);
+//    return send_command(cmd_buf);
+//}
+//bool lcd_draw_rect_gradient(int x, int y, int w, int h, unsigned char sr, unsigned char sg, unsigned char sb, unsigned char er, unsigned char eg, unsigned char eb)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "l,3,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", x, y, w, h, sr, sg, sb, er, eg, eb);
+//    return send_command(cmd_buf);
+//}
+//bool lcd_draw_rect_rounded(int x, int y, int w, int h, int rad, bool bfill)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "l,4,%d,%d,%d,%d,%d,%d", x, y, w, h, rad, bfill == true ? 1 : 0);
+//    return send_command(cmd_buf);
+//}
+//bool lcd_draw_thickline(int x, int y, int endx, int endy, int thick)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "l,5,%d,%d,%d,%d,%d", x, y, endx, endy, thick);
+//    return send_command(cmd_buf);
+//}
+//bool lcd_draw_circle(int x, int y, int r, bool bfill)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "l,6,%d,%d,%d,%d", x, y, r, bfill == true ? 1 : 0);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_draw_ellipse(int x, int y, int rx, int ry, bool bfill)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "l,7,%d,%d,%d,%d,%d", x, y, rx, ry, bfill == true ? 1 : 0);
+//    return send_command(cmd_buf);
+//}
+//bool lcd_image_load(int index, char* fname)
+//{
+//    if (index >= 1024)
+//        return false;
+//    else if (index < 0)
+//        return false;
+//
+//    sprintf_s(cmd_buf,MAX_PACKET, "i,1,%d,%s", index, fname);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_image_draw(int index, int x, int y)
+//{
+//    if (index >= 1024)
+//        return false;
+//    else if (index < 0)
+//        return false;
+//
+//    sprintf_s(cmd_buf,MAX_PACKET, "i,2,%d,%d,%d", index, x, y);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_image_draw_rect(int index, int x, int y, int sx, int sy, int w, int h)
+//{
+//    if (index >= 1024)
+//        return false;
+//    else if (index < 0)
+//        return false;
+//
+//    sprintf_s(cmd_buf,MAX_PACKET, "i,3,%d,%d,%d,%d,%d,%d,%d", index, x, y, sx, sy, w, h);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_image_draw_scale(int index, int x, int y, int w, int h)
+//{
+//    if (index >= 1024)
+//        return false;
+//    else if (index < 0)
+//        return false;
+//
+//    sprintf_s(cmd_buf,MAX_PACKET, "i,4,%d,%d,%d,%d,%d", index, x, y, w, h);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_image_draw_scale_rect(int index, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh)
+//{
+//    if (index >= 1024)
+//        return false;
+//    else if (index < 0)
+//        return false;
+//
+//    sprintf_s(cmd_buf,MAX_PACKET, "i,5,%d,%d,%d,%d,%d,%d,%d,%d,%d", index, dx, dy, dw, dh, sx, sy, sw, sh);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_image_release(int index)
+//{
+//    if (index >= 1024)
+//        return false;
+//    else if (index < 0)
+//        return false;
+//
+//    sprintf_s(cmd_buf, MAX_PACKET, "i,6,%d", index);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_textcolor(unsigned char r, unsigned char g, unsigned char b)
+//{
+//    sprintf_s(cmd_buf,MAX_PACKET, "f,1,%d,%d,%d", r, g, b);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_textout(char* str, int x, int y)
+//{
+//    if (strlen(str) > 1000)
+//        return false;
+//
+//    sprintf_s(cmd_buf,MAX_PACKET, "f,0,%s,%d,%d", str, x, y);
+//    return send_command(cmd_buf);
+//}
+//
+//bool lcd_set_touchmode(bool bAsync)
+//{
+//
+//    if (bAsync)
+//        return send_command("t,0,1");
+//    else
+//        return send_command("t,0,0");
+//
+//}
+//
+//bool lcd_get_touch(unsigned short *x, unsigned short *y)
+//{
+//    /*
+//    char* cmd = "$t,1#";
+//    DWORD nRead;
+//    unsigned char res[5];
+//    serial.Write(cmd, strlen(cmd));
+//    if (serial.Read(res, 5, &nRead) != ERROR_SUCCESS)
+//        return false;
+//    if (nRead != 5)
+//        return false;
+//    if (res[4] != '+')
+//        return false;
+//    *x = (unsigned short)(res[0] << 8) + res[1];
+//    *y = (unsigned short)(res[2] << 8) + res[3];
+//    */
+//    return true;
+//}
+//
+//bool lcd_run_script(char* fname)
+//{
+//    if (strlen(fname) > 1000)
+//        return false;
+//
+//    sprintf_s(cmd_buf, MAX_PACKET, "c,0,%s", fname);
+//    return send_command(cmd_buf);
+//}
+//
+////Read data from the serial port
+//int lcd_get_serial_data(unsigned char* buf)
+//{
+//    int res = 0;
+//    if(serial.IsActive())
+//    {
+//        res = serial.GetReceiveData(buf);
+//    }
+//    return res;
+//}
diff -r 000000000000 -r e4340e1e2d7f JUTF43/lcd_cmd.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JUTF43/lcd_cmd.h	Wed Aug 26 04:38:43 2015 +0000
@@ -0,0 +1,41 @@
+#pragma once
+bool lcd_connect(int portnum);
+void lcd_disconnect();
+bool lcd_is_open();
+void set_receive_window(HWND h, UINT msg);
+
+bool send_command(char* str);
+
+bool lcd_connect_check();
+bool lcd_set_double_buffer_mode();
+bool lcd_set_single_buffer_mode();
+bool lcd_brightness(int val);
+bool lcd_flip();
+bool lcd_usb_mass_storage();
+bool lcd_reset();
+
+bool lcd_set_color(unsigned char r, unsigned char g, unsigned char b);
+bool lcd_draw_line(int x, int y, int endx, int endy);
+bool lcd_draw_rect(int x, int y, int w, int h, bool bfill);
+bool lcd_draw_rect_gradient(int x, int y, int w, int h, unsigned char sr, unsigned char sg, unsigned char sb, unsigned char er, unsigned char eg, unsigned char eb);
+bool lcd_draw_rect_rounded(int x, int y, int w, int h, int rad, bool bfill);
+bool lcd_draw_thickline(int x, int y, int endx, int endy, int thick);
+bool lcd_draw_circle(int x, int y, int r, bool bfill);
+bool lcd_draw_ellipse(int x, int y, int rx, int ry, bool bfill);
+
+bool lcd_image_load(int index, char* fname);
+bool lcd_image_draw(int index, int x, int y);
+bool lcd_image_draw_rect(int index, int x, int y, int sx, int sy, int w, int h);
+bool lcd_image_draw_scale(int index, int x, int y, int w, int h);
+bool lcd_image_draw_scale_rect(int index, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh);
+bool lcd_image_release(int index);
+
+bool lcd_textcolor(unsigned char r, unsigned char g, unsigned char b);
+bool lcd_textout(char* str, int x, int y);
+
+bool lcd_set_touchmode(bool bAsync);
+bool lcd_get_touch(unsigned short *x, unsigned short *y);
+
+bool lcd_run_script(char* fname);
+
+int lcd_get_serial_data(unsigned char* buf);
diff -r 000000000000 -r e4340e1e2d7f main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Aug 26 04:38:43 2015 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+
+
+Serial pc(USBTX,USBRX); // tx, rx
+Serial TFT(PA_13,PA_14); // tx, rx
+void send_command(char* str);
+int main() {
+	char data=0;
+	char buffer[22]={"$l,1,10,10,100,100,#"};
+    int process_it;
+    int i;
+    
+    pc.baud(115200); 
+    TFT.baud(115200); 
+    pc.printf("Hello World!\r\n");
+    for(i = 0; i<=sizeof(buffer) ;i++)
+			{
+				buffer[i] += data;
+				printf("%x\r\n",buffer[i]);
+			}
+	  TFT.printf(buffer);
+ 
+}
diff -r 000000000000 -r e4340e1e2d7f mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Aug 26 04:38:43 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c
\ No newline at end of file