Video image display and touch panel sample for GR-PEACH LCD Shield.

Information

Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.

Information

This sample has multiple frame buffers so that the clock source can display different cameras and LCDs cleanly. If you are using the NTSC signal, the following sample is simpler.
このサンプルはクロック元が異なるカメラとLCDを綺麗に表示するために、複数のフレームバッファを持っています。NTSC信号を使用するのであれば、以下のサンプルの方が単純です。

https://developer.mbed.org/users/dkato/code/GR-PEACH_NTSC_in_2ch/

What is this ?

The basic function of the GR-PEACH LCD Shield can be tried by this sample.
Display the information of the touch panel on the camera image.
A character font is shown to the screen lower right every 1 second.

Touch panel information

The touch location of the blue and the 2nd point becomes pink in the 1st touch location in case of a multi-touch.
While touching the screen, a white square in the upper left corner of the screen will be displayed.
Touch information is being output in printf. When doing terminal designation, please set 230400 as a baud rate.

Composition

GR-PEACH, GR-PEACH 4.3 inch LCD Shield or GR-PEACH 7.1 inch LCD Shield, GR-PEACH AUDIO CAMERA Shield and Camera.
/media/uploads/dkato/gr-peach_with_camera_lcd.png

When using analog input for video input, GR-PEACH AUDIO CAMERA Shield and the camera are unnecessary.
(Setting the VIDEO_CVBS to VIDEO_INPUT_METHOD)
Please input analog signal to NTSC1A pin. (Even if there are no input signals, a touch panel can be operated.).
/media/uploads/dkato/video_display_analog.jpg

Video input of default is a digital input (Cmos Camera). When changing the video input, please change the below.

mbed_app.json

{
    "config": {
        "camera":{
            "help": "0:disable 1:enable",
            "value": "1"
        },
        "camera-type":{
            "help": "Please see README.md",
            "value": "CAMERA_CVBS"
        },
        "lcd":{
            "help": "0:disable 1:enable",
            "value": "1"
        },
        "lcd-type":{
            "help": "Please see README.md",
            "value": "GR_PEACH_4_3INCH_SHIELD"
        }
    }
}
camera-type "value"Description
CAMERA_CVBSGR-PEACH NTSC signal
CAMERA_MT9V111GR-PEACH MT9V111
CAMERA_OV7725GR-LYHCEE included camera
CAMERA_OV5642GR-PEACH OV5642
CAMERA_WIRELESS_CAMERAGR-PEACH Wireless/Camera shield (MT9V111)
lcd-type "value"Description
GR_PEACH_4_3INCH_SHIELDGR-PEACH 4.3 inch LCD shield
GR_PEACH_7_1INCH_SHIELDGR-PEACH 7.1 inch LCD shield
GR_PEACH_RSK_TFTGR-PEACH RSK board LCD
GR_PEACH_DISPLAY_SHIELDGR-PEACH Display Shield or DVi-Board
GR_LYCHEE_LCDGR-LYHCEE TF043HV001A0..etc(40pin)




概要

このサンプルではGR-PEACH LCD Shieldの基本的な機能を試せます。
カメラ画像の上にタッチパネルの情報を重ねて表示します。
文字フォントが右下に1秒毎に表示されます。

タッチパネルの情報

マルチタッチの場合は1点目のタッチ位置は青、2点目のタッチ位置はピンクになります。
画面がタッチされている間、画面左上に白い四角が表示されます。
printfでもタッチ情報を出力しています。ターミナル表示を行う際は、ボーレートに230400を設定してください。

構成

GR-PEACH、GR-PEACH 4.3 inch LCD Shield または GR-PEACH 7.1 inch LCD Shield、GR-PEACH AUDIO CAMERA Shield 、カメラ。
/media/uploads/dkato/gr-peach_with_camera_lcd.png

ビデオ入力にアナログ入力を使用する場合はGR-PEACH AUDIO CAMERA Shield とカメラは不要です。
(VIDEO_INPUT_METHOD にVIDEO_CVBS を設定)
NTSC1Aピンにアナログ信号を入力してください。(入力信号が無くてもタッチパネルは操作できます。)
/media/uploads/dkato/video_display_analog.jpg

デフォルトのビデオ入力はデジタル入力(Cmos Camera)です。ビデオ入力を変更する際は以下を変更してください。

mbed_app.json

{
    "config": {
        "camera":{
            "help": "0:disable 1:enable",
            "value": "1"
        },
        "camera-type":{
            "help": "Please see README.md",
            "value": "CAMERA_CVBS"
        },
        "lcd":{
            "help": "0:disable 1:enable",
            "value": "1"
        },
        "lcd-type":{
            "help": "Please see README.md",
            "value": "GR_PEACH_4_3INCH_SHIELD"
        }
    }
}
camera-type "value"Description
CAMERA_CVBSGR-PEACH NTSC signal
CAMERA_MT9V111GR-PEACH MT9V111
CAMERA_OV7725GR-LYHCEE included camera
CAMERA_OV5642GR-PEACH OV5642
CAMERA_WIRELESS_CAMERAGR-PEACH Wireless/Camera shield (MT9V111)
lcd-type "value"Description
GR_PEACH_4_3INCH_SHIELDGR-PEACH 4.3 inch LCD shield
GR_PEACH_7_1INCH_SHIELDGR-PEACH 7.1 inch LCD shield
GR_PEACH_RSK_TFTGR-PEACH RSK board LCD
GR_PEACH_DISPLAY_SHIELDGR-PEACH Display Shield or DVi-Board
GR_LYCHEE_LCDGR-LYHCEE TF043HV001A0..etc(40pin)
Revision:
4:bafd63604b7c
Parent:
2:8721836b639d
Child:
5:4e96673f4830
--- a/main.cpp	Fri Nov 25 10:10:19 2016 +0000
+++ b/main.cpp	Fri Nov 25 11:16:42 2016 +0000
@@ -1,6 +1,7 @@
 #include "mbed.h"
 #include "DisplayBace.h"
 #include "rtos.h"
+#include "AsciiFont.h"
 
 #define VIDEO_CVBS             (0)                 /* Analog  Video Signal */
 #define VIDEO_CMOS_CAMERA      (1)                 /* Digital Video Signal */
@@ -80,6 +81,12 @@
 #define TOUCH_NUM                     (2u)
 #define DROW_POINT                    (5)
 
+/* STRING BUFFER Parameter GRAPHICS_LAYER_2 */
+#define STRING_PIXEL_HW               (120)
+#define STRING_PIXEL_VM               (24)
+#define STRING_BUFFER_BYTE_PER_PIXEL  (2u)
+#define STRING_BUFFER_STRIDE          (((LCD_PIXEL_WIDTH * STRING_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
+
 static DisplayBase Display;
 static DigitalOut  lcd_pwon(P7_15);
 static DigitalOut  lcd_blon(P8_1);
@@ -100,12 +107,15 @@
 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
 #pragma data_alignment=32
 static uint8_t user_frame_buffer_touch[TOUCH_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
+#pragma data_alignment=32
+static uint8_t user_frame_buffer_string[STRING_BUFFER_STRIDE * STRING_PIXEL_VM];
 #else
 /* 32 bytes aligned */
 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
 static uint8_t user_frame_buffer_touch[TOUCH_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
+static uint8_t user_frame_buffer_string[STRING_BUFFER_STRIDE * STRING_PIXEL_VM]__attribute((aligned(32)));
 #endif
 static uint8_t * FrameBufferTbl[FRAME_BUFFER_NUM] = {user_frame_buffer0, user_frame_buffer1, user_frame_buffer2};
 #if VIDEO_INPUT_METHOD == VIDEO_CVBS
@@ -535,6 +545,9 @@
 
 /****** main ******/
 int main(void) {
+    DisplayBase::rect_t rect;
+    char test_cnt = 0x20;
+
     /* Change the baud rate of the printf() */
     pc.baud(921600);
 
@@ -552,8 +565,38 @@
     Thread touchTask;
     touchTask.start(touch_task);
 
+    /* The layer by which the touch panel location is drawn */
+    memset(user_frame_buffer_string, 0, sizeof(user_frame_buffer_string));
+    dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string));
+    rect.vs = LCD_PIXEL_HEIGHT - STRING_PIXEL_VM - 10;
+    rect.vw = STRING_PIXEL_VM;
+    rect.hs = LCD_PIXEL_WIDTH - STRING_PIXEL_HW - 10;
+    rect.hw = STRING_PIXEL_HW;
+    Display.Graphics_Read_Setting(
+        DisplayBase::GRAPHICS_LAYER_2,
+        (void *)user_frame_buffer_string,
+        STRING_BUFFER_STRIDE,
+        DisplayBase::GRAPHICS_FORMAT_ARGB4444,
+        DisplayBase::WR_RD_WRSWA_32_16BIT,
+        &rect
+    );
+    Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2);
+
+    /* String */
+    AsciiFont ascii_font(user_frame_buffer_string, STRING_PIXEL_HW, STRING_PIXEL_VM,
+                         STRING_BUFFER_STRIDE, STRING_BUFFER_BYTE_PER_PIXEL);
     while (1) {
         led_blue = !led_blue;
+
+        //colour: rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red
+        ascii_font.DrawStr("Font:", 0, 8, 0x0000ffff, 2);
+        ascii_font.DrawChar(test_cnt, 84, 0, 0x0000aa9f, 3);
+        if (test_cnt < 0x7e) {
+            test_cnt++;
+        } else {
+            test_cnt = 0x20;
+        }
+        dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string));
         Thread::wait(1000);
     }
 }