Lcd companion boards support (VKLCD50RTA & VKLCD70RT)
What is this ?
This is a demo program using Renesas RGA library & USB Camera to demonstrate VK-RZ/A1H's companion boards workability.
Supported companion Boards:
VKLCD50RTA
VKLCD70RT
How to Configure ?
You can choose which display is installed by altering the lcd_panel.h file
Leave the active one & comment out the others:
#define LCD_VDC5_CH0_PANEL LCD_CH0_PANEL_VKLCD50RTA //#define LCD_VDC5_CH0_PANEL LCD_CH0_PANEL_VKLCD70RT
You can alter the whole demo with your pictures if you like:
How to compile ?
- The Demo can be compiled in 3 modes:
- I. Execution from the internal 10-MB on-chip SRAM.
- II. Execution from the on-board serial FALSH in dual (32-MB) mode.
- After import in the online compiler just leave only the VKRZA1H_DOUBLE.sct & delete all others linker files in the TOOLCHAIN_ARM_STD folder.
- Drag & drop the result binary in MBED disk, (previously inited in double flash mode)
- III. Execution from the on-board serial FALSH in single (16-MB) mode.
- After import in the online compiler just leave only the VKRZA1H_SINGLE.sct & delete all others linker files in the TOOLCHAIN_ARM_STD folder.
- Drag & drop the result binary in MBED disk, (previously inited in single flash mode )
Quick presentation:
Other demos ?
More demos you can find on our FTP
RGA/main.cpp@0:6435b67ad23c, 2017-02-16 (annotated)
- Committer:
- tvendov
- Date:
- Thu Feb 16 10:23:48 2017 +0000
- Revision:
- 0:6435b67ad23c
Initial lcd support (VKLCD50RTA & VKLCD70RT companion boards)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tvendov | 0:6435b67ad23c | 1 | /* |
tvendov | 0:6435b67ad23c | 2 | Permission is hereby granted, free of charge, to any person obtaining a copy |
tvendov | 0:6435b67ad23c | 3 | of this software and associated documentation files (the "Software"), to deal |
tvendov | 0:6435b67ad23c | 4 | in the Software without restriction, including without limitation the rights |
tvendov | 0:6435b67ad23c | 5 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
tvendov | 0:6435b67ad23c | 6 | copies of the Software, and to permit persons to whom the Software is |
tvendov | 0:6435b67ad23c | 7 | furnished to do so, subject to the following conditions: |
tvendov | 0:6435b67ad23c | 8 | |
tvendov | 0:6435b67ad23c | 9 | The above copyright notice and this permission notice shall be included in |
tvendov | 0:6435b67ad23c | 10 | all copies or substantial portions of the Software. |
tvendov | 0:6435b67ad23c | 11 | |
tvendov | 0:6435b67ad23c | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
tvendov | 0:6435b67ad23c | 13 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
tvendov | 0:6435b67ad23c | 14 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
tvendov | 0:6435b67ad23c | 15 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
tvendov | 0:6435b67ad23c | 16 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
tvendov | 0:6435b67ad23c | 17 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
tvendov | 0:6435b67ad23c | 18 | THE SOFTWARE. |
tvendov | 0:6435b67ad23c | 19 | */ |
tvendov | 0:6435b67ad23c | 20 | |
tvendov | 0:6435b67ad23c | 21 | |
tvendov | 0:6435b67ad23c | 22 | #define __SOFT_JPEG__ |
tvendov | 0:6435b67ad23c | 23 | |
tvendov | 0:6435b67ad23c | 24 | #include "mbed.h" |
tvendov | 0:6435b67ad23c | 25 | #include "rga_func.h" |
tvendov | 0:6435b67ad23c | 26 | #include "DisplayBace.h" |
tvendov | 0:6435b67ad23c | 27 | #include "rtos.h" |
tvendov | 0:6435b67ad23c | 28 | #include "LcdCfg.h" |
tvendov | 0:6435b67ad23c | 29 | #include "Touch.h" |
tvendov | 0:6435b67ad23c | 30 | #include "rza_io_regrw.h" |
tvendov | 0:6435b67ad23c | 31 | #include "USBHostCam.h" |
tvendov | 0:6435b67ad23c | 32 | //#include "JPEG_Converter.h" |
tvendov | 0:6435b67ad23c | 33 | |
tvendov | 0:6435b67ad23c | 34 | #include "Images/BinaryImage_RZ_A1H.h" |
tvendov | 0:6435b67ad23c | 35 | |
tvendov | 0:6435b67ad23c | 36 | #ifdef __SOFT_JPEG__ |
tvendov | 0:6435b67ad23c | 37 | #include "jpeglib.h" |
tvendov | 0:6435b67ad23c | 38 | #include <setjmp.h> |
tvendov | 0:6435b67ad23c | 39 | #endif |
tvendov | 0:6435b67ad23c | 40 | |
tvendov | 0:6435b67ad23c | 41 | #define VIDEO_CVBS (0) /* Analog Video Signal */ |
tvendov | 0:6435b67ad23c | 42 | #define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */ |
tvendov | 0:6435b67ad23c | 43 | |
tvendov | 0:6435b67ad23c | 44 | #define VIDEO_YCBCR422 (0) |
tvendov | 0:6435b67ad23c | 45 | #define VIDEO_RGB888 (1) |
tvendov | 0:6435b67ad23c | 46 | #define VIDEO_RGB565 (2) |
tvendov | 0:6435b67ad23c | 47 | |
tvendov | 0:6435b67ad23c | 48 | /**** User Selection *********/ |
tvendov | 0:6435b67ad23c | 49 | #define VIDEO_INPUT_METHOD (VIDEO_CVBS) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */ |
tvendov | 0:6435b67ad23c | 50 | #define VIDEO_INPUT_FORMAT (VIDEO_RGB565) /* Select VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565 */ |
tvendov | 0:6435b67ad23c | 51 | #define USE_VIDEO_CH (0) /* Select 0 or 1 If selecting VIDEO_CMOS_CAMERA, should be 0.) */ |
tvendov | 0:6435b67ad23c | 52 | #define VIDEO_PAL (1) /* Select 0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */ |
tvendov | 0:6435b67ad23c | 53 | /*****************************/ |
tvendov | 0:6435b67ad23c | 54 | |
tvendov | 0:6435b67ad23c | 55 | #if USE_VIDEO_CH == (0) |
tvendov | 0:6435b67ad23c | 56 | #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_0) |
tvendov | 0:6435b67ad23c | 57 | #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S0_VFIELD) |
tvendov | 0:6435b67ad23c | 58 | #else |
tvendov | 0:6435b67ad23c | 59 | #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_1) |
tvendov | 0:6435b67ad23c | 60 | #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S1_VFIELD) |
tvendov | 0:6435b67ad23c | 61 | #endif |
tvendov | 0:6435b67ad23c | 62 | |
tvendov | 0:6435b67ad23c | 63 | /** Video and Grapics (GRAPHICS_LAYER_0) parameter **/ |
tvendov | 0:6435b67ad23c | 64 | /* NTSC or PAL */ |
tvendov | 0:6435b67ad23c | 65 | #if VIDEO_PAL == 0 |
tvendov | 0:6435b67ad23c | 66 | #define COL_SYS (DisplayBase::COL_SYS_NTSC_358) |
tvendov | 0:6435b67ad23c | 67 | #else |
tvendov | 0:6435b67ad23c | 68 | #define COL_SYS (DisplayBase::COL_SYS_PAL_443) |
tvendov | 0:6435b67ad23c | 69 | #endif |
tvendov | 0:6435b67ad23c | 70 | |
tvendov | 0:6435b67ad23c | 71 | /* Video input and LCD layer 0 output */ |
tvendov | 0:6435b67ad23c | 72 | #if VIDEO_INPUT_FORMAT == VIDEO_YCBCR422 |
tvendov | 0:6435b67ad23c | 73 | #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_YCBCR422) |
tvendov | 0:6435b67ad23c | 74 | #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_YCBCR422) |
tvendov | 0:6435b67ad23c | 75 | #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_NON) |
tvendov | 0:6435b67ad23c | 76 | #elif VIDEO_INPUT_FORMAT == VIDEO_RGB565 |
tvendov | 0:6435b67ad23c | 77 | #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_RGB565) |
tvendov | 0:6435b67ad23c | 78 | #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB565) |
tvendov | 0:6435b67ad23c | 79 | #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT) |
tvendov | 0:6435b67ad23c | 80 | #else |
tvendov | 0:6435b67ad23c | 81 | #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_RGB888) |
tvendov | 0:6435b67ad23c | 82 | #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB888) |
tvendov | 0:6435b67ad23c | 83 | #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32BIT) |
tvendov | 0:6435b67ad23c | 84 | #endif |
tvendov | 0:6435b67ad23c | 85 | |
tvendov | 0:6435b67ad23c | 86 | /* NOSIGNAL bit position */ |
tvendov | 0:6435b67ad23c | 87 | #define NOSIGNAL (11u) |
tvendov | 0:6435b67ad23c | 88 | #define MASK(n) (1<<(n)) |
tvendov | 0:6435b67ad23c | 89 | |
tvendov | 0:6435b67ad23c | 90 | #define MAX_TRY 3 |
tvendov | 0:6435b67ad23c | 91 | |
tvendov | 0:6435b67ad23c | 92 | /* FRAME BUFFER Parameter */ |
tvendov | 0:6435b67ad23c | 93 | #if ( VIDEO_INPUT_FORMAT == VIDEO_YCBCR422 || VIDEO_INPUT_FORMAT == VIDEO_RGB565 ) |
tvendov | 0:6435b67ad23c | 94 | #define FRAME_BUFFER_BYTE_PER_PIXEL (2u) |
tvendov | 0:6435b67ad23c | 95 | #else |
tvendov | 0:6435b67ad23c | 96 | #define FRAME_BUFFER_BYTE_PER_PIXEL (4u) |
tvendov | 0:6435b67ad23c | 97 | #endif |
tvendov | 0:6435b67ad23c | 98 | #define FRAME_BUFFER_STRIDE (((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u) |
tvendov | 0:6435b67ad23c | 99 | #define FASTR_RENDER user_video_buffer |
tvendov | 0:6435b67ad23c | 100 | |
tvendov | 0:6435b67ad23c | 101 | #define DRAW_RECTANGLE_CNT_MAX (4) |
tvendov | 0:6435b67ad23c | 102 | #define TOUCH_NUM (1u) |
tvendov | 0:6435b67ad23c | 103 | #define ROTRNDR_SIZE ((uint8_t*)Board_wide_jpg_File - (uint8_t *)Board_jpg_File) |
tvendov | 0:6435b67ad23c | 104 | #define SCRRNDR_SIZE ((uint8_t*)TopScrn_jpg_File - (uint8_t *)Board_wide_jpg_File) |
tvendov | 0:6435b67ad23c | 105 | |
tvendov | 0:6435b67ad23c | 106 | #define VID_X 0 |
tvendov | 0:6435b67ad23c | 107 | #define VID_Y 0 |
tvendov | 0:6435b67ad23c | 108 | #define VID_W LCD_PIXEL_WIDTH-SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 109 | #define VID_H SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 110 | |
tvendov | 0:6435b67ad23c | 111 | #define RVID_X SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 112 | #define RVID_Y LCD_PIXEL_HEIGHT-SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 113 | #define RVID_W LCD_PIXEL_WIDTH-SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 114 | #define RVID_H SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 115 | |
tvendov | 0:6435b67ad23c | 116 | |
tvendov | 0:6435b67ad23c | 117 | #define CAM_X LCD_PIXEL_WIDTH-SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 118 | #define CAM_Y 0 |
tvendov | 0:6435b67ad23c | 119 | #define CAM_W SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 120 | #define CAM_H LCD_PIXEL_HEIGHT |
tvendov | 0:6435b67ad23c | 121 | |
tvendov | 0:6435b67ad23c | 122 | #define RCAM_X 0 |
tvendov | 0:6435b67ad23c | 123 | #define RCAM_Y 0 |
tvendov | 0:6435b67ad23c | 124 | #define RCAM_W SLIDE_WIDTH |
tvendov | 0:6435b67ad23c | 125 | #define RCAM_H LCD_PIXEL_HEIGHT |
tvendov | 0:6435b67ad23c | 126 | |
tvendov | 0:6435b67ad23c | 127 | |
tvendov | 0:6435b67ad23c | 128 | typedef enum { |
tvendov | 0:6435b67ad23c | 129 | RGA_FUNC_NON, |
tvendov | 0:6435b67ad23c | 130 | RGA_FUNC_DRAW_RECTANGLE, |
tvendov | 0:6435b67ad23c | 131 | RGA_FUNC_DRAW_IMAGE, |
tvendov | 0:6435b67ad23c | 132 | RGA_FUNC_DISSOLVE, |
tvendov | 0:6435b67ad23c | 133 | RGA_FUNC_SCROLL, |
tvendov | 0:6435b67ad23c | 134 | RGA_FUNC_ZOOM, |
tvendov | 0:6435b67ad23c | 135 | RGA_FUNC_ROTATION, |
tvendov | 0:6435b67ad23c | 136 | RGA_FUNC_ACCELERATE, |
tvendov | 0:6435b67ad23c | 137 | RGA_FUNC_ANIME_EASE, |
tvendov | 0:6435b67ad23c | 138 | RGA_FUNC_ANIME_LINEAR, |
tvendov | 0:6435b67ad23c | 139 | RGA_FUNC_ANIME_EASE_IN, |
tvendov | 0:6435b67ad23c | 140 | RGA_FUNC_ANIME_EASE_OUT, |
tvendov | 0:6435b67ad23c | 141 | RGA_FUNC_ANIME_EASE_IN_OUT, |
tvendov | 0:6435b67ad23c | 142 | RGA_FUNC_RETURN, |
tvendov | 0:6435b67ad23c | 143 | RGA_FUNC_AUTO_MANUAL, |
tvendov | 0:6435b67ad23c | 144 | RGA_FUNC_VIDEO, |
tvendov | 0:6435b67ad23c | 145 | RGA_FUNC_USBCAM, |
tvendov | 0:6435b67ad23c | 146 | RGA_FUNC_END |
tvendov | 0:6435b67ad23c | 147 | } func_code_t; |
tvendov | 0:6435b67ad23c | 148 | |
tvendov | 0:6435b67ad23c | 149 | DigitalOut test_point(LED1); |
tvendov | 0:6435b67ad23c | 150 | PwmOut lcd_cntrst(P8_15); |
tvendov | 0:6435b67ad23c | 151 | DisplayBase Display; |
tvendov | 0:6435b67ad23c | 152 | Touch STMPE811; |
tvendov | 0:6435b67ad23c | 153 | USBHostCam Cam(_432x240); |
tvendov | 0:6435b67ad23c | 154 | interact_t Interaction_mode; |
tvendov | 0:6435b67ad23c | 155 | |
tvendov | 0:6435b67ad23c | 156 | typedef struct { |
tvendov | 0:6435b67ad23c | 157 | uint32_t x; /**< The position of the x-coordinate. */ |
tvendov | 0:6435b67ad23c | 158 | uint32_t y; /**< The position of the y-coordinate. */ |
tvendov | 0:6435b67ad23c | 159 | bool touch_down; /**< IS stylus still down */ |
tvendov | 0:6435b67ad23c | 160 | } touch_pos_t; |
tvendov | 0:6435b67ad23c | 161 | |
tvendov | 0:6435b67ad23c | 162 | typedef struct { |
tvendov | 0:6435b67ad23c | 163 | uint32_t pic_pos_x; /* X position of the key picture. */ |
tvendov | 0:6435b67ad23c | 164 | uint32_t pic_pos_y; /* Y position of the key picture. */ |
tvendov | 0:6435b67ad23c | 165 | uint32_t pic_width; /* Width of the key picture. */ |
tvendov | 0:6435b67ad23c | 166 | uint32_t pic_height; /* Height of the key picture. */ |
tvendov | 0:6435b67ad23c | 167 | func_code_t func_code; /* func code of the key picture. */ |
tvendov | 0:6435b67ad23c | 168 | } key_pic_info_t; |
tvendov | 0:6435b67ad23c | 169 | |
tvendov | 0:6435b67ad23c | 170 | #ifdef __SOFT_JPEG__ |
tvendov | 0:6435b67ad23c | 171 | struct my_error_mgr { |
tvendov | 0:6435b67ad23c | 172 | struct jpeg_error_mgr pub; /* "public" fields */ |
tvendov | 0:6435b67ad23c | 173 | |
tvendov | 0:6435b67ad23c | 174 | jmp_buf setjmp_buffer; /* for return to caller */ |
tvendov | 0:6435b67ad23c | 175 | }; |
tvendov | 0:6435b67ad23c | 176 | |
tvendov | 0:6435b67ad23c | 177 | typedef struct my_error_mgr * my_error_ptr; |
tvendov | 0:6435b67ad23c | 178 | #endif |
tvendov | 0:6435b67ad23c | 179 | |
tvendov | 0:6435b67ad23c | 180 | #if defined(__ICCARM__) |
tvendov | 0:6435b67ad23c | 181 | #pragma data_alignment=32 |
tvendov | 0:6435b67ad23c | 182 | static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]; |
tvendov | 0:6435b67ad23c | 183 | static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]; |
tvendov | 0:6435b67ad23c | 184 | static uint8_t user_video_buffer[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]; |
tvendov | 0:6435b67ad23c | 185 | #pragma data_alignment=4 |
tvendov | 0:6435b67ad23c | 186 | #else |
tvendov | 0:6435b67ad23c | 187 | static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */ |
tvendov | 0:6435b67ad23c | 188 | static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */ |
tvendov | 0:6435b67ad23c | 189 | static uint8_t user_video_buffer[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */ |
tvendov | 0:6435b67ad23c | 190 | static uint8_t shot_buffer[100 * 1024]__attribute((aligned(32))); /* 32 bytes aligned */ |
tvendov | 0:6435b67ad23c | 191 | //static uint8_t shot_buffer[200*1024]__attribute((section("NC_BSS"),aligned(32))); /* 32 bytes aligned */ |
tvendov | 0:6435b67ad23c | 192 | #endif |
tvendov | 0:6435b67ad23c | 193 | static frame_buffer_t frame_buffer_info; |
tvendov | 0:6435b67ad23c | 194 | static volatile int32_t vsync_count = 0; |
tvendov | 0:6435b67ad23c | 195 | //static volatile int32_t vfield_count_0 = 1; |
tvendov | 0:6435b67ad23c | 196 | static volatile bool usb_plug = false; |
tvendov | 0:6435b67ad23c | 197 | static volatile bool video_signal = false; |
tvendov | 0:6435b67ad23c | 198 | static volatile bool try_cam_connect = false; |
tvendov | 0:6435b67ad23c | 199 | static volatile DisplayBase::slide_t slide_screen = DisplayBase::SLIDE_NONE; |
tvendov | 0:6435b67ad23c | 200 | static bool graphics_init_end = false; |
tvendov | 0:6435b67ad23c | 201 | |
tvendov | 0:6435b67ad23c | 202 | |
tvendov | 0:6435b67ad23c | 203 | #if (LCD_VDC5_CH0_PANEL == LCD_CH0_PANEL_VKLCD70RT) |
tvendov | 0:6435b67ad23c | 204 | static const key_pic_info_t top_screen_key_tbl[] = { |
tvendov | 0:6435b67ad23c | 205 | /* X Y Width Height Func code */ |
tvendov | 0:6435b67ad23c | 206 | { 40, 468, 102, 106, RGA_FUNC_DRAW_RECTANGLE }, /* RGA Func1 */ |
tvendov | 0:6435b67ad23c | 207 | { 180, 468, 102, 106, RGA_FUNC_DRAW_IMAGE }, /* RGA Func2 */ |
tvendov | 0:6435b67ad23c | 208 | { 322, 468, 102, 106, RGA_FUNC_DISSOLVE }, /* RGA Func3 */ |
tvendov | 0:6435b67ad23c | 209 | { 462, 468, 102, 106, RGA_FUNC_SCROLL }, /* RGA Func4 */ |
tvendov | 0:6435b67ad23c | 210 | { 884, 468, 102, 106, RGA_FUNC_ZOOM }, /* RGA Func5 */ |
tvendov | 0:6435b67ad23c | 211 | { 604, 468, 102, 106, RGA_FUNC_ROTATION }, /* RGA Func6 */ |
tvendov | 0:6435b67ad23c | 212 | { 744, 468, 102, 106, RGA_FUNC_ACCELERATE }, /* RGA Func7 */ |
tvendov | 0:6435b67ad23c | 213 | { VID_X, VID_Y, VID_W, VID_H, RGA_FUNC_VIDEO }, /* RGA FuncN */ |
tvendov | 0:6435b67ad23c | 214 | { CAM_X, CAM_Y, CAM_W, CAM_H, RGA_FUNC_USBCAM }, |
tvendov | 0:6435b67ad23c | 215 | { 0, 0, 0, 0, RGA_FUNC_END } /* table end */ |
tvendov | 0:6435b67ad23c | 216 | }; |
tvendov | 0:6435b67ad23c | 217 | |
tvendov | 0:6435b67ad23c | 218 | static const key_pic_info_t return_key_tbl[] = { |
tvendov | 0:6435b67ad23c | 219 | /* X Y Width Height Func code */ |
tvendov | 0:6435b67ad23c | 220 | { 792, 6, 226, 93, RGA_FUNC_RETURN }, /* Return Top Screen */ |
tvendov | 0:6435b67ad23c | 221 | { 849, 230, 117, 124, RGA_FUNC_AUTO_MANUAL }, /* Interaction_Mode */ |
tvendov | 0:6435b67ad23c | 222 | { 0, 0, 0, 0, RGA_FUNC_END } /* table end */ |
tvendov | 0:6435b67ad23c | 223 | }; |
tvendov | 0:6435b67ad23c | 224 | |
tvendov | 0:6435b67ad23c | 225 | static const key_pic_info_t animetion_timing_key_tbl[] = { |
tvendov | 0:6435b67ad23c | 226 | /* X Y Width Height Func code */ |
tvendov | 0:6435b67ad23c | 227 | { 792, 6, 226, 93, RGA_FUNC_RETURN }, /* Return Top Screen */ |
tvendov | 0:6435b67ad23c | 228 | { 21, 501, 173, 66, RGA_FUNC_ANIME_EASE }, /* ease */ |
tvendov | 0:6435b67ad23c | 229 | { 220, 501, 173, 66, RGA_FUNC_ANIME_LINEAR }, /* linear */ |
tvendov | 0:6435b67ad23c | 230 | { 422, 501, 173, 66, RGA_FUNC_ANIME_EASE_IN }, /* ease-in */ |
tvendov | 0:6435b67ad23c | 231 | { 623, 501, 173, 66, RGA_FUNC_ANIME_EASE_OUT }, /* ease-out */ |
tvendov | 0:6435b67ad23c | 232 | { 823, 501, 173, 66, RGA_FUNC_ANIME_EASE_IN_OUT }, /* ease-in-out */ |
tvendov | 0:6435b67ad23c | 233 | { 0, 0, 0, 0, RGA_FUNC_END } /* table end */ |
tvendov | 0:6435b67ad23c | 234 | }; |
tvendov | 0:6435b67ad23c | 235 | #else |
tvendov | 0:6435b67ad23c | 236 | static const key_pic_info_t top_screen_key_tbl[] = { |
tvendov | 0:6435b67ad23c | 237 | /* X Y Width Height Func code */ |
tvendov | 0:6435b67ad23c | 238 | { 18, 216, 50, 50, RGA_FUNC_DRAW_RECTANGLE }, /* RGA Func1 */ |
tvendov | 0:6435b67ad23c | 239 | { 84, 216, 50, 50, RGA_FUNC_DRAW_IMAGE }, /* RGA Func2 */ |
tvendov | 0:6435b67ad23c | 240 | { 150, 216, 50, 50, RGA_FUNC_DISSOLVE }, /* RGA Func3 */ |
tvendov | 0:6435b67ad23c | 241 | { 216, 216, 50, 50, RGA_FUNC_SCROLL }, /* RGA Func4 */ |
tvendov | 0:6435b67ad23c | 242 | { 414, 216, 50, 50, RGA_FUNC_ZOOM }, /* RGA Func5 */ |
tvendov | 0:6435b67ad23c | 243 | { 282, 216, 50, 50, RGA_FUNC_ROTATION }, /* RGA Func6 */ |
tvendov | 0:6435b67ad23c | 244 | { 348, 216, 50, 50, RGA_FUNC_ACCELERATE }, /* RGA Func7 */ |
tvendov | 0:6435b67ad23c | 245 | { VID_X, VID_Y, VID_W, VID_H, RGA_FUNC_VIDEO }, /* RGA FuncN */ |
tvendov | 0:6435b67ad23c | 246 | { CAM_X, CAM_Y, CAM_W, CAM_H, RGA_FUNC_USBCAM }, |
tvendov | 0:6435b67ad23c | 247 | { 0, 0, 0, 0, RGA_FUNC_END } /* table end */ |
tvendov | 0:6435b67ad23c | 248 | }; |
tvendov | 0:6435b67ad23c | 249 | |
tvendov | 0:6435b67ad23c | 250 | static const key_pic_info_t return_key_tbl[] = { |
tvendov | 0:6435b67ad23c | 251 | /* X Y Width Height Func code */ |
tvendov | 0:6435b67ad23c | 252 | { 372, 6, 104, 40, RGA_FUNC_RETURN }, /* Return Top Screen */ |
tvendov | 0:6435b67ad23c | 253 | { 398, 104, 55, 56, RGA_FUNC_AUTO_MANUAL }, /* Interaction_Mode */ |
tvendov | 0:6435b67ad23c | 254 | { 0, 0, 0, 0, RGA_FUNC_END } /* table end */ |
tvendov | 0:6435b67ad23c | 255 | }; |
tvendov | 0:6435b67ad23c | 256 | |
tvendov | 0:6435b67ad23c | 257 | static const key_pic_info_t animetion_timing_key_tbl[] = { |
tvendov | 0:6435b67ad23c | 258 | /* X Y Width Height Func code */ |
tvendov | 0:6435b67ad23c | 259 | { 372, 6, 104, 40, RGA_FUNC_RETURN }, /* Return Top Screen */ |
tvendov | 0:6435b67ad23c | 260 | { 10, 227, 81, 30, RGA_FUNC_ANIME_EASE }, /* ease */ |
tvendov | 0:6435b67ad23c | 261 | { 103, 227, 81, 30, RGA_FUNC_ANIME_LINEAR }, /* linear */ |
tvendov | 0:6435b67ad23c | 262 | { 198, 227, 81, 30, RGA_FUNC_ANIME_EASE_IN }, /* ease-in */ |
tvendov | 0:6435b67ad23c | 263 | { 292, 227, 81, 30, RGA_FUNC_ANIME_EASE_OUT }, /* ease-out */ |
tvendov | 0:6435b67ad23c | 264 | { 386, 227, 81, 30, RGA_FUNC_ANIME_EASE_IN_OUT }, /* ease-in-out */ |
tvendov | 0:6435b67ad23c | 265 | { 0, 0, 0, 0, RGA_FUNC_END } /* table end */ |
tvendov | 0:6435b67ad23c | 266 | }; |
tvendov | 0:6435b67ad23c | 267 | #endif |
tvendov | 0:6435b67ad23c | 268 | |
tvendov | 0:6435b67ad23c | 269 | static const key_pic_info_t video_screen_key_tbl[] = { |
tvendov | 0:6435b67ad23c | 270 | /* X Y Width Height Func code */ |
tvendov | 0:6435b67ad23c | 271 | {RVID_X, RVID_Y, RVID_W, RVID_H, RGA_FUNC_RETURN }, /* Return Top Screen */ |
tvendov | 0:6435b67ad23c | 272 | { 0, 0, 0, 0, RGA_FUNC_END } /* table end */ |
tvendov | 0:6435b67ad23c | 273 | }; |
tvendov | 0:6435b67ad23c | 274 | |
tvendov | 0:6435b67ad23c | 275 | static const key_pic_info_t cam_screen_key_tbl[] = { |
tvendov | 0:6435b67ad23c | 276 | /* X Y Width Height Func code */ |
tvendov | 0:6435b67ad23c | 277 | {RCAM_X, RCAM_Y, RCAM_W, RCAM_H, RGA_FUNC_RETURN }, /* Return Top Screen */ |
tvendov | 0:6435b67ad23c | 278 | { 0, 0, 0, 0, RGA_FUNC_END } /* table end */ |
tvendov | 0:6435b67ad23c | 279 | }; |
tvendov | 0:6435b67ad23c | 280 | |
tvendov | 0:6435b67ad23c | 281 | #ifdef __SOFT_JPEG__ |
tvendov | 0:6435b67ad23c | 282 | METHODDEF(void) |
tvendov | 0:6435b67ad23c | 283 | my_error_exit (j_common_ptr cinfo) |
tvendov | 0:6435b67ad23c | 284 | { |
tvendov | 0:6435b67ad23c | 285 | /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ |
tvendov | 0:6435b67ad23c | 286 | my_error_ptr myerr = (my_error_ptr) cinfo->err; |
tvendov | 0:6435b67ad23c | 287 | |
tvendov | 0:6435b67ad23c | 288 | /* Always display the message. */ |
tvendov | 0:6435b67ad23c | 289 | /* We could postpone this until after returning, if we chose. */ |
tvendov | 0:6435b67ad23c | 290 | (*cinfo->err->output_message) (cinfo); |
tvendov | 0:6435b67ad23c | 291 | |
tvendov | 0:6435b67ad23c | 292 | /* Return control to the setjmp point */ |
tvendov | 0:6435b67ad23c | 293 | longjmp(myerr->setjmp_buffer, 1); |
tvendov | 0:6435b67ad23c | 294 | } |
tvendov | 0:6435b67ad23c | 295 | #endif |
tvendov | 0:6435b67ad23c | 296 | |
tvendov | 0:6435b67ad23c | 297 | |
tvendov | 0:6435b67ad23c | 298 | /****** LCD ******/ |
tvendov | 0:6435b67ad23c | 299 | static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type) { |
tvendov | 0:6435b67ad23c | 300 | bool plug = Cam.plugged(); |
tvendov | 0:6435b67ad23c | 301 | /* Interrupt callback function for Vsync interruption */ |
tvendov | 0:6435b67ad23c | 302 | if (vsync_count > 0) { |
tvendov | 0:6435b67ad23c | 303 | vsync_count--; |
tvendov | 0:6435b67ad23c | 304 | } |
tvendov | 0:6435b67ad23c | 305 | |
tvendov | 0:6435b67ad23c | 306 | if(slide_screen != DisplayBase::SLIDE_NONE) |
tvendov | 0:6435b67ad23c | 307 | { |
tvendov | 0:6435b67ad23c | 308 | Display.Graphics_Read_Change_More(DisplayBase::GRAPHICS_LAYER_2, |
tvendov | 0:6435b67ad23c | 309 | (void *)frame_buffer_info.buffer_address[frame_buffer_info.draw_buffer_index], FRAME_BUFFER_STRIDE, (DisplayBase::slide_t *)&slide_screen); |
tvendov | 0:6435b67ad23c | 310 | } |
tvendov | 0:6435b67ad23c | 311 | |
tvendov | 0:6435b67ad23c | 312 | /* Read NOSIGNAL bit */ |
tvendov | 0:6435b67ad23c | 313 | video_signal = (RZA_IO_RegRead_16(&DVDEC0.VSYNCSR, NOSIGNAL, MASK(NOSIGNAL)))? false : true; |
tvendov | 0:6435b67ad23c | 314 | /* Read USB ATTCH DTTCH signals */ |
tvendov | 0:6435b67ad23c | 315 | if(plug ^ usb_plug) |
tvendov | 0:6435b67ad23c | 316 | { |
tvendov | 0:6435b67ad23c | 317 | try_cam_connect = plug; |
tvendov | 0:6435b67ad23c | 318 | usb_plug = plug; |
tvendov | 0:6435b67ad23c | 319 | } |
tvendov | 0:6435b67ad23c | 320 | } |
tvendov | 0:6435b67ad23c | 321 | |
tvendov | 0:6435b67ad23c | 322 | static void Wait_Vsync(const int32_t wait_count) { |
tvendov | 0:6435b67ad23c | 323 | /* Wait for the specified number of times Vsync occurs */ |
tvendov | 0:6435b67ad23c | 324 | vsync_count = wait_count; |
tvendov | 0:6435b67ad23c | 325 | while (vsync_count > 0) { |
tvendov | 0:6435b67ad23c | 326 | /* Do nothing */ |
tvendov | 0:6435b67ad23c | 327 | } |
tvendov | 0:6435b67ad23c | 328 | } |
tvendov | 0:6435b67ad23c | 329 | |
tvendov | 0:6435b67ad23c | 330 | static void IntCallbackFunc_Vfield_0(DisplayBase::int_type_t int_type) { |
tvendov | 0:6435b67ad23c | 331 | /*DisplayBase::graphics_error_t error; |
tvendov | 0:6435b67ad23c | 332 | |
tvendov | 0:6435b67ad23c | 333 | // Interrupt callback function |
tvendov | 0:6435b67ad23c | 334 | if (vfield_count_0 == 0) { |
tvendov | 0:6435b67ad23c | 335 | vfield_count_0 = 1; |
tvendov | 0:6435b67ad23c | 336 | error = Display.Video_Stop( DisplayBase::VIDEO_INPUT_CHANNEL_0 ); |
tvendov | 0:6435b67ad23c | 337 | if (error != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 338 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 339 | mbed_die(); |
tvendov | 0:6435b67ad23c | 340 | } |
tvendov | 0:6435b67ad23c | 341 | } else { |
tvendov | 0:6435b67ad23c | 342 | ; |
tvendov | 0:6435b67ad23c | 343 | }*/ |
tvendov | 0:6435b67ad23c | 344 | } |
tvendov | 0:6435b67ad23c | 345 | |
tvendov | 0:6435b67ad23c | 346 | static void Init_LCD_Display(void) { |
tvendov | 0:6435b67ad23c | 347 | DisplayBase::graphics_error_t error; |
tvendov | 0:6435b67ad23c | 348 | DisplayBase::lcd_config_t lcd_config; |
tvendov | 0:6435b67ad23c | 349 | |
tvendov | 0:6435b67ad23c | 350 | #if (LCD_VDC5_CH0_PANEL == LCD_CH0_PANEL_VKLCD70RT) |
tvendov | 0:6435b67ad23c | 351 | PinName lvds_pin[] = {P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0}; |
tvendov | 0:6435b67ad23c | 352 | Display.Graphics_Lvds_Port_Init(lvds_pin, sizeof(lvds_pin)/sizeof(lvds_pin[0])); |
tvendov | 0:6435b67ad23c | 353 | #else /* D15, D14, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0, DE, CLK */ |
tvendov | 0:6435b67ad23c | 354 | PinName lcd_pin[] = {P4_7, P4_6, P4_5, P4_4, P4_3, P4_2, P4_1, P4_0, P3_15, P3_14, P3_13, P3_12, P3_11, P3_10, P3_9, P3_8, P3_1, P3_0}; |
tvendov | 0:6435b67ad23c | 355 | Display.Graphics_Lcd_Port_Init(lcd_pin, sizeof(lcd_pin)/sizeof(lcd_pin[0])); |
tvendov | 0:6435b67ad23c | 356 | #endif |
tvendov | 0:6435b67ad23c | 357 | |
tvendov | 0:6435b67ad23c | 358 | |
tvendov | 0:6435b67ad23c | 359 | /* Graphics initialization process */ |
tvendov | 0:6435b67ad23c | 360 | lcd_config = LcdCfgTbl; |
tvendov | 0:6435b67ad23c | 361 | error = Display.Graphics_init(&lcd_config); |
tvendov | 0:6435b67ad23c | 362 | if (error != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 363 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 364 | mbed_die(); |
tvendov | 0:6435b67ad23c | 365 | } |
tvendov | 0:6435b67ad23c | 366 | |
tvendov | 0:6435b67ad23c | 367 | /* Interrupt callback function setting (Vsync signal output from scaler 0) */ |
tvendov | 0:6435b67ad23c | 368 | error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, IntCallbackFunc_LoVsync); |
tvendov | 0:6435b67ad23c | 369 | if (error != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 370 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 371 | mbed_die(); |
tvendov | 0:6435b67ad23c | 372 | } |
tvendov | 0:6435b67ad23c | 373 | |
tvendov | 0:6435b67ad23c | 374 | graphics_init_end = true; |
tvendov | 0:6435b67ad23c | 375 | } |
tvendov | 0:6435b67ad23c | 376 | |
tvendov | 0:6435b67ad23c | 377 | /****** Video ******/ |
tvendov | 0:6435b67ad23c | 378 | static void Init_Video(void) { |
tvendov | 0:6435b67ad23c | 379 | DisplayBase::graphics_error_t error; |
tvendov | 0:6435b67ad23c | 380 | |
tvendov | 0:6435b67ad23c | 381 | /* Graphics initialization process */ |
tvendov | 0:6435b67ad23c | 382 | if (graphics_init_end == false) { |
tvendov | 0:6435b67ad23c | 383 | /* When not initializing LCD, this processing is needed. */ |
tvendov | 0:6435b67ad23c | 384 | error = Display.Graphics_init(NULL); |
tvendov | 0:6435b67ad23c | 385 | if (error != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 386 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 387 | mbed_die(); |
tvendov | 0:6435b67ad23c | 388 | } |
tvendov | 0:6435b67ad23c | 389 | graphics_init_end = true; |
tvendov | 0:6435b67ad23c | 390 | } |
tvendov | 0:6435b67ad23c | 391 | |
tvendov | 0:6435b67ad23c | 392 | error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_VDEC, NULL); |
tvendov | 0:6435b67ad23c | 393 | if( error != DisplayBase::GRAPHICS_OK ) { |
tvendov | 0:6435b67ad23c | 394 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 395 | mbed_die(); |
tvendov | 0:6435b67ad23c | 396 | } |
tvendov | 0:6435b67ad23c | 397 | |
tvendov | 0:6435b67ad23c | 398 | /* Interrupt callback function setting (Field end signal for recording function in scaler 0) */ |
tvendov | 0:6435b67ad23c | 399 | error = Display.Graphics_Irq_Handler_Set(VIDEO_INT_TYPE, 0, IntCallbackFunc_Vfield_0); |
tvendov | 0:6435b67ad23c | 400 | if (error != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 401 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 402 | mbed_die(); |
tvendov | 0:6435b67ad23c | 403 | } |
tvendov | 0:6435b67ad23c | 404 | } |
tvendov | 0:6435b67ad23c | 405 | |
tvendov | 0:6435b67ad23c | 406 | static void Start_Video(DisplayBase::video_input_channel_t ch, uint8_t * p_frame_buffer, |
tvendov | 0:6435b67ad23c | 407 | uint16_t pos_x, uint16_t pos_y, uint16_t width, uint16_t height) { |
tvendov | 0:6435b67ad23c | 408 | DisplayBase::graphics_error_t error; |
tvendov | 0:6435b67ad23c | 409 | //uint8_t * p_buf; |
tvendov | 0:6435b67ad23c | 410 | |
tvendov | 0:6435b67ad23c | 411 | //p_buf = p_frame_buffer + (FRAME_BUFFER_BYTE_PER_PIXEL * pos_x) + (FRAME_BUFFER_STRIDE * pos_y); |
tvendov | 0:6435b67ad23c | 412 | |
tvendov | 0:6435b67ad23c | 413 | /* Video capture setting (progressive form fixed) */ |
tvendov | 0:6435b67ad23c | 414 | error = Display.Video_Write_Setting( |
tvendov | 0:6435b67ad23c | 415 | ch, |
tvendov | 0:6435b67ad23c | 416 | COL_SYS, |
tvendov | 0:6435b67ad23c | 417 | p_frame_buffer, //p_buf, |
tvendov | 0:6435b67ad23c | 418 | FRAME_BUFFER_STRIDE, |
tvendov | 0:6435b67ad23c | 419 | VIDEO_FORMAT, |
tvendov | 0:6435b67ad23c | 420 | WR_RD_WRSWA, |
tvendov | 0:6435b67ad23c | 421 | height, //(height & ~7u), /* A multiple of 8 */ |
tvendov | 0:6435b67ad23c | 422 | width //(width & ~15u) /* A multiple of 16 */ |
tvendov | 0:6435b67ad23c | 423 | ); |
tvendov | 0:6435b67ad23c | 424 | if (error != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 425 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 426 | mbed_die(); |
tvendov | 0:6435b67ad23c | 427 | } |
tvendov | 0:6435b67ad23c | 428 | |
tvendov | 0:6435b67ad23c | 429 | /* Video write process start */ |
tvendov | 0:6435b67ad23c | 430 | error = Display.Video_Start(ch); |
tvendov | 0:6435b67ad23c | 431 | if (error != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 432 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 433 | mbed_die(); |
tvendov | 0:6435b67ad23c | 434 | } |
tvendov | 0:6435b67ad23c | 435 | |
tvendov | 0:6435b67ad23c | 436 | error = Display.Video_Stop( DisplayBase::VIDEO_INPUT_CHANNEL_0 ); |
tvendov | 0:6435b67ad23c | 437 | if (error != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 438 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 439 | mbed_die(); |
tvendov | 0:6435b67ad23c | 440 | } |
tvendov | 0:6435b67ad23c | 441 | } |
tvendov | 0:6435b67ad23c | 442 | |
tvendov | 0:6435b67ad23c | 443 | static void Start_LCD_Display(uint8_t * p_buf) { |
tvendov | 0:6435b67ad23c | 444 | DisplayBase::rect_t rect; |
tvendov | 0:6435b67ad23c | 445 | |
tvendov | 0:6435b67ad23c | 446 | rect.vs = 0; |
tvendov | 0:6435b67ad23c | 447 | rect.vw = LCD_PIXEL_HEIGHT; |
tvendov | 0:6435b67ad23c | 448 | rect.hs = 0; |
tvendov | 0:6435b67ad23c | 449 | rect.hw = LCD_PIXEL_WIDTH; |
tvendov | 0:6435b67ad23c | 450 | Display.Graphics_Read_Setting( |
tvendov | 0:6435b67ad23c | 451 | DisplayBase::GRAPHICS_LAYER_0, |
tvendov | 0:6435b67ad23c | 452 | (void *)user_video_buffer, |
tvendov | 0:6435b67ad23c | 453 | FRAME_BUFFER_STRIDE, |
tvendov | 0:6435b67ad23c | 454 | GRAPHICS_FORMAT, |
tvendov | 0:6435b67ad23c | 455 | WR_RD_WRSWA, |
tvendov | 0:6435b67ad23c | 456 | &rect |
tvendov | 0:6435b67ad23c | 457 | ); |
tvendov | 0:6435b67ad23c | 458 | |
tvendov | 0:6435b67ad23c | 459 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0); |
tvendov | 0:6435b67ad23c | 460 | |
tvendov | 0:6435b67ad23c | 461 | rect.vs = 0; |
tvendov | 0:6435b67ad23c | 462 | rect.vw = LCD_PIXEL_HEIGHT; |
tvendov | 0:6435b67ad23c | 463 | rect.hs = 0; |
tvendov | 0:6435b67ad23c | 464 | rect.hw = LCD_PIXEL_WIDTH; |
tvendov | 0:6435b67ad23c | 465 | Display.Graphics_Read_Setting( |
tvendov | 0:6435b67ad23c | 466 | DisplayBase::GRAPHICS_LAYER_2, |
tvendov | 0:6435b67ad23c | 467 | (void *)p_buf, |
tvendov | 0:6435b67ad23c | 468 | FRAME_BUFFER_STRIDE, |
tvendov | 0:6435b67ad23c | 469 | GRAPHICS_FORMAT, |
tvendov | 0:6435b67ad23c | 470 | WR_RD_WRSWA, |
tvendov | 0:6435b67ad23c | 471 | &rect |
tvendov | 0:6435b67ad23c | 472 | ); |
tvendov | 0:6435b67ad23c | 473 | |
tvendov | 0:6435b67ad23c | 474 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2); |
tvendov | 0:6435b67ad23c | 475 | } |
tvendov | 0:6435b67ad23c | 476 | |
tvendov | 0:6435b67ad23c | 477 | static void Update_LCD_Display(frame_buffer_t * frmbuf_info) { |
tvendov | 0:6435b67ad23c | 478 | Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_2, |
tvendov | 0:6435b67ad23c | 479 | (void *)frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index]); |
tvendov | 0:6435b67ad23c | 480 | Wait_Vsync(1); |
tvendov | 0:6435b67ad23c | 481 | } |
tvendov | 0:6435b67ad23c | 482 | |
tvendov | 0:6435b67ad23c | 483 | static void Update_VIDEO_Display(frame_buffer_t * frmbuf_info) { |
tvendov | 0:6435b67ad23c | 484 | Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0, |
tvendov | 0:6435b67ad23c | 485 | (void *)frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index]); |
tvendov | 0:6435b67ad23c | 486 | Wait_Vsync(1); |
tvendov | 0:6435b67ad23c | 487 | } |
tvendov | 0:6435b67ad23c | 488 | |
tvendov | 0:6435b67ad23c | 489 | static void Swap_FrameBuffer(frame_buffer_t * frmbuf_info) { |
tvendov | 0:6435b67ad23c | 490 | if (frmbuf_info->draw_buffer_index == 1) { |
tvendov | 0:6435b67ad23c | 491 | frmbuf_info->draw_buffer_index = 0; |
tvendov | 0:6435b67ad23c | 492 | } else { |
tvendov | 0:6435b67ad23c | 493 | frmbuf_info->draw_buffer_index = 1; |
tvendov | 0:6435b67ad23c | 494 | } |
tvendov | 0:6435b67ad23c | 495 | } |
tvendov | 0:6435b67ad23c | 496 | |
tvendov | 0:6435b67ad23c | 497 | |
tvendov | 0:6435b67ad23c | 498 | /****** Touch ******/ |
tvendov | 0:6435b67ad23c | 499 | static func_code_t Scan_Key(const key_pic_info_t * key_tbl, const uint32_t pos_x, const uint32_t pos_y) { |
tvendov | 0:6435b67ad23c | 500 | func_code_t ret = RGA_FUNC_NON; |
tvendov | 0:6435b67ad23c | 501 | |
tvendov | 0:6435b67ad23c | 502 | while (ret == RGA_FUNC_NON) { |
tvendov | 0:6435b67ad23c | 503 | if (key_tbl->func_code == RGA_FUNC_END) { |
tvendov | 0:6435b67ad23c | 504 | break; |
tvendov | 0:6435b67ad23c | 505 | } |
tvendov | 0:6435b67ad23c | 506 | /* Check the range of the X position */ |
tvendov | 0:6435b67ad23c | 507 | if ((pos_x >= key_tbl->pic_pos_x) && (pos_x <= (key_tbl->pic_pos_x + key_tbl->pic_width))) { |
tvendov | 0:6435b67ad23c | 508 | /* Check the range of the Y position */ |
tvendov | 0:6435b67ad23c | 509 | if ((pos_y >= key_tbl->pic_pos_y) && (pos_y <= (key_tbl->pic_pos_y + key_tbl->pic_height))) { |
tvendov | 0:6435b67ad23c | 510 | /* Decide the func code. */ |
tvendov | 0:6435b67ad23c | 511 | ret = key_tbl->func_code; |
tvendov | 0:6435b67ad23c | 512 | } |
tvendov | 0:6435b67ad23c | 513 | } |
tvendov | 0:6435b67ad23c | 514 | key_tbl++; |
tvendov | 0:6435b67ad23c | 515 | } |
tvendov | 0:6435b67ad23c | 516 | |
tvendov | 0:6435b67ad23c | 517 | return ret; |
tvendov | 0:6435b67ad23c | 518 | } |
tvendov | 0:6435b67ad23c | 519 | |
tvendov | 0:6435b67ad23c | 520 | static int GetCoordinates(touch_pos_t * p_touch) { |
tvendov | 0:6435b67ad23c | 521 | touch_pos_t * wk_touch; |
tvendov | 0:6435b67ad23c | 522 | int count = 0; |
tvendov | 0:6435b67ad23c | 523 | int i; |
tvendov | 0:6435b67ad23c | 524 | |
tvendov | 0:6435b67ad23c | 525 | if (p_touch != NULL) |
tvendov | 0:6435b67ad23c | 526 | { |
tvendov | 0:6435b67ad23c | 527 | wk_touch = p_touch; |
tvendov | 0:6435b67ad23c | 528 | wk_touch->x = 0; |
tvendov | 0:6435b67ad23c | 529 | wk_touch->y = 0; |
tvendov | 0:6435b67ad23c | 530 | wk_touch->touch_down = false; |
tvendov | 0:6435b67ad23c | 531 | |
tvendov | 0:6435b67ad23c | 532 | wk_touch->touch_down = STMPE811.Handle_touch((uint8_t*)&count); |
tvendov | 0:6435b67ad23c | 533 | if(count) |
tvendov | 0:6435b67ad23c | 534 | { |
tvendov | 0:6435b67ad23c | 535 | wk_touch->x = STMPE811.x; |
tvendov | 0:6435b67ad23c | 536 | wk_touch->y = STMPE811.y; |
tvendov | 0:6435b67ad23c | 537 | } |
tvendov | 0:6435b67ad23c | 538 | } |
tvendov | 0:6435b67ad23c | 539 | |
tvendov | 0:6435b67ad23c | 540 | return count; |
tvendov | 0:6435b67ad23c | 541 | } |
tvendov | 0:6435b67ad23c | 542 | |
tvendov | 0:6435b67ad23c | 543 | /****** Efect ******/ |
tvendov | 0:6435b67ad23c | 544 | static void Exe_RGA_Func(func_code_t func_name, frame_buffer_t* frmbuf_info) { |
tvendov | 0:6435b67ad23c | 545 | uint8_t touch_num = 0; |
tvendov | 0:6435b67ad23c | 546 | touch_pos_t touch_pos[TOUCH_NUM]; |
tvendov | 0:6435b67ad23c | 547 | |
tvendov | 0:6435b67ad23c | 548 | switch (func_name) { |
tvendov | 0:6435b67ad23c | 549 | case RGA_FUNC_DRAW_RECTANGLE: |
tvendov | 0:6435b67ad23c | 550 | bool key_on = false; |
tvendov | 0:6435b67ad23c | 551 | bool first = false; |
tvendov | 0:6435b67ad23c | 552 | bool second = false; |
tvendov | 0:6435b67ad23c | 553 | int cnt = 0; |
tvendov | 0:6435b67ad23c | 554 | int color_cnt = 0; |
tvendov | 0:6435b67ad23c | 555 | int x_0 = 0; |
tvendov | 0:6435b67ad23c | 556 | int y_0 = 0; |
tvendov | 0:6435b67ad23c | 557 | draw_rectangle_pos_t pos_tbl[DRAW_RECTANGLE_CNT_MAX] = {0}; |
tvendov | 0:6435b67ad23c | 558 | |
tvendov | 0:6435b67ad23c | 559 | pos_tbl[0].style = "#FF0000"; /* red */ |
tvendov | 0:6435b67ad23c | 560 | pos_tbl[1].style = "#00FF00"; /* green */ |
tvendov | 0:6435b67ad23c | 561 | pos_tbl[2].style = "#0000FF"; /* blue */ |
tvendov | 0:6435b67ad23c | 562 | pos_tbl[3].style = "#000000"; /* black */ |
tvendov | 0:6435b67ad23c | 563 | |
tvendov | 0:6435b67ad23c | 564 | while (1) { |
tvendov | 0:6435b67ad23c | 565 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 566 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 567 | if (touch_num != 0) |
tvendov | 0:6435b67ad23c | 568 | { |
tvendov | 0:6435b67ad23c | 569 | if (Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 570 | break; |
tvendov | 0:6435b67ad23c | 571 | } |
tvendov | 0:6435b67ad23c | 572 | if(touch_pos[0].touch_down) { |
tvendov | 0:6435b67ad23c | 573 | if(!key_on) { |
tvendov | 0:6435b67ad23c | 574 | pos_tbl[cnt].x = x_0 = touch_pos[0].x; |
tvendov | 0:6435b67ad23c | 575 | pos_tbl[cnt].y = y_0 = touch_pos[0].y; |
tvendov | 0:6435b67ad23c | 576 | pos_tbl[cnt].w = 0; |
tvendov | 0:6435b67ad23c | 577 | pos_tbl[cnt].h = 0; |
tvendov | 0:6435b67ad23c | 578 | if(cnt == 0) { |
tvendov | 0:6435b67ad23c | 579 | for (color_cnt = 1; color_cnt < DRAW_RECTANGLE_CNT_MAX; color_cnt++) { |
tvendov | 0:6435b67ad23c | 580 | pos_tbl[color_cnt].x = 0; |
tvendov | 0:6435b67ad23c | 581 | pos_tbl[color_cnt].y = 0; |
tvendov | 0:6435b67ad23c | 582 | pos_tbl[color_cnt].w = 0; |
tvendov | 0:6435b67ad23c | 583 | pos_tbl[color_cnt].h = 0; |
tvendov | 0:6435b67ad23c | 584 | } |
tvendov | 0:6435b67ad23c | 585 | } |
tvendov | 0:6435b67ad23c | 586 | key_on = true; |
tvendov | 0:6435b67ad23c | 587 | } |
tvendov | 0:6435b67ad23c | 588 | else { |
tvendov | 0:6435b67ad23c | 589 | if(touch_pos[0].x >= x_0) { |
tvendov | 0:6435b67ad23c | 590 | pos_tbl[cnt].x = x_0; |
tvendov | 0:6435b67ad23c | 591 | pos_tbl[cnt].w = touch_pos[0].x - pos_tbl[cnt].x; |
tvendov | 0:6435b67ad23c | 592 | } |
tvendov | 0:6435b67ad23c | 593 | else { |
tvendov | 0:6435b67ad23c | 594 | pos_tbl[cnt].x = touch_pos[0].x; |
tvendov | 0:6435b67ad23c | 595 | pos_tbl[cnt].w = x_0 - touch_pos[0].x; |
tvendov | 0:6435b67ad23c | 596 | } |
tvendov | 0:6435b67ad23c | 597 | |
tvendov | 0:6435b67ad23c | 598 | if(touch_pos[0].y >= y_0) { |
tvendov | 0:6435b67ad23c | 599 | pos_tbl[cnt].y = y_0; |
tvendov | 0:6435b67ad23c | 600 | pos_tbl[cnt].h = touch_pos[0].y - pos_tbl[cnt].y; |
tvendov | 0:6435b67ad23c | 601 | } |
tvendov | 0:6435b67ad23c | 602 | else { |
tvendov | 0:6435b67ad23c | 603 | pos_tbl[cnt].y = touch_pos[0].y; |
tvendov | 0:6435b67ad23c | 604 | pos_tbl[cnt].h = y_0 - touch_pos[0].y; |
tvendov | 0:6435b67ad23c | 605 | } |
tvendov | 0:6435b67ad23c | 606 | } |
tvendov | 0:6435b67ad23c | 607 | |
tvendov | 0:6435b67ad23c | 608 | } |
tvendov | 0:6435b67ad23c | 609 | else { |
tvendov | 0:6435b67ad23c | 610 | if(key_on) { |
tvendov | 0:6435b67ad23c | 611 | if(touch_pos[0].x >= x_0) { |
tvendov | 0:6435b67ad23c | 612 | pos_tbl[cnt].x = x_0; |
tvendov | 0:6435b67ad23c | 613 | pos_tbl[cnt].w = touch_pos[0].x - pos_tbl[cnt].x; |
tvendov | 0:6435b67ad23c | 614 | } |
tvendov | 0:6435b67ad23c | 615 | else { |
tvendov | 0:6435b67ad23c | 616 | pos_tbl[cnt].x = touch_pos[0].x; |
tvendov | 0:6435b67ad23c | 617 | pos_tbl[cnt].w = x_0 - touch_pos[0].x; |
tvendov | 0:6435b67ad23c | 618 | } |
tvendov | 0:6435b67ad23c | 619 | |
tvendov | 0:6435b67ad23c | 620 | if(touch_pos[0].y >= y_0) { |
tvendov | 0:6435b67ad23c | 621 | pos_tbl[cnt].y = y_0; |
tvendov | 0:6435b67ad23c | 622 | pos_tbl[cnt].h = touch_pos[0].y - pos_tbl[cnt].y; |
tvendov | 0:6435b67ad23c | 623 | } |
tvendov | 0:6435b67ad23c | 624 | else { |
tvendov | 0:6435b67ad23c | 625 | pos_tbl[cnt].y = touch_pos[0].y; |
tvendov | 0:6435b67ad23c | 626 | pos_tbl[cnt].h = y_0 - touch_pos[0].y; |
tvendov | 0:6435b67ad23c | 627 | } |
tvendov | 0:6435b67ad23c | 628 | |
tvendov | 0:6435b67ad23c | 629 | cnt++; |
tvendov | 0:6435b67ad23c | 630 | if (cnt == DRAW_RECTANGLE_CNT_MAX) |
tvendov | 0:6435b67ad23c | 631 | cnt = 0; |
tvendov | 0:6435b67ad23c | 632 | key_on = false; |
tvendov | 0:6435b67ad23c | 633 | } |
tvendov | 0:6435b67ad23c | 634 | else |
tvendov | 0:6435b67ad23c | 635 | { |
tvendov | 0:6435b67ad23c | 636 | |
tvendov | 0:6435b67ad23c | 637 | } |
tvendov | 0:6435b67ad23c | 638 | } |
tvendov | 0:6435b67ad23c | 639 | } |
tvendov | 0:6435b67ad23c | 640 | /* Draw screen */ |
tvendov | 0:6435b67ad23c | 641 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 642 | RGA_Func_DrawRectangle(frmbuf_info, pos_tbl, DRAW_RECTANGLE_CNT_MAX); |
tvendov | 0:6435b67ad23c | 643 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 644 | } |
tvendov | 0:6435b67ad23c | 645 | break; |
tvendov | 0:6435b67ad23c | 646 | case RGA_FUNC_DRAW_IMAGE: |
tvendov | 0:6435b67ad23c | 647 | int center_pos_x = 320; |
tvendov | 0:6435b67ad23c | 648 | int center_pos_y = 110; |
tvendov | 0:6435b67ad23c | 649 | while (1) { |
tvendov | 0:6435b67ad23c | 650 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 651 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 652 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 653 | if (Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 654 | break; |
tvendov | 0:6435b67ad23c | 655 | } |
tvendov | 0:6435b67ad23c | 656 | center_pos_x = touch_pos[0].x; |
tvendov | 0:6435b67ad23c | 657 | center_pos_y = touch_pos[0].y; |
tvendov | 0:6435b67ad23c | 658 | } |
tvendov | 0:6435b67ad23c | 659 | /* Draw screen */ |
tvendov | 0:6435b67ad23c | 660 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 661 | RGA_Func_DrawImage(frmbuf_info, center_pos_x, center_pos_y); |
tvendov | 0:6435b67ad23c | 662 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 663 | } |
tvendov | 0:6435b67ad23c | 664 | break; |
tvendov | 0:6435b67ad23c | 665 | case RGA_FUNC_DISSOLVE: |
tvendov | 0:6435b67ad23c | 666 | float32_t work_alpha = 0.0f; |
tvendov | 0:6435b67ad23c | 667 | uint16_t xa = LCD_PIXEL_WIDTH; |
tvendov | 0:6435b67ad23c | 668 | |
tvendov | 0:6435b67ad23c | 669 | RGA_Func_Dissolve(frmbuf_info, 0.0f, Interaction_mode); |
tvendov | 0:6435b67ad23c | 670 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 671 | RGA_Func_Dissolve(frmbuf_info, 0.0f, Interaction_mode); |
tvendov | 0:6435b67ad23c | 672 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 673 | memcpy(FASTR_RENDER, (uint8_t*)Board_jpg_File, ROTRNDR_SIZE); |
tvendov | 0:6435b67ad23c | 674 | while (1) { |
tvendov | 0:6435b67ad23c | 675 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 676 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 677 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 678 | func_code_t func_code; |
tvendov | 0:6435b67ad23c | 679 | |
tvendov | 0:6435b67ad23c | 680 | func_code = Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y); |
tvendov | 0:6435b67ad23c | 681 | if (func_code == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 682 | break; |
tvendov | 0:6435b67ad23c | 683 | } |
tvendov | 0:6435b67ad23c | 684 | |
tvendov | 0:6435b67ad23c | 685 | if(!touch_pos[0].touch_down && (func_code == RGA_FUNC_AUTO_MANUAL)) |
tvendov | 0:6435b67ad23c | 686 | Interaction_mode = (Interaction_mode == AUTO_INTERACT)? MANUAL_INTERACT : AUTO_INTERACT; |
tvendov | 0:6435b67ad23c | 687 | else |
tvendov | 0:6435b67ad23c | 688 | work_alpha = (float32_t)touch_pos[0].x / (float32_t)(LCD_PIXEL_WIDTH); |
tvendov | 0:6435b67ad23c | 689 | } |
tvendov | 0:6435b67ad23c | 690 | if(Interaction_mode == AUTO_INTERACT) |
tvendov | 0:6435b67ad23c | 691 | { |
tvendov | 0:6435b67ad23c | 692 | xa= (xa >= LCD_PIXEL_WIDTH)? 0: (xa+1); |
tvendov | 0:6435b67ad23c | 693 | work_alpha = (float32_t)xa / (float32_t)(LCD_PIXEL_WIDTH); |
tvendov | 0:6435b67ad23c | 694 | } |
tvendov | 0:6435b67ad23c | 695 | /* Draw screen */ |
tvendov | 0:6435b67ad23c | 696 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 697 | RGA_Func_Diss(frmbuf_info, work_alpha, Interaction_mode, (graphics_image_t*)FASTR_RENDER); |
tvendov | 0:6435b67ad23c | 698 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 699 | } |
tvendov | 0:6435b67ad23c | 700 | break; |
tvendov | 0:6435b67ad23c | 701 | case RGA_FUNC_SCROLL: |
tvendov | 0:6435b67ad23c | 702 | int work_width_pos = 0; |
tvendov | 0:6435b67ad23c | 703 | uint16_t xs = LCD_PIXEL_WIDTH; |
tvendov | 0:6435b67ad23c | 704 | |
tvendov | 0:6435b67ad23c | 705 | RGA_Func_Scroll(frmbuf_info, 0, Interaction_mode); |
tvendov | 0:6435b67ad23c | 706 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 707 | RGA_Func_Scroll(frmbuf_info, 0, Interaction_mode); |
tvendov | 0:6435b67ad23c | 708 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 709 | memcpy(FASTR_RENDER, (uint8_t*)Board_wide_jpg_File, SCRRNDR_SIZE); |
tvendov | 0:6435b67ad23c | 710 | while (1) { |
tvendov | 0:6435b67ad23c | 711 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 712 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 713 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 714 | func_code_t func_code; |
tvendov | 0:6435b67ad23c | 715 | |
tvendov | 0:6435b67ad23c | 716 | func_code = Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y); |
tvendov | 0:6435b67ad23c | 717 | if (func_code == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 718 | break; |
tvendov | 0:6435b67ad23c | 719 | } |
tvendov | 0:6435b67ad23c | 720 | |
tvendov | 0:6435b67ad23c | 721 | if(!touch_pos[0].touch_down && (func_code == RGA_FUNC_AUTO_MANUAL)) |
tvendov | 0:6435b67ad23c | 722 | Interaction_mode = (Interaction_mode == AUTO_INTERACT)? MANUAL_INTERACT : AUTO_INTERACT; |
tvendov | 0:6435b67ad23c | 723 | else |
tvendov | 0:6435b67ad23c | 724 | work_width_pos = SCROLL_MAX_NUM * ((float32_t)touch_pos[0].x / (float32_t)(LCD_PIXEL_WIDTH)); |
tvendov | 0:6435b67ad23c | 725 | } |
tvendov | 0:6435b67ad23c | 726 | if(Interaction_mode == AUTO_INTERACT) |
tvendov | 0:6435b67ad23c | 727 | { |
tvendov | 0:6435b67ad23c | 728 | xs= (xs >= LCD_PIXEL_WIDTH)? 0: (xs+1); |
tvendov | 0:6435b67ad23c | 729 | work_width_pos = SCROLL_MAX_NUM * ((float32_t)xs / (float32_t)(LCD_PIXEL_WIDTH)); |
tvendov | 0:6435b67ad23c | 730 | } |
tvendov | 0:6435b67ad23c | 731 | /* Draw screen */ |
tvendov | 0:6435b67ad23c | 732 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 733 | RGA_Func_Scr(frmbuf_info, work_width_pos, Interaction_mode, (graphics_image_t*)FASTR_RENDER); |
tvendov | 0:6435b67ad23c | 734 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 735 | } |
tvendov | 0:6435b67ad23c | 736 | break; |
tvendov | 0:6435b67ad23c | 737 | case RGA_FUNC_ZOOM: |
tvendov | 0:6435b67ad23c | 738 | int work_height_pos = ZOOM_MAX_NUM; |
tvendov | 0:6435b67ad23c | 739 | uint16_t xz = LCD_PIXEL_WIDTH; |
tvendov | 0:6435b67ad23c | 740 | |
tvendov | 0:6435b67ad23c | 741 | RGA_Func_Zoom(frmbuf_info, 0, Interaction_mode); |
tvendov | 0:6435b67ad23c | 742 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 743 | RGA_Func_Zoom(frmbuf_info, 0, Interaction_mode); |
tvendov | 0:6435b67ad23c | 744 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 745 | memcpy(FASTR_RENDER, (uint8_t*)Board_jpg_File, ROTRNDR_SIZE); |
tvendov | 0:6435b67ad23c | 746 | while (1) { |
tvendov | 0:6435b67ad23c | 747 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 748 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 749 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 750 | func_code_t func_code; |
tvendov | 0:6435b67ad23c | 751 | |
tvendov | 0:6435b67ad23c | 752 | func_code = Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y); |
tvendov | 0:6435b67ad23c | 753 | if (func_code == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 754 | break; |
tvendov | 0:6435b67ad23c | 755 | } |
tvendov | 0:6435b67ad23c | 756 | |
tvendov | 0:6435b67ad23c | 757 | if(!touch_pos[0].touch_down && (func_code == RGA_FUNC_AUTO_MANUAL)) |
tvendov | 0:6435b67ad23c | 758 | Interaction_mode = (Interaction_mode == AUTO_INTERACT)? MANUAL_INTERACT : AUTO_INTERACT; |
tvendov | 0:6435b67ad23c | 759 | else |
tvendov | 0:6435b67ad23c | 760 | work_height_pos = ZOOM_MAX_NUM * ((float32_t)touch_pos[0].x / (float32_t)(LCD_PIXEL_WIDTH)); |
tvendov | 0:6435b67ad23c | 761 | } |
tvendov | 0:6435b67ad23c | 762 | if(Interaction_mode == AUTO_INTERACT) |
tvendov | 0:6435b67ad23c | 763 | { |
tvendov | 0:6435b67ad23c | 764 | xz= (xz >= LCD_PIXEL_WIDTH)? 0: (xz+1); |
tvendov | 0:6435b67ad23c | 765 | work_height_pos = ZOOM_MAX_NUM * ((float32_t)xz / (float32_t)(LCD_PIXEL_WIDTH)); |
tvendov | 0:6435b67ad23c | 766 | } |
tvendov | 0:6435b67ad23c | 767 | /* Draw screen */ |
tvendov | 0:6435b67ad23c | 768 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 769 | RGA_Func_Zo(frmbuf_info, work_height_pos, Interaction_mode, (graphics_image_t*)FASTR_RENDER); |
tvendov | 0:6435b67ad23c | 770 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 771 | } |
tvendov | 0:6435b67ad23c | 772 | break; |
tvendov | 0:6435b67ad23c | 773 | case RGA_FUNC_ROTATION: |
tvendov | 0:6435b67ad23c | 774 | graphics_matrix_float_t work_angle = 0; |
tvendov | 0:6435b67ad23c | 775 | uint16_t xr = LCD_PIXEL_WIDTH; |
tvendov | 0:6435b67ad23c | 776 | |
tvendov | 0:6435b67ad23c | 777 | RGA_Func_Rotation(frmbuf_info, 0, Interaction_mode); |
tvendov | 0:6435b67ad23c | 778 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 779 | RGA_Func_Rotation(frmbuf_info, 0, Interaction_mode); |
tvendov | 0:6435b67ad23c | 780 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 781 | memcpy(FASTR_RENDER, (uint8_t*)Board_jpg_File, ROTRNDR_SIZE); |
tvendov | 0:6435b67ad23c | 782 | while (1) { |
tvendov | 0:6435b67ad23c | 783 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 784 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 785 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 786 | func_code_t func_code; |
tvendov | 0:6435b67ad23c | 787 | |
tvendov | 0:6435b67ad23c | 788 | func_code = Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y); |
tvendov | 0:6435b67ad23c | 789 | if (func_code == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 790 | break; |
tvendov | 0:6435b67ad23c | 791 | } |
tvendov | 0:6435b67ad23c | 792 | |
tvendov | 0:6435b67ad23c | 793 | if(!touch_pos[0].touch_down && (func_code == RGA_FUNC_AUTO_MANUAL)) |
tvendov | 0:6435b67ad23c | 794 | Interaction_mode = (Interaction_mode == AUTO_INTERACT)? MANUAL_INTERACT : AUTO_INTERACT; |
tvendov | 0:6435b67ad23c | 795 | else |
tvendov | 0:6435b67ad23c | 796 | work_angle = ROTATION_MAX_NUM * ((float32_t)touch_pos[0].x / (float32_t)(LCD_PIXEL_WIDTH)); |
tvendov | 0:6435b67ad23c | 797 | } |
tvendov | 0:6435b67ad23c | 798 | if(Interaction_mode == AUTO_INTERACT) |
tvendov | 0:6435b67ad23c | 799 | { |
tvendov | 0:6435b67ad23c | 800 | xr= (xr >= LCD_PIXEL_WIDTH)? 0: (xr+1); |
tvendov | 0:6435b67ad23c | 801 | work_angle = ROTATION_MAX_NUM * ((float32_t)xr / (float32_t)(LCD_PIXEL_WIDTH)); |
tvendov | 0:6435b67ad23c | 802 | } |
tvendov | 0:6435b67ad23c | 803 | /* Draw screen */ |
tvendov | 0:6435b67ad23c | 804 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 805 | RGA_Func_Rotor(frmbuf_info, work_angle, Interaction_mode, (graphics_image_t*)FASTR_RENDER); |
tvendov | 0:6435b67ad23c | 806 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 807 | } |
tvendov | 0:6435b67ad23c | 808 | break; |
tvendov | 0:6435b67ad23c | 809 | case RGA_FUNC_ACCELERATE: |
tvendov | 0:6435b67ad23c | 810 | int acce_frame_num = 0; |
tvendov | 0:6435b67ad23c | 811 | int animation_timing = 0; |
tvendov | 0:6435b67ad23c | 812 | float32_t work_relative_pos; |
tvendov | 0:6435b67ad23c | 813 | |
tvendov | 0:6435b67ad23c | 814 | RGA_Func_Accelerate(frmbuf_info, 0, 0); |
tvendov | 0:6435b67ad23c | 815 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 816 | RGA_Func_Accelerate(frmbuf_info, 0, 0); |
tvendov | 0:6435b67ad23c | 817 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 818 | memcpy(FASTR_RENDER, (uint8_t*)Board_jpg_File, ROTRNDR_SIZE); |
tvendov | 0:6435b67ad23c | 819 | while (1) { |
tvendov | 0:6435b67ad23c | 820 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 821 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 822 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 823 | func_code_t func_code; |
tvendov | 0:6435b67ad23c | 824 | |
tvendov | 0:6435b67ad23c | 825 | func_code = Scan_Key(animetion_timing_key_tbl, touch_pos[0].x, touch_pos[0].y); |
tvendov | 0:6435b67ad23c | 826 | if (func_code == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 827 | break; |
tvendov | 0:6435b67ad23c | 828 | } |
tvendov | 0:6435b67ad23c | 829 | switch (func_code) { |
tvendov | 0:6435b67ad23c | 830 | case RGA_FUNC_ANIME_EASE: |
tvendov | 0:6435b67ad23c | 831 | animation_timing = 0; |
tvendov | 0:6435b67ad23c | 832 | acce_frame_num = 0; |
tvendov | 0:6435b67ad23c | 833 | break; |
tvendov | 0:6435b67ad23c | 834 | case RGA_FUNC_ANIME_LINEAR: |
tvendov | 0:6435b67ad23c | 835 | animation_timing = 1; |
tvendov | 0:6435b67ad23c | 836 | acce_frame_num = 0; |
tvendov | 0:6435b67ad23c | 837 | break; |
tvendov | 0:6435b67ad23c | 838 | case RGA_FUNC_ANIME_EASE_IN: |
tvendov | 0:6435b67ad23c | 839 | animation_timing = 2; |
tvendov | 0:6435b67ad23c | 840 | acce_frame_num = 0; |
tvendov | 0:6435b67ad23c | 841 | break; |
tvendov | 0:6435b67ad23c | 842 | case RGA_FUNC_ANIME_EASE_OUT: |
tvendov | 0:6435b67ad23c | 843 | animation_timing = 3; |
tvendov | 0:6435b67ad23c | 844 | acce_frame_num = 0; |
tvendov | 0:6435b67ad23c | 845 | break; |
tvendov | 0:6435b67ad23c | 846 | case RGA_FUNC_ANIME_EASE_IN_OUT: |
tvendov | 0:6435b67ad23c | 847 | animation_timing = 4; |
tvendov | 0:6435b67ad23c | 848 | acce_frame_num = 0; |
tvendov | 0:6435b67ad23c | 849 | break; |
tvendov | 0:6435b67ad23c | 850 | default: |
tvendov | 0:6435b67ad23c | 851 | /* Do Nothing */ |
tvendov | 0:6435b67ad23c | 852 | break; |
tvendov | 0:6435b67ad23c | 853 | } |
tvendov | 0:6435b67ad23c | 854 | } |
tvendov | 0:6435b67ad23c | 855 | work_relative_pos = acce_frame_num / (float32_t)ACCELERATE_MAX_NUM; |
tvendov | 0:6435b67ad23c | 856 | acce_frame_num++; |
tvendov | 0:6435b67ad23c | 857 | if (acce_frame_num > ACCELERATE_MAX_NUM) { |
tvendov | 0:6435b67ad23c | 858 | acce_frame_num = 0; |
tvendov | 0:6435b67ad23c | 859 | } |
tvendov | 0:6435b67ad23c | 860 | /* Draw screen */ |
tvendov | 0:6435b67ad23c | 861 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 862 | RGA_Func_Axel(frmbuf_info, animation_timing, work_relative_pos, (graphics_image_t*)FASTR_RENDER); |
tvendov | 0:6435b67ad23c | 863 | Update_LCD_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 864 | } |
tvendov | 0:6435b67ad23c | 865 | break; |
tvendov | 0:6435b67ad23c | 866 | |
tvendov | 0:6435b67ad23c | 867 | case RGA_FUNC_VIDEO: |
tvendov | 0:6435b67ad23c | 868 | static bool old_signal; |
tvendov | 0:6435b67ad23c | 869 | |
tvendov | 0:6435b67ad23c | 870 | if(video_signal) |
tvendov | 0:6435b67ad23c | 871 | { /* Video write process start */ |
tvendov | 0:6435b67ad23c | 872 | if (Display.Video_Start(DisplayBase::VIDEO_INPUT_CHANNEL_0) != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 873 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 874 | mbed_die(); |
tvendov | 0:6435b67ad23c | 875 | } |
tvendov | 0:6435b67ad23c | 876 | } |
tvendov | 0:6435b67ad23c | 877 | else |
tvendov | 0:6435b67ad23c | 878 | { |
tvendov | 0:6435b67ad23c | 879 | frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index] = user_video_buffer; |
tvendov | 0:6435b67ad23c | 880 | RGA_Func_DrawFullScreen(frmbuf_info, TstScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 881 | frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index] = (frmbuf_info->draw_buffer_index)? user_frame_buffer2 : user_frame_buffer1; |
tvendov | 0:6435b67ad23c | 882 | } |
tvendov | 0:6435b67ad23c | 883 | |
tvendov | 0:6435b67ad23c | 884 | old_signal = video_signal; |
tvendov | 0:6435b67ad23c | 885 | slide_screen = DisplayBase::SLIDE_OUT_BOTTOM; |
tvendov | 0:6435b67ad23c | 886 | while(slide_screen !=DisplayBase::SLIDE_NONE); |
tvendov | 0:6435b67ad23c | 887 | frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index] = user_video_buffer; |
tvendov | 0:6435b67ad23c | 888 | |
tvendov | 0:6435b67ad23c | 889 | while (1) { |
tvendov | 0:6435b67ad23c | 890 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 891 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 892 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 893 | if (Scan_Key(video_screen_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 894 | if(video_signal) |
tvendov | 0:6435b67ad23c | 895 | { |
tvendov | 0:6435b67ad23c | 896 | if (Display.Video_Stop(DisplayBase::VIDEO_INPUT_CHANNEL_0) != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 897 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 898 | mbed_die(); |
tvendov | 0:6435b67ad23c | 899 | } |
tvendov | 0:6435b67ad23c | 900 | } |
tvendov | 0:6435b67ad23c | 901 | frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index] = (frmbuf_info->draw_buffer_index)? user_frame_buffer2 : user_frame_buffer1; |
tvendov | 0:6435b67ad23c | 902 | slide_screen = DisplayBase::SLIDE_IN_BOTTOM; |
tvendov | 0:6435b67ad23c | 903 | break; |
tvendov | 0:6435b67ad23c | 904 | } |
tvendov | 0:6435b67ad23c | 905 | } |
tvendov | 0:6435b67ad23c | 906 | |
tvendov | 0:6435b67ad23c | 907 | if(video_signal ^ old_signal) |
tvendov | 0:6435b67ad23c | 908 | { |
tvendov | 0:6435b67ad23c | 909 | if(video_signal) |
tvendov | 0:6435b67ad23c | 910 | { |
tvendov | 0:6435b67ad23c | 911 | if (Display.Video_Start(DisplayBase::VIDEO_INPUT_CHANNEL_0) != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 912 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 913 | mbed_die(); |
tvendov | 0:6435b67ad23c | 914 | } |
tvendov | 0:6435b67ad23c | 915 | } |
tvendov | 0:6435b67ad23c | 916 | else |
tvendov | 0:6435b67ad23c | 917 | { |
tvendov | 0:6435b67ad23c | 918 | if (Display.Video_Stop(DisplayBase::VIDEO_INPUT_CHANNEL_0) != DisplayBase::GRAPHICS_OK) { |
tvendov | 0:6435b67ad23c | 919 | printf("Line %d, error %d\n", __LINE__, error); |
tvendov | 0:6435b67ad23c | 920 | mbed_die(); |
tvendov | 0:6435b67ad23c | 921 | } |
tvendov | 0:6435b67ad23c | 922 | Wait_Vsync(3); |
tvendov | 0:6435b67ad23c | 923 | RGA_Func_DrawFullScreen(frmbuf_info, TstScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 924 | } |
tvendov | 0:6435b67ad23c | 925 | old_signal = video_signal; |
tvendov | 0:6435b67ad23c | 926 | } |
tvendov | 0:6435b67ad23c | 927 | } |
tvendov | 0:6435b67ad23c | 928 | break; |
tvendov | 0:6435b67ad23c | 929 | |
tvendov | 0:6435b67ad23c | 930 | case RGA_FUNC_USBCAM: |
tvendov | 0:6435b67ad23c | 931 | static int swaped_idx; |
tvendov | 0:6435b67ad23c | 932 | static bool old_usbplug; |
tvendov | 0:6435b67ad23c | 933 | static int try_recognize; |
tvendov | 0:6435b67ad23c | 934 | int shot_size; |
tvendov | 0:6435b67ad23c | 935 | |
tvendov | 0:6435b67ad23c | 936 | try_recognize = 0; |
tvendov | 0:6435b67ad23c | 937 | swaped_idx = frmbuf_info->draw_buffer_index; |
tvendov | 0:6435b67ad23c | 938 | frmbuf_info->buffer_address[(swaped_idx)? 0 : 1] = user_video_buffer; |
tvendov | 0:6435b67ad23c | 939 | frmbuf_info->buffer_address[swaped_idx] = (swaped_idx)? user_frame_buffer1 : user_frame_buffer2; |
tvendov | 0:6435b67ad23c | 940 | |
tvendov | 0:6435b67ad23c | 941 | RGA_Func_DrawFullScreen(frmbuf_info, CamScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 942 | if(!Cam.connected()) |
tvendov | 0:6435b67ad23c | 943 | RGA_Func_DrawPNG(frmbuf_info, NoDevice_png_ARGB4444, NO_DEV_X, NO_DEV_Y); |
tvendov | 0:6435b67ad23c | 944 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 945 | RGA_Func_DrawFullScreen(frmbuf_info, CamScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 946 | if(!Cam.connected()) |
tvendov | 0:6435b67ad23c | 947 | RGA_Func_DrawPNG(frmbuf_info, NoDevice_png_ARGB4444, NO_DEV_X, NO_DEV_Y); |
tvendov | 0:6435b67ad23c | 948 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 949 | |
tvendov | 0:6435b67ad23c | 950 | frmbuf_info->buffer_address[swaped_idx] = (swaped_idx)? user_frame_buffer2 : user_frame_buffer1; |
tvendov | 0:6435b67ad23c | 951 | old_usbplug = usb_plug; |
tvendov | 0:6435b67ad23c | 952 | slide_screen = DisplayBase::SLIDE_OUT_LEFT; |
tvendov | 0:6435b67ad23c | 953 | while(slide_screen !=DisplayBase::SLIDE_NONE); |
tvendov | 0:6435b67ad23c | 954 | frmbuf_info->buffer_address[swaped_idx] = (swaped_idx)? user_frame_buffer1 : user_frame_buffer2; |
tvendov | 0:6435b67ad23c | 955 | |
tvendov | 0:6435b67ad23c | 956 | if(Cam.connected()) |
tvendov | 0:6435b67ad23c | 957 | { |
tvendov | 0:6435b67ad23c | 958 | RGA_Func_DrawFullScreen(frmbuf_info, NULL); |
tvendov | 0:6435b67ad23c | 959 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 960 | RGA_Func_DrawFullScreen(frmbuf_info, NULL); |
tvendov | 0:6435b67ad23c | 961 | } |
tvendov | 0:6435b67ad23c | 962 | |
tvendov | 0:6435b67ad23c | 963 | |
tvendov | 0:6435b67ad23c | 964 | #ifdef __SOFT_JPEG__ |
tvendov | 0:6435b67ad23c | 965 | // decompression with libJPEG |
tvendov | 0:6435b67ad23c | 966 | //1: Allocate and initialize a JPEG decompression object |
tvendov | 0:6435b67ad23c | 967 | //2: Specify the source of the compressed data (eg, a file) |
tvendov | 0:6435b67ad23c | 968 | //3: Call jpeg_read_header() to obtain image info |
tvendov | 0:6435b67ad23c | 969 | //4: Set parameters for decompression |
tvendov | 0:6435b67ad23c | 970 | //5: jpeg_start_decompress(...); |
tvendov | 0:6435b67ad23c | 971 | //6: while (scan lines remain to be read) |
tvendov | 0:6435b67ad23c | 972 | // jpeg_read_scanlines(...); |
tvendov | 0:6435b67ad23c | 973 | //7: jpeg_finish_decompress(...); |
tvendov | 0:6435b67ad23c | 974 | //8: Release the JPEG decompression object |
tvendov | 0:6435b67ad23c | 975 | |
tvendov | 0:6435b67ad23c | 976 | struct jpeg_decompress_struct cinfo; |
tvendov | 0:6435b67ad23c | 977 | struct my_error_mgr jerr; |
tvendov | 0:6435b67ad23c | 978 | JSAMPARRAY buffer; /* Output row buffer */ |
tvendov | 0:6435b67ad23c | 979 | int row_stride; /* physical row width in output buffer */ |
tvendov | 0:6435b67ad23c | 980 | //... |
tvendov | 0:6435b67ad23c | 981 | cinfo.err = jpeg_std_error(&jerr.pub); /* We set up the normal JPEG error routines */ |
tvendov | 0:6435b67ad23c | 982 | jerr.pub.error_exit = my_error_exit; /* then override error_exit. */ |
tvendov | 0:6435b67ad23c | 983 | |
tvendov | 0:6435b67ad23c | 984 | /* Establish the setjmp return context for my_error_exit to use. */ |
tvendov | 0:6435b67ad23c | 985 | if (setjmp(jerr.setjmp_buffer)) { |
tvendov | 0:6435b67ad23c | 986 | /* If we get here, the JPEG code has signaled an error. |
tvendov | 0:6435b67ad23c | 987 | * We need to clean up the JPEG object, close the input file, and return. |
tvendov | 0:6435b67ad23c | 988 | */ |
tvendov | 0:6435b67ad23c | 989 | jpeg_destroy_decompress(&cinfo); |
tvendov | 0:6435b67ad23c | 990 | } |
tvendov | 0:6435b67ad23c | 991 | |
tvendov | 0:6435b67ad23c | 992 | //1: |
tvendov | 0:6435b67ad23c | 993 | jpeg_create_decompress(&cinfo); |
tvendov | 0:6435b67ad23c | 994 | #endif |
tvendov | 0:6435b67ad23c | 995 | |
tvendov | 0:6435b67ad23c | 996 | while (1) { |
tvendov | 0:6435b67ad23c | 997 | /* Get coordinates */ |
tvendov | 0:6435b67ad23c | 998 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 999 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 1000 | if (Scan_Key(cam_screen_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) { |
tvendov | 0:6435b67ad23c | 1001 | frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index] = user_video_buffer; |
tvendov | 0:6435b67ad23c | 1002 | Update_VIDEO_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1003 | frmbuf_info->buffer_address[0] = user_frame_buffer1; |
tvendov | 0:6435b67ad23c | 1004 | frmbuf_info->buffer_address[1] = user_frame_buffer2; |
tvendov | 0:6435b67ad23c | 1005 | slide_screen = DisplayBase::SLIDE_IN_LEFT; |
tvendov | 0:6435b67ad23c | 1006 | break; |
tvendov | 0:6435b67ad23c | 1007 | } |
tvendov | 0:6435b67ad23c | 1008 | } |
tvendov | 0:6435b67ad23c | 1009 | |
tvendov | 0:6435b67ad23c | 1010 | if(Cam.connected()) |
tvendov | 0:6435b67ad23c | 1011 | { |
tvendov | 0:6435b67ad23c | 1012 | shot_size = Cam.readJPEG(shot_buffer, sizeof(shot_buffer)); |
tvendov | 0:6435b67ad23c | 1013 | //printf("JPEG size: %d\r\n", shot_size); |
tvendov | 0:6435b67ad23c | 1014 | //test_point = !test_point; |
tvendov | 0:6435b67ad23c | 1015 | |
tvendov | 0:6435b67ad23c | 1016 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1017 | |
tvendov | 0:6435b67ad23c | 1018 | #ifdef __SOFT_JPEG__ |
tvendov | 0:6435b67ad23c | 1019 | //2: |
tvendov | 0:6435b67ad23c | 1020 | jpeg_mem_src(&cinfo, shot_buffer ,shot_size); |
tvendov | 0:6435b67ad23c | 1021 | |
tvendov | 0:6435b67ad23c | 1022 | //3: |
tvendov | 0:6435b67ad23c | 1023 | jpeg_read_header(&cinfo, TRUE); |
tvendov | 0:6435b67ad23c | 1024 | //4: |
tvendov | 0:6435b67ad23c | 1025 | // Default decompression parameters |
tvendov | 0:6435b67ad23c | 1026 | //5: |
tvendov | 0:6435b67ad23c | 1027 | jpeg_start_decompress(&cinfo); |
tvendov | 0:6435b67ad23c | 1028 | |
tvendov | 0:6435b67ad23c | 1029 | //6: |
tvendov | 0:6435b67ad23c | 1030 | row_stride = cinfo.output_width * cinfo.output_components; |
tvendov | 0:6435b67ad23c | 1031 | buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); |
tvendov | 0:6435b67ad23c | 1032 | while (cinfo.output_scanline < cinfo.output_height) { |
tvendov | 0:6435b67ad23c | 1033 | jpeg_read_scanlines(&cinfo, buffer, 1); |
tvendov | 0:6435b67ad23c | 1034 | |
tvendov | 0:6435b67ad23c | 1035 | for(int i=0; i<cinfo.output_width; i++) |
tvendov | 0:6435b67ad23c | 1036 | { |
tvendov | 0:6435b67ad23c | 1037 | uint16_t _565; |
tvendov | 0:6435b67ad23c | 1038 | |
tvendov | 0:6435b67ad23c | 1039 | _565 = (uint16_t)(0xF8 & buffer[0][(i*3)+2])>>3; |
tvendov | 0:6435b67ad23c | 1040 | _565 |= (uint16_t)(0xFC & buffer[0][(i*3)+1])<<3; |
tvendov | 0:6435b67ad23c | 1041 | _565 |= (uint16_t)(0xF8 & buffer[0][i*3])<<8; |
tvendov | 0:6435b67ad23c | 1042 | |
tvendov | 0:6435b67ad23c | 1043 | ((uint16_t*)(frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index]))[((cinfo.output_scanline-1)*LCD_PIXEL_WIDTH)+i] = _565; |
tvendov | 0:6435b67ad23c | 1044 | } |
tvendov | 0:6435b67ad23c | 1045 | } |
tvendov | 0:6435b67ad23c | 1046 | //7: |
tvendov | 0:6435b67ad23c | 1047 | jpeg_finish_decompress(&cinfo); |
tvendov | 0:6435b67ad23c | 1048 | |
tvendov | 0:6435b67ad23c | 1049 | RGA_Func_DrawCamScreen(NULL); |
tvendov | 0:6435b67ad23c | 1050 | #else |
tvendov | 0:6435b67ad23c | 1051 | RGA_Func_DrawCamScreen(shot_buffer); |
tvendov | 0:6435b67ad23c | 1052 | #endif |
tvendov | 0:6435b67ad23c | 1053 | |
tvendov | 0:6435b67ad23c | 1054 | Update_VIDEO_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1055 | |
tvendov | 0:6435b67ad23c | 1056 | Cam.poll(); |
tvendov | 0:6435b67ad23c | 1057 | } |
tvendov | 0:6435b67ad23c | 1058 | |
tvendov | 0:6435b67ad23c | 1059 | if(usb_plug ^ old_usbplug) |
tvendov | 0:6435b67ad23c | 1060 | { |
tvendov | 0:6435b67ad23c | 1061 | if(usb_plug) |
tvendov | 0:6435b67ad23c | 1062 | { |
tvendov | 0:6435b67ad23c | 1063 | //Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1064 | //RGA_Func_DrawFullScreen(frmbuf_info, CamScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 1065 | //Update_VIDEO_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1066 | } |
tvendov | 0:6435b67ad23c | 1067 | else |
tvendov | 0:6435b67ad23c | 1068 | { |
tvendov | 0:6435b67ad23c | 1069 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1070 | RGA_Func_DrawFullScreen(frmbuf_info, CamScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 1071 | RGA_Func_DrawPNG(frmbuf_info, NoDevice_png_ARGB4444, NO_DEV_X, NO_DEV_Y); |
tvendov | 0:6435b67ad23c | 1072 | Update_VIDEO_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1073 | } |
tvendov | 0:6435b67ad23c | 1074 | old_usbplug = usb_plug; |
tvendov | 0:6435b67ad23c | 1075 | } |
tvendov | 0:6435b67ad23c | 1076 | |
tvendov | 0:6435b67ad23c | 1077 | if(try_cam_connect) |
tvendov | 0:6435b67ad23c | 1078 | { |
tvendov | 0:6435b67ad23c | 1079 | if(!Cam.connected()) |
tvendov | 0:6435b67ad23c | 1080 | { |
tvendov | 0:6435b67ad23c | 1081 | Cam.connect(); |
tvendov | 0:6435b67ad23c | 1082 | Thread::wait(500); |
tvendov | 0:6435b67ad23c | 1083 | if(try_recognize == 0) |
tvendov | 0:6435b67ad23c | 1084 | { |
tvendov | 0:6435b67ad23c | 1085 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1086 | RGA_Func_DrawFullScreen(frmbuf_info, CamScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 1087 | Update_VIDEO_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1088 | } |
tvendov | 0:6435b67ad23c | 1089 | |
tvendov | 0:6435b67ad23c | 1090 | try_recognize++; |
tvendov | 0:6435b67ad23c | 1091 | if(try_recognize > MAX_TRY) |
tvendov | 0:6435b67ad23c | 1092 | { |
tvendov | 0:6435b67ad23c | 1093 | try_cam_connect = false; |
tvendov | 0:6435b67ad23c | 1094 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1095 | RGA_Func_DrawFullScreen(frmbuf_info, CamScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 1096 | RGA_Func_DrawPNG(frmbuf_info, NoDevice_png_ARGB4444, NO_DEV_X, NO_DEV_Y); |
tvendov | 0:6435b67ad23c | 1097 | Update_VIDEO_Display(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1098 | } |
tvendov | 0:6435b67ad23c | 1099 | } |
tvendov | 0:6435b67ad23c | 1100 | else |
tvendov | 0:6435b67ad23c | 1101 | { |
tvendov | 0:6435b67ad23c | 1102 | try_cam_connect = false; |
tvendov | 0:6435b67ad23c | 1103 | RGA_Func_DrawFullScreen(frmbuf_info, NULL); |
tvendov | 0:6435b67ad23c | 1104 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1105 | RGA_Func_DrawFullScreen(frmbuf_info, NULL); |
tvendov | 0:6435b67ad23c | 1106 | Swap_FrameBuffer(frmbuf_info); |
tvendov | 0:6435b67ad23c | 1107 | } |
tvendov | 0:6435b67ad23c | 1108 | } |
tvendov | 0:6435b67ad23c | 1109 | else |
tvendov | 0:6435b67ad23c | 1110 | try_recognize = 0; |
tvendov | 0:6435b67ad23c | 1111 | } |
tvendov | 0:6435b67ad23c | 1112 | |
tvendov | 0:6435b67ad23c | 1113 | #ifdef __SOFT_JPEG__ |
tvendov | 0:6435b67ad23c | 1114 | //8: |
tvendov | 0:6435b67ad23c | 1115 | jpeg_destroy_decompress(&cinfo); |
tvendov | 0:6435b67ad23c | 1116 | #endif |
tvendov | 0:6435b67ad23c | 1117 | break; |
tvendov | 0:6435b67ad23c | 1118 | |
tvendov | 0:6435b67ad23c | 1119 | default : |
tvendov | 0:6435b67ad23c | 1120 | /* Do nothing */ |
tvendov | 0:6435b67ad23c | 1121 | break; |
tvendov | 0:6435b67ad23c | 1122 | } |
tvendov | 0:6435b67ad23c | 1123 | } |
tvendov | 0:6435b67ad23c | 1124 | |
tvendov | 0:6435b67ad23c | 1125 | |
tvendov | 0:6435b67ad23c | 1126 | //void test(int x) |
tvendov | 0:6435b67ad23c | 1127 | //{ |
tvendov | 0:6435b67ad23c | 1128 | // test_point=x; |
tvendov | 0:6435b67ad23c | 1129 | //} |
tvendov | 0:6435b67ad23c | 1130 | |
tvendov | 0:6435b67ad23c | 1131 | int main(void) { |
tvendov | 0:6435b67ad23c | 1132 | func_code_t func_code; |
tvendov | 0:6435b67ad23c | 1133 | uint8_t touch_num = 0; |
tvendov | 0:6435b67ad23c | 1134 | touch_pos_t touch_pos[TOUCH_NUM]; |
tvendov | 0:6435b67ad23c | 1135 | |
tvendov | 0:6435b67ad23c | 1136 | /* Initialization of LCD */ |
tvendov | 0:6435b67ad23c | 1137 | Init_LCD_Display(); /* When using LCD, please call before than Init_Video(). */ |
tvendov | 0:6435b67ad23c | 1138 | |
tvendov | 0:6435b67ad23c | 1139 | /* Initialization of Video */ |
tvendov | 0:6435b67ad23c | 1140 | Init_Video(); |
tvendov | 0:6435b67ad23c | 1141 | |
tvendov | 0:6435b67ad23c | 1142 | /* Start of Video ch0 */ |
tvendov | 0:6435b67ad23c | 1143 | Start_Video( |
tvendov | 0:6435b67ad23c | 1144 | DisplayBase::VIDEO_INPUT_CHANNEL_0, /* Video input channe */ |
tvendov | 0:6435b67ad23c | 1145 | user_video_buffer, /* Output buffer */ |
tvendov | 0:6435b67ad23c | 1146 | 0, /* The x coordinate of the upper-left corner */ |
tvendov | 0:6435b67ad23c | 1147 | 0, /* The y coordinate of the upper-left corner */ |
tvendov | 0:6435b67ad23c | 1148 | LCD_PIXEL_WIDTH, /* width (A multiple of 16) */ |
tvendov | 0:6435b67ad23c | 1149 | LCD_PIXEL_HEIGHT /* height (A multiple of 8) */ |
tvendov | 0:6435b67ad23c | 1150 | ); |
tvendov | 0:6435b67ad23c | 1151 | |
tvendov | 0:6435b67ad23c | 1152 | memset(user_frame_buffer1, 0, sizeof(user_frame_buffer1)); |
tvendov | 0:6435b67ad23c | 1153 | memset(user_frame_buffer2, 0, sizeof(user_frame_buffer2)); |
tvendov | 0:6435b67ad23c | 1154 | frame_buffer_info.buffer_address[0] = user_frame_buffer1; |
tvendov | 0:6435b67ad23c | 1155 | frame_buffer_info.buffer_address[1] = user_frame_buffer2; |
tvendov | 0:6435b67ad23c | 1156 | frame_buffer_info.buffer_count = 2; |
tvendov | 0:6435b67ad23c | 1157 | frame_buffer_info.show_buffer_index = 0; |
tvendov | 0:6435b67ad23c | 1158 | frame_buffer_info.draw_buffer_index = 0; |
tvendov | 0:6435b67ad23c | 1159 | frame_buffer_info.width = LCD_PIXEL_WIDTH; |
tvendov | 0:6435b67ad23c | 1160 | frame_buffer_info.byte_per_pixel = FRAME_BUFFER_BYTE_PER_PIXEL; |
tvendov | 0:6435b67ad23c | 1161 | frame_buffer_info.stride = LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL; |
tvendov | 0:6435b67ad23c | 1162 | frame_buffer_info.height = LCD_PIXEL_HEIGHT; |
tvendov | 0:6435b67ad23c | 1163 | frame_buffer_info.pixel_format = PIXEL_FORMAT_RGB565; |
tvendov | 0:6435b67ad23c | 1164 | |
tvendov | 0:6435b67ad23c | 1165 | /* Display Top Screen */ |
tvendov | 0:6435b67ad23c | 1166 | Set_RGAObject(&frame_buffer_info); |
tvendov | 0:6435b67ad23c | 1167 | RGA_Func_DrawFullScreen(&frame_buffer_info, TopScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 1168 | |
tvendov | 0:6435b67ad23c | 1169 | Swap_FrameBuffer(&frame_buffer_info); |
tvendov | 0:6435b67ad23c | 1170 | RGA_Func_DrawFullScreen(&frame_buffer_info, TopScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 1171 | Swap_FrameBuffer(&frame_buffer_info); |
tvendov | 0:6435b67ad23c | 1172 | |
tvendov | 0:6435b67ad23c | 1173 | /* Start of LCD */ |
tvendov | 0:6435b67ad23c | 1174 | Start_LCD_Display(frame_buffer_info.buffer_address[0]); |
tvendov | 0:6435b67ad23c | 1175 | |
tvendov | 0:6435b67ad23c | 1176 | /* Backlight on */ |
tvendov | 0:6435b67ad23c | 1177 | Thread::wait(200); |
tvendov | 0:6435b67ad23c | 1178 | lcd_cntrst.period_us(100); |
tvendov | 0:6435b67ad23c | 1179 | lcd_cntrst.write(((float)LCD_CH0_INITIAL_DC)/100.0f); // |
tvendov | 0:6435b67ad23c | 1180 | |
tvendov | 0:6435b67ad23c | 1181 | /* Reset touch IC */ |
tvendov | 0:6435b67ad23c | 1182 | STMPE811.Init(); |
tvendov | 0:6435b67ad23c | 1183 | |
tvendov | 0:6435b67ad23c | 1184 | Interaction_mode = MANUAL_INTERACT; |
tvendov | 0:6435b67ad23c | 1185 | |
tvendov | 0:6435b67ad23c | 1186 | while (1) { |
tvendov | 0:6435b67ad23c | 1187 | /* Get Coordinates */ |
tvendov | 0:6435b67ad23c | 1188 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 1189 | if (touch_num != 0) { |
tvendov | 0:6435b67ad23c | 1190 | func_code = Scan_Key(top_screen_key_tbl, touch_pos[0].x, touch_pos[0].y); |
tvendov | 0:6435b67ad23c | 1191 | if (func_code != RGA_FUNC_NON) { |
tvendov | 0:6435b67ad23c | 1192 | /* Wait key off */ |
tvendov | 0:6435b67ad23c | 1193 | while (1) { |
tvendov | 0:6435b67ad23c | 1194 | touch_num = GetCoordinates(touch_pos); |
tvendov | 0:6435b67ad23c | 1195 | if (touch_num == 0) { |
tvendov | 0:6435b67ad23c | 1196 | break; |
tvendov | 0:6435b67ad23c | 1197 | } |
tvendov | 0:6435b67ad23c | 1198 | Thread::wait(20); |
tvendov | 0:6435b67ad23c | 1199 | } |
tvendov | 0:6435b67ad23c | 1200 | |
tvendov | 0:6435b67ad23c | 1201 | /* Execute RGA functions */ |
tvendov | 0:6435b67ad23c | 1202 | Exe_RGA_Func(func_code, &frame_buffer_info); |
tvendov | 0:6435b67ad23c | 1203 | |
tvendov | 0:6435b67ad23c | 1204 | /* Return Top Screen */ |
tvendov | 0:6435b67ad23c | 1205 | touch_num = 0; |
tvendov | 0:6435b67ad23c | 1206 | touch_num = (RGA_Func_CheckPorts(&frame_buffer_info, false, false))? 1 : 0; |
tvendov | 0:6435b67ad23c | 1207 | touch_num = (RGA_Func_CheckPorts(&frame_buffer_info, video_signal, usb_plug))? 1 : 0; |
tvendov | 0:6435b67ad23c | 1208 | if(touch_num == 0) |
tvendov | 0:6435b67ad23c | 1209 | { |
tvendov | 0:6435b67ad23c | 1210 | Swap_FrameBuffer(&frame_buffer_info); |
tvendov | 0:6435b67ad23c | 1211 | RGA_Func_DrawFullScreen(&frame_buffer_info, TopScrn_jpg_File); |
tvendov | 0:6435b67ad23c | 1212 | } |
tvendov | 0:6435b67ad23c | 1213 | Update_LCD_Display(&frame_buffer_info); |
tvendov | 0:6435b67ad23c | 1214 | } |
tvendov | 0:6435b67ad23c | 1215 | } |
tvendov | 0:6435b67ad23c | 1216 | else |
tvendov | 0:6435b67ad23c | 1217 | if(RGA_Func_CheckPorts(&frame_buffer_info, video_signal, usb_plug)) |
tvendov | 0:6435b67ad23c | 1218 | Update_LCD_Display(&frame_buffer_info); |
tvendov | 0:6435b67ad23c | 1219 | Thread::wait(20); |
tvendov | 0:6435b67ad23c | 1220 | } |
tvendov | 0:6435b67ad23c | 1221 | } |
tvendov | 0:6435b67ad23c | 1222 | |
tvendov | 0:6435b67ad23c | 1223 |