LCD Shield sample. 4.3inch.

Dependencies:   GR-PEACH_video mbed-rtos mbed

Fork of GR-PEACH_LCD_sample by Daiki Kato

Information

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

This program displays the NTSC input from NTSC1A of LCD Shield on the screen. Touch coordinates are displayed on the terminal when you touch the screen. You can touch at the same time up to 2 points.

When you connect the "GR-PEACH AUDIO CAMERA Shield", you can display an image of the CMOS Camera(MT9V111).
If you use CMOS Camera, Please change the below in the “main.cpp”.

main.cpp

#define VIDEO_INPUT_METHOD     (VIDEO_CVBS)
->
#define VIDEO_INPUT_METHOD     (VIDEO_CMOS_CAMERA)


Please refer to following link about "GR-PEACH AUDIO CAMERA Shield".
https://developer.mbed.org/teams/Renesas/wiki/Audio_Camera-shield


このプログラムは、NTSC1AからのNTSC入力をLCDシールドの画面上に表示します。画面をタッチすると、タッチ座標がprintf表示されます。2点まで同時にタッチできます。
GR-PEACH AUDIO CAMERA Shieldを接続すると、CMOSカメラ(MT9V111)の画像を表示することができます。CMOSカメラを使用する場合は、「main.cpp」の以下を変更してください。

main.cpp

#define VIDEO_INPUT_METHOD     (VIDEO_CVBS)
->
#define VIDEO_INPUT_METHOD     (VIDEO_CMOS_CAMERA)


GR-PEACH AUDIO CAMERA Shieldについては下記を参照ください。
https://developer.mbed.org/teams/Renesas/wiki/Audio_Camera-shield

Committer:
dkato
Date:
Fri Nov 06 10:52:15 2015 +0000
Revision:
2:8e78c957adb5
Parent:
1:f0d5f9c28404
Child:
3:b5aaf7215800
bug fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:47ea8de0be6c 1 #include "mbed.h"
dkato 0:47ea8de0be6c 2 #include "DisplayBace.h"
dkato 0:47ea8de0be6c 3 #include "rtos.h"
dkato 0:47ea8de0be6c 4
dkato 0:47ea8de0be6c 5 #define VIDEO_CVBS (0) /* Analog Video Signal */
dkato 0:47ea8de0be6c 6 #define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */
dkato 0:47ea8de0be6c 7 #define VIDEO_YCBCR422 (0)
dkato 0:47ea8de0be6c 8 #define VIDEO_RGB888 (1)
dkato 0:47ea8de0be6c 9 #define VIDEO_RGB565 (2)
dkato 0:47ea8de0be6c 10
dkato 0:47ea8de0be6c 11 /**** User Selection *********/
dkato 0:47ea8de0be6c 12 #define VIDEO_INPUT_METHOD (VIDEO_CVBS) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */
dkato 0:47ea8de0be6c 13 #define VIDEO_INPUT_FORMAT (VIDEO_YCBCR422) /* Select VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565 */
dkato 0:47ea8de0be6c 14 #define USE_VIDEO_CH (0) /* Select 0 or 1 If selecting VIDEO_CMOS_CAMERA, should be 0.) */
dkato 0:47ea8de0be6c 15 #define VIDEO_PAL (0) /* Select 0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */
dkato 0:47ea8de0be6c 16 /*****************************/
dkato 1:f0d5f9c28404 17
dkato 1:f0d5f9c28404 18 /**** LCD Parameter **********/
dkato 1:f0d5f9c28404 19 #define LCD_DE_MODE (0)
dkato 1:f0d5f9c28404 20 #define LCD_SYNC_MODE (1)
dkato 1:f0d5f9c28404 21
dkato 1:f0d5f9c28404 22 #define LCD_DOT_CLOCK (13.40f) // 13.4MHz
dkato 1:f0d5f9c28404 23
dkato 1:f0d5f9c28404 24 #define LCD_H_WIDTH (480u)
dkato 1:f0d5f9c28404 25 #define LCD_H_BACK_PORCH (43u)
dkato 1:f0d5f9c28404 26 #define LCD_H_FRONT_PORCH (52u)
dkato 1:f0d5f9c28404 27 #define LCD_H_SYNC_WIDTH (41u)
dkato 1:f0d5f9c28404 28
dkato 1:f0d5f9c28404 29 #define LCD_V_WIDTH (272u)
dkato 1:f0d5f9c28404 30 #define LCD_V_BACK_PORCH (12u)
dkato 1:f0d5f9c28404 31 #define LCD_V_FRONT_PORCH (2u)
dkato 1:f0d5f9c28404 32 #define LCD_V_SYNC_WIDTH (10u)
dkato 1:f0d5f9c28404 33
dkato 1:f0d5f9c28404 34 #define LCD_MODE (LCD_SYNC_MODE)
dkato 1:f0d5f9c28404 35
dkato 1:f0d5f9c28404 36 /*****************************/
dkato 1:f0d5f9c28404 37
dkato 0:47ea8de0be6c 38
dkato 0:47ea8de0be6c 39 #if USE_VIDEO_CH == (0)
dkato 0:47ea8de0be6c 40 #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_0)
dkato 0:47ea8de0be6c 41 #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S0_VFIELD)
dkato 0:47ea8de0be6c 42 #else
dkato 0:47ea8de0be6c 43 #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_1)
dkato 0:47ea8de0be6c 44 #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S1_VFIELD)
dkato 0:47ea8de0be6c 45 #endif
dkato 0:47ea8de0be6c 46
dkato 0:47ea8de0be6c 47 #if ( VIDEO_INPUT_FORMAT == VIDEO_YCBCR422 || VIDEO_INPUT_FORMAT == VIDEO_RGB565 )
dkato 0:47ea8de0be6c 48 #define DATA_SIZE_PER_PIC (2u)
dkato 0:47ea8de0be6c 49 #else
dkato 0:47ea8de0be6c 50 #define DATA_SIZE_PER_PIC (4u)
dkato 0:47ea8de0be6c 51 #endif
dkato 0:47ea8de0be6c 52
dkato 0:47ea8de0be6c 53 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
dkato 0:47ea8de0be6c 54 in accordance with the frame buffer burst transfer mode. */
dkato 1:f0d5f9c28404 55 #define PIXEL_HW (480u) /* WQVGA */
dkato 1:f0d5f9c28404 56 #define PIXEL_VW (272u) /* WQVGA */
dkato 0:47ea8de0be6c 57
dkato 0:47ea8de0be6c 58 #define VIDEO_BUFFER_STRIDE (((PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u)
dkato 0:47ea8de0be6c 59 #define VIDEO_BUFFER_HEIGHT (PIXEL_VW)
dkato 0:47ea8de0be6c 60
dkato 0:47ea8de0be6c 61 DigitalIn button(USER_BUTTON0);
dkato 0:47ea8de0be6c 62 #if(1) //lcd
dkato 0:47ea8de0be6c 63 DigitalOut lcd_pwon(P7_15);
dkato 0:47ea8de0be6c 64 DigitalOut lcd_blon(P8_1);
dkato 0:47ea8de0be6c 65 PwmOut lcd_cntrst(P8_15);
dkato 0:47ea8de0be6c 66 I2C mI2c(I2C_SDA, I2C_SCL);
dkato 0:47ea8de0be6c 67
dkato 0:47ea8de0be6c 68 typedef struct {
dkato 0:47ea8de0be6c 69 uint8_t y_h: 3,
dkato 0:47ea8de0be6c 70 reserved: 1,
dkato 0:47ea8de0be6c 71 x_h: 3,
dkato 0:47ea8de0be6c 72 valid: 1;
dkato 0:47ea8de0be6c 73 uint8_t x_l;
dkato 0:47ea8de0be6c 74 uint8_t y_l;
dkato 0:47ea8de0be6c 75 uint8_t z;
dkato 0:47ea8de0be6c 76 } xyz_data_t;
dkato 0:47ea8de0be6c 77
dkato 0:47ea8de0be6c 78 typedef struct {
dkato 0:47ea8de0be6c 79 uint8_t fingers: 4,
dkato 0:47ea8de0be6c 80 reserved: 4;
dkato 0:47ea8de0be6c 81 uint8_t keys;
dkato 0:47ea8de0be6c 82 xyz_data_t xyz_data[2];
dkato 0:47ea8de0be6c 83 } stx_report_data_t;
dkato 0:47ea8de0be6c 84
dkato 0:47ea8de0be6c 85 static int get_coordinates(uint8_t *count, uint32_t *x0, uint32_t *y0, uint32_t *x1, uint32_t *y1) {
dkato 0:47ea8de0be6c 86 char buf[10];
dkato 0:47ea8de0be6c 87 stx_report_data_t *pdata;
dkato 0:47ea8de0be6c 88 int ret = -1;
dkato 0:47ea8de0be6c 89 *count = 0; // Set point detected count to 0.
dkato 0:47ea8de0be6c 90
dkato 0:47ea8de0be6c 91 if (mI2c.read((0x55 << 1), buf, sizeof(buf)) == 0) {
dkato 0:47ea8de0be6c 92 pdata = (stx_report_data_t *)buf;
dkato 0:47ea8de0be6c 93 if (pdata->fingers) {
dkato 0:47ea8de0be6c 94 if (pdata->xyz_data[0].valid) {
dkato 0:47ea8de0be6c 95 *x0 = (pdata->xyz_data[0].x_h << 8) | pdata->xyz_data[0].x_l;
dkato 0:47ea8de0be6c 96 *y0 = (pdata->xyz_data[0].y_h << 8) | pdata->xyz_data[0].y_l;
dkato 0:47ea8de0be6c 97 (*count)++;
dkato 0:47ea8de0be6c 98 }
dkato 0:47ea8de0be6c 99 }
dkato 0:47ea8de0be6c 100 if (pdata->xyz_data[1].valid) {
dkato 0:47ea8de0be6c 101 *x1 = (pdata->xyz_data[1].x_h << 8) | pdata->xyz_data[1].x_l;
dkato 0:47ea8de0be6c 102 *y1 = (pdata->xyz_data[1].y_h << 8) | pdata->xyz_data[1].y_l;
dkato 0:47ea8de0be6c 103 (*count)++;
dkato 0:47ea8de0be6c 104 }
dkato 0:47ea8de0be6c 105 ret = 0;
dkato 0:47ea8de0be6c 106 }
dkato 0:47ea8de0be6c 107
dkato 0:47ea8de0be6c 108 return ret;
dkato 0:47ea8de0be6c 109 }
dkato 0:47ea8de0be6c 110 #endif
dkato 0:47ea8de0be6c 111
dkato 0:47ea8de0be6c 112 static uint8_t FrameBuffer_Video[VIDEO_BUFFER_STRIDE * VIDEO_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(16))); //16 bytes aligned!;
dkato 0:47ea8de0be6c 113 static volatile int32_t vsync_count = 0;
dkato 0:47ea8de0be6c 114 static volatile int32_t vfield_count = 1;
dkato 0:47ea8de0be6c 115 static int image_change = 0;
dkato 0:47ea8de0be6c 116
dkato 0:47ea8de0be6c 117 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type)
dkato 0:47ea8de0be6c 118 {
dkato 0:47ea8de0be6c 119 //Interrupt callback function
dkato 0:47ea8de0be6c 120 if (vfield_count != 0) {
dkato 0:47ea8de0be6c 121 vfield_count = 0;
dkato 0:47ea8de0be6c 122 } else {
dkato 0:47ea8de0be6c 123 vfield_count = 1;
dkato 0:47ea8de0be6c 124 image_change = 1;
dkato 0:47ea8de0be6c 125 }
dkato 0:47ea8de0be6c 126 }
dkato 0:47ea8de0be6c 127
dkato 0:47ea8de0be6c 128 static void IntCallbackFunc_Vsync(DisplayBase::int_type_t int_type)
dkato 0:47ea8de0be6c 129 {
dkato 0:47ea8de0be6c 130 //Interrupt callback function for Vsync interruption
dkato 0:47ea8de0be6c 131 if (vsync_count > 0) {
dkato 0:47ea8de0be6c 132 vsync_count--;
dkato 0:47ea8de0be6c 133 }
dkato 0:47ea8de0be6c 134 }
dkato 0:47ea8de0be6c 135
dkato 0:47ea8de0be6c 136 static void WaitVsync(const int32_t wait_count)
dkato 0:47ea8de0be6c 137 {
dkato 0:47ea8de0be6c 138 //Wait for the specified number of times Vsync occurs
dkato 0:47ea8de0be6c 139 vsync_count = wait_count;
dkato 0:47ea8de0be6c 140 while (vsync_count > 0) {
dkato 0:47ea8de0be6c 141 /* Do nothing */
dkato 0:47ea8de0be6c 142 }
dkato 0:47ea8de0be6c 143 }
dkato 0:47ea8de0be6c 144
dkato 0:47ea8de0be6c 145 int main(void)
dkato 0:47ea8de0be6c 146 {
dkato 0:47ea8de0be6c 147 /* Create DisplayBase object */
dkato 0:47ea8de0be6c 148 DisplayBase Display;
dkato 0:47ea8de0be6c 149 DisplayBase::graphics_error_t error;
dkato 0:47ea8de0be6c 150
dkato 0:47ea8de0be6c 151 #if VIDEO_INPUT_METHOD == VIDEO_CMOS_CAMERA
dkato 0:47ea8de0be6c 152 DisplayBase::video_ext_in_config_t ext_in_config;
dkato 0:47ea8de0be6c 153 PinName cmos_camera_pin[11] = {
dkato 0:47ea8de0be6c 154 /* data pin */
dkato 0:47ea8de0be6c 155 P2_7, P2_6, P2_5, P2_4, P2_3, P2_2, P2_1, P2_0,
dkato 0:47ea8de0be6c 156 /* control pin */
dkato 0:47ea8de0be6c 157 P10_0, /* DV0_CLK */
dkato 0:47ea8de0be6c 158 P1_0, /* DV0_Vsync */
dkato 0:47ea8de0be6c 159 P1_1 /* DV0_Hsync */
dkato 0:47ea8de0be6c 160 };
dkato 0:47ea8de0be6c 161 #endif
dkato 0:47ea8de0be6c 162 #if(1) //lcd
dkato 1:f0d5f9c28404 163 lcd_pwon = 0;
dkato 1:f0d5f9c28404 164 lcd_blon = 0;
dkato 1:f0d5f9c28404 165 Thread::wait(100);
dkato 1:f0d5f9c28404 166
dkato 0:47ea8de0be6c 167 lcd_pwon = 1;
dkato 0:47ea8de0be6c 168 lcd_blon = 1;
dkato 1:f0d5f9c28404 169 Thread::wait(100);
dkato 0:47ea8de0be6c 170
dkato 0:47ea8de0be6c 171 DisplayBase::lcd_config_t lcd_config;
dkato 0:47ea8de0be6c 172 PinName lvds_pin[8] = {
dkato 0:47ea8de0be6c 173 /* data pin */
dkato 0:47ea8de0be6c 174 P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
dkato 0:47ea8de0be6c 175 };
dkato 0:47ea8de0be6c 176 DisplayBase::rect_t rect;
dkato 0:47ea8de0be6c 177
dkato 0:47ea8de0be6c 178 lcd_config.lcd_type = DisplayBase::LCD_TYPE_LVDS;
dkato 0:47ea8de0be6c 179 lcd_config.intputClock = 66.67f;
dkato 1:f0d5f9c28404 180 lcd_config.outputClock = LCD_DOT_CLOCK;
dkato 0:47ea8de0be6c 181 lcd_config.lcd_outformat = DisplayBase::LCD_OUTFORMAT_RGB888;
dkato 0:47ea8de0be6c 182 lcd_config.lcd_edge = DisplayBase::EDGE_RISING;
dkato 1:f0d5f9c28404 183 #if(LCD_MODE) //SYNC Mode
dkato 1:f0d5f9c28404 184 lcd_config.h_toatal_period = (LCD_H_BACK_PORCH + LCD_H_WIDTH + LCD_H_FRONT_PORCH);
dkato 1:f0d5f9c28404 185 lcd_config.v_toatal_period = (LCD_V_BACK_PORCH + LCD_V_WIDTH + LCD_V_FRONT_PORCH);
dkato 1:f0d5f9c28404 186
dkato 1:f0d5f9c28404 187 lcd_config.h_disp_widht = (LCD_H_WIDTH);
dkato 1:f0d5f9c28404 188 lcd_config.v_disp_widht = (LCD_V_WIDTH);
dkato 1:f0d5f9c28404 189 lcd_config.h_back_porch = (LCD_H_BACK_PORCH);
dkato 1:f0d5f9c28404 190 lcd_config.v_back_porch = (LCD_V_BACK_PORCH);
dkato 1:f0d5f9c28404 191
dkato 1:f0d5f9c28404 192 lcd_config.h_sync_port = DisplayBase::LCD_TCON_PIN_2;
dkato 1:f0d5f9c28404 193 lcd_config.h_sync_port_polarity = DisplayBase::SIG_POL_INVERTED;
dkato 1:f0d5f9c28404 194 lcd_config.h_sync_width = LCD_H_SYNC_WIDTH;
dkato 1:f0d5f9c28404 195
dkato 1:f0d5f9c28404 196 lcd_config.v_sync_port = DisplayBase::LCD_TCON_PIN_0;
dkato 1:f0d5f9c28404 197 lcd_config.v_sync_port_polarity = DisplayBase::SIG_POL_INVERTED;
dkato 1:f0d5f9c28404 198 lcd_config.v_sync_width = LCD_V_SYNC_WIDTH;
dkato 1:f0d5f9c28404 199
dkato 2:8e78c957adb5 200 lcd_config.de_port = DisplayBase::LCD_TCON_PIN_3;
dkato 1:f0d5f9c28404 201 lcd_config.de_port_polarity = DisplayBase::SIG_POL_NOT_INVERTED;
dkato 1:f0d5f9c28404 202 #else //DE Mode
dkato 1:f0d5f9c28404 203 lcd_config.h_toatal_period = (LCD_H_WIDTH + 80u);
dkato 1:f0d5f9c28404 204 lcd_config.v_toatal_period = (LCD_V_WIDTH);
dkato 0:47ea8de0be6c 205
dkato 1:f0d5f9c28404 206 lcd_config.h_disp_widht = (LCD_H_WIDTH);
dkato 1:f0d5f9c28404 207 lcd_config.v_disp_widht = (LCD_V_WIDTH);
dkato 1:f0d5f9c28404 208 lcd_config.h_back_porch = (68u);
dkato 1:f0d5f9c28404 209 lcd_config.v_back_porch = (18u);
dkato 0:47ea8de0be6c 210
dkato 0:47ea8de0be6c 211 lcd_config.h_sync_port = DisplayBase::LCD_TCON_PIN_NON;
dkato 0:47ea8de0be6c 212 lcd_config.h_sync_port_polarity = DisplayBase::SIG_POL_NOT_INVERTED;
dkato 0:47ea8de0be6c 213 lcd_config.h_sync_width = 0;
dkato 0:47ea8de0be6c 214
dkato 0:47ea8de0be6c 215 lcd_config.v_sync_port = DisplayBase::LCD_TCON_PIN_NON;
dkato 0:47ea8de0be6c 216 lcd_config.v_sync_port_polarity = DisplayBase::SIG_POL_NOT_INVERTED;
dkato 0:47ea8de0be6c 217 lcd_config.v_sync_width = 0;
dkato 0:47ea8de0be6c 218
dkato 0:47ea8de0be6c 219 lcd_config.de_port = DisplayBase::LCD_TCON_PIN_3;
dkato 1:f0d5f9c28404 220 lcd_config.de_port_polarity = DisplayBase::SIG_POL_INVERTED;
dkato 1:f0d5f9c28404 221 #endif
dkato 0:47ea8de0be6c 222
dkato 0:47ea8de0be6c 223 /* Graphics initialization process */
dkato 0:47ea8de0be6c 224 error = Display.Graphics_init(&lcd_config);
dkato 0:47ea8de0be6c 225 #else
dkato 0:47ea8de0be6c 226 /* Graphics initialization process */
dkato 0:47ea8de0be6c 227 error = Display.Graphics_init(NULL);
dkato 0:47ea8de0be6c 228 #endif
dkato 0:47ea8de0be6c 229
dkato 0:47ea8de0be6c 230 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:47ea8de0be6c 231 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 232 while (1);
dkato 0:47ea8de0be6c 233 }
dkato 0:47ea8de0be6c 234
dkato 0:47ea8de0be6c 235 #if VIDEO_INPUT_METHOD == VIDEO_CVBS
dkato 0:47ea8de0be6c 236 error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_VDEC, NULL);
dkato 0:47ea8de0be6c 237 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:47ea8de0be6c 238 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 239 while(1);
dkato 0:47ea8de0be6c 240 }
dkato 0:47ea8de0be6c 241
dkato 0:47ea8de0be6c 242 #elif VIDEO_INPUT_METHOD == VIDEO_CMOS_CAMERA
dkato 0:47ea8de0be6c 243 /* MT9V111 camera input config */
dkato 0:47ea8de0be6c 244 ext_in_config.inp_format = DisplayBase::VIDEO_EXTIN_FORMAT_BT601; /* BT601 8bit YCbCr format */
dkato 0:47ea8de0be6c 245 ext_in_config.inp_pxd_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing data */
dkato 0:47ea8de0be6c 246 ext_in_config.inp_vs_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing Vsync signals */
dkato 0:47ea8de0be6c 247 ext_in_config.inp_hs_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing Hsync signals */
dkato 0:47ea8de0be6c 248 ext_in_config.inp_endian_on = DisplayBase::OFF; /* External input bit endian change on/off */
dkato 0:47ea8de0be6c 249 ext_in_config.inp_swap_on = DisplayBase::OFF; /* External input B/R signal swap on/off */
dkato 0:47ea8de0be6c 250 ext_in_config.inp_vs_inv = DisplayBase::SIG_POL_NOT_INVERTED; /* External input DV_VSYNC inversion control */
dkato 0:47ea8de0be6c 251 ext_in_config.inp_hs_inv = DisplayBase::SIG_POL_INVERTED; /* External input DV_HSYNC inversion control */
dkato 0:47ea8de0be6c 252 ext_in_config.inp_f525_625 = DisplayBase::EXTIN_LINE_525; /* Number of lines for BT.656 external input */
dkato 0:47ea8de0be6c 253 ext_in_config.inp_h_pos = DisplayBase::EXTIN_H_POS_CRYCBY; /* Y/Cb/Y/Cr data string start timing to Hsync reference */
dkato 0:47ea8de0be6c 254 ext_in_config.cap_vs_pos = 6; /* Capture start position from Vsync */
dkato 0:47ea8de0be6c 255 ext_in_config.cap_hs_pos = 150; /* Capture start position form Hsync */
dkato 0:47ea8de0be6c 256 ext_in_config.cap_width = 640; /* Capture width */
dkato 0:47ea8de0be6c 257 ext_in_config.cap_height = 468u; /* Capture height Max 468[line]
dkato 0:47ea8de0be6c 258 Due to CMOS(MT9V111) output signal timing and VDC5 specification */
dkato 0:47ea8de0be6c 259 error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_EXT, &ext_in_config);
dkato 0:47ea8de0be6c 260 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:47ea8de0be6c 261 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 262 while(1);
dkato 0:47ea8de0be6c 263 }
dkato 0:47ea8de0be6c 264
dkato 0:47ea8de0be6c 265 /* MT9V111 camera input port setting */
dkato 0:47ea8de0be6c 266 error = Display.Graphics_Dvinput_Port_Init(cmos_camera_pin, 11);
dkato 0:47ea8de0be6c 267 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:47ea8de0be6c 268 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 269 while (1);
dkato 0:47ea8de0be6c 270 }
dkato 0:47ea8de0be6c 271 #endif
dkato 0:47ea8de0be6c 272
dkato 0:47ea8de0be6c 273 /* Interrupt callback function setting (Vsync signal input to scaler 0) */
dkato 0:47ea8de0be6c 274 error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VI_VSYNC, 0, IntCallbackFunc_Vsync);
dkato 0:47ea8de0be6c 275 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:47ea8de0be6c 276 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 277 while (1);
dkato 0:47ea8de0be6c 278 }
dkato 0:47ea8de0be6c 279 /* Video capture setting (progressive form fixed) */
dkato 0:47ea8de0be6c 280 error = Display.Video_Write_Setting(
dkato 0:47ea8de0be6c 281 VIDEO_INPUT_CH,
dkato 0:47ea8de0be6c 282 #if VIDEO_PAL == 0
dkato 0:47ea8de0be6c 283 DisplayBase::COL_SYS_NTSC_358,
dkato 0:47ea8de0be6c 284 #else
dkato 0:47ea8de0be6c 285 DisplayBase::COL_SYS_PAL_443,
dkato 0:47ea8de0be6c 286 #endif
dkato 0:47ea8de0be6c 287 FrameBuffer_Video,
dkato 0:47ea8de0be6c 288 VIDEO_BUFFER_STRIDE,
dkato 0:47ea8de0be6c 289 #if VIDEO_INPUT_FORMAT == VIDEO_YCBCR422
dkato 0:47ea8de0be6c 290 DisplayBase::VIDEO_FORMAT_YCBCR422,
dkato 0:47ea8de0be6c 291 DisplayBase::WR_RD_WRSWA_NON,
dkato 0:47ea8de0be6c 292 #elif VIDEO_INPUT_FORMAT == VIDEO_RGB565
dkato 0:47ea8de0be6c 293 DisplayBase::VIDEO_FORMAT_RGB565,
dkato 0:47ea8de0be6c 294 DisplayBase::WR_RD_WRSWA_32_16BIT,
dkato 0:47ea8de0be6c 295 #else
dkato 0:47ea8de0be6c 296 DisplayBase::VIDEO_FORMAT_RGB888,
dkato 0:47ea8de0be6c 297 DisplayBase::WR_RD_WRSWA_32BIT,
dkato 0:47ea8de0be6c 298 #endif
dkato 0:47ea8de0be6c 299 PIXEL_VW,
dkato 0:47ea8de0be6c 300 PIXEL_HW
dkato 0:47ea8de0be6c 301 );
dkato 0:47ea8de0be6c 302 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:47ea8de0be6c 303 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 304 while (1);
dkato 0:47ea8de0be6c 305 }
dkato 0:47ea8de0be6c 306
dkato 0:47ea8de0be6c 307 /* Interrupt callback function setting (Field end signal for recording function in scaler 0) */
dkato 0:47ea8de0be6c 308 error = Display.Graphics_Irq_Handler_Set(VIDEO_INT_TYPE, 0, IntCallbackFunc_Vfield);
dkato 0:47ea8de0be6c 309 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:47ea8de0be6c 310 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 311 while (1);
dkato 0:47ea8de0be6c 312 }
dkato 0:47ea8de0be6c 313
dkato 0:47ea8de0be6c 314 /* Video write process start */
dkato 0:47ea8de0be6c 315 error = Display.Video_Start (VIDEO_INPUT_CH);
dkato 0:47ea8de0be6c 316 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:47ea8de0be6c 317 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 318 while (1);
dkato 0:47ea8de0be6c 319 }
dkato 0:47ea8de0be6c 320
dkato 0:47ea8de0be6c 321 /* Video write process stop */
dkato 0:47ea8de0be6c 322 error = Display.Video_Stop (VIDEO_INPUT_CH);
dkato 0:47ea8de0be6c 323 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:47ea8de0be6c 324 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 325 while (1);
dkato 0:47ea8de0be6c 326 }
dkato 0:47ea8de0be6c 327
dkato 0:47ea8de0be6c 328 /* Video write process start */
dkato 0:47ea8de0be6c 329 error = Display.Video_Start (VIDEO_INPUT_CH);
dkato 0:47ea8de0be6c 330 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:47ea8de0be6c 331 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:47ea8de0be6c 332 while (1);
dkato 0:47ea8de0be6c 333 }
dkato 0:47ea8de0be6c 334
dkato 0:47ea8de0be6c 335 /* Wait vsync to update resister */
dkato 0:47ea8de0be6c 336 WaitVsync(1);
dkato 0:47ea8de0be6c 337
dkato 0:47ea8de0be6c 338 #if(1) //lcd
dkato 0:47ea8de0be6c 339 Display.Graphics_Lvds_Port_Init(lvds_pin, 8);
dkato 0:47ea8de0be6c 340 rect.vs = 0;
dkato 0:47ea8de0be6c 341 rect.vw = PIXEL_VW;
dkato 0:47ea8de0be6c 342 rect.hs = 0;
dkato 0:47ea8de0be6c 343 rect.hw = PIXEL_HW;
dkato 0:47ea8de0be6c 344
dkato 0:47ea8de0be6c 345 Display.Graphics_Read_Setting(
dkato 0:47ea8de0be6c 346 DisplayBase::GRAPHICS_LAYER_0,
dkato 0:47ea8de0be6c 347 (void *)FrameBuffer_Video,
dkato 0:47ea8de0be6c 348 VIDEO_BUFFER_STRIDE,
dkato 0:47ea8de0be6c 349 DisplayBase::GRAPHICS_FORMAT_YCBCR422,
dkato 0:47ea8de0be6c 350 DisplayBase::WR_RD_WRSWA_NON,
dkato 0:47ea8de0be6c 351 &rect
dkato 0:47ea8de0be6c 352 );
dkato 0:47ea8de0be6c 353 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
dkato 0:47ea8de0be6c 354
dkato 0:47ea8de0be6c 355 lcd_cntrst.write(1.0);
dkato 0:47ea8de0be6c 356
dkato 0:47ea8de0be6c 357 while (1) {
dkato 0:47ea8de0be6c 358 uint8_t count;
dkato 0:47ea8de0be6c 359 uint32_t x0;
dkato 0:47ea8de0be6c 360 uint32_t y0;
dkato 0:47ea8de0be6c 361 uint32_t x1;
dkato 0:47ea8de0be6c 362 uint32_t y1;
dkato 0:47ea8de0be6c 363
dkato 0:47ea8de0be6c 364 count = 0;
dkato 0:47ea8de0be6c 365 x0 = 0;
dkato 0:47ea8de0be6c 366 y0 = 0;
dkato 0:47ea8de0be6c 367 x1 = 0;
dkato 0:47ea8de0be6c 368 y1 = 0;
dkato 0:47ea8de0be6c 369 get_coordinates(&count, &x0, &y0, &x1, &y1);
dkato 0:47ea8de0be6c 370 if (count != 0) {
dkato 0:47ea8de0be6c 371 printf("count=%d, {X=%d,Y=%d}, {X=%d,Y=%d} \n", count, x0, y0, x1, y1);
dkato 0:47ea8de0be6c 372 }
dkato 0:47ea8de0be6c 373 Thread::wait(100);
dkato 0:47ea8de0be6c 374 }
dkato 0:47ea8de0be6c 375 #endif
dkato 0:47ea8de0be6c 376 }