Set analog camera to default

Dependencies:   AsciiFont GR-PEACH_video LCD_shield_config

Fork of GR-PEACH_Video_Display by Daiki Kato

Committer:
dkato
Date:
Mon Nov 28 03:41:26 2016 +0000
Revision:
6:95b92f2035dc
Parent:
5:4e96673f4830
Child:
7:ef7429270f19
Change symbol name

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:b2184c2d15dd 1 #include "mbed.h"
dkato 0:b2184c2d15dd 2 #include "DisplayBace.h"
dkato 0:b2184c2d15dd 3 #include "rtos.h"
dkato 4:bafd63604b7c 4 #include "AsciiFont.h"
dkato 0:b2184c2d15dd 5
dkato 0:b2184c2d15dd 6 #define VIDEO_CVBS (0) /* Analog Video Signal */
dkato 0:b2184c2d15dd 7 #define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */
dkato 0:b2184c2d15dd 8 #define VIDEO_YCBCR422 (0)
dkato 0:b2184c2d15dd 9 #define VIDEO_RGB888 (1)
dkato 0:b2184c2d15dd 10 #define VIDEO_RGB565 (2)
dkato 0:b2184c2d15dd 11
dkato 0:b2184c2d15dd 12 /**** User Selection *********/
dkato 1:54a3e69f6f09 13 /** Camera setting **/
dkato 0:b2184c2d15dd 14 #define VIDEO_INPUT_METHOD (VIDEO_CMOS_CAMERA) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */
dkato 0:b2184c2d15dd 15 #define VIDEO_INPUT_FORMAT (VIDEO_YCBCR422) /* Select VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565 */
dkato 0:b2184c2d15dd 16 #define USE_VIDEO_CH (0) /* Select 0 or 1 If selecting VIDEO_CMOS_CAMERA, should be 0.) */
dkato 0:b2184c2d15dd 17 #define VIDEO_PAL (0) /* Select 0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */
dkato 1:54a3e69f6f09 18 /** LCD setting **/
dkato 0:b2184c2d15dd 19 #define LCD_TYPE (0) /* Select 0(4.3inch) or 1(7.1inch) */
dkato 0:b2184c2d15dd 20 /*****************************/
dkato 0:b2184c2d15dd 21
dkato 0:b2184c2d15dd 22 /** LCD shield config **/
dkato 0:b2184c2d15dd 23 #if (LCD_TYPE == 0)
dkato 0:b2184c2d15dd 24 #include "LCD_shield_config_4_3inch.h"
dkato 0:b2184c2d15dd 25 #else
dkato 0:b2184c2d15dd 26 #include "LCD_shield_config_7_1inch.h"
dkato 0:b2184c2d15dd 27 #endif
dkato 0:b2184c2d15dd 28
dkato 0:b2184c2d15dd 29 /** Video and Grapics (GRAPHICS_LAYER_0) parameter **/
dkato 0:b2184c2d15dd 30 /* video input */
dkato 0:b2184c2d15dd 31 #if USE_VIDEO_CH == (0)
dkato 0:b2184c2d15dd 32 #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_0)
dkato 0:b2184c2d15dd 33 #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S0_VFIELD)
dkato 0:b2184c2d15dd 34 #else
dkato 0:b2184c2d15dd 35 #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_1)
dkato 0:b2184c2d15dd 36 #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S1_VFIELD)
dkato 0:b2184c2d15dd 37 #endif
dkato 0:b2184c2d15dd 38
dkato 0:b2184c2d15dd 39 /* NTSC or PAL */
dkato 0:b2184c2d15dd 40 #if VIDEO_PAL == 0
dkato 0:b2184c2d15dd 41 #define COL_SYS (DisplayBase::COL_SYS_NTSC_358)
dkato 0:b2184c2d15dd 42 #else
dkato 0:b2184c2d15dd 43 #define COL_SYS (DisplayBase::COL_SYS_PAL_443)
dkato 0:b2184c2d15dd 44 #endif
dkato 0:b2184c2d15dd 45
dkato 0:b2184c2d15dd 46 /* Video input and LCD layer 0 output */
dkato 0:b2184c2d15dd 47 #if VIDEO_INPUT_FORMAT == VIDEO_YCBCR422
dkato 0:b2184c2d15dd 48 #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_YCBCR422)
dkato 0:b2184c2d15dd 49 #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_YCBCR422)
dkato 0:b2184c2d15dd 50 #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_NON)
dkato 0:b2184c2d15dd 51 #elif VIDEO_INPUT_FORMAT == VIDEO_RGB565
dkato 0:b2184c2d15dd 52 #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_RGB565)
dkato 0:b2184c2d15dd 53 #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB565)
dkato 0:b2184c2d15dd 54 #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT)
dkato 0:b2184c2d15dd 55 #else
dkato 0:b2184c2d15dd 56 #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_RGB888)
dkato 0:b2184c2d15dd 57 #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB888)
dkato 0:b2184c2d15dd 58 #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32BIT)
dkato 0:b2184c2d15dd 59 #endif
dkato 0:b2184c2d15dd 60
dkato 0:b2184c2d15dd 61 /* The size of the video input is adjusted to the LCD size. */
dkato 0:b2184c2d15dd 62 #define VIDEO_PIXEL_HW LCD_PIXEL_WIDTH
dkato 0:b2184c2d15dd 63 #define VIDEO_PIXEL_VW LCD_PIXEL_HEIGHT
dkato 0:b2184c2d15dd 64
dkato 0:b2184c2d15dd 65 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
dkato 0:b2184c2d15dd 66 in accordance with the frame buffer burst transfer mode. */
dkato 0:b2184c2d15dd 67 /* FRAME BUFFER Parameter GRAPHICS_LAYER_0 */
dkato 0:b2184c2d15dd 68 #define FRAME_BUFFER_NUM (3u)
dkato 0:b2184c2d15dd 69 #if ( VIDEO_INPUT_FORMAT == VIDEO_YCBCR422 || VIDEO_INPUT_FORMAT == VIDEO_RGB565 )
dkato 0:b2184c2d15dd 70 #define FRAME_BUFFER_BYTE_PER_PIXEL (2u)
dkato 0:b2184c2d15dd 71 #else
dkato 0:b2184c2d15dd 72 #define FRAME_BUFFER_BYTE_PER_PIXEL (4u)
dkato 0:b2184c2d15dd 73 #endif
dkato 0:b2184c2d15dd 74 #define FRAME_BUFFER_STRIDE (((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
dkato 0:b2184c2d15dd 75
dkato 0:b2184c2d15dd 76 /* TOUCH BUFFER Parameter GRAPHICS_LAYER_1 */
dkato 0:b2184c2d15dd 77 #define TOUCH_BUFFER_BYTE_PER_PIXEL (2u)
dkato 0:b2184c2d15dd 78 #define TOUCH_BUFFER_STRIDE (((LCD_PIXEL_WIDTH * TOUCH_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
dkato 0:b2184c2d15dd 79
dkato 0:b2184c2d15dd 80 /* Touch panel parameter */
dkato 0:b2184c2d15dd 81 #define TOUCH_NUM (2u)
dkato 6:95b92f2035dc 82 #define DRAW_POINT (5)
dkato 0:b2184c2d15dd 83
dkato 4:bafd63604b7c 84 /* STRING BUFFER Parameter GRAPHICS_LAYER_2 */
dkato 4:bafd63604b7c 85 #define STRING_PIXEL_HW (120)
dkato 4:bafd63604b7c 86 #define STRING_PIXEL_VM (24)
dkato 4:bafd63604b7c 87 #define STRING_BUFFER_BYTE_PER_PIXEL (2u)
dkato 4:bafd63604b7c 88 #define STRING_BUFFER_STRIDE (((LCD_PIXEL_WIDTH * STRING_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
dkato 4:bafd63604b7c 89
dkato 0:b2184c2d15dd 90 static DisplayBase Display;
dkato 0:b2184c2d15dd 91 static DigitalOut lcd_pwon(P7_15);
dkato 0:b2184c2d15dd 92 static DigitalOut lcd_blon(P8_1);
dkato 0:b2184c2d15dd 93 static PwmOut lcd_cntrst(P8_15);
dkato 0:b2184c2d15dd 94 static Serial pc(USBTX, USBRX);
dkato 0:b2184c2d15dd 95 static Semaphore sem_touch_int(0);
dkato 0:b2184c2d15dd 96 static TouckKey_LCD_shield touch(P4_0, P2_13, I2C_SDA, I2C_SCL);
dkato 0:b2184c2d15dd 97 static Thread * p_VideoLcdTask = NULL;
dkato 0:b2184c2d15dd 98 static DigitalOut led_blue(LED_BLUE);
dkato 0:b2184c2d15dd 99
dkato 0:b2184c2d15dd 100 #if defined(__ICCARM__)
dkato 0:b2184c2d15dd 101 /* 32 bytes aligned */
dkato 0:b2184c2d15dd 102 #pragma data_alignment=32
dkato 0:b2184c2d15dd 103 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 2:8721836b639d 104 #pragma data_alignment=32
dkato 0:b2184c2d15dd 105 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 2:8721836b639d 106 #pragma data_alignment=32
dkato 0:b2184c2d15dd 107 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 2:8721836b639d 108 #pragma data_alignment=32
dkato 0:b2184c2d15dd 109 static uint8_t user_frame_buffer_touch[TOUCH_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 4:bafd63604b7c 110 #pragma data_alignment=32
dkato 4:bafd63604b7c 111 static uint8_t user_frame_buffer_string[STRING_BUFFER_STRIDE * STRING_PIXEL_VM];
dkato 0:b2184c2d15dd 112 #else
dkato 0:b2184c2d15dd 113 /* 32 bytes aligned */
dkato 0:b2184c2d15dd 114 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
dkato 0:b2184c2d15dd 115 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
dkato 0:b2184c2d15dd 116 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
dkato 0:b2184c2d15dd 117 static uint8_t user_frame_buffer_touch[TOUCH_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32)));
dkato 4:bafd63604b7c 118 static uint8_t user_frame_buffer_string[STRING_BUFFER_STRIDE * STRING_PIXEL_VM]__attribute((aligned(32)));
dkato 0:b2184c2d15dd 119 #endif
dkato 1:54a3e69f6f09 120 static uint8_t * FrameBufferTbl[FRAME_BUFFER_NUM] = {user_frame_buffer0, user_frame_buffer1, user_frame_buffer2};
dkato 2:8721836b639d 121 #if VIDEO_INPUT_METHOD == VIDEO_CVBS
dkato 0:b2184c2d15dd 122 static volatile int32_t vfield_count = 0;
dkato 2:8721836b639d 123 #endif
dkato 0:b2184c2d15dd 124 static int write_buff_num = 0;
dkato 0:b2184c2d15dd 125 static int read_buff_num = 0;
dkato 0:b2184c2d15dd 126 static bool graphics_init_end = false;
dkato 0:b2184c2d15dd 127
dkato 0:b2184c2d15dd 128 /****** cache control ******/
dkato 0:b2184c2d15dd 129 static void dcache_clean(void * p_buf, uint32_t size) {
dkato 0:b2184c2d15dd 130 uint32_t start_addr = (uint32_t)p_buf & 0xFFFFFFE0;
dkato 0:b2184c2d15dd 131 uint32_t end_addr = (uint32_t)p_buf + size;
dkato 0:b2184c2d15dd 132 uint32_t addr;
dkato 0:b2184c2d15dd 133
dkato 0:b2184c2d15dd 134 /* Data cache clean */
dkato 0:b2184c2d15dd 135 for (addr = start_addr; addr < end_addr; addr += 0x20) {
dkato 0:b2184c2d15dd 136 __v7_clean_dcache_mva((void *)addr);
dkato 0:b2184c2d15dd 137 }
dkato 0:b2184c2d15dd 138 }
dkato 0:b2184c2d15dd 139
dkato 0:b2184c2d15dd 140 /****** LCD ******/
dkato 0:b2184c2d15dd 141 #if(0) /* When needing LCD Vsync interrupt, please make it effective. */
dkato 0:b2184c2d15dd 142 static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type) {
dkato 0:b2184c2d15dd 143 /* Interrupt callback function for Vsync interruption */
dkato 0:b2184c2d15dd 144 }
dkato 0:b2184c2d15dd 145 #endif
dkato 0:b2184c2d15dd 146
dkato 0:b2184c2d15dd 147 static void Init_LCD_Display(void) {
dkato 0:b2184c2d15dd 148 DisplayBase::graphics_error_t error;
dkato 0:b2184c2d15dd 149 DisplayBase::lcd_config_t lcd_config;
dkato 0:b2184c2d15dd 150 PinName lvds_pin[8] = {
dkato 0:b2184c2d15dd 151 /* data pin */
dkato 0:b2184c2d15dd 152 P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
dkato 0:b2184c2d15dd 153 };
dkato 0:b2184c2d15dd 154
dkato 0:b2184c2d15dd 155 lcd_pwon = 0;
dkato 0:b2184c2d15dd 156 lcd_blon = 0;
dkato 0:b2184c2d15dd 157 Thread::wait(100);
dkato 0:b2184c2d15dd 158 lcd_pwon = 1;
dkato 0:b2184c2d15dd 159 lcd_blon = 1;
dkato 0:b2184c2d15dd 160
dkato 0:b2184c2d15dd 161 Display.Graphics_Lvds_Port_Init(lvds_pin, 8);
dkato 0:b2184c2d15dd 162
dkato 0:b2184c2d15dd 163 /* Graphics initialization process */
dkato 0:b2184c2d15dd 164 lcd_config = LcdCfgTbl_LCD_shield;
dkato 0:b2184c2d15dd 165 error = Display.Graphics_init(&lcd_config);
dkato 0:b2184c2d15dd 166 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 167 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 168 mbed_die();
dkato 0:b2184c2d15dd 169 }
dkato 0:b2184c2d15dd 170 graphics_init_end = true;
dkato 0:b2184c2d15dd 171
dkato 0:b2184c2d15dd 172 #if(0) /* When needing LCD Vsync interrupt, please make it effective. */
dkato 0:b2184c2d15dd 173 /* Interrupt callback function setting (Vsync signal output from scaler 0) */
dkato 0:b2184c2d15dd 174 error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, IntCallbackFunc_LoVsync);
dkato 0:b2184c2d15dd 175 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 176 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 177 mbed_die();
dkato 0:b2184c2d15dd 178 }
dkato 0:b2184c2d15dd 179 #endif
dkato 0:b2184c2d15dd 180 }
dkato 0:b2184c2d15dd 181
dkato 0:b2184c2d15dd 182 static void Start_LCD_Display(uint8_t * p_buf) {
dkato 0:b2184c2d15dd 183 DisplayBase::rect_t rect;
dkato 0:b2184c2d15dd 184
dkato 0:b2184c2d15dd 185 rect.vs = 0;
dkato 0:b2184c2d15dd 186 rect.vw = LCD_PIXEL_HEIGHT;
dkato 0:b2184c2d15dd 187 rect.hs = 0;
dkato 0:b2184c2d15dd 188 rect.hw = LCD_PIXEL_WIDTH;
dkato 0:b2184c2d15dd 189 Display.Graphics_Read_Setting(
dkato 0:b2184c2d15dd 190 DisplayBase::GRAPHICS_LAYER_0,
dkato 0:b2184c2d15dd 191 (void *)p_buf,
dkato 0:b2184c2d15dd 192 FRAME_BUFFER_STRIDE,
dkato 0:b2184c2d15dd 193 GRAPHICS_FORMAT,
dkato 0:b2184c2d15dd 194 WR_RD_WRSWA,
dkato 0:b2184c2d15dd 195 &rect
dkato 0:b2184c2d15dd 196 );
dkato 0:b2184c2d15dd 197 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
dkato 0:b2184c2d15dd 198 }
dkato 0:b2184c2d15dd 199
dkato 0:b2184c2d15dd 200 /****** Video ******/
dkato 0:b2184c2d15dd 201 #if(0) /* When needing video Vsync interrupt, please make it effective. */
dkato 0:b2184c2d15dd 202 static void IntCallbackFunc_ViVsync(DisplayBase::int_type_t int_type) {
dkato 0:b2184c2d15dd 203 /* Interrupt callback function for Vsync interruption */
dkato 0:b2184c2d15dd 204 }
dkato 0:b2184c2d15dd 205 #endif
dkato 0:b2184c2d15dd 206
dkato 0:b2184c2d15dd 207 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
dkato 0:b2184c2d15dd 208 /* Interrupt callback function */
dkato 2:8721836b639d 209 #if VIDEO_INPUT_METHOD == VIDEO_CVBS
dkato 0:b2184c2d15dd 210 if (vfield_count == 0) {
dkato 0:b2184c2d15dd 211 vfield_count = 1;
dkato 0:b2184c2d15dd 212 } else {
dkato 0:b2184c2d15dd 213 vfield_count = 0;
dkato 2:8721836b639d 214 #else
dkato 2:8721836b639d 215 {
dkato 2:8721836b639d 216 #endif
dkato 0:b2184c2d15dd 217 if (p_VideoLcdTask != NULL) {
dkato 0:b2184c2d15dd 218 p_VideoLcdTask->signal_set(1);
dkato 0:b2184c2d15dd 219 }
dkato 0:b2184c2d15dd 220 }
dkato 0:b2184c2d15dd 221 }
dkato 0:b2184c2d15dd 222
dkato 0:b2184c2d15dd 223 static void Init_Video(void) {
dkato 0:b2184c2d15dd 224 DisplayBase::graphics_error_t error;
dkato 0:b2184c2d15dd 225
dkato 0:b2184c2d15dd 226 /* Graphics initialization process */
dkato 0:b2184c2d15dd 227 if (graphics_init_end == false) {
dkato 0:b2184c2d15dd 228 /* When not initializing LCD, this processing is needed. */
dkato 0:b2184c2d15dd 229 error = Display.Graphics_init(NULL);
dkato 0:b2184c2d15dd 230 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 231 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 232 mbed_die();
dkato 0:b2184c2d15dd 233 }
dkato 0:b2184c2d15dd 234 graphics_init_end = true;
dkato 0:b2184c2d15dd 235 }
dkato 0:b2184c2d15dd 236
dkato 0:b2184c2d15dd 237 #if VIDEO_INPUT_METHOD == VIDEO_CVBS
dkato 0:b2184c2d15dd 238 error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_VDEC, NULL);
dkato 0:b2184c2d15dd 239 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:b2184c2d15dd 240 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 241 mbed_die();
dkato 0:b2184c2d15dd 242 }
dkato 0:b2184c2d15dd 243 #elif VIDEO_INPUT_METHOD == VIDEO_CMOS_CAMERA
dkato 0:b2184c2d15dd 244 DisplayBase::video_ext_in_config_t ext_in_config;
dkato 0:b2184c2d15dd 245 PinName cmos_camera_pin[11] = {
dkato 0:b2184c2d15dd 246 /* data pin */
dkato 0:b2184c2d15dd 247 P2_7, P2_6, P2_5, P2_4, P2_3, P2_2, P2_1, P2_0,
dkato 0:b2184c2d15dd 248 /* control pin */
dkato 0:b2184c2d15dd 249 P10_0, /* DV0_CLK */
dkato 0:b2184c2d15dd 250 P1_0, /* DV0_Vsync */
dkato 0:b2184c2d15dd 251 P1_1 /* DV0_Hsync */
dkato 0:b2184c2d15dd 252 };
dkato 0:b2184c2d15dd 253
dkato 0:b2184c2d15dd 254 /* MT9V111 camera input config */
dkato 0:b2184c2d15dd 255 ext_in_config.inp_format = DisplayBase::VIDEO_EXTIN_FORMAT_BT601; /* BT601 8bit YCbCr format */
dkato 0:b2184c2d15dd 256 ext_in_config.inp_pxd_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing data */
dkato 0:b2184c2d15dd 257 ext_in_config.inp_vs_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing Vsync signals */
dkato 0:b2184c2d15dd 258 ext_in_config.inp_hs_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing Hsync signals */
dkato 0:b2184c2d15dd 259 ext_in_config.inp_endian_on = DisplayBase::OFF; /* External input bit endian change on/off */
dkato 0:b2184c2d15dd 260 ext_in_config.inp_swap_on = DisplayBase::OFF; /* External input B/R signal swap on/off */
dkato 0:b2184c2d15dd 261 ext_in_config.inp_vs_inv = DisplayBase::SIG_POL_NOT_INVERTED; /* External input DV_VSYNC inversion control */
dkato 0:b2184c2d15dd 262 ext_in_config.inp_hs_inv = DisplayBase::SIG_POL_INVERTED; /* External input DV_HSYNC inversion control */
dkato 0:b2184c2d15dd 263 ext_in_config.inp_f525_625 = DisplayBase::EXTIN_LINE_525; /* Number of lines for BT.656 external input */
dkato 0:b2184c2d15dd 264 ext_in_config.inp_h_pos = DisplayBase::EXTIN_H_POS_CRYCBY; /* Y/Cb/Y/Cr data string start timing to Hsync reference */
dkato 0:b2184c2d15dd 265 ext_in_config.cap_vs_pos = 6; /* Capture start position from Vsync */
dkato 0:b2184c2d15dd 266 ext_in_config.cap_hs_pos = 150; /* Capture start position form Hsync */
dkato 0:b2184c2d15dd 267 #if (LCD_TYPE == 0)
dkato 0:b2184c2d15dd 268 /* The same screen ratio as the screen ratio of the LCD. */
dkato 0:b2184c2d15dd 269 ext_in_config.cap_width = 640; /* Capture width */
dkato 0:b2184c2d15dd 270 ext_in_config.cap_height = 363; /* Capture height Max 468[line]
dkato 0:b2184c2d15dd 271 Due to CMOS(MT9V111) output signal timing and VDC5 specification */
dkato 0:b2184c2d15dd 272 #else
dkato 0:b2184c2d15dd 273 ext_in_config.cap_width = 640; /* Capture width */
dkato 1:54a3e69f6f09 274 ext_in_config.cap_height = 468; /* Capture height Max 468[line]
dkato 0:b2184c2d15dd 275 Due to CMOS(MT9V111) output signal timing and VDC5 specification */
dkato 0:b2184c2d15dd 276 #endif
dkato 0:b2184c2d15dd 277 error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_EXT, &ext_in_config);
dkato 0:b2184c2d15dd 278 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:b2184c2d15dd 279 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 280 mbed_die();
dkato 0:b2184c2d15dd 281 }
dkato 0:b2184c2d15dd 282
dkato 1:54a3e69f6f09 283 /* Camera input port setting */
dkato 0:b2184c2d15dd 284 error = Display.Graphics_Dvinput_Port_Init(cmos_camera_pin, 11);
dkato 0:b2184c2d15dd 285 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:b2184c2d15dd 286 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 287 mbed_die();
dkato 0:b2184c2d15dd 288 }
dkato 0:b2184c2d15dd 289 #endif
dkato 0:b2184c2d15dd 290
dkato 0:b2184c2d15dd 291 #if(0) /* When needing video Vsync interrupt, please make it effective. */
dkato 0:b2184c2d15dd 292 /* Interrupt callback function setting (Vsync signal input to scaler 0) */
dkato 0:b2184c2d15dd 293 error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VI_VSYNC, 0, IntCallbackFunc_ViVsync);
dkato 0:b2184c2d15dd 294 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 295 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 296 mbed_die();
dkato 0:b2184c2d15dd 297 }
dkato 0:b2184c2d15dd 298 #endif
dkato 0:b2184c2d15dd 299
dkato 0:b2184c2d15dd 300 /* Interrupt callback function setting (Field end signal for recording function in scaler 0) */
dkato 0:b2184c2d15dd 301 error = Display.Graphics_Irq_Handler_Set(VIDEO_INT_TYPE, 0, IntCallbackFunc_Vfield);
dkato 0:b2184c2d15dd 302 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 303 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 304 mbed_die();
dkato 0:b2184c2d15dd 305 }
dkato 0:b2184c2d15dd 306 }
dkato 0:b2184c2d15dd 307
dkato 0:b2184c2d15dd 308 static void Start_Video(uint8_t * p_buf) {
dkato 0:b2184c2d15dd 309 DisplayBase::graphics_error_t error;
dkato 0:b2184c2d15dd 310
dkato 0:b2184c2d15dd 311 /* Video capture setting (progressive form fixed) */
dkato 0:b2184c2d15dd 312 error = Display.Video_Write_Setting(
dkato 0:b2184c2d15dd 313 VIDEO_INPUT_CH,
dkato 0:b2184c2d15dd 314 COL_SYS,
dkato 0:b2184c2d15dd 315 p_buf,
dkato 0:b2184c2d15dd 316 FRAME_BUFFER_STRIDE,
dkato 0:b2184c2d15dd 317 VIDEO_FORMAT,
dkato 0:b2184c2d15dd 318 WR_RD_WRSWA,
dkato 0:b2184c2d15dd 319 VIDEO_PIXEL_VW,
dkato 0:b2184c2d15dd 320 VIDEO_PIXEL_HW
dkato 0:b2184c2d15dd 321 );
dkato 0:b2184c2d15dd 322 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 323 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 324 mbed_die();
dkato 0:b2184c2d15dd 325 }
dkato 0:b2184c2d15dd 326
dkato 0:b2184c2d15dd 327 /* Video write process start */
dkato 0:b2184c2d15dd 328 error = Display.Video_Start(VIDEO_INPUT_CH);
dkato 0:b2184c2d15dd 329 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 330 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 331 mbed_die();
dkato 0:b2184c2d15dd 332 }
dkato 0:b2184c2d15dd 333
dkato 0:b2184c2d15dd 334 /* Video write process stop */
dkato 0:b2184c2d15dd 335 error = Display.Video_Stop(VIDEO_INPUT_CH);
dkato 0:b2184c2d15dd 336 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 337 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 338 mbed_die();
dkato 0:b2184c2d15dd 339 }
dkato 0:b2184c2d15dd 340
dkato 0:b2184c2d15dd 341 /* Video write process start */
dkato 0:b2184c2d15dd 342 error = Display.Video_Start(VIDEO_INPUT_CH);
dkato 0:b2184c2d15dd 343 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 344 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 345 mbed_die();
dkato 0:b2184c2d15dd 346 }
dkato 0:b2184c2d15dd 347 }
dkato 0:b2184c2d15dd 348
dkato 0:b2184c2d15dd 349 /****** Video input is output to LCD ******/
dkato 2:8721836b639d 350 static void video_lcd_task(void) {
dkato 0:b2184c2d15dd 351 DisplayBase::graphics_error_t error;
dkato 0:b2184c2d15dd 352 int wk_num;
dkato 0:b2184c2d15dd 353 int i;
dkato 0:b2184c2d15dd 354
dkato 0:b2184c2d15dd 355 /* Initialization memory */
dkato 0:b2184c2d15dd 356 for (i = 0; i < FRAME_BUFFER_NUM; i++) {
dkato 0:b2184c2d15dd 357 memset(FrameBufferTbl[i], 0, (FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT));
dkato 0:b2184c2d15dd 358 dcache_clean(FrameBufferTbl[i], (FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT));
dkato 0:b2184c2d15dd 359 }
dkato 0:b2184c2d15dd 360
dkato 0:b2184c2d15dd 361 /* Start of Video */
dkato 0:b2184c2d15dd 362 Start_Video(FrameBufferTbl[write_buff_num]);
dkato 0:b2184c2d15dd 363
dkato 0:b2184c2d15dd 364 /* Wait for first video drawing */
dkato 0:b2184c2d15dd 365 Thread::signal_wait(1);
dkato 0:b2184c2d15dd 366 write_buff_num++;
dkato 0:b2184c2d15dd 367 if (write_buff_num >= FRAME_BUFFER_NUM) {
dkato 0:b2184c2d15dd 368 write_buff_num = 0;
dkato 0:b2184c2d15dd 369 }
dkato 0:b2184c2d15dd 370 error = Display.Video_Write_Change(VIDEO_INPUT_CH, FrameBufferTbl[write_buff_num], FRAME_BUFFER_STRIDE);
dkato 0:b2184c2d15dd 371 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 372 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 373 mbed_die();
dkato 0:b2184c2d15dd 374 }
dkato 0:b2184c2d15dd 375
dkato 0:b2184c2d15dd 376 /* Start of LCD */
dkato 0:b2184c2d15dd 377 Start_LCD_Display(FrameBufferTbl[read_buff_num]);
dkato 0:b2184c2d15dd 378
dkato 0:b2184c2d15dd 379 /* Backlight on */
dkato 0:b2184c2d15dd 380 Thread::wait(200);
dkato 0:b2184c2d15dd 381 lcd_cntrst.write(1.0);
dkato 0:b2184c2d15dd 382
dkato 0:b2184c2d15dd 383 while (1) {
dkato 0:b2184c2d15dd 384 Thread::signal_wait(1);
dkato 0:b2184c2d15dd 385 wk_num = write_buff_num + 1;
dkato 0:b2184c2d15dd 386 if (wk_num >= FRAME_BUFFER_NUM) {
dkato 0:b2184c2d15dd 387 wk_num = 0;
dkato 0:b2184c2d15dd 388 }
dkato 0:b2184c2d15dd 389 /* If the next buffer is empty, it's changed. */
dkato 0:b2184c2d15dd 390 if (wk_num != read_buff_num) {
dkato 0:b2184c2d15dd 391 read_buff_num = write_buff_num;
dkato 0:b2184c2d15dd 392 write_buff_num = wk_num;
dkato 0:b2184c2d15dd 393 /* Change video buffer */
dkato 0:b2184c2d15dd 394 error = Display.Video_Write_Change(VIDEO_INPUT_CH, FrameBufferTbl[write_buff_num], FRAME_BUFFER_STRIDE);
dkato 0:b2184c2d15dd 395 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:b2184c2d15dd 396 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:b2184c2d15dd 397 mbed_die();
dkato 0:b2184c2d15dd 398 }
dkato 0:b2184c2d15dd 399 /* Change LCD buffer */
dkato 0:b2184c2d15dd 400 Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0, (void *)FrameBufferTbl[read_buff_num]);
dkato 0:b2184c2d15dd 401 }
dkato 0:b2184c2d15dd 402 }
dkato 0:b2184c2d15dd 403 }
dkato 0:b2184c2d15dd 404
dkato 0:b2184c2d15dd 405 /****** Touch panel ******/
dkato 6:95b92f2035dc 406 static void draw_touch_pos(uint8_t * p_buf, int id, int x, int y) {
dkato 0:b2184c2d15dd 407 int idx_base;
dkato 0:b2184c2d15dd 408 int wk_idx;
dkato 0:b2184c2d15dd 409 int i;
dkato 0:b2184c2d15dd 410 int j;
dkato 0:b2184c2d15dd 411 uint8_t coller_pix[TOUCH_BUFFER_BYTE_PER_PIXEL]; /* ARGB4444 */
dkato 0:b2184c2d15dd 412
dkato 0:b2184c2d15dd 413 /* A coordinate in the upper left is calculated from a central coordinate. */
dkato 6:95b92f2035dc 414 if ((x - (DRAW_POINT / 2)) >= 0) {
dkato 6:95b92f2035dc 415 x -= (DRAW_POINT / 2);
dkato 0:b2184c2d15dd 416 }
dkato 6:95b92f2035dc 417 if (x > (LCD_PIXEL_WIDTH - DRAW_POINT)) {
dkato 6:95b92f2035dc 418 x = (LCD_PIXEL_WIDTH - DRAW_POINT);
dkato 0:b2184c2d15dd 419 }
dkato 6:95b92f2035dc 420 if ((y - (DRAW_POINT / 2)) >= 0) {
dkato 6:95b92f2035dc 421 y -= (DRAW_POINT / 2);
dkato 0:b2184c2d15dd 422 }
dkato 6:95b92f2035dc 423 if (y > (LCD_PIXEL_HEIGHT - DRAW_POINT)) {
dkato 6:95b92f2035dc 424 y = (LCD_PIXEL_HEIGHT - DRAW_POINT);
dkato 0:b2184c2d15dd 425 }
dkato 0:b2184c2d15dd 426 idx_base = (x + (LCD_PIXEL_WIDTH * y)) * TOUCH_BUFFER_BYTE_PER_PIXEL;
dkato 0:b2184c2d15dd 427
dkato 0:b2184c2d15dd 428 /* Select color */
dkato 0:b2184c2d15dd 429 if (id == 0) {
dkato 0:b2184c2d15dd 430 /* Blue */
dkato 0:b2184c2d15dd 431 coller_pix[0] = 0x0F; /* 4:Green 4:Blue */
dkato 0:b2184c2d15dd 432 coller_pix[1] = 0xF0; /* 4:Alpha 4:Red */
dkato 0:b2184c2d15dd 433 } else {
dkato 0:b2184c2d15dd 434 /* Pink */
dkato 0:b2184c2d15dd 435 coller_pix[0] = 0x07; /* 4:Green 4:Blue */
dkato 0:b2184c2d15dd 436 coller_pix[1] = 0xFF; /* 4:Alpha 4:Red */
dkato 0:b2184c2d15dd 437 }
dkato 0:b2184c2d15dd 438
dkato 0:b2184c2d15dd 439 /* Drawing */
dkato 6:95b92f2035dc 440 for (i = 0; i < DRAW_POINT; i++) {
dkato 0:b2184c2d15dd 441 wk_idx = idx_base + (LCD_PIXEL_WIDTH * TOUCH_BUFFER_BYTE_PER_PIXEL * i);
dkato 6:95b92f2035dc 442 for (j = 0; j < DRAW_POINT; j++) {
dkato 0:b2184c2d15dd 443 p_buf[wk_idx++] = coller_pix[0];
dkato 0:b2184c2d15dd 444 p_buf[wk_idx++] = coller_pix[1];
dkato 0:b2184c2d15dd 445 }
dkato 0:b2184c2d15dd 446 }
dkato 0:b2184c2d15dd 447 }
dkato 0:b2184c2d15dd 448
dkato 6:95b92f2035dc 449 static void draw_touch_keyonoff(uint8_t * p_buf, int id, bool onoff) {
dkato 0:b2184c2d15dd 450 int idx_base;
dkato 0:b2184c2d15dd 451 int wk_idx;
dkato 0:b2184c2d15dd 452 int i;
dkato 0:b2184c2d15dd 453 int j;
dkato 0:b2184c2d15dd 454 uint8_t coller_pix[TOUCH_BUFFER_BYTE_PER_PIXEL]; /* ARGB4444 */
dkato 0:b2184c2d15dd 455
dkato 0:b2184c2d15dd 456 /* Display position */
dkato 0:b2184c2d15dd 457 if (id == 0) {
dkato 0:b2184c2d15dd 458 idx_base = 0;
dkato 0:b2184c2d15dd 459 } else {
dkato 6:95b92f2035dc 460 idx_base = DRAW_POINT * TOUCH_BUFFER_BYTE_PER_PIXEL;
dkato 0:b2184c2d15dd 461 }
dkato 0:b2184c2d15dd 462
dkato 0:b2184c2d15dd 463 /* Select color */
dkato 0:b2184c2d15dd 464 if (onoff == false) {
dkato 0:b2184c2d15dd 465 /* Transparency */
dkato 0:b2184c2d15dd 466 coller_pix[0] = 0x00; /* 4:Green 4:Blue */
dkato 0:b2184c2d15dd 467 coller_pix[1] = 0x00; /* 4:Alpha 4:Red */
dkato 0:b2184c2d15dd 468 } else {
dkato 0:b2184c2d15dd 469 /* White */
dkato 0:b2184c2d15dd 470 coller_pix[0] = 0xff; /* 4:Green 4:Blue */
dkato 0:b2184c2d15dd 471 coller_pix[1] = 0xff; /* 4:Alpha 4:Red */
dkato 0:b2184c2d15dd 472 }
dkato 0:b2184c2d15dd 473
dkato 0:b2184c2d15dd 474 /* Drawing */
dkato 6:95b92f2035dc 475 for (i = 0; i < DRAW_POINT; i++) {
dkato 0:b2184c2d15dd 476 wk_idx = idx_base + (LCD_PIXEL_WIDTH * TOUCH_BUFFER_BYTE_PER_PIXEL * i);
dkato 6:95b92f2035dc 477 for (j = 0; j < DRAW_POINT; j++) {
dkato 0:b2184c2d15dd 478 p_buf[wk_idx++] = coller_pix[0];
dkato 0:b2184c2d15dd 479 p_buf[wk_idx++] = coller_pix[1];
dkato 0:b2184c2d15dd 480 }
dkato 0:b2184c2d15dd 481 }
dkato 0:b2184c2d15dd 482 }
dkato 0:b2184c2d15dd 483
dkato 0:b2184c2d15dd 484 static void touch_int_callback(void) {
dkato 0:b2184c2d15dd 485 sem_touch_int.release();
dkato 0:b2184c2d15dd 486 }
dkato 0:b2184c2d15dd 487
dkato 2:8721836b639d 488 static void touch_task(void) {
dkato 0:b2184c2d15dd 489 DisplayBase::rect_t rect;
dkato 0:b2184c2d15dd 490 TouchKey::touch_pos_t touch_pos[TOUCH_NUM];
dkato 0:b2184c2d15dd 491 int touch_num = 0;
dkato 0:b2184c2d15dd 492 int touch_num_last = 0;
dkato 0:b2184c2d15dd 493 int i;
dkato 0:b2184c2d15dd 494
dkato 0:b2184c2d15dd 495 /* The layer by which the touch panel location is drawn */
dkato 0:b2184c2d15dd 496 memset(user_frame_buffer_touch, 0, sizeof(user_frame_buffer_touch));
dkato 0:b2184c2d15dd 497 dcache_clean(user_frame_buffer_touch, sizeof(user_frame_buffer_touch));
dkato 0:b2184c2d15dd 498 rect.vs = 0;
dkato 0:b2184c2d15dd 499 rect.vw = LCD_PIXEL_HEIGHT;
dkato 0:b2184c2d15dd 500 rect.hs = 0;
dkato 0:b2184c2d15dd 501 rect.hw = LCD_PIXEL_WIDTH;
dkato 0:b2184c2d15dd 502 Display.Graphics_Read_Setting(
dkato 0:b2184c2d15dd 503 DisplayBase::GRAPHICS_LAYER_1,
dkato 0:b2184c2d15dd 504 (void *)user_frame_buffer_touch,
dkato 0:b2184c2d15dd 505 TOUCH_BUFFER_STRIDE,
dkato 0:b2184c2d15dd 506 DisplayBase::GRAPHICS_FORMAT_ARGB4444,
dkato 0:b2184c2d15dd 507 DisplayBase::WR_RD_WRSWA_32_16BIT,
dkato 0:b2184c2d15dd 508 &rect
dkato 0:b2184c2d15dd 509 );
dkato 0:b2184c2d15dd 510 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_1);
dkato 0:b2184c2d15dd 511
dkato 0:b2184c2d15dd 512 /* Callback setting */
dkato 0:b2184c2d15dd 513 touch.SetCallback(&touch_int_callback);
dkato 0:b2184c2d15dd 514
dkato 0:b2184c2d15dd 515 /* Reset touch IC */
dkato 0:b2184c2d15dd 516 touch.Reset();
dkato 0:b2184c2d15dd 517
dkato 0:b2184c2d15dd 518 while (1) {
dkato 0:b2184c2d15dd 519 /* Wait touch event */
dkato 0:b2184c2d15dd 520 sem_touch_int.wait();
dkato 0:b2184c2d15dd 521
dkato 0:b2184c2d15dd 522 /* Get touch coordinates */
dkato 0:b2184c2d15dd 523 touch_num = touch.GetCoordinates(TOUCH_NUM, touch_pos);
dkato 0:b2184c2d15dd 524
dkato 0:b2184c2d15dd 525 /* When it's a new touch, touch frame buffer is initialized */
dkato 0:b2184c2d15dd 526 if ((touch_num != 0) && (touch_num_last == 0)) {
dkato 0:b2184c2d15dd 527 memset(user_frame_buffer_touch, 0, sizeof(user_frame_buffer_touch));
dkato 0:b2184c2d15dd 528 }
dkato 0:b2184c2d15dd 529 touch_num_last = touch_num;
dkato 0:b2184c2d15dd 530
dkato 0:b2184c2d15dd 531 /* Drawing of a touch coordinate */
dkato 0:b2184c2d15dd 532 for (i = 0; i < TOUCH_NUM; i ++) {
dkato 0:b2184c2d15dd 533 printf("{valid=%d,x=%d,y=%d} ", touch_pos[i].valid, touch_pos[i].x, touch_pos[i].y);
dkato 6:95b92f2035dc 534 draw_touch_keyonoff(user_frame_buffer_touch, i, touch_pos[i].valid);
dkato 0:b2184c2d15dd 535 if (touch_pos[i].valid) {
dkato 6:95b92f2035dc 536 draw_touch_pos(user_frame_buffer_touch, i, touch_pos[i].x, touch_pos[i].y);
dkato 0:b2184c2d15dd 537 }
dkato 0:b2184c2d15dd 538 }
dkato 0:b2184c2d15dd 539 printf("\n");
dkato 0:b2184c2d15dd 540
dkato 0:b2184c2d15dd 541 /* Data cache clean */
dkato 0:b2184c2d15dd 542 dcache_clean(user_frame_buffer_touch, sizeof(user_frame_buffer_touch));
dkato 0:b2184c2d15dd 543 }
dkato 0:b2184c2d15dd 544 }
dkato 0:b2184c2d15dd 545
dkato 0:b2184c2d15dd 546 /****** main ******/
dkato 0:b2184c2d15dd 547 int main(void) {
dkato 4:bafd63604b7c 548 DisplayBase::rect_t rect;
dkato 4:bafd63604b7c 549 char test_cnt = 0x20;
dkato 4:bafd63604b7c 550
dkato 0:b2184c2d15dd 551 /* Change the baud rate of the printf() */
dkato 0:b2184c2d15dd 552 pc.baud(921600);
dkato 0:b2184c2d15dd 553
dkato 0:b2184c2d15dd 554 /* Initialization of LCD */
dkato 0:b2184c2d15dd 555 Init_LCD_Display(); /* When using LCD, please call before than Init_Video(). */
dkato 0:b2184c2d15dd 556
dkato 0:b2184c2d15dd 557 /* Initialization of Video */
dkato 0:b2184c2d15dd 558 Init_Video();
dkato 0:b2184c2d15dd 559
dkato 0:b2184c2d15dd 560 /* Start Video and Lcd processing */
dkato 2:8721836b639d 561 p_VideoLcdTask = new Thread;
dkato 2:8721836b639d 562 p_VideoLcdTask->start(video_lcd_task);
dkato 0:b2184c2d15dd 563
dkato 0:b2184c2d15dd 564 /* Start touch panel processing */
dkato 2:8721836b639d 565 Thread touchTask;
dkato 2:8721836b639d 566 touchTask.start(touch_task);
dkato 0:b2184c2d15dd 567
dkato 5:4e96673f4830 568 /* The layer by which the character string is drawn */
dkato 4:bafd63604b7c 569 memset(user_frame_buffer_string, 0, sizeof(user_frame_buffer_string));
dkato 4:bafd63604b7c 570 dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string));
dkato 4:bafd63604b7c 571 rect.vs = LCD_PIXEL_HEIGHT - STRING_PIXEL_VM - 10;
dkato 4:bafd63604b7c 572 rect.vw = STRING_PIXEL_VM;
dkato 4:bafd63604b7c 573 rect.hs = LCD_PIXEL_WIDTH - STRING_PIXEL_HW - 10;
dkato 4:bafd63604b7c 574 rect.hw = STRING_PIXEL_HW;
dkato 4:bafd63604b7c 575 Display.Graphics_Read_Setting(
dkato 4:bafd63604b7c 576 DisplayBase::GRAPHICS_LAYER_2,
dkato 4:bafd63604b7c 577 (void *)user_frame_buffer_string,
dkato 4:bafd63604b7c 578 STRING_BUFFER_STRIDE,
dkato 4:bafd63604b7c 579 DisplayBase::GRAPHICS_FORMAT_ARGB4444,
dkato 4:bafd63604b7c 580 DisplayBase::WR_RD_WRSWA_32_16BIT,
dkato 4:bafd63604b7c 581 &rect
dkato 4:bafd63604b7c 582 );
dkato 4:bafd63604b7c 583 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2);
dkato 4:bafd63604b7c 584
dkato 4:bafd63604b7c 585 /* String */
dkato 4:bafd63604b7c 586 AsciiFont ascii_font(user_frame_buffer_string, STRING_PIXEL_HW, STRING_PIXEL_VM,
dkato 4:bafd63604b7c 587 STRING_BUFFER_STRIDE, STRING_BUFFER_BYTE_PER_PIXEL);
dkato 5:4e96673f4830 588 ascii_font.DrawStr("Font:", 0, 8, 0x0000ffff, 2);
dkato 0:b2184c2d15dd 589 while (1) {
dkato 0:b2184c2d15dd 590 led_blue = !led_blue;
dkato 4:bafd63604b7c 591 //colour: rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red
dkato 4:bafd63604b7c 592 ascii_font.DrawChar(test_cnt, 84, 0, 0x0000aa9f, 3);
dkato 4:bafd63604b7c 593 if (test_cnt < 0x7e) {
dkato 4:bafd63604b7c 594 test_cnt++;
dkato 4:bafd63604b7c 595 } else {
dkato 4:bafd63604b7c 596 test_cnt = 0x20;
dkato 4:bafd63604b7c 597 }
dkato 4:bafd63604b7c 598 dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string));
dkato 0:b2184c2d15dd 599 Thread::wait(1000);
dkato 0:b2184c2d15dd 600 }
dkato 0:b2184c2d15dd 601 }