This is the sample program that can see the decode result of barcode data on Watson IoT.
Dependencies: AsciiFont DisplayApp GR-PEACH_video LCD_shield_config LWIPBP3595Interface_STA_for_mbed-os USBDevice
mbed-endpoint-resources/ZXingResource.h@1:67f8b5cfde75, 2016-11-10 (annotated)
- Committer:
- Osamu Nakamura
- Date:
- Thu Nov 10 20:23:55 2016 +0900
- Revision:
- 1:67f8b5cfde75
- Parent:
- 0:7d720671e6dc
Revised the initial value of /888/0/7700
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Osamu Nakamura |
0:7d720671e6dc | 1 | /** |
Osamu Nakamura |
0:7d720671e6dc | 2 | * @file ZXingResource.h |
Osamu Nakamura |
0:7d720671e6dc | 3 | * @brief mbed CoAP Endpoint Accelerometer sensor resource supporting CoAP GET |
Osamu Nakamura |
0:7d720671e6dc | 4 | * @author Doug Anson |
Osamu Nakamura |
0:7d720671e6dc | 5 | * @version 1.0 |
Osamu Nakamura |
0:7d720671e6dc | 6 | * @see |
Osamu Nakamura |
0:7d720671e6dc | 7 | * |
Osamu Nakamura |
0:7d720671e6dc | 8 | * Copyright (c) 2014 |
Osamu Nakamura |
0:7d720671e6dc | 9 | * |
Osamu Nakamura |
0:7d720671e6dc | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Osamu Nakamura |
0:7d720671e6dc | 11 | * you may not use this file except in compliance with the License. |
Osamu Nakamura |
0:7d720671e6dc | 12 | * You may obtain a copy of the License at |
Osamu Nakamura |
0:7d720671e6dc | 13 | * |
Osamu Nakamura |
0:7d720671e6dc | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
Osamu Nakamura |
0:7d720671e6dc | 15 | * |
Osamu Nakamura |
0:7d720671e6dc | 16 | * Unless required by applicable law or agreed to in writing, software |
Osamu Nakamura |
0:7d720671e6dc | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
Osamu Nakamura |
0:7d720671e6dc | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Osamu Nakamura |
0:7d720671e6dc | 19 | * See the License for the specific language governing permissions and |
Osamu Nakamura |
0:7d720671e6dc | 20 | * limitations under the License. |
Osamu Nakamura |
0:7d720671e6dc | 21 | */ |
Osamu Nakamura |
0:7d720671e6dc | 22 | |
Osamu Nakamura |
0:7d720671e6dc | 23 | #ifndef __ZXING_RESOURCE_H__ |
Osamu Nakamura |
0:7d720671e6dc | 24 | #define __ZXING_RESOURCE_H__ |
Osamu Nakamura |
0:7d720671e6dc | 25 | |
Osamu Nakamura |
0:7d720671e6dc | 26 | // Base class |
Osamu Nakamura |
0:7d720671e6dc | 27 | #include "mbed-connector-interface/DynamicResource.h" |
Osamu Nakamura |
0:7d720671e6dc | 28 | |
Osamu Nakamura |
0:7d720671e6dc | 29 | #include "DisplayBace.h" |
Osamu Nakamura |
0:7d720671e6dc | 30 | #include "ImageReaderSource.h" |
Osamu Nakamura |
0:7d720671e6dc | 31 | #include "DisplayApp.h" |
Osamu Nakamura |
0:7d720671e6dc | 32 | #include "AsciiFont.h" |
Osamu Nakamura |
0:7d720671e6dc | 33 | |
Osamu Nakamura |
0:7d720671e6dc | 34 | // forward declarations |
Osamu Nakamura |
0:7d720671e6dc | 35 | static void *_instance = NULL; |
Osamu Nakamura |
0:7d720671e6dc | 36 | extern "C" void _zxing_processing(const void *args); |
Osamu Nakamura |
0:7d720671e6dc | 37 | extern "C" void _zxing_loop(void); |
Osamu Nakamura |
0:7d720671e6dc | 38 | |
Osamu Nakamura |
0:7d720671e6dc | 39 | #define VIDEO_CVBS (0) /* Analog Video Signal */ |
Osamu Nakamura |
0:7d720671e6dc | 40 | #define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */ |
Osamu Nakamura |
0:7d720671e6dc | 41 | #define VIDEO_RGB888 (1) |
Osamu Nakamura |
0:7d720671e6dc | 42 | |
Osamu Nakamura |
0:7d720671e6dc | 43 | /**** User Selection *********/ |
Osamu Nakamura |
0:7d720671e6dc | 44 | /** Camera setting **/ |
Osamu Nakamura |
0:7d720671e6dc | 45 | #define VIDEO_INPUT_METHOD (VIDEO_CMOS_CAMERA) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */ |
Osamu Nakamura |
0:7d720671e6dc | 46 | #define VIDEO_INPUT_FORMAT (VIDEO_RGB888) /* Select VIDEO_RGB888 */ |
Osamu Nakamura |
0:7d720671e6dc | 47 | #define USE_VIDEO_CH (0) /* Select 0 or 1 If selecting VIDEO_CMOS_CAMERA, should be 0.) */ |
Osamu Nakamura |
0:7d720671e6dc | 48 | #define VIDEO_PAL (0) /* Select 0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */ |
Osamu Nakamura |
0:7d720671e6dc | 49 | /** LCD setting **/ |
Osamu Nakamura |
0:7d720671e6dc | 50 | #define LCD_ONOFF (1) /* Select 0(without LCD) or 1(with LCD) */ |
Osamu Nakamura |
0:7d720671e6dc | 51 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 52 | #define LCD_TYPE (0) /* Select 0(4.3inch) or 1(7.1inch) */ |
Osamu Nakamura |
0:7d720671e6dc | 53 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 54 | /*****************************/ |
Osamu Nakamura |
0:7d720671e6dc | 55 | |
Osamu Nakamura |
0:7d720671e6dc | 56 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 57 | /** LCD shield config **/ |
Osamu Nakamura |
0:7d720671e6dc | 58 | #if (LCD_TYPE == 0) |
Osamu Nakamura |
0:7d720671e6dc | 59 | #include "LCD_shield_config_4_3inch.h" |
Osamu Nakamura |
0:7d720671e6dc | 60 | #else |
Osamu Nakamura |
0:7d720671e6dc | 61 | #include "LCD_shield_config_7_1inch.h" |
Osamu Nakamura |
0:7d720671e6dc | 62 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 63 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 64 | |
Osamu Nakamura |
0:7d720671e6dc | 65 | /** Video and Grapics (GRAPHICS_LAYER_0) parameter **/ |
Osamu Nakamura |
0:7d720671e6dc | 66 | /* video input */ |
Osamu Nakamura |
0:7d720671e6dc | 67 | #if USE_VIDEO_CH == (0) |
Osamu Nakamura |
0:7d720671e6dc | 68 | #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_0) |
Osamu Nakamura |
0:7d720671e6dc | 69 | #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S0_VFIELD) |
Osamu Nakamura |
0:7d720671e6dc | 70 | #else |
Osamu Nakamura |
0:7d720671e6dc | 71 | #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_1) |
Osamu Nakamura |
0:7d720671e6dc | 72 | #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S1_VFIELD) |
Osamu Nakamura |
0:7d720671e6dc | 73 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 74 | |
Osamu Nakamura |
0:7d720671e6dc | 75 | /* NTSC or PAL */ |
Osamu Nakamura |
0:7d720671e6dc | 76 | #if VIDEO_PAL == 0 |
Osamu Nakamura |
0:7d720671e6dc | 77 | #define COL_SYS (DisplayBase::COL_SYS_NTSC_358) |
Osamu Nakamura |
0:7d720671e6dc | 78 | #else |
Osamu Nakamura |
0:7d720671e6dc | 79 | #define COL_SYS (DisplayBase::COL_SYS_PAL_443) |
Osamu Nakamura |
0:7d720671e6dc | 80 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 81 | |
Osamu Nakamura |
0:7d720671e6dc | 82 | /* Video input */ |
Osamu Nakamura |
0:7d720671e6dc | 83 | #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_RGB888) |
Osamu Nakamura |
0:7d720671e6dc | 84 | #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB888) |
Osamu Nakamura |
0:7d720671e6dc | 85 | #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32BIT) |
Osamu Nakamura |
0:7d720671e6dc | 86 | |
Osamu Nakamura |
0:7d720671e6dc | 87 | /* The size of the video input */ |
Osamu Nakamura |
0:7d720671e6dc | 88 | #if ((LCD_ONOFF) && (LCD_TYPE == 0)) |
Osamu Nakamura |
0:7d720671e6dc | 89 | #define VIDEO_PIXEL_HW LCD_PIXEL_WIDTH |
Osamu Nakamura |
0:7d720671e6dc | 90 | #define VIDEO_PIXEL_VW LCD_PIXEL_HEIGHT |
Osamu Nakamura |
0:7d720671e6dc | 91 | #else |
Osamu Nakamura |
0:7d720671e6dc | 92 | #define VIDEO_PIXEL_HW (640) /* VGA */ |
Osamu Nakamura |
0:7d720671e6dc | 93 | #define VIDEO_PIXEL_VW (480) /* VGA */ |
Osamu Nakamura |
0:7d720671e6dc | 94 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 95 | |
Osamu Nakamura |
0:7d720671e6dc | 96 | /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128 |
Osamu Nakamura |
0:7d720671e6dc | 97 | in accordance with the frame buffer burst transfer mode. */ |
Osamu Nakamura |
0:7d720671e6dc | 98 | /* FRAME BUFFER Parameter GRAPHICS_LAYER_0 */ |
Osamu Nakamura |
0:7d720671e6dc | 99 | #define FRAME_BUFFER_NUM (2u) |
Osamu Nakamura |
0:7d720671e6dc | 100 | #define FRAME_BUFFER_BYTE_PER_PIXEL (4u) |
Osamu Nakamura |
0:7d720671e6dc | 101 | #define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u) |
Osamu Nakamura |
0:7d720671e6dc | 102 | |
Osamu Nakamura |
0:7d720671e6dc | 103 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 104 | #define VIDEO_PIXEL_HW_STR (VIDEO_PIXEL_HW - 64) |
Osamu Nakamura |
0:7d720671e6dc | 105 | #define VIDEO_PIXEL_VW_STR (VIDEO_PIXEL_VW - 64) |
Osamu Nakamura |
0:7d720671e6dc | 106 | #define FRAME_BUFFER_BYTE_PER_PIXEL_STR (2u) |
Osamu Nakamura |
0:7d720671e6dc | 107 | #define FRAME_BUFFER_STRIDE_STR (((VIDEO_PIXEL_HW_STR * FRAME_BUFFER_BYTE_PER_PIXEL_STR) + 31u) & ~31u) |
Osamu Nakamura |
0:7d720671e6dc | 108 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 109 | |
Osamu Nakamura |
0:7d720671e6dc | 110 | static DisplayBase Display; |
Osamu Nakamura |
0:7d720671e6dc | 111 | static DisplayApp display_app; |
Osamu Nakamura |
0:7d720671e6dc | 112 | static Timer decode_timer; |
Osamu Nakamura |
0:7d720671e6dc | 113 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 114 | static DigitalOut lcd_pwon(P7_15); |
Osamu Nakamura |
0:7d720671e6dc | 115 | static DigitalOut lcd_blon(P8_1); |
Osamu Nakamura |
0:7d720671e6dc | 116 | static PwmOut lcd_cntrst(P8_15); |
Osamu Nakamura |
0:7d720671e6dc | 117 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 118 | |
Osamu Nakamura |
0:7d720671e6dc | 119 | /* 32 bytes aligned */ |
Osamu Nakamura |
0:7d720671e6dc | 120 | static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW]__attribute((aligned(32))); |
Osamu Nakamura |
0:7d720671e6dc | 121 | static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW]__attribute((aligned(32))); |
Osamu Nakamura |
0:7d720671e6dc | 122 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 123 | static uint8_t user_frame_buffer_string[FRAME_BUFFER_STRIDE_STR * VIDEO_PIXEL_VW_STR]__attribute((aligned(32))); |
Osamu Nakamura |
0:7d720671e6dc | 124 | static AsciiFont ascii_font(user_frame_buffer_string, VIDEO_PIXEL_HW_STR, VIDEO_PIXEL_VW_STR, FRAME_BUFFER_STRIDE_STR, FRAME_BUFFER_BYTE_PER_PIXEL_STR); |
Osamu Nakamura |
0:7d720671e6dc | 125 | static bool string_draw; |
Osamu Nakamura |
0:7d720671e6dc | 126 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 127 | static uint8_t * decode_buffer = user_frame_buffer0; |
Osamu Nakamura |
0:7d720671e6dc | 128 | static uint8_t * FrameBufferTbl[FRAME_BUFFER_NUM] = {user_frame_buffer0, user_frame_buffer1}; |
Osamu Nakamura |
0:7d720671e6dc | 129 | static volatile int32_t vfield_count = 0; |
Osamu Nakamura |
0:7d720671e6dc | 130 | static int write_buff_num = 0; |
Osamu Nakamura |
0:7d720671e6dc | 131 | static bool graphics_init_end = false; |
Osamu Nakamura |
0:7d720671e6dc | 132 | static int decode_wait_time = 0; |
Osamu Nakamura |
0:7d720671e6dc | 133 | |
Osamu Nakamura |
0:7d720671e6dc | 134 | vector<Ref<Result> > results; |
Osamu Nakamura |
0:7d720671e6dc | 135 | char ** decode_str; |
Osamu Nakamura |
0:7d720671e6dc | 136 | |
Osamu Nakamura |
0:7d720671e6dc | 137 | /****** cache control ******/ |
Osamu Nakamura |
0:7d720671e6dc | 138 | static void dcache_clean(void * p_buf, uint32_t size) { |
Osamu Nakamura |
0:7d720671e6dc | 139 | uint32_t start_addr = (uint32_t)p_buf & 0xFFFFFFE0; |
Osamu Nakamura |
0:7d720671e6dc | 140 | uint32_t end_addr = (uint32_t)p_buf + size; |
Osamu Nakamura |
0:7d720671e6dc | 141 | uint32_t addr; |
Osamu Nakamura |
0:7d720671e6dc | 142 | |
Osamu Nakamura |
0:7d720671e6dc | 143 | /* Data cache clean */ |
Osamu Nakamura |
0:7d720671e6dc | 144 | for (addr = start_addr; addr < end_addr; addr += 0x20) { |
Osamu Nakamura |
0:7d720671e6dc | 145 | __v7_clean_dcache_mva((void *)addr); |
Osamu Nakamura |
0:7d720671e6dc | 146 | } |
Osamu Nakamura |
0:7d720671e6dc | 147 | } |
Osamu Nakamura |
0:7d720671e6dc | 148 | |
Osamu Nakamura |
0:7d720671e6dc | 149 | static void dcache_invalid(void * p_buf, uint32_t size){ |
Osamu Nakamura |
0:7d720671e6dc | 150 | uint32_t start_addr = (uint32_t)p_buf & 0xFFFFFFE0; |
Osamu Nakamura |
0:7d720671e6dc | 151 | uint32_t end_addr = (uint32_t)p_buf + size; |
Osamu Nakamura |
0:7d720671e6dc | 152 | uint32_t addr; |
Osamu Nakamura |
0:7d720671e6dc | 153 | |
Osamu Nakamura |
0:7d720671e6dc | 154 | /* Data cache invalid */ |
Osamu Nakamura |
0:7d720671e6dc | 155 | for (addr = start_addr; addr < end_addr; addr += 0x20) { |
Osamu Nakamura |
0:7d720671e6dc | 156 | __v7_inv_dcache_mva((void *)addr); |
Osamu Nakamura |
0:7d720671e6dc | 157 | } |
Osamu Nakamura |
0:7d720671e6dc | 158 | } |
Osamu Nakamura |
0:7d720671e6dc | 159 | |
Osamu Nakamura |
0:7d720671e6dc | 160 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 161 | /****** LCD ******/ |
Osamu Nakamura |
0:7d720671e6dc | 162 | static void Init_LCD_Display(void) { |
Osamu Nakamura |
0:7d720671e6dc | 163 | DisplayBase::graphics_error_t error; |
Osamu Nakamura |
0:7d720671e6dc | 164 | DisplayBase::lcd_config_t lcd_config; |
Osamu Nakamura |
0:7d720671e6dc | 165 | PinName lvds_pin[8] = { |
Osamu Nakamura |
0:7d720671e6dc | 166 | /* data pin */ |
Osamu Nakamura |
0:7d720671e6dc | 167 | P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0 |
Osamu Nakamura |
0:7d720671e6dc | 168 | }; |
Osamu Nakamura |
0:7d720671e6dc | 169 | |
Osamu Nakamura |
0:7d720671e6dc | 170 | lcd_pwon = 0; |
Osamu Nakamura |
0:7d720671e6dc | 171 | lcd_blon = 0; |
Osamu Nakamura |
0:7d720671e6dc | 172 | Thread::wait(100); |
Osamu Nakamura |
0:7d720671e6dc | 173 | lcd_pwon = 1; |
Osamu Nakamura |
0:7d720671e6dc | 174 | lcd_blon = 1; |
Osamu Nakamura |
0:7d720671e6dc | 175 | |
Osamu Nakamura |
0:7d720671e6dc | 176 | Display.Graphics_Lvds_Port_Init(lvds_pin, 8); |
Osamu Nakamura |
0:7d720671e6dc | 177 | |
Osamu Nakamura |
0:7d720671e6dc | 178 | /* Graphics initialization process */ |
Osamu Nakamura |
0:7d720671e6dc | 179 | lcd_config = LcdCfgTbl_LCD_shield; |
Osamu Nakamura |
0:7d720671e6dc | 180 | error = Display.Graphics_init(&lcd_config); |
Osamu Nakamura |
0:7d720671e6dc | 181 | if (error != DisplayBase::GRAPHICS_OK) { |
Osamu Nakamura |
0:7d720671e6dc | 182 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 183 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 184 | } |
Osamu Nakamura |
0:7d720671e6dc | 185 | graphics_init_end = true; |
Osamu Nakamura |
0:7d720671e6dc | 186 | } |
Osamu Nakamura |
0:7d720671e6dc | 187 | |
Osamu Nakamura |
0:7d720671e6dc | 188 | static void Start_LCD_Display(uint8_t * p_buf) { |
Osamu Nakamura |
0:7d720671e6dc | 189 | DisplayBase::rect_t rect; |
Osamu Nakamura |
0:7d720671e6dc | 190 | |
Osamu Nakamura |
0:7d720671e6dc | 191 | rect.vs = 0; |
Osamu Nakamura |
0:7d720671e6dc | 192 | rect.vw = VIDEO_PIXEL_VW; |
Osamu Nakamura |
0:7d720671e6dc | 193 | rect.hs = 0; |
Osamu Nakamura |
0:7d720671e6dc | 194 | rect.hw = VIDEO_PIXEL_HW; |
Osamu Nakamura |
0:7d720671e6dc | 195 | Display.Graphics_Read_Setting( |
Osamu Nakamura |
0:7d720671e6dc | 196 | DisplayBase::GRAPHICS_LAYER_0, |
Osamu Nakamura |
0:7d720671e6dc | 197 | (void *)p_buf, |
Osamu Nakamura |
0:7d720671e6dc | 198 | FRAME_BUFFER_STRIDE, |
Osamu Nakamura |
0:7d720671e6dc | 199 | GRAPHICS_FORMAT, |
Osamu Nakamura |
0:7d720671e6dc | 200 | WR_RD_WRSWA, |
Osamu Nakamura |
0:7d720671e6dc | 201 | &rect |
Osamu Nakamura |
0:7d720671e6dc | 202 | ); |
Osamu Nakamura |
0:7d720671e6dc | 203 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0); |
Osamu Nakamura |
0:7d720671e6dc | 204 | } |
Osamu Nakamura |
0:7d720671e6dc | 205 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 206 | |
Osamu Nakamura |
0:7d720671e6dc | 207 | /****** Video ******/ |
Osamu Nakamura |
0:7d720671e6dc | 208 | static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) { |
Osamu Nakamura |
0:7d720671e6dc | 209 | /* Interrupt callback function for Vfield interruption */ |
Osamu Nakamura |
0:7d720671e6dc | 210 | if (vfield_count > 0) { |
Osamu Nakamura |
0:7d720671e6dc | 211 | vfield_count--; |
Osamu Nakamura |
0:7d720671e6dc | 212 | } |
Osamu Nakamura |
0:7d720671e6dc | 213 | } |
Osamu Nakamura |
0:7d720671e6dc | 214 | |
Osamu Nakamura |
0:7d720671e6dc | 215 | static void Wait_Vfield(const int32_t wait_count) { |
Osamu Nakamura |
0:7d720671e6dc | 216 | /* Wait for the specified number of times Vsync occurs */ |
Osamu Nakamura |
0:7d720671e6dc | 217 | vfield_count = wait_count; |
Osamu Nakamura |
0:7d720671e6dc | 218 | while (vfield_count > 0) { |
Osamu Nakamura |
0:7d720671e6dc | 219 | Thread::wait(1); |
Osamu Nakamura |
0:7d720671e6dc | 220 | } |
Osamu Nakamura |
0:7d720671e6dc | 221 | } |
Osamu Nakamura |
0:7d720671e6dc | 222 | |
Osamu Nakamura |
0:7d720671e6dc | 223 | static void Init_Video(void) { |
Osamu Nakamura |
0:7d720671e6dc | 224 | DisplayBase::graphics_error_t error; |
Osamu Nakamura |
0:7d720671e6dc | 225 | |
Osamu Nakamura |
0:7d720671e6dc | 226 | /* Graphics initialization process */ |
Osamu Nakamura |
0:7d720671e6dc | 227 | if (graphics_init_end == false) { |
Osamu Nakamura |
0:7d720671e6dc | 228 | /* When not initializing LCD, this processing is needed. */ |
Osamu Nakamura |
0:7d720671e6dc | 229 | error = Display.Graphics_init(NULL); |
Osamu Nakamura |
0:7d720671e6dc | 230 | if (error != DisplayBase::GRAPHICS_OK) { |
Osamu Nakamura |
0:7d720671e6dc | 231 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 232 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 233 | } |
Osamu Nakamura |
0:7d720671e6dc | 234 | graphics_init_end = true; |
Osamu Nakamura |
0:7d720671e6dc | 235 | } |
Osamu Nakamura |
0:7d720671e6dc | 236 | |
Osamu Nakamura |
0:7d720671e6dc | 237 | #if VIDEO_INPUT_METHOD == VIDEO_CVBS |
Osamu Nakamura |
0:7d720671e6dc | 238 | error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_VDEC, NULL); |
Osamu Nakamura |
0:7d720671e6dc | 239 | if( error != DisplayBase::GRAPHICS_OK ) { |
Osamu Nakamura |
0:7d720671e6dc | 240 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 241 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 242 | } |
Osamu Nakamura |
0:7d720671e6dc | 243 | #elif VIDEO_INPUT_METHOD == VIDEO_CMOS_CAMERA |
Osamu Nakamura |
0:7d720671e6dc | 244 | DisplayBase::video_ext_in_config_t ext_in_config; |
Osamu Nakamura |
0:7d720671e6dc | 245 | PinName cmos_camera_pin[11] = { |
Osamu Nakamura |
0:7d720671e6dc | 246 | /* data pin */ |
Osamu Nakamura |
0:7d720671e6dc | 247 | P2_7, P2_6, P2_5, P2_4, P2_3, P2_2, P2_1, P2_0, |
Osamu Nakamura |
0:7d720671e6dc | 248 | /* control pin */ |
Osamu Nakamura |
0:7d720671e6dc | 249 | P10_0, /* DV0_CLK */ |
Osamu Nakamura |
0:7d720671e6dc | 250 | P1_0, /* DV0_Vsync */ |
Osamu Nakamura |
0:7d720671e6dc | 251 | P1_1 /* DV0_Hsync */ |
Osamu Nakamura |
0:7d720671e6dc | 252 | }; |
Osamu Nakamura |
0:7d720671e6dc | 253 | |
Osamu Nakamura |
0:7d720671e6dc | 254 | /* MT9V111 camera input config */ |
Osamu Nakamura |
0:7d720671e6dc | 255 | ext_in_config.inp_format = DisplayBase::VIDEO_EXTIN_FORMAT_BT601; /* BT601 8bit YCbCr format */ |
Osamu Nakamura |
0:7d720671e6dc | 256 | ext_in_config.inp_pxd_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing data */ |
Osamu Nakamura |
0:7d720671e6dc | 257 | ext_in_config.inp_vs_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing Vsync signals */ |
Osamu Nakamura |
0:7d720671e6dc | 258 | ext_in_config.inp_hs_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing Hsync signals */ |
Osamu Nakamura |
0:7d720671e6dc | 259 | ext_in_config.inp_endian_on = DisplayBase::OFF; /* External input bit endian change on/off */ |
Osamu Nakamura |
0:7d720671e6dc | 260 | ext_in_config.inp_swap_on = DisplayBase::OFF; /* External input B/R signal swap on/off */ |
Osamu Nakamura |
0:7d720671e6dc | 261 | ext_in_config.inp_vs_inv = DisplayBase::SIG_POL_NOT_INVERTED; /* External input DV_VSYNC inversion control */ |
Osamu Nakamura |
0:7d720671e6dc | 262 | ext_in_config.inp_hs_inv = DisplayBase::SIG_POL_INVERTED; /* External input DV_HSYNC inversion control */ |
Osamu Nakamura |
0:7d720671e6dc | 263 | ext_in_config.inp_f525_625 = DisplayBase::EXTIN_LINE_525; /* Number of lines for BT.656 external input */ |
Osamu Nakamura |
0:7d720671e6dc | 264 | ext_in_config.inp_h_pos = DisplayBase::EXTIN_H_POS_CRYCBY; /* Y/Cb/Y/Cr data string start timing to Hsync reference */ |
Osamu Nakamura |
0:7d720671e6dc | 265 | ext_in_config.cap_vs_pos = 6; /* Capture start position from Vsync */ |
Osamu Nakamura |
0:7d720671e6dc | 266 | ext_in_config.cap_hs_pos = 150; /* Capture start position form Hsync */ |
Osamu Nakamura |
0:7d720671e6dc | 267 | #if ((LCD_ONOFF) && (LCD_TYPE == 0)) |
Osamu Nakamura |
0:7d720671e6dc | 268 | /* The same screen ratio as the screen ratio of the LCD. */ |
Osamu Nakamura |
0:7d720671e6dc | 269 | ext_in_config.cap_width = 640; /* Capture width */ |
Osamu Nakamura |
0:7d720671e6dc | 270 | ext_in_config.cap_height = 363; /* Capture height Max 468[line] |
Osamu Nakamura |
0:7d720671e6dc | 271 | Due to CMOS(MT9V111) output signal timing and VDC5 specification */ |
Osamu Nakamura |
0:7d720671e6dc | 272 | #else |
Osamu Nakamura |
0:7d720671e6dc | 273 | ext_in_config.cap_width = 640; /* Capture width */ |
Osamu Nakamura |
0:7d720671e6dc | 274 | ext_in_config.cap_height = 468; /* Capture height Max 468[line] |
Osamu Nakamura |
0:7d720671e6dc | 275 | Due to CMOS(MT9V111) output signal timing and VDC5 specification */ |
Osamu Nakamura |
0:7d720671e6dc | 276 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 277 | error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_EXT, &ext_in_config); |
Osamu Nakamura |
0:7d720671e6dc | 278 | if( error != DisplayBase::GRAPHICS_OK ) { |
Osamu Nakamura |
0:7d720671e6dc | 279 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 280 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 281 | } |
Osamu Nakamura |
0:7d720671e6dc | 282 | |
Osamu Nakamura |
0:7d720671e6dc | 283 | /* Camera input port setting */ |
Osamu Nakamura |
0:7d720671e6dc | 284 | error = Display.Graphics_Dvinput_Port_Init(cmos_camera_pin, 11); |
Osamu Nakamura |
0:7d720671e6dc | 285 | if( error != DisplayBase::GRAPHICS_OK ) { |
Osamu Nakamura |
0:7d720671e6dc | 286 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 287 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 288 | } |
Osamu Nakamura |
0:7d720671e6dc | 289 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 290 | |
Osamu Nakamura |
0:7d720671e6dc | 291 | /* Interrupt callback function setting (Field end signal for recording function in scaler 0) */ |
Osamu Nakamura |
0:7d720671e6dc | 292 | error = Display.Graphics_Irq_Handler_Set(VIDEO_INT_TYPE, 0, IntCallbackFunc_Vfield); |
Osamu Nakamura |
0:7d720671e6dc | 293 | if (error != DisplayBase::GRAPHICS_OK) { |
Osamu Nakamura |
0:7d720671e6dc | 294 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 295 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 296 | } |
Osamu Nakamura |
0:7d720671e6dc | 297 | } |
Osamu Nakamura |
0:7d720671e6dc | 298 | |
Osamu Nakamura |
0:7d720671e6dc | 299 | static void Start_Video(uint8_t * p_buf) { |
Osamu Nakamura |
0:7d720671e6dc | 300 | DisplayBase::graphics_error_t error; |
Osamu Nakamura |
0:7d720671e6dc | 301 | |
Osamu Nakamura |
0:7d720671e6dc | 302 | /* Video capture setting (progressive form fixed) */ |
Osamu Nakamura |
0:7d720671e6dc | 303 | error = Display.Video_Write_Setting( |
Osamu Nakamura |
0:7d720671e6dc | 304 | VIDEO_INPUT_CH, |
Osamu Nakamura |
0:7d720671e6dc | 305 | COL_SYS, |
Osamu Nakamura |
0:7d720671e6dc | 306 | p_buf, |
Osamu Nakamura |
0:7d720671e6dc | 307 | FRAME_BUFFER_STRIDE, |
Osamu Nakamura |
0:7d720671e6dc | 308 | VIDEO_FORMAT, |
Osamu Nakamura |
0:7d720671e6dc | 309 | WR_RD_WRSWA, |
Osamu Nakamura |
0:7d720671e6dc | 310 | VIDEO_PIXEL_VW, |
Osamu Nakamura |
0:7d720671e6dc | 311 | VIDEO_PIXEL_HW |
Osamu Nakamura |
0:7d720671e6dc | 312 | ); |
Osamu Nakamura |
0:7d720671e6dc | 313 | if (error != DisplayBase::GRAPHICS_OK) { |
Osamu Nakamura |
0:7d720671e6dc | 314 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 315 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 316 | } |
Osamu Nakamura |
0:7d720671e6dc | 317 | |
Osamu Nakamura |
0:7d720671e6dc | 318 | /* Video write process start */ |
Osamu Nakamura |
0:7d720671e6dc | 319 | error = Display.Video_Start(VIDEO_INPUT_CH); |
Osamu Nakamura |
0:7d720671e6dc | 320 | if (error != DisplayBase::GRAPHICS_OK) { |
Osamu Nakamura |
0:7d720671e6dc | 321 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 322 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 323 | } |
Osamu Nakamura |
0:7d720671e6dc | 324 | |
Osamu Nakamura |
0:7d720671e6dc | 325 | /* Video write process stop */ |
Osamu Nakamura |
0:7d720671e6dc | 326 | error = Display.Video_Stop(VIDEO_INPUT_CH); |
Osamu Nakamura |
0:7d720671e6dc | 327 | if (error != DisplayBase::GRAPHICS_OK) { |
Osamu Nakamura |
0:7d720671e6dc | 328 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 329 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 330 | } |
Osamu Nakamura |
0:7d720671e6dc | 331 | |
Osamu Nakamura |
0:7d720671e6dc | 332 | /* Video write process start */ |
Osamu Nakamura |
0:7d720671e6dc | 333 | error = Display.Video_Start(VIDEO_INPUT_CH); |
Osamu Nakamura |
0:7d720671e6dc | 334 | if (error != DisplayBase::GRAPHICS_OK) { |
Osamu Nakamura |
0:7d720671e6dc | 335 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 336 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 337 | } |
Osamu Nakamura |
0:7d720671e6dc | 338 | } |
Osamu Nakamura |
0:7d720671e6dc | 339 | |
Osamu Nakamura |
0:7d720671e6dc | 340 | /** |
Osamu Nakamura |
0:7d720671e6dc | 341 | * ZXingResource class |
Osamu Nakamura |
0:7d720671e6dc | 342 | */ |
Osamu Nakamura |
0:7d720671e6dc | 343 | class ZXingResource : public DynamicResource |
Osamu Nakamura |
0:7d720671e6dc | 344 | { |
Osamu Nakamura |
0:7d720671e6dc | 345 | private: |
Osamu Nakamura |
0:7d720671e6dc | 346 | Thread * m_zxing_processor; |
Osamu Nakamura |
0:7d720671e6dc | 347 | |
Osamu Nakamura |
0:7d720671e6dc | 348 | public: |
Osamu Nakamura |
0:7d720671e6dc | 349 | /** |
Osamu Nakamura |
0:7d720671e6dc | 350 | Default constructor |
Osamu Nakamura |
0:7d720671e6dc | 351 | @param logger input logger instance for this resource |
Osamu Nakamura |
0:7d720671e6dc | 352 | @param obj_name input the Accelerometer Object name |
Osamu Nakamura |
0:7d720671e6dc | 353 | @param res_name input the Accelerometer Resource name |
Osamu Nakamura |
0:7d720671e6dc | 354 | @param observable input the resource is Observable (default: FALSE) |
Osamu Nakamura |
0:7d720671e6dc | 355 | */ |
Osamu Nakamura |
0:7d720671e6dc | 356 | |
Osamu Nakamura |
0:7d720671e6dc | 357 | ZXingResource(const Logger *logger,const char *obj_name,const char *res_name,const bool observable = false) : DynamicResource(logger,obj_name,res_name,"ZXing",M2MBase::GET_ALLOWED,observable) { |
Osamu Nakamura |
0:7d720671e6dc | 358 | // init |
Osamu Nakamura |
0:7d720671e6dc | 359 | _instance = (void *)this; |
Osamu Nakamura |
0:7d720671e6dc | 360 | |
Osamu Nakamura |
0:7d720671e6dc | 361 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 362 | // Initialze LCD |
Osamu Nakamura |
0:7d720671e6dc | 363 | Init_LCD_Display(); |
Osamu Nakamura |
0:7d720671e6dc | 364 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 365 | // Initialize Video |
Osamu Nakamura |
0:7d720671e6dc | 366 | Init_Video(); |
Osamu Nakamura |
0:7d720671e6dc | 367 | |
Osamu Nakamura |
0:7d720671e6dc | 368 | // Initialize frame buffer |
Osamu Nakamura |
0:7d720671e6dc | 369 | for (int i = 0; i < FRAME_BUFFER_NUM; i++) { |
Osamu Nakamura |
0:7d720671e6dc | 370 | memset(FrameBufferTbl[i], 0, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW)); |
Osamu Nakamura |
0:7d720671e6dc | 371 | dcache_clean(FrameBufferTbl[i], (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW)); |
Osamu Nakamura |
0:7d720671e6dc | 372 | } |
Osamu Nakamura |
0:7d720671e6dc | 373 | |
Osamu Nakamura |
0:7d720671e6dc | 374 | // Start Video |
Osamu Nakamura |
0:7d720671e6dc | 375 | Start_Video(FrameBufferTbl[write_buff_num]); |
Osamu Nakamura |
0:7d720671e6dc | 376 | /* Wait for first video drawing */ |
Osamu Nakamura |
0:7d720671e6dc | 377 | Wait_Vfield(2); |
Osamu Nakamura |
0:7d720671e6dc | 378 | |
Osamu Nakamura |
0:7d720671e6dc | 379 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 380 | DisplayBase::rect_t rect; |
Osamu Nakamura |
0:7d720671e6dc | 381 | |
Osamu Nakamura |
0:7d720671e6dc | 382 | /* The layer by which the touch panel location is drawn */ |
Osamu Nakamura |
0:7d720671e6dc | 383 | ascii_font.Erase(0x00000000); /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */ |
Osamu Nakamura |
0:7d720671e6dc | 384 | dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string)); |
Osamu Nakamura |
0:7d720671e6dc | 385 | rect.vs = 32; |
Osamu Nakamura |
0:7d720671e6dc | 386 | rect.vw = VIDEO_PIXEL_VW_STR; |
Osamu Nakamura |
0:7d720671e6dc | 387 | rect.hs = 32; |
Osamu Nakamura |
0:7d720671e6dc | 388 | rect.hw = VIDEO_PIXEL_HW_STR; |
Osamu Nakamura |
0:7d720671e6dc | 389 | Display.Graphics_Read_Setting( |
Osamu Nakamura |
0:7d720671e6dc | 390 | DisplayBase::GRAPHICS_LAYER_1, |
Osamu Nakamura |
0:7d720671e6dc | 391 | (void *)user_frame_buffer_string, |
Osamu Nakamura |
0:7d720671e6dc | 392 | FRAME_BUFFER_STRIDE_STR, |
Osamu Nakamura |
0:7d720671e6dc | 393 | DisplayBase::GRAPHICS_FORMAT_ARGB4444, |
Osamu Nakamura |
0:7d720671e6dc | 394 | DisplayBase::WR_RD_WRSWA_32_16BIT, |
Osamu Nakamura |
0:7d720671e6dc | 395 | &rect |
Osamu Nakamura |
0:7d720671e6dc | 396 | ); |
Osamu Nakamura |
0:7d720671e6dc | 397 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_1); |
Osamu Nakamura |
0:7d720671e6dc | 398 | string_draw = false; |
Osamu Nakamura |
0:7d720671e6dc | 399 | /* Start of LCD */ |
Osamu Nakamura |
0:7d720671e6dc | 400 | Start_LCD_Display(FrameBufferTbl[write_buff_num]); |
Osamu Nakamura |
0:7d720671e6dc | 401 | /* Backlight on */ |
Osamu Nakamura |
0:7d720671e6dc | 402 | Thread::wait(200); |
Osamu Nakamura |
0:7d720671e6dc | 403 | lcd_cntrst.write(1.0); |
Osamu Nakamura |
0:7d720671e6dc | 404 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 405 | decode_timer.reset(); |
Osamu Nakamura |
0:7d720671e6dc | 406 | decode_timer.start(); |
Osamu Nakamura |
0:7d720671e6dc | 407 | |
Osamu Nakamura |
0:7d720671e6dc | 408 | // no Thread yet |
Osamu Nakamura |
0:7d720671e6dc | 409 | this->m_zxing_processor = NULL; |
Osamu Nakamura |
0:7d720671e6dc | 410 | } |
Osamu Nakamura |
0:7d720671e6dc | 411 | |
Osamu Nakamura |
0:7d720671e6dc | 412 | /** |
Osamu Nakamura |
0:7d720671e6dc | 413 | Get the value of the barcode data |
Osamu Nakamura |
0:7d720671e6dc | 414 | @returns string containing the acclerometer sensor value |
Osamu Nakamura |
0:7d720671e6dc | 415 | */ |
Osamu Nakamura |
0:7d720671e6dc | 416 | virtual string get() { |
Osamu Nakamura |
0:7d720671e6dc | 417 | #if 1 |
Osamu Nakamura |
0:7d720671e6dc | 418 | if (this->m_zxing_processor == NULL) { |
Osamu Nakamura |
0:7d720671e6dc | 419 | // create the processing thread |
Osamu Nakamura |
0:7d720671e6dc | 420 | this->m_zxing_processor = new Thread(_zxing_processing); |
Osamu Nakamura |
0:7d720671e6dc | 421 | } |
Osamu Nakamura |
0:7d720671e6dc | 422 | |
Osamu Nakamura |
0:7d720671e6dc | 423 | if (*decode_str == NULL) { |
Osamu Nakamura |
1:67f8b5cfde75 | 424 | return string("0\0"); |
Osamu Nakamura |
0:7d720671e6dc | 425 | } else { |
Osamu Nakamura |
0:7d720671e6dc | 426 | return string(*decode_str); |
Osamu Nakamura |
0:7d720671e6dc | 427 | } |
Osamu Nakamura |
0:7d720671e6dc | 428 | |
Osamu Nakamura |
0:7d720671e6dc | 429 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 430 | } |
Osamu Nakamura |
0:7d720671e6dc | 431 | }; |
Osamu Nakamura |
0:7d720671e6dc | 432 | |
Osamu Nakamura |
0:7d720671e6dc | 433 | void _zxing_processing(const void *args) { |
Osamu Nakamura |
0:7d720671e6dc | 434 | while (true) { |
Osamu Nakamura |
0:7d720671e6dc | 435 | _zxing_loop(); |
Osamu Nakamura |
0:7d720671e6dc | 436 | Thread::wait(5); |
Osamu Nakamura |
0:7d720671e6dc | 437 | } |
Osamu Nakamura |
0:7d720671e6dc | 438 | } |
Osamu Nakamura |
0:7d720671e6dc | 439 | |
Osamu Nakamura |
0:7d720671e6dc | 440 | void _zxing_loop(void) { |
Osamu Nakamura |
0:7d720671e6dc | 441 | DisplayBase::graphics_error_t error; |
Osamu Nakamura |
0:7d720671e6dc | 442 | int decode_result = -1; |
Osamu Nakamura |
0:7d720671e6dc | 443 | |
Osamu Nakamura |
0:7d720671e6dc | 444 | #if 1 |
Osamu Nakamura |
0:7d720671e6dc | 445 | decode_buffer = FrameBufferTbl[write_buff_num]; |
Osamu Nakamura |
0:7d720671e6dc | 446 | write_buff_num++; |
Osamu Nakamura |
0:7d720671e6dc | 447 | |
Osamu Nakamura |
0:7d720671e6dc | 448 | if (write_buff_num >= FRAME_BUFFER_NUM) { |
Osamu Nakamura |
0:7d720671e6dc | 449 | write_buff_num = 0; |
Osamu Nakamura |
0:7d720671e6dc | 450 | } |
Osamu Nakamura |
0:7d720671e6dc | 451 | /* Change video buffer */ |
Osamu Nakamura |
0:7d720671e6dc | 452 | error = Display.Video_Write_Change(VIDEO_INPUT_CH, FrameBufferTbl[write_buff_num], FRAME_BUFFER_STRIDE); |
Osamu Nakamura |
0:7d720671e6dc | 453 | if (error != DisplayBase::GRAPHICS_OK) { |
Osamu Nakamura |
0:7d720671e6dc | 454 | printf("Line %d, error %d\n", __LINE__, error); |
Osamu Nakamura |
0:7d720671e6dc | 455 | mbed_die(); |
Osamu Nakamura |
0:7d720671e6dc | 456 | } |
Osamu Nakamura |
0:7d720671e6dc | 457 | Wait_Vfield(2); |
Osamu Nakamura |
0:7d720671e6dc | 458 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 459 | /* Change LCD buffer */ |
Osamu Nakamura |
0:7d720671e6dc | 460 | Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0, (void *)FrameBufferTbl[write_buff_num]); |
Osamu Nakamura |
0:7d720671e6dc | 461 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 462 | dcache_invalid(decode_buffer, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW)); |
Osamu Nakamura |
0:7d720671e6dc | 463 | /* Decode barcode image */ |
Osamu Nakamura |
0:7d720671e6dc | 464 | if (decode_timer.read_ms() >= decode_wait_time) { |
Osamu Nakamura |
0:7d720671e6dc | 465 | decode_timer.reset(); |
Osamu Nakamura |
0:7d720671e6dc | 466 | decode_result = ex_decode(decode_buffer, (FRAME_BUFFER_STRIDE * VIDEO_PIXEL_VW), VIDEO_PIXEL_HW, VIDEO_PIXEL_VW, &results); |
Osamu Nakamura |
0:7d720671e6dc | 467 | if (decode_result == 0) { |
Osamu Nakamura |
0:7d720671e6dc | 468 | decode_str = (char **)&(results[0]->getText()->getText()); |
Osamu Nakamura |
0:7d720671e6dc | 469 | |
Osamu Nakamura |
0:7d720671e6dc | 470 | if (_instance != NULL) { |
Osamu Nakamura |
0:7d720671e6dc | 471 | // observe... |
Osamu Nakamura |
0:7d720671e6dc | 472 | ((ZXingResource *)_instance)->observe(); |
Osamu Nakamura |
0:7d720671e6dc | 473 | } |
Osamu Nakamura |
0:7d720671e6dc | 474 | |
Osamu Nakamura |
0:7d720671e6dc | 475 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 476 | /* Drow string */ |
Osamu Nakamura |
0:7d720671e6dc | 477 | ascii_font.Erase(0x00000090); /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */ |
Osamu Nakamura |
0:7d720671e6dc | 478 | int rest_size = strlen(*decode_str); |
Osamu Nakamura |
0:7d720671e6dc | 479 | int draw_idx = 0; |
Osamu Nakamura |
0:7d720671e6dc | 480 | int draw_size; |
Osamu Nakamura |
0:7d720671e6dc | 481 | int draw_line = 0; |
Osamu Nakamura |
0:7d720671e6dc | 482 | |
Osamu Nakamura |
0:7d720671e6dc | 483 | while (rest_size > 0) { |
Osamu Nakamura |
0:7d720671e6dc | 484 | draw_size = ascii_font.DrawStr(*decode_str + draw_idx, 6, 5 + (18 * draw_line), 0x0000ffff, 2); |
Osamu Nakamura |
0:7d720671e6dc | 485 | if (draw_size <= 0) { |
Osamu Nakamura |
0:7d720671e6dc | 486 | break; |
Osamu Nakamura |
0:7d720671e6dc | 487 | } |
Osamu Nakamura |
0:7d720671e6dc | 488 | rest_size -= draw_size; |
Osamu Nakamura |
0:7d720671e6dc | 489 | draw_idx += draw_size; |
Osamu Nakamura |
0:7d720671e6dc | 490 | draw_line++; |
Osamu Nakamura |
0:7d720671e6dc | 491 | } |
Osamu Nakamura |
0:7d720671e6dc | 492 | |
Osamu Nakamura |
0:7d720671e6dc | 493 | dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string)); |
Osamu Nakamura |
0:7d720671e6dc | 494 | string_draw = true; |
Osamu Nakamura |
0:7d720671e6dc | 495 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 496 | decode_wait_time = 500; |
Osamu Nakamura |
0:7d720671e6dc | 497 | } else { |
Osamu Nakamura |
0:7d720671e6dc | 498 | #if LCD_ONOFF |
Osamu Nakamura |
0:7d720671e6dc | 499 | if (string_draw != false) { |
Osamu Nakamura |
0:7d720671e6dc | 500 | /* Clear string */ |
Osamu Nakamura |
0:7d720671e6dc | 501 | ascii_font.Erase(0x00000000); /* rrrrGBAR (r:Reserve G:Green B:Blue A:Alpha R:Red */ |
Osamu Nakamura |
0:7d720671e6dc | 502 | dcache_clean(user_frame_buffer_string, sizeof(user_frame_buffer_string)); |
Osamu Nakamura |
0:7d720671e6dc | 503 | string_draw = false; |
Osamu Nakamura |
0:7d720671e6dc | 504 | } |
Osamu Nakamura |
0:7d720671e6dc | 505 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 506 | decode_wait_time = 10; |
Osamu Nakamura |
0:7d720671e6dc | 507 | } |
Osamu Nakamura |
0:7d720671e6dc | 508 | } |
Osamu Nakamura |
0:7d720671e6dc | 509 | display_app.SendRgb888(decode_buffer, VIDEO_PIXEL_HW, VIDEO_PIXEL_VW); |
Osamu Nakamura |
0:7d720671e6dc | 510 | #endif |
Osamu Nakamura |
0:7d720671e6dc | 511 | } |
Osamu Nakamura |
0:7d720671e6dc | 512 | #endif // __ZXING_RESOURCE_H__ |