GR-PEACH Digital Signage sample.

Dependencies:   Display_shield_config GR-PEACH_video GraphicsFramework LCD_shield_config R_BSP SDBlockDevice_GR_PEACH USBHost_custom scan_folder

Information

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



What is this ?

This example is decording JPEG files in onboard flash memory using the GR-PEACH hardware decoders. You can easily operate the screen with your fingers or USB mouse. When micro SD card or USB memory is detected, the sample will show JPEG giles on the deteted filesystem.
After displaying a certain period of time, to display the next JPEG file. JPEG files will be enlarged / reduced in accordance with the image resolution to be output to the display. For this reason, the JPEG file resolution is most clearly displayed when the same as the resolution of the display output. Display order of the JPEG file is a directory analyze order. Please write the JPEG file to the memory in the order you want to display.

/media/uploads/dkato/digital_signage_1.jpg

Supported JPEG image

The location of the fileThe depth of the folder is to 8 hierarchies.
Extension".jpg" , ".JPG"
Resolution restrictionUpper limit 1280 x 800 Pixel. MCU unit.
The size upper limit450Kbyte
The formatJPEG baseline. (Optimization and progressive are not supported.)


Touch panel operation

The following operation is possible by a touch panel.

operationwork
Left flickThe next JPEG file is indicated.
(In the case of "SCROLL_DIRECTION=1", the previous JPEG file is indicated.)
Right flickThe previous JPEG file is indicated.
(In the case of "SCROLL_DIRECTION=1", the next JPEG file is indicated.)
Pinch outEnlarge the image.
Pinch inReduced the image.
Double tapReturn the image to its original size.


Mouse operation

The following operation is possible by a usb mouse.

operationwork
Left clickhe next JPEG file is indicated.
Right clickThe previous JPEG file is indicated.
Center click
(Center wheel push)
Mouse pointer display. While a mouse pointer is being indicated, automatic page turning isn't done.
Center wheelWhen a mouse pointer is indicated:Enlarge / Reduced the image.
When a mouse pointer is not indicated:The automatic page turning interval is changed.

The USB mouse which functions by the following sample can be used.
https://developer.mbed.org/handbook/USBHostMouse

Function settings

The function setting can be changed by the following macro.

main.cpp

/**** User Selection *********/
#define WAIT_TIME                           (10000) /* wait time (ms) 0:infinite */
#define DISSOLVE_STEP_NUM                   (16)    /* minimum 1 */
#define SCROLL_STEP_NUM                     (8)     /* minimum 1 */
#define SCROLL_DIRECTION                    (-1)    /* Select 1(left to right) or -1(right to left) */
/** LCD setting **/
#define LCD_TYPE                            (0)     /* Select 0(4.3inch) , 1(7.1inch), 2(Display shield) or 3(RSK TFT) */
/*****************************/


WAIT_TIMEThe automatic page turning interval is changed. The unit is ms.
The center wheel of USB mouse or USER_BUTTON0 can be changed.
DISSOLVE_STEP_NUMThe effect amount at automatic page turning is set. The minimum value is 1.
SCROLL_STEP_NUMThe effect amount at manual page turning is set. The minimum value is 1.
SCROLL_DIRECTIONThe scrolling direction at manual page turning is set. 1:left to right. -1:right to left.
LCD_TYPEType of LCD. 0:GR-PEACH 4.3 inch LCD Shield. 1:GR-PEACH 7.1 inch LCD Shield. 2:DISPLAY SHIELD(Not for sale).3:RSK TFT.
When using the DISPLAY SHIELD, you need to close the JP3, JP8, JP9, JP10 and JP11. For more details, see here.


Constitution

GR-PEACH, micro SD card or USB memory, USB mouse(If you want to mouse operation), USB HUB(If you use both USB memory and USB mouse), LCD Shield
You need to close the JP3 when using USB.. /media/uploads/RyoheiHagimoto/usb.jpg

Examples of creating images that conform to the JPEG baseline using the GIMP

In this sample, you can display only JPEG files that conform to the JPEG baseline.
Please try the following steps if there is a JPEG file that can not be displayed.

  1. Install picture edit tool GIMP
  2. Open an image file in GIMP.
    1. Right-click on the image file.
    2. Choose "Edit with GIMP".
  3. Change the picture size
    1. "Image" -> "Scale Image"
  4. Save it by the JPEG form.
    1. "File" -> "Export As..."
    2. Choose the save places.(The file extension ".jpg".)
    3. Click on the "Export".
    4. Click on "+Advanced Options".
    5. Remove the check of the "Progressive" and "Optimize".
    6. Click on "Export". (Attention: When the output size exceeds 450Kbyte, please adjust the quality value.)


概要

オンボードフラッシュメモリに書き込まれたJPEGファイルをGR-PEACHのハードウエアでデコードしています。 表示画面はタッチパネルやUSBマウスで操作することができます。 micro SDカード、または、USBメモリを接続すると、ファイルシステム上のJPEGファイルを表示します。
一定時間表示(時間の変更可)すると次のJPEGファイルを表示します。 JPEGファイルはディスプレイに出力する画像解像度にあわせて拡大/縮小されます。そのため、JPEGファイルはディスプレイ出力に近い解像度のほうが鮮明に表示されます。 JPEGファイルの表示順はディレクトリ解析順です。表示したい順にJPEGファイルを1ファイルずつUSBメモリに書き込んでください。

/media/uploads/dkato/digital_signage_1.jpg

表示可能なJPEGファイル

ファイル位置フォルダの深さはルートフォルダを含め8階層まで。
ファイル名半角英数字 (全角には対応していません)
拡張子".jpg" , ".JPG"
解像度制限上限1280 x 800 ピクセル。MCU単位のサイズ。
サイズ上限450Kbyte
フォーマットJPEGベースラインに準拠 (最適化、および、プログレッシブには対応していません)


タッチパネル操作

LCD上のタッチパネルにて、以下の操作が可能です。

操作動作
左フリック次のJPEGファイルを表示します。
(SCROLL_DIRECTION=1時は一つ前のJPEGファイルを表示します。)
右フリック一つ前のJPEGファイルを表示します。
(SCROLL_DIRECTION=1時は次のJPEGファイルを表示します。)
ピンチアウト画面を拡大します。
ピンチイン拡大した画面を縮小します。
ダブルタップ拡大中に、素早く画面を2回タップすると元のサイズに戻します。


マウス操作

USBマウスを接続することで、以下の操作が可能です。

操作動作
左クリック次のJPEGファイルを表示します。
右クリック一つ前のJPEGファイルを表示します。
センタークリック
(センターホイール押し込み)
マウスポインタ表示。マウスポインタ表示中は時間経過による次ファイル遷移は行いません。
センターホイールマウスポインタ表示中:画面の拡大/縮小。
マウスポインタ非表示中:JPEGファイルの表示する時間を変更。

一部使用できないUSBマウスがあります。使用可能なUSBマウスは下記サンプルで動作するデバイスのみです。
https://developer.mbed.org/handbook/USBHostMouse

機能設定

下記のマクロを変更することで、一部機能を変更できます。

main.cpp

/**** User Selection *********/
#define WAIT_TIME                           (10000) /* wait time (ms) 0:infinite */
#define DISSOLVE_STEP_NUM                   (16)    /* minimum 1 */
#define SCROLL_STEP_NUM                     (8)     /* minimum 1 */
#define SCROLL_DIRECTION                    (-1)    /* Select 1(left to right) or -1(right to left) */
/** LCD setting **/
#define LCD_TYPE                            (0)    /* Select 0(4.3inch) , 1(7.1inch), 2(Display shield) or 3(RSK TFT) */
/*****************************/


WAIT_TIME一つのJPEGファイルを表示する時間(デフォルト値)を設定します。単位はmsです。
動作後はUSER_BUTTON0、または、マウスのホイールで表示時間を変更できます。
DISSOLVE_STEP_NUM時間経過によって表示が変わる際のDISSOLVEエフェクトの長さを設定します。設定可能な最小値は1です。
SCROLL_STEP_NUM画面遷移時のスクロールエフェクトの長さを設定します。設定可能な最小値は1です。
SCROLL_DIRECTION次画面遷移時のスクロール方向を設定します。1を設定すると左から右へスクロール、-1を設定すると右から左へスクロールします。
LCD_TYPE0を設定するとGR-PEACH 4.3 inch LCD Shield、1を設定するとGR-PEACH 7.1 inch LCD Shield、2を設定するとDISPLAY SHIELD(非売品)、3を設定するとRSKボード用TFTの設定となります。
DISPLAY SHIELDを使用する際は、GR-PEACHのJP3、JP8、JP9、JP10、JP11をショートする必要があります。Jumper位置についてはこちらを参照ください。


構成

GR-PEACH、micro SDカード または USBメモリ、USBマウス(マウス操作を行わない場合は不要)、USB HUB(USBメモリとUSBマウスを両方使用する場合)、LCD Shield。
USBを使用する際はJP3をショートする必要があります。 /media/uploads/RyoheiHagimoto/usb.jpg

GIMPを使ったJPEGベースラインに準拠 したJPEGファイルの作成例

このサンプルでは、JPEGベースラインに準拠したJPEGファイルのみ表示可能です。
表示できないJPEGファイルがある場合は以下の手順をお試しください。

  1. 画像編集ツールGIMPをインストールする
  2. GIMPで画像ファイルを開く
    1. 画像ファイル上で右クリック
    2. Edit with GIMPを選択
  3. 画像サイズを変更する
    1. 「画像」→「画像の拡大・縮小」を選んで、画像の拡大・縮小ダイアログをから変更する
  4. JPEG形式で保存
    1. 「ファイル」→「名前をつけてエクスポート」で保存ダイアログを表示
    2. 保存先フォルダを選択 (ファイルの拡張子は.jpg)
    3. 「エクスポート」をクリックし、エクスポートダイアログを表示
    4. 「+詳細設定」の「+」部分をクリックして詳細設定画面を表示
    5. 「最適化」と「プログレッシブ」のチェックを外す
    6. エクスポートボタンを押す (注意:出力サイズが450Kbyteを超える場合は、品質値を調整して下さい。)
Committer:
dkato
Date:
Tue Sep 27 12:37:51 2016 +0000
Revision:
1:73b6cf66cb9a
Parent:
0:2156833a74a8
Child:
2:45e172d6f8b2
Add LCD type RSK TFT.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:2156833a74a8 1 #include "mbed.h"
dkato 0:2156833a74a8 2 #include "DisplayBace.h"
dkato 0:2156833a74a8 3 #include "rtos.h"
dkato 0:2156833a74a8 4 #include "RGA.h"
dkato 0:2156833a74a8 5 #include "BinaryImage_RZ_A1H.h"
dkato 0:2156833a74a8 6 #include "USBHostMouse.h"
dkato 0:2156833a74a8 7 #include "scan_folder.h"
dkato 0:2156833a74a8 8
dkato 0:2156833a74a8 9 /**** User Selection *********/
dkato 0:2156833a74a8 10 #define WAIT_TIME (10000) /* wait time (ms) 0:infinite */
dkato 0:2156833a74a8 11 #define DISSOLVE_STEP_NUM (16) /* minimum 1 */
dkato 0:2156833a74a8 12 #define SCROLL_STEP_NUM (8) /* minimum 1 */
dkato 0:2156833a74a8 13 #define SCROLL_DIRECTION (-1) /* Select 1(left to right) or -1(right to left) */
dkato 0:2156833a74a8 14 /** Storage setting **/
dkato 0:2156833a74a8 15 #define STORAGE_TYPE (0) /* Select 0(SD) or 1(USB) */
dkato 0:2156833a74a8 16 /** LCD setting **/
dkato 1:73b6cf66cb9a 17 #define LCD_TYPE (0) /* Select 0(4.3inch) , 1(7.1inch), 2(Display shield) or 3(RSK TFT) */
dkato 0:2156833a74a8 18 /*****************************/
dkato 0:2156833a74a8 19
dkato 0:2156833a74a8 20 #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB565)
dkato 0:2156833a74a8 21 #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT)
dkato 0:2156833a74a8 22
dkato 0:2156833a74a8 23 /** Storage config **/
dkato 0:2156833a74a8 24 #if (STORAGE_TYPE == 0)
dkato 0:2156833a74a8 25 #include "SDFileSystem_GR_PEACH.h"
dkato 0:2156833a74a8 26 #else
dkato 0:2156833a74a8 27 #include "USBHostMSD.h"
dkato 0:2156833a74a8 28 #endif
dkato 0:2156833a74a8 29
dkato 0:2156833a74a8 30 /** LCD shield config **/
dkato 0:2156833a74a8 31 #if (LCD_TYPE == 0)
dkato 0:2156833a74a8 32 #include "LCD_shield_config_4_3inch.h"
dkato 0:2156833a74a8 33 #elif (LCD_TYPE == 1)
dkato 0:2156833a74a8 34 #include "LCD_shield_config_7_1inch.h"
dkato 1:73b6cf66cb9a 35 #elif (LCD_TYPE == 2)
dkato 1:73b6cf66cb9a 36 #include "Display_shield_config.h"
dkato 0:2156833a74a8 37 #else
dkato 1:73b6cf66cb9a 38 #include "LCD_shield_config_RSK_TFT.h"
dkato 0:2156833a74a8 39 #endif
dkato 0:2156833a74a8 40
dkato 0:2156833a74a8 41 #if (SCROLL_DIRECTION == -1)
dkato 0:2156833a74a8 42 #define SCROLL_DIRECTION_NEXT (-1)
dkato 0:2156833a74a8 43 #define SCROLL_DIRECTION_PREV (1)
dkato 0:2156833a74a8 44 #else
dkato 0:2156833a74a8 45 #define SCROLL_DIRECTION_NEXT (1)
dkato 0:2156833a74a8 46 #define SCROLL_DIRECTION_PREV (-1)
dkato 0:2156833a74a8 47 #endif
dkato 0:2156833a74a8 48
dkato 0:2156833a74a8 49 /* FRAME BUFFER Parameter */
dkato 0:2156833a74a8 50 #define FRAME_BUFFER_BYTE_PER_PIXEL (2)
dkato 0:2156833a74a8 51 #define FRAME_BUFFER_STRIDE (((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
dkato 0:2156833a74a8 52
dkato 0:2156833a74a8 53 #define EVENT_NONE (0)
dkato 0:2156833a74a8 54 #define EVENT_DISP (1)
dkato 0:2156833a74a8 55 #define EVENT_NEXT (2)
dkato 0:2156833a74a8 56 #define EVENT_PREV (3)
dkato 0:2156833a74a8 57 #define EVENT_MOVE (4)
dkato 0:2156833a74a8 58 #define EVENT_MOVE_END (5)
dkato 0:2156833a74a8 59
dkato 0:2156833a74a8 60 #define MAX_JPEG_SIZE (1024 * 450)
dkato 0:2156833a74a8 61 #define MOUNT_NAME "storage"
dkato 0:2156833a74a8 62
dkato 0:2156833a74a8 63 #define TOUCH_NUM (2u)
dkato 0:2156833a74a8 64
dkato 0:2156833a74a8 65 typedef struct {
dkato 0:2156833a74a8 66 int pos_x;
dkato 0:2156833a74a8 67 int pos_y;
dkato 0:2156833a74a8 68 bool disp_pos;
dkato 0:2156833a74a8 69 bool disp_time;
dkato 0:2156833a74a8 70 bool change;
dkato 0:2156833a74a8 71 } mouse_info_t;
dkato 0:2156833a74a8 72
dkato 0:2156833a74a8 73 typedef struct {
dkato 0:2156833a74a8 74 int event_req;
dkato 0:2156833a74a8 75 uint8_t * p_pic_next;
dkato 0:2156833a74a8 76 uint8_t * p_pic_now;
dkato 0:2156833a74a8 77 float32_t magnification;
dkato 0:2156833a74a8 78 int x_move;
dkato 0:2156833a74a8 79 int swipe_end_move;
dkato 0:2156833a74a8 80 int drow_pos_x;
dkato 0:2156833a74a8 81 int drow_pos_y;
dkato 0:2156833a74a8 82 int scale_end_move_x;
dkato 0:2156833a74a8 83 int scale_end_move_y;
dkato 0:2156833a74a8 84 int min_x;
dkato 0:2156833a74a8 85 int min_y;
dkato 0:2156833a74a8 86 bool scroll;
dkato 0:2156833a74a8 87 } efect_info_t;
dkato 0:2156833a74a8 88
dkato 0:2156833a74a8 89 static const char_t * extension_tbl[] = {
dkato 0:2156833a74a8 90 ".jpg",
dkato 0:2156833a74a8 91 NULL
dkato 0:2156833a74a8 92 };
dkato 0:2156833a74a8 93 static InterruptIn button(USER_BUTTON0);
dkato 0:2156833a74a8 94 static DisplayBase Display;
dkato 0:2156833a74a8 95 static Canvas2D_ContextClass canvas2d;
dkato 0:2156833a74a8 96 #if (LCD_TYPE != 2)
dkato 0:2156833a74a8 97 static DigitalOut lcd_pwon(P7_15);
dkato 0:2156833a74a8 98 static DigitalOut lcd_blon(P8_1);
dkato 0:2156833a74a8 99 static PwmOut lcd_cntrst(P8_15);
dkato 0:2156833a74a8 100 #endif
dkato 0:2156833a74a8 101 static Serial pc(USBTX, USBRX);
dkato 0:2156833a74a8 102 static Timer system_timer;
dkato 0:2156833a74a8 103 static Semaphore sem_touch_int(0);
dkato 0:2156833a74a8 104
dkato 0:2156833a74a8 105 #if defined(__ICCARM__)
dkato 0:2156833a74a8 106 #pragma data_alignment=32
dkato 0:2156833a74a8 107 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 0:2156833a74a8 108 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 0:2156833a74a8 109 #pragma data_alignment=8
dkato 0:2156833a74a8 110 static uint8_t JpegBuffer[MAX_JPEG_SIZE]@ ".mirrorram"; //8 bytes aligned!;
dkato 0:2156833a74a8 111 #pragma data_alignment=4
dkato 0:2156833a74a8 112 #else
dkato 0:2156833a74a8 113 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */
dkato 0:2156833a74a8 114 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */
dkato 0:2156833a74a8 115 static uint8_t JpegBuffer[MAX_JPEG_SIZE]__attribute((section("NC_BSS"),aligned(8))); //8 bytes aligned!;
dkato 0:2156833a74a8 116 #endif
dkato 0:2156833a74a8 117 static frame_buffer_t frame_buffer_info;
dkato 0:2156833a74a8 118 static volatile int32_t vsync_count = 0;
dkato 0:2156833a74a8 119 static ScanFolder scan_foler;
dkato 0:2156833a74a8 120
dkato 0:2156833a74a8 121 static mouse_info_t mouse_info = {0, 0, false, false, false};
dkato 0:2156833a74a8 122
dkato 0:2156833a74a8 123 static int disp_wait_time = WAIT_TIME;
dkato 0:2156833a74a8 124 static uint32_t file_id_now = 0xffffffff;
dkato 0:2156833a74a8 125 static uint32_t file_id_next = 0xffffffff;
dkato 0:2156833a74a8 126 static int dissolve_seq = 0;
dkato 0:2156833a74a8 127 static efect_info_t efect_info;
dkato 0:2156833a74a8 128
dkato 0:2156833a74a8 129 #define ROM_PIC_NUM (4)
dkato 0:2156833a74a8 130 static bool storage_mode = false;
dkato 0:2156833a74a8 131 static uint32_t total_file_num = ROM_PIC_NUM;
dkato 0:2156833a74a8 132
dkato 0:2156833a74a8 133 static const graphics_image_t* number_tbl[10] = {
dkato 0:2156833a74a8 134 number0_Img,
dkato 0:2156833a74a8 135 number1_Img,
dkato 0:2156833a74a8 136 number2_Img,
dkato 0:2156833a74a8 137 number3_Img,
dkato 0:2156833a74a8 138 number4_Img,
dkato 0:2156833a74a8 139 number5_Img,
dkato 0:2156833a74a8 140 number6_Img,
dkato 0:2156833a74a8 141 number7_Img,
dkato 0:2156833a74a8 142 number8_Img,
dkato 0:2156833a74a8 143 number9_Img
dkato 0:2156833a74a8 144 };
dkato 0:2156833a74a8 145
dkato 0:2156833a74a8 146 /****** LCD ******/
dkato 0:2156833a74a8 147 static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type) {
dkato 0:2156833a74a8 148 /* Interrupt callback function for Vsync interruption */
dkato 0:2156833a74a8 149 if (vsync_count > 0) {
dkato 0:2156833a74a8 150 vsync_count--;
dkato 0:2156833a74a8 151 }
dkato 0:2156833a74a8 152 }
dkato 0:2156833a74a8 153
dkato 0:2156833a74a8 154 static void Wait_Vsync(const int32_t wait_count) {
dkato 0:2156833a74a8 155 /* Wait for the specified number of times Vsync occurs */
dkato 0:2156833a74a8 156 vsync_count = wait_count;
dkato 0:2156833a74a8 157 while (vsync_count > 0) {
dkato 0:2156833a74a8 158 /* Do nothing */
dkato 0:2156833a74a8 159 }
dkato 0:2156833a74a8 160 }
dkato 0:2156833a74a8 161
dkato 0:2156833a74a8 162 static void Init_LCD_Display(void) {
dkato 0:2156833a74a8 163 DisplayBase::graphics_error_t error;
dkato 0:2156833a74a8 164 DisplayBase::lcd_config_t lcd_config;
dkato 0:2156833a74a8 165 #if (LCD_TYPE == 2)
dkato 0:2156833a74a8 166 PinName lcd_pin[28] = {
dkato 0:2156833a74a8 167 /* data pin */
dkato 0:2156833a74a8 168 P11_15, P11_14, P11_13, P11_12, P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0,
dkato 0:2156833a74a8 169 P4_7, P4_6, P4_5, P4_4, P10_12, P10_13, P10_14, P10_15, P3_15, P3_14, P3_13,
dkato 0:2156833a74a8 170 P3_12, P3_11, P3_10, P3_9, P3_8
dkato 0:2156833a74a8 171 };
dkato 0:2156833a74a8 172 Display.Graphics_Lcd_Port_Init(lcd_pin, 28);
dkato 0:2156833a74a8 173 #else
dkato 0:2156833a74a8 174 PinName lvds_pin[8] = {
dkato 0:2156833a74a8 175 /* data pin */
dkato 0:2156833a74a8 176 P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
dkato 0:2156833a74a8 177 };
dkato 0:2156833a74a8 178
dkato 0:2156833a74a8 179 lcd_pwon = 0;
dkato 0:2156833a74a8 180 lcd_blon = 0;
dkato 0:2156833a74a8 181 Thread::wait(100);
dkato 0:2156833a74a8 182 lcd_pwon = 1;
dkato 0:2156833a74a8 183 lcd_blon = 1;
dkato 0:2156833a74a8 184
dkato 0:2156833a74a8 185 Display.Graphics_Lvds_Port_Init(lvds_pin, 8);
dkato 0:2156833a74a8 186 #endif
dkato 0:2156833a74a8 187
dkato 0:2156833a74a8 188 /* Graphics initialization process */
dkato 0:2156833a74a8 189 lcd_config = LcdCfgTbl_LCD_shield;
dkato 0:2156833a74a8 190 error = Display.Graphics_init(&lcd_config);
dkato 0:2156833a74a8 191 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:2156833a74a8 192 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:2156833a74a8 193 mbed_die();
dkato 0:2156833a74a8 194 }
dkato 0:2156833a74a8 195
dkato 0:2156833a74a8 196 /* Interrupt callback function setting (Vsync signal output from scaler 0) */
dkato 0:2156833a74a8 197 error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, IntCallbackFunc_LoVsync);
dkato 0:2156833a74a8 198 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:2156833a74a8 199 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:2156833a74a8 200 mbed_die();
dkato 0:2156833a74a8 201 }
dkato 0:2156833a74a8 202 }
dkato 0:2156833a74a8 203
dkato 0:2156833a74a8 204 static void Start_LCD_Display(uint8_t * p_buf) {
dkato 0:2156833a74a8 205 DisplayBase::rect_t rect;
dkato 0:2156833a74a8 206
dkato 0:2156833a74a8 207 rect.vs = 0;
dkato 0:2156833a74a8 208 rect.vw = LCD_PIXEL_HEIGHT;
dkato 0:2156833a74a8 209 rect.hs = 0;
dkato 0:2156833a74a8 210 rect.hw = LCD_PIXEL_WIDTH;
dkato 0:2156833a74a8 211 Display.Graphics_Read_Setting(
dkato 0:2156833a74a8 212 DisplayBase::GRAPHICS_LAYER_0,
dkato 0:2156833a74a8 213 (void *)p_buf,
dkato 0:2156833a74a8 214 FRAME_BUFFER_STRIDE,
dkato 0:2156833a74a8 215 GRAPHICS_FORMAT,
dkato 0:2156833a74a8 216 WR_RD_WRSWA,
dkato 0:2156833a74a8 217 &rect
dkato 0:2156833a74a8 218 );
dkato 0:2156833a74a8 219 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
dkato 0:2156833a74a8 220 }
dkato 0:2156833a74a8 221
dkato 0:2156833a74a8 222 static void Update_LCD_Display(frame_buffer_t * frmbuf_info) {
dkato 0:2156833a74a8 223 Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0,
dkato 0:2156833a74a8 224 (void *)frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index]);
dkato 0:2156833a74a8 225 Wait_Vsync(1);
dkato 0:2156833a74a8 226 }
dkato 0:2156833a74a8 227
dkato 0:2156833a74a8 228 static void Swap_FrameBuffer(frame_buffer_t * frmbuf_info) {
dkato 0:2156833a74a8 229 if (frmbuf_info->draw_buffer_index == 1) {
dkato 0:2156833a74a8 230 frmbuf_info->draw_buffer_index = 0;
dkato 0:2156833a74a8 231 } else {
dkato 0:2156833a74a8 232 frmbuf_info->draw_buffer_index = 1;
dkato 0:2156833a74a8 233 }
dkato 0:2156833a74a8 234 }
dkato 0:2156833a74a8 235
dkato 0:2156833a74a8 236
dkato 0:2156833a74a8 237 /****** Draw Image ******/
dkato 0:2156833a74a8 238 static void draw_mouse_pos(void) {
dkato 0:2156833a74a8 239 if (mouse_info.disp_pos != false) {
dkato 0:2156833a74a8 240 /* Draw a image */
dkato 0:2156833a74a8 241 canvas2d.drawImage(mousu_pos_Img, mouse_info.pos_x, mouse_info.pos_y);
dkato 0:2156833a74a8 242 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 243 }
dkato 0:2156833a74a8 244 }
dkato 0:2156833a74a8 245
dkato 0:2156833a74a8 246 static void draw_disp_time(void) {
dkato 0:2156833a74a8 247 if (mouse_info.disp_time != false) {
dkato 0:2156833a74a8 248 int wk_ofs = (LCD_PIXEL_WIDTH - 215) / 2 + 103;
dkato 0:2156833a74a8 249 int wk_sec;
dkato 0:2156833a74a8 250
dkato 0:2156833a74a8 251 /* Draw a image */
dkato 0:2156833a74a8 252 canvas2d.drawImage(disp_xsec_Img, (LCD_PIXEL_WIDTH - 215) / 2, LCD_PIXEL_HEIGHT / 2);
dkato 0:2156833a74a8 253 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 254
dkato 0:2156833a74a8 255 if (disp_wait_time == 0) {
dkato 0:2156833a74a8 256 /* Draw a image */
dkato 0:2156833a74a8 257 canvas2d.drawImage(number_inf_Img, wk_ofs, LCD_PIXEL_HEIGHT / 2);
dkato 0:2156833a74a8 258 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 259 } else {
dkato 0:2156833a74a8 260 wk_sec = (disp_wait_time / 10000) % 10;
dkato 0:2156833a74a8 261 if (wk_sec != 0) {
dkato 0:2156833a74a8 262 /* Draw a image */
dkato 0:2156833a74a8 263 canvas2d.drawImage(number_tbl[wk_sec], wk_ofs, LCD_PIXEL_HEIGHT / 2);
dkato 0:2156833a74a8 264 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 265 wk_ofs += 12;
dkato 0:2156833a74a8 266 } else {
dkato 0:2156833a74a8 267 wk_ofs += 6;
dkato 0:2156833a74a8 268 }
dkato 0:2156833a74a8 269 wk_sec = (disp_wait_time / 1000) % 10;
dkato 0:2156833a74a8 270 /* Draw a image */
dkato 0:2156833a74a8 271 canvas2d.drawImage(number_tbl[wk_sec], wk_ofs, LCD_PIXEL_HEIGHT / 2);
dkato 0:2156833a74a8 272 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 273 }
dkato 0:2156833a74a8 274 }
dkato 0:2156833a74a8 275 }
dkato 0:2156833a74a8 276
dkato 0:2156833a74a8 277 static void draw_image_scroll(frame_buffer_t* frmbuf_info, const graphics_image_t* image_last,
dkato 0:2156833a74a8 278 const graphics_image_t* image_new, float32_t scroll, int ditection) {
dkato 0:2156833a74a8 279 Swap_FrameBuffer(frmbuf_info);
dkato 0:2156833a74a8 280 /* Clear */
dkato 0:2156833a74a8 281 canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height);
dkato 0:2156833a74a8 282 /* Draw a image */
dkato 0:2156833a74a8 283 canvas2d.globalAlpha = 1.0f;
dkato 0:2156833a74a8 284 canvas2d.drawImage((const graphics_image_t*)image_last,
dkato 0:2156833a74a8 285 (int_t)(frmbuf_info->width * scroll) * ditection, 0,
dkato 0:2156833a74a8 286 frmbuf_info->width, frmbuf_info->height);
dkato 0:2156833a74a8 287 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 288 canvas2d.globalAlpha = 1.0f;
dkato 0:2156833a74a8 289 canvas2d.drawImage((const graphics_image_t*)image_new,
dkato 0:2156833a74a8 290 ((int_t)(frmbuf_info->width * scroll) - frmbuf_info->width) * ditection, 0,
dkato 0:2156833a74a8 291 frmbuf_info->width, frmbuf_info->height);
dkato 0:2156833a74a8 292 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 293 /* mouse pos */
dkato 0:2156833a74a8 294 draw_mouse_pos();
dkato 0:2156833a74a8 295 draw_disp_time();
dkato 0:2156833a74a8 296 /* Complete drawing */
dkato 0:2156833a74a8 297 R_GRAPHICS_Finish(canvas2d.c_LanguageContext);
dkato 0:2156833a74a8 298 Update_LCD_Display(frmbuf_info);
dkato 0:2156833a74a8 299 }
dkato 0:2156833a74a8 300
dkato 0:2156833a74a8 301 static void draw_image_dissolve(frame_buffer_t* frmbuf_info, const graphics_image_t* image_last,
dkato 0:2156833a74a8 302 const graphics_image_t* image_new, float32_t alpha) {
dkato 0:2156833a74a8 303 Swap_FrameBuffer(frmbuf_info);
dkato 0:2156833a74a8 304 /* Clear */
dkato 0:2156833a74a8 305 canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height);
dkato 0:2156833a74a8 306 /* Draw a image */
dkato 0:2156833a74a8 307 canvas2d.globalAlpha = 1.0f - alpha;
dkato 0:2156833a74a8 308 canvas2d.drawImage((const graphics_image_t*)image_last, 0, 0, frmbuf_info->width, frmbuf_info->height);
dkato 0:2156833a74a8 309 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 310 canvas2d.globalAlpha = alpha;
dkato 0:2156833a74a8 311 canvas2d.drawImage((const graphics_image_t*)image_new, 0, 0, frmbuf_info->width, frmbuf_info->height);
dkato 0:2156833a74a8 312 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 313 /* mouse pos */
dkato 0:2156833a74a8 314 draw_mouse_pos();
dkato 0:2156833a74a8 315 draw_disp_time();
dkato 0:2156833a74a8 316 /* Complete drawing */
dkato 0:2156833a74a8 317 R_GRAPHICS_Finish(canvas2d.c_LanguageContext);
dkato 0:2156833a74a8 318 Update_LCD_Display(frmbuf_info);
dkato 0:2156833a74a8 319 }
dkato 0:2156833a74a8 320
dkato 0:2156833a74a8 321 static void draw_image(frame_buffer_t* frmbuf_info, const graphics_image_t* image_new,
dkato 0:2156833a74a8 322 uint32_t pos_x, uint32_t pos_y, graphics_matrix_float_t zoom) {
dkato 0:2156833a74a8 323 int_t dest_width;
dkato 0:2156833a74a8 324 int_t dest_height;
dkato 0:2156833a74a8 325
dkato 0:2156833a74a8 326 Swap_FrameBuffer(frmbuf_info);
dkato 0:2156833a74a8 327 /* Clear */
dkato 0:2156833a74a8 328 canvas2d.clearRect(0, 0, frmbuf_info->width, frmbuf_info->height);
dkato 0:2156833a74a8 329 /* Draw a image */
dkato 0:2156833a74a8 330 canvas2d.globalAlpha = 1.0f;
dkato 0:2156833a74a8 331 dest_width = frmbuf_info->width * zoom;
dkato 0:2156833a74a8 332 dest_height = frmbuf_info->height * zoom;
dkato 0:2156833a74a8 333 canvas2d.drawImage((const graphics_image_t*)image_new,
dkato 0:2156833a74a8 334 pos_x, pos_y, dest_width, dest_height);
dkato 0:2156833a74a8 335 R_OSPL_CLEAR_ERROR();
dkato 0:2156833a74a8 336 /* mouse pos */
dkato 0:2156833a74a8 337 draw_mouse_pos();
dkato 0:2156833a74a8 338 draw_disp_time();
dkato 0:2156833a74a8 339 /* Complete drawing */
dkato 0:2156833a74a8 340 R_GRAPHICS_Finish(canvas2d.c_LanguageContext);
dkato 0:2156833a74a8 341 Update_LCD_Display(frmbuf_info);
dkato 0:2156833a74a8 342 }
dkato 0:2156833a74a8 343
dkato 0:2156833a74a8 344
dkato 0:2156833a74a8 345 /****** File Access ******/
dkato 0:2156833a74a8 346 static bool read_new_file(uint8_t ** pp_buf, uint32_t file_id) {
dkato 0:2156833a74a8 347 bool ret = false;
dkato 0:2156833a74a8 348
dkato 0:2156833a74a8 349 if (storage_mode == false) {
dkato 0:2156833a74a8 350 ret = true;
dkato 0:2156833a74a8 351 switch (file_id) {
dkato 0:2156833a74a8 352 case 0: *pp_buf = (uint8_t *)img01_File; break;
dkato 0:2156833a74a8 353 case 1: *pp_buf = (uint8_t *)img02_File; break;
dkato 0:2156833a74a8 354 case 2: *pp_buf = (uint8_t *)img03_File; break;
dkato 0:2156833a74a8 355 case 3: *pp_buf = (uint8_t *)img04_File; break;
dkato 0:2156833a74a8 356 default: ret = false; break;
dkato 0:2156833a74a8 357 }
dkato 0:2156833a74a8 358 } else {
dkato 0:2156833a74a8 359 FILE * fp = scan_foler.open(file_id);
dkato 0:2156833a74a8 360 size_t read_size;
dkato 0:2156833a74a8 361
dkato 0:2156833a74a8 362 read_size = fread(*pp_buf, sizeof(char), MAX_JPEG_SIZE, fp);
dkato 0:2156833a74a8 363 scan_foler.close(fp);
dkato 0:2156833a74a8 364 if (read_size < MAX_JPEG_SIZE) {
dkato 0:2156833a74a8 365 ret = true;
dkato 0:2156833a74a8 366 }
dkato 0:2156833a74a8 367 }
dkato 0:2156833a74a8 368
dkato 0:2156833a74a8 369 return ret;
dkato 0:2156833a74a8 370 }
dkato 0:2156833a74a8 371
dkato 0:2156833a74a8 372 static void swap_file_buff(void) {
dkato 0:2156833a74a8 373 uint8_t * p_wk_pic = efect_info.p_pic_now;
dkato 0:2156833a74a8 374 uint32_t wk_file_id = file_id_now;
dkato 0:2156833a74a8 375
dkato 0:2156833a74a8 376 efect_info.p_pic_now = efect_info.p_pic_next;
dkato 0:2156833a74a8 377 efect_info.p_pic_next = p_wk_pic;
dkato 0:2156833a74a8 378 file_id_now = file_id_next;
dkato 0:2156833a74a8 379 file_id_next = wk_file_id;
dkato 0:2156833a74a8 380 }
dkato 0:2156833a74a8 381
dkato 0:2156833a74a8 382 static bool read_next_file(void) {
dkato 0:2156833a74a8 383 uint32_t wk_file_id;
dkato 0:2156833a74a8 384 bool ret = false;
dkato 0:2156833a74a8 385
dkato 0:2156833a74a8 386 if (file_id_now < (total_file_num - 1)) {
dkato 0:2156833a74a8 387 wk_file_id = file_id_now + 1;
dkato 0:2156833a74a8 388 } else {
dkato 0:2156833a74a8 389 wk_file_id = 0;
dkato 0:2156833a74a8 390 }
dkato 0:2156833a74a8 391 if (wk_file_id != file_id_next) {
dkato 0:2156833a74a8 392 ret = read_new_file(&efect_info.p_pic_next, wk_file_id);
dkato 0:2156833a74a8 393 if (ret != false) {
dkato 0:2156833a74a8 394 file_id_next = wk_file_id;
dkato 0:2156833a74a8 395 }
dkato 0:2156833a74a8 396 } else {
dkato 0:2156833a74a8 397 ret = true;
dkato 0:2156833a74a8 398 }
dkato 0:2156833a74a8 399
dkato 0:2156833a74a8 400 return ret;
dkato 0:2156833a74a8 401 }
dkato 0:2156833a74a8 402
dkato 0:2156833a74a8 403 static bool read_prev_file(void) {
dkato 0:2156833a74a8 404 uint32_t wk_file_id;
dkato 0:2156833a74a8 405 bool ret = false;
dkato 0:2156833a74a8 406
dkato 0:2156833a74a8 407 if (file_id_now >= total_file_num) {
dkato 0:2156833a74a8 408 wk_file_id = 0;
dkato 0:2156833a74a8 409 } else if (file_id_now != 0) {
dkato 0:2156833a74a8 410 wk_file_id = file_id_now - 1;
dkato 0:2156833a74a8 411 } else {
dkato 0:2156833a74a8 412 wk_file_id = total_file_num - 1;
dkato 0:2156833a74a8 413 }
dkato 0:2156833a74a8 414 if (wk_file_id != file_id_next) {
dkato 0:2156833a74a8 415 ret = read_new_file(&efect_info.p_pic_next, wk_file_id);
dkato 0:2156833a74a8 416 if (ret != false) {
dkato 0:2156833a74a8 417 file_id_next = wk_file_id;
dkato 0:2156833a74a8 418 }
dkato 0:2156833a74a8 419 } else {
dkato 0:2156833a74a8 420 ret = true;
dkato 0:2156833a74a8 421 }
dkato 0:2156833a74a8 422
dkato 0:2156833a74a8 423 return ret;
dkato 0:2156833a74a8 424 }
dkato 0:2156833a74a8 425
dkato 0:2156833a74a8 426
dkato 0:2156833a74a8 427 /****** Efect setting ******/
dkato 0:2156833a74a8 428 static void zoom_scroll(int x, int y) {
dkato 0:2156833a74a8 429 efect_info.drow_pos_x += x;
dkato 0:2156833a74a8 430 if (efect_info.drow_pos_x < efect_info.min_x) {
dkato 0:2156833a74a8 431 efect_info.drow_pos_x = efect_info.min_x;
dkato 0:2156833a74a8 432 }
dkato 0:2156833a74a8 433 if (efect_info.drow_pos_x > 0) {
dkato 0:2156833a74a8 434 efect_info.drow_pos_x = 0;
dkato 0:2156833a74a8 435 }
dkato 0:2156833a74a8 436 efect_info.drow_pos_y += y;
dkato 0:2156833a74a8 437 if (efect_info.drow_pos_y < efect_info.min_y) {
dkato 0:2156833a74a8 438 efect_info.drow_pos_y = efect_info.min_y;
dkato 0:2156833a74a8 439 }
dkato 0:2156833a74a8 440 if (efect_info.drow_pos_y > 0) {
dkato 0:2156833a74a8 441 efect_info.drow_pos_y = 0;
dkato 0:2156833a74a8 442 }
dkato 0:2156833a74a8 443 }
dkato 0:2156833a74a8 444
dkato 0:2156833a74a8 445 static void move_func(int x, int y) {
dkato 0:2156833a74a8 446 if (efect_info.magnification != 1.0f) {
dkato 0:2156833a74a8 447 zoom_scroll(x, y);
dkato 0:2156833a74a8 448 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 449 } else {
dkato 0:2156833a74a8 450 efect_info.scroll = true;
dkato 0:2156833a74a8 451 efect_info.x_move += x;
dkato 0:2156833a74a8 452 efect_info.event_req = EVENT_MOVE;
dkato 0:2156833a74a8 453 }
dkato 0:2156833a74a8 454 }
dkato 0:2156833a74a8 455
dkato 0:2156833a74a8 456 static void move_end_func(int x, int y) {
dkato 0:2156833a74a8 457 if (efect_info.magnification != 1.0f) {
dkato 0:2156833a74a8 458 efect_info.scale_end_move_x = x;
dkato 0:2156833a74a8 459 efect_info.scale_end_move_y = y;
dkato 0:2156833a74a8 460 } else {
dkato 0:2156833a74a8 461 if (efect_info.scroll != false) {
dkato 0:2156833a74a8 462 efect_info.scroll = false;
dkato 0:2156833a74a8 463 if (efect_info.x_move != 0) {
dkato 0:2156833a74a8 464 efect_info.swipe_end_move = x;
dkato 0:2156833a74a8 465 efect_info.event_req = EVENT_MOVE_END;
dkato 0:2156833a74a8 466 }
dkato 0:2156833a74a8 467 }
dkato 0:2156833a74a8 468 }
dkato 0:2156833a74a8 469 }
dkato 0:2156833a74a8 470
dkato 0:2156833a74a8 471 static void zoom_func(uint32_t center_x_last, uint32_t center_y_last, uint32_t center_x, uint32_t center_y, float32_t new_magnification) {
dkato 0:2156833a74a8 472 if (new_magnification != efect_info.magnification) {
dkato 0:2156833a74a8 473 if (new_magnification < 1.0f) {
dkato 0:2156833a74a8 474 new_magnification = 1.0f;
dkato 0:2156833a74a8 475 }
dkato 0:2156833a74a8 476 if (new_magnification > 10.0f) {
dkato 0:2156833a74a8 477 new_magnification = 10.0f;
dkato 0:2156833a74a8 478 }
dkato 0:2156833a74a8 479 efect_info.min_x = 0 - (frame_buffer_info.width * (new_magnification - 1.0f));
dkato 0:2156833a74a8 480 efect_info.min_y = 0 - (frame_buffer_info.height * (new_magnification - 1.0f));
dkato 0:2156833a74a8 481
dkato 0:2156833a74a8 482 efect_info.drow_pos_x = -((center_x_last - efect_info.drow_pos_x) / efect_info.magnification * new_magnification - center_x);
dkato 0:2156833a74a8 483 if (efect_info.drow_pos_x < efect_info.min_x) {
dkato 0:2156833a74a8 484 efect_info.drow_pos_x = efect_info.min_x;
dkato 0:2156833a74a8 485 }
dkato 0:2156833a74a8 486 if (efect_info.drow_pos_x > 0) {
dkato 0:2156833a74a8 487 efect_info.drow_pos_x = 0;
dkato 0:2156833a74a8 488 }
dkato 0:2156833a74a8 489
dkato 0:2156833a74a8 490 efect_info.drow_pos_y = -((center_y_last - efect_info.drow_pos_y) / efect_info.magnification * new_magnification - center_y);
dkato 0:2156833a74a8 491 if (efect_info.drow_pos_y < efect_info.min_y) {
dkato 0:2156833a74a8 492 efect_info.drow_pos_y = efect_info.min_y;
dkato 0:2156833a74a8 493 }
dkato 0:2156833a74a8 494 if (efect_info.drow_pos_y > 0) {
dkato 0:2156833a74a8 495 efect_info.drow_pos_y = 0;
dkato 0:2156833a74a8 496 }
dkato 0:2156833a74a8 497 if (new_magnification == 1.0f) {
dkato 0:2156833a74a8 498 efect_info.drow_pos_x = 0;
dkato 0:2156833a74a8 499 efect_info.drow_pos_y = 0;
dkato 0:2156833a74a8 500 }
dkato 0:2156833a74a8 501 efect_info.x_move = 0;
dkato 0:2156833a74a8 502 efect_info.magnification = new_magnification;
dkato 0:2156833a74a8 503 if (efect_info.event_req == EVENT_NONE) {
dkato 0:2156833a74a8 504 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 505 }
dkato 0:2156833a74a8 506 }
dkato 0:2156833a74a8 507 }
dkato 0:2156833a74a8 508
dkato 0:2156833a74a8 509 /****** Mouse ******/
dkato 0:2156833a74a8 510 void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) {
dkato 0:2156833a74a8 511 static uint8_t last_buttons = 0;
dkato 0:2156833a74a8 512 int wk_pos;
dkato 0:2156833a74a8 513 int wk_disp_time;
dkato 0:2156833a74a8 514 int mouse_move_x;
dkato 0:2156833a74a8 515 int mouse_move_y;
dkato 0:2156833a74a8 516
dkato 0:2156833a74a8 517 // printf("buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z);
dkato 0:2156833a74a8 518
dkato 0:2156833a74a8 519 wk_pos = mouse_info.pos_x;
dkato 0:2156833a74a8 520 wk_pos += x;
dkato 0:2156833a74a8 521 mouse_move_x = x;
dkato 0:2156833a74a8 522 if (wk_pos < 0) {
dkato 0:2156833a74a8 523 wk_pos = 0;
dkato 0:2156833a74a8 524 mouse_move_x = 0;
dkato 0:2156833a74a8 525 }
dkato 0:2156833a74a8 526 if (wk_pos > (LCD_PIXEL_WIDTH - 10)) {
dkato 0:2156833a74a8 527 wk_pos = LCD_PIXEL_WIDTH - 10;
dkato 0:2156833a74a8 528 mouse_move_x = 0;
dkato 0:2156833a74a8 529 }
dkato 0:2156833a74a8 530 mouse_info.pos_x = wk_pos;
dkato 0:2156833a74a8 531
dkato 0:2156833a74a8 532 wk_pos = mouse_info.pos_y;
dkato 0:2156833a74a8 533 wk_pos += y;
dkato 0:2156833a74a8 534 mouse_move_y = y;
dkato 0:2156833a74a8 535 if (wk_pos < 0) {
dkato 0:2156833a74a8 536 wk_pos = 0;
dkato 0:2156833a74a8 537 mouse_move_y = 0;
dkato 0:2156833a74a8 538 }
dkato 0:2156833a74a8 539 if (wk_pos > (LCD_PIXEL_HEIGHT - 10)) {
dkato 0:2156833a74a8 540 wk_pos = (LCD_PIXEL_HEIGHT - 10);
dkato 0:2156833a74a8 541 mouse_move_y = 0;
dkato 0:2156833a74a8 542 }
dkato 0:2156833a74a8 543 mouse_info.pos_y = wk_pos;
dkato 0:2156833a74a8 544
dkato 0:2156833a74a8 545 if (mouse_info.disp_pos != false) {
dkato 0:2156833a74a8 546 if ((buttons & 0x01) != 0) {
dkato 0:2156833a74a8 547 move_func(mouse_move_x, mouse_move_y);
dkato 0:2156833a74a8 548 } else if (((buttons & 0x01) == 0) && ((last_buttons & 0x01) != 0)) {
dkato 0:2156833a74a8 549 move_end_func(mouse_move_x, mouse_move_y);
dkato 0:2156833a74a8 550 } else if ((efect_info.event_req == EVENT_NONE) && (dissolve_seq == 0)) {
dkato 0:2156833a74a8 551 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 552 } else {
dkato 0:2156833a74a8 553 /* do nothing */
dkato 0:2156833a74a8 554 }
dkato 0:2156833a74a8 555 } else {
dkato 0:2156833a74a8 556 // left
dkato 0:2156833a74a8 557 if (((buttons & 0x01) == 0) && ((last_buttons & 0x01) != 0)) {
dkato 0:2156833a74a8 558 efect_info.event_req = EVENT_NEXT;
dkato 0:2156833a74a8 559 }
dkato 0:2156833a74a8 560
dkato 0:2156833a74a8 561 // rigth
dkato 0:2156833a74a8 562 if (((buttons & 0x02) == 0) && ((last_buttons & 0x02) != 0)) {
dkato 0:2156833a74a8 563 efect_info.event_req = EVENT_PREV;
dkato 0:2156833a74a8 564 }
dkato 0:2156833a74a8 565 }
dkato 0:2156833a74a8 566
dkato 0:2156833a74a8 567 if (((buttons & 0x04) != 0) && ((last_buttons & 0x04) == 0)) {
dkato 0:2156833a74a8 568 mouse_info.disp_pos = !mouse_info.disp_pos;
dkato 0:2156833a74a8 569 if ((efect_info.event_req == EVENT_NONE) && (dissolve_seq == 0)) {
dkato 0:2156833a74a8 570 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 571 }
dkato 0:2156833a74a8 572 }
dkato 0:2156833a74a8 573
dkato 0:2156833a74a8 574 if (z != 0) {
dkato 0:2156833a74a8 575 if (mouse_info.disp_pos == false) {
dkato 0:2156833a74a8 576 wk_disp_time = disp_wait_time;
dkato 0:2156833a74a8 577 if (z > 0) {
dkato 0:2156833a74a8 578 wk_disp_time += 1000;
dkato 0:2156833a74a8 579 if (wk_disp_time > 15000) {
dkato 0:2156833a74a8 580 wk_disp_time = 15000;
dkato 0:2156833a74a8 581 }
dkato 0:2156833a74a8 582 } else {
dkato 0:2156833a74a8 583 wk_disp_time -= 1000;
dkato 0:2156833a74a8 584 if (wk_disp_time < 1000) {
dkato 0:2156833a74a8 585 wk_disp_time = 0;
dkato 0:2156833a74a8 586 }
dkato 0:2156833a74a8 587 }
dkato 0:2156833a74a8 588 disp_wait_time = wk_disp_time;
dkato 0:2156833a74a8 589 system_timer.reset();
dkato 0:2156833a74a8 590 system_timer.start();
dkato 0:2156833a74a8 591 mouse_info.disp_time = true;
dkato 0:2156833a74a8 592 if ((efect_info.event_req == EVENT_NONE) && (dissolve_seq == 0)) {
dkato 0:2156833a74a8 593 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 594 }
dkato 0:2156833a74a8 595 } else {
dkato 0:2156833a74a8 596 zoom_func(mouse_info.pos_x + 3, mouse_info.pos_y + 3,
dkato 0:2156833a74a8 597 mouse_info.pos_x + 3, mouse_info.pos_y + 3,
dkato 0:2156833a74a8 598 efect_info.magnification * (1.0f + (float_t)z / 10.0f));
dkato 0:2156833a74a8 599 }
dkato 0:2156833a74a8 600 }
dkato 0:2156833a74a8 601
dkato 0:2156833a74a8 602 last_buttons = buttons;
dkato 0:2156833a74a8 603 }
dkato 0:2156833a74a8 604
dkato 0:2156833a74a8 605 void mouse_task(void const *) {
dkato 0:2156833a74a8 606 USBHostMouse mouse;
dkato 0:2156833a74a8 607
dkato 0:2156833a74a8 608 while (1) {
dkato 0:2156833a74a8 609 /* try to connect a USB mouse */
dkato 0:2156833a74a8 610 while (!mouse.connect()) {
dkato 0:2156833a74a8 611 Thread::wait(500);
dkato 0:2156833a74a8 612 }
dkato 0:2156833a74a8 613
dkato 0:2156833a74a8 614 /* when connected, attach handler called on mouse event */
dkato 0:2156833a74a8 615 mouse.attachEvent(onMouseEvent);
dkato 0:2156833a74a8 616
dkato 0:2156833a74a8 617 /* wait until the mouse is disconnected */
dkato 0:2156833a74a8 618 while (mouse.connected()) {
dkato 0:2156833a74a8 619 Thread::wait(500);
dkato 0:2156833a74a8 620 }
dkato 0:2156833a74a8 621 mouse_info.disp_pos = false;
dkato 0:2156833a74a8 622 mouse_info.disp_time = false;
dkato 0:2156833a74a8 623 if ((efect_info.event_req == EVENT_NONE) && (dissolve_seq == 0)) {
dkato 0:2156833a74a8 624 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 625 }
dkato 0:2156833a74a8 626 }
dkato 0:2156833a74a8 627 }
dkato 0:2156833a74a8 628
dkato 0:2156833a74a8 629
dkato 0:2156833a74a8 630 /****** Touch ******/
dkato 0:2156833a74a8 631 #ifdef TouckKey_LCD_shield
dkato 0:2156833a74a8 632 static float32_t get_distance(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1) {
dkato 0:2156833a74a8 633 float32_t distance_x;
dkato 0:2156833a74a8 634 float32_t distance_y;
dkato 0:2156833a74a8 635
dkato 0:2156833a74a8 636 if (x0 > x1) {
dkato 0:2156833a74a8 637 distance_x = x0 - x1;
dkato 0:2156833a74a8 638 } else {
dkato 0:2156833a74a8 639 distance_x = x1 - x0;
dkato 0:2156833a74a8 640 }
dkato 0:2156833a74a8 641 if (y0 > y1) {
dkato 0:2156833a74a8 642 distance_y = y0 - y1;
dkato 0:2156833a74a8 643 } else {
dkato 0:2156833a74a8 644 distance_y = y1 - y0;
dkato 0:2156833a74a8 645 }
dkato 0:2156833a74a8 646 return hypotf(distance_x, distance_y);
dkato 0:2156833a74a8 647 }
dkato 0:2156833a74a8 648
dkato 0:2156833a74a8 649 static uint32_t get_center(uint32_t xy0, uint32_t xy1) {
dkato 0:2156833a74a8 650 uint32_t center_pos;
dkato 0:2156833a74a8 651
dkato 0:2156833a74a8 652 if (xy0 > xy1) {
dkato 0:2156833a74a8 653 center_pos = (xy0 - xy1) / 2 + xy1;
dkato 0:2156833a74a8 654 } else {
dkato 0:2156833a74a8 655 center_pos = (xy1 - xy0) / 2 + xy0;
dkato 0:2156833a74a8 656 }
dkato 0:2156833a74a8 657
dkato 0:2156833a74a8 658 return center_pos;
dkato 0:2156833a74a8 659 }
dkato 0:2156833a74a8 660
dkato 0:2156833a74a8 661 static void touch_int_callback(void) {
dkato 0:2156833a74a8 662 sem_touch_int.release();
dkato 0:2156833a74a8 663 }
dkato 0:2156833a74a8 664
dkato 0:2156833a74a8 665 static void touch_task(void const*) {
dkato 0:2156833a74a8 666 bool skip = false;
dkato 0:2156833a74a8 667 bool zoom_on = false;
dkato 0:2156833a74a8 668 uint32_t center_x;
dkato 0:2156833a74a8 669 uint32_t center_y;
dkato 0:2156833a74a8 670 uint32_t center_x_last = 0;
dkato 0:2156833a74a8 671 uint32_t center_y_last = 0;
dkato 0:2156833a74a8 672 int click_cnt = 0;
dkato 0:2156833a74a8 673 int move_x = 0;
dkato 0:2156833a74a8 674 int move_y = 0;
dkato 0:2156833a74a8 675 float32_t distance;
dkato 0:2156833a74a8 676 float32_t distance_last;
dkato 0:2156833a74a8 677 int down_time = 0;;
dkato 0:2156833a74a8 678 int last_down_time = 0;
dkato 0:2156833a74a8 679 int event_time = 0;;
dkato 0:2156833a74a8 680 int event_time_last = 0;
dkato 0:2156833a74a8 681 TouchKey::touch_pos_t touch_pos[TOUCH_NUM];
dkato 0:2156833a74a8 682 TouchKey::touch_pos_t touch_pos_last[TOUCH_NUM];
dkato 0:2156833a74a8 683 int touch_num = 0;
dkato 0:2156833a74a8 684 int touch_num_last = 0;
dkato 0:2156833a74a8 685 Timer touch_timer;
dkato 0:2156833a74a8 686 TouckKey_LCD_shield touch(P4_0, P2_13, I2C_SDA, I2C_SCL);
dkato 0:2156833a74a8 687
dkato 0:2156833a74a8 688 /* Callback setting */
dkato 0:2156833a74a8 689 touch.SetCallback(&touch_int_callback);
dkato 0:2156833a74a8 690
dkato 0:2156833a74a8 691 /* Reset touch IC */
dkato 0:2156833a74a8 692 touch.Reset();
dkato 0:2156833a74a8 693
dkato 0:2156833a74a8 694 touch_timer.reset();
dkato 0:2156833a74a8 695 touch_timer.start();
dkato 0:2156833a74a8 696
dkato 0:2156833a74a8 697 while (1) {
dkato 0:2156833a74a8 698 /* Wait touch event */
dkato 0:2156833a74a8 699 sem_touch_int.wait();
dkato 0:2156833a74a8 700
dkato 0:2156833a74a8 701 /* Get touch coordinates */
dkato 0:2156833a74a8 702 touch_num = touch.GetCoordinates(TOUCH_NUM, touch_pos);
dkato 0:2156833a74a8 703 event_time = touch_timer.read_ms();
dkato 0:2156833a74a8 704 if (touch_num > touch_num_last) {
dkato 0:2156833a74a8 705 if (touch_num_last == 0) {
dkato 0:2156833a74a8 706 down_time = event_time;
dkato 0:2156833a74a8 707 }
dkato 0:2156833a74a8 708 if (touch_num == 2) {
dkato 0:2156833a74a8 709 zoom_on = true;
dkato 0:2156833a74a8 710 }
dkato 0:2156833a74a8 711 move_x = 0;
dkato 0:2156833a74a8 712 move_y = 0;
dkato 0:2156833a74a8 713 distance_last = 0;
dkato 0:2156833a74a8 714 if ((down_time - last_down_time) > 500) {
dkato 0:2156833a74a8 715 click_cnt = 0;
dkato 0:2156833a74a8 716 }
dkato 0:2156833a74a8 717 last_down_time = down_time;
dkato 0:2156833a74a8 718 } else if ((touch_num == 0) && (touch_num_last != 0)) {
dkato 0:2156833a74a8 719 if (((event_time - down_time) < 200)
dkato 0:2156833a74a8 720 && (abs(move_x) < 10) && (abs(move_y) < 10)) {
dkato 0:2156833a74a8 721 click_cnt++;
dkato 0:2156833a74a8 722 if (click_cnt == 2) {
dkato 0:2156833a74a8 723 zoom_func(0, 0, 0, 0, 1.0f);
dkato 0:2156833a74a8 724 }
dkato 0:2156833a74a8 725 move_x = 0;
dkato 0:2156833a74a8 726 move_y = 0;
dkato 0:2156833a74a8 727 } else {
dkato 0:2156833a74a8 728 click_cnt = 0;
dkato 0:2156833a74a8 729 }
dkato 0:2156833a74a8 730 if (zoom_on == false) {
dkato 0:2156833a74a8 731 move_end_func(move_x, move_y);
dkato 0:2156833a74a8 732 }
dkato 0:2156833a74a8 733 zoom_on = false;
dkato 0:2156833a74a8 734 distance_last = 0;
dkato 0:2156833a74a8 735 } else if ((touch_num == 1) && (touch_num_last == 2)) {
dkato 0:2156833a74a8 736 distance_last = 0;
dkato 0:2156833a74a8 737 } else if ((touch_num != 0) && ((event_time - event_time_last) >= 50)) {
dkato 0:2156833a74a8 738 event_time_last = event_time;
dkato 0:2156833a74a8 739 if (touch_num == 1) {
dkato 0:2156833a74a8 740 if (zoom_on == false) {
dkato 0:2156833a74a8 741 move_x = (touch_pos[0].x - touch_pos_last[0].x);
dkato 0:2156833a74a8 742 move_y = (touch_pos[0].y - touch_pos_last[0].y);
dkato 0:2156833a74a8 743 move_func(move_x, move_y);
dkato 0:2156833a74a8 744 }
dkato 0:2156833a74a8 745 } else {
dkato 0:2156833a74a8 746 center_x = get_center(touch_pos[0].x, touch_pos[1].x);
dkato 0:2156833a74a8 747 center_y = get_center(touch_pos[0].y, touch_pos[1].y);
dkato 0:2156833a74a8 748 distance = get_distance(touch_pos[0].x, touch_pos[0].y, touch_pos[1].x, touch_pos[1].y);
dkato 0:2156833a74a8 749 if (distance < 1) {
dkato 0:2156833a74a8 750 distance = 1;
dkato 0:2156833a74a8 751 }
dkato 0:2156833a74a8 752 if (distance_last != 0) {
dkato 0:2156833a74a8 753 zoom_func(center_x_last, center_y_last, center_x, center_y, efect_info.magnification * (distance / distance_last));
dkato 0:2156833a74a8 754 }
dkato 0:2156833a74a8 755 center_x_last = center_x;
dkato 0:2156833a74a8 756 center_y_last = center_y;
dkato 0:2156833a74a8 757 distance_last = distance;
dkato 0:2156833a74a8 758 }
dkato 0:2156833a74a8 759 } else {
dkato 0:2156833a74a8 760 skip = true;
dkato 0:2156833a74a8 761 }
dkato 0:2156833a74a8 762 if (skip == false) {
dkato 0:2156833a74a8 763 touch_pos_last[0] = touch_pos[0];
dkato 0:2156833a74a8 764 touch_pos_last[1] = touch_pos[1];
dkato 0:2156833a74a8 765 touch_num_last = touch_num;
dkato 0:2156833a74a8 766 }
dkato 0:2156833a74a8 767 skip = false;
dkato 0:2156833a74a8 768 }
dkato 0:2156833a74a8 769 }
dkato 0:2156833a74a8 770 #endif
dkato 0:2156833a74a8 771
dkato 0:2156833a74a8 772 static void button_rise(void) {
dkato 0:2156833a74a8 773 int wk_disp_time;
dkato 0:2156833a74a8 774
dkato 0:2156833a74a8 775 wk_disp_time = disp_wait_time;
dkato 0:2156833a74a8 776 wk_disp_time += 1000;
dkato 0:2156833a74a8 777 if (wk_disp_time > 15000) {
dkato 0:2156833a74a8 778 wk_disp_time = 0;
dkato 0:2156833a74a8 779 }
dkato 0:2156833a74a8 780 disp_wait_time = wk_disp_time;
dkato 0:2156833a74a8 781 system_timer.reset();
dkato 0:2156833a74a8 782 system_timer.start();
dkato 0:2156833a74a8 783 mouse_info.disp_time = true;
dkato 0:2156833a74a8 784 if ((efect_info.event_req == EVENT_NONE) && (dissolve_seq == 0)) {
dkato 0:2156833a74a8 785 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 786 }
dkato 0:2156833a74a8 787 }
dkato 0:2156833a74a8 788
dkato 0:2156833a74a8 789 int main(void) {
dkato 0:2156833a74a8 790 errnum_t err;
dkato 0:2156833a74a8 791 Canvas2D_ContextConfigClass config;
dkato 0:2156833a74a8 792
dkato 0:2156833a74a8 793 /* Change the baud rate of the printf() */
dkato 0:2156833a74a8 794 pc.baud(921600);
dkato 0:2156833a74a8 795
dkato 0:2156833a74a8 796 /* Initialization of LCD */
dkato 0:2156833a74a8 797 Init_LCD_Display(); /* When using LCD, please call before than Init_Video(). */
dkato 0:2156833a74a8 798
dkato 0:2156833a74a8 799 memset(user_frame_buffer1, 0, sizeof(user_frame_buffer1));
dkato 0:2156833a74a8 800 memset(user_frame_buffer2, 0, sizeof(user_frame_buffer2));
dkato 0:2156833a74a8 801 frame_buffer_info.buffer_address[0] = user_frame_buffer1;
dkato 0:2156833a74a8 802 frame_buffer_info.buffer_address[1] = user_frame_buffer2;
dkato 0:2156833a74a8 803 frame_buffer_info.buffer_count = 2;
dkato 0:2156833a74a8 804 frame_buffer_info.show_buffer_index = 0;
dkato 0:2156833a74a8 805 frame_buffer_info.draw_buffer_index = 0;
dkato 0:2156833a74a8 806 frame_buffer_info.width = LCD_PIXEL_WIDTH;
dkato 0:2156833a74a8 807 frame_buffer_info.byte_per_pixel = FRAME_BUFFER_BYTE_PER_PIXEL;
dkato 0:2156833a74a8 808 frame_buffer_info.stride = LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL;
dkato 0:2156833a74a8 809 frame_buffer_info.height = LCD_PIXEL_HEIGHT;
dkato 0:2156833a74a8 810 frame_buffer_info.pixel_format = PIXEL_FORMAT_RGB565;
dkato 0:2156833a74a8 811
dkato 0:2156833a74a8 812 config.frame_buffer = &frame_buffer_info;
dkato 0:2156833a74a8 813 canvas2d = R_RGA_New_Canvas2D_ContextClass(config);
dkato 0:2156833a74a8 814 err = R_OSPL_GetErrNum();
dkato 0:2156833a74a8 815 if (err != 0) {
dkato 0:2156833a74a8 816 printf("Line %d, error %d\n", __LINE__, err);
dkato 0:2156833a74a8 817 mbed_die();
dkato 0:2156833a74a8 818 }
dkato 0:2156833a74a8 819
dkato 0:2156833a74a8 820 /* Start of LCD */
dkato 0:2156833a74a8 821 Start_LCD_Display(frame_buffer_info.buffer_address[0]);
dkato 0:2156833a74a8 822
dkato 0:2156833a74a8 823 #if (LCD_TYPE != 2)
dkato 0:2156833a74a8 824 /* Backlight on */
dkato 0:2156833a74a8 825 Thread::wait(200);
dkato 0:2156833a74a8 826 lcd_cntrst.write(1.0);
dkato 0:2156833a74a8 827 #endif
dkato 0:2156833a74a8 828
dkato 0:2156833a74a8 829 Thread mouseTask(mouse_task, NULL, osPriorityNormal, 1024);
dkato 0:2156833a74a8 830 #ifdef TouckKey_LCD_shield
dkato 0:2156833a74a8 831 Thread touchTask(&touch_task, NULL, osPriorityNormal, 1024 * 8);
dkato 0:2156833a74a8 832 #endif
dkato 0:2156833a74a8 833 button.rise(&button_rise);
dkato 0:2156833a74a8 834
dkato 0:2156833a74a8 835 #if (STORAGE_TYPE == 0)
dkato 0:2156833a74a8 836 SDFileSystem_GR_PEACH storage(MOUNT_NAME);
dkato 0:2156833a74a8 837 #else
dkato 0:2156833a74a8 838 USBHostMSD storage(MOUNT_NAME);
dkato 0:2156833a74a8 839 #endif
dkato 0:2156833a74a8 840 int wait_time = 0;
dkato 0:2156833a74a8 841 uint8_t * temp_buf[2];
dkato 0:2156833a74a8 842 bool touch_key_in = false;
dkato 0:2156833a74a8 843 int direction;
dkato 0:2156833a74a8 844 int i;
dkato 0:2156833a74a8 845 int wk_event_req;
dkato 0:2156833a74a8 846 int type;
dkato 0:2156833a74a8 847 int wk_abs_x_pos;
dkato 0:2156833a74a8 848
dkato 0:2156833a74a8 849 temp_buf[0] = JpegBuffer;
dkato 0:2156833a74a8 850 temp_buf[1] = new uint8_t[MAX_JPEG_SIZE];
dkato 0:2156833a74a8 851 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 852 efect_info.p_pic_now = (uint8_t *)Renesas_logo_File;
dkato 0:2156833a74a8 853 efect_info.p_pic_next = NULL;
dkato 0:2156833a74a8 854 efect_info.magnification = 1.0f;
dkato 0:2156833a74a8 855 efect_info.swipe_end_move = 0;
dkato 0:2156833a74a8 856 efect_info.drow_pos_x = 0;
dkato 0:2156833a74a8 857 efect_info.drow_pos_y = 0;
dkato 0:2156833a74a8 858 efect_info.scale_end_move_x = 0;
dkato 0:2156833a74a8 859 efect_info.scale_end_move_y = 0;
dkato 0:2156833a74a8 860 efect_info.min_x = 0;
dkato 0:2156833a74a8 861 efect_info.min_y = 0;
dkato 0:2156833a74a8 862 efect_info.scroll = false;
dkato 0:2156833a74a8 863 zoom_func(0, 0, 0, 0, 1.0f);
dkato 0:2156833a74a8 864
dkato 0:2156833a74a8 865 while (1) {
dkato 0:2156833a74a8 866 /* USB connect check */
dkato 0:2156833a74a8 867 if (!storage.connected()) {
dkato 0:2156833a74a8 868 if (!storage.connect()) {
dkato 0:2156833a74a8 869 if (storage_mode != false) {
dkato 0:2156833a74a8 870 storage_mode = false;
dkato 0:2156833a74a8 871 storage.unmount();
dkato 0:2156833a74a8 872 total_file_num = ROM_PIC_NUM;
dkato 0:2156833a74a8 873 file_id_now = 0xffffffff;
dkato 0:2156833a74a8 874 file_id_next = 0xffffffff;
dkato 0:2156833a74a8 875 efect_info.p_pic_now = (uint8_t *)Renesas_logo_File;
dkato 0:2156833a74a8 876 efect_info.p_pic_next = NULL;
dkato 0:2156833a74a8 877 zoom_func(0, 0, 0, 0, 1.0f);
dkato 0:2156833a74a8 878 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 879 }
dkato 0:2156833a74a8 880 } else {
dkato 0:2156833a74a8 881 storage.unmount();
dkato 0:2156833a74a8 882 storage.mount();
dkato 0:2156833a74a8 883 storage_mode = true;
dkato 0:2156833a74a8 884 scan_foler.scan("/"MOUNT_NAME, extension_tbl);
dkato 0:2156833a74a8 885 total_file_num = scan_foler.getTotalFile();
dkato 0:2156833a74a8 886 file_id_now = 0;
dkato 0:2156833a74a8 887 file_id_next = 0xffffffff;
dkato 0:2156833a74a8 888 efect_info.p_pic_now = temp_buf[0];
dkato 0:2156833a74a8 889 efect_info.p_pic_next = temp_buf[1];
dkato 0:2156833a74a8 890 read_new_file(&efect_info.p_pic_now, file_id_now);
dkato 0:2156833a74a8 891 zoom_func(0, 0, 0, 0, 1.0f);
dkato 0:2156833a74a8 892 efect_info.event_req = EVENT_DISP;
dkato 0:2156833a74a8 893 }
dkato 0:2156833a74a8 894 }
dkato 0:2156833a74a8 895
dkato 0:2156833a74a8 896 wk_event_req = efect_info.event_req;
dkato 0:2156833a74a8 897 efect_info.event_req = EVENT_NONE;
dkato 0:2156833a74a8 898
dkato 0:2156833a74a8 899 if (wk_event_req != EVENT_NONE) {
dkato 0:2156833a74a8 900 dissolve_seq = 0;
dkato 0:2156833a74a8 901 }
dkato 0:2156833a74a8 902
dkato 0:2156833a74a8 903 switch (wk_event_req) {
dkato 0:2156833a74a8 904 case EVENT_NEXT:
dkato 0:2156833a74a8 905 case EVENT_PREV:
dkato 0:2156833a74a8 906 zoom_func(0, 0, 0, 0, 1.0f);
dkato 0:2156833a74a8 907 if (wk_event_req == EVENT_NEXT) {
dkato 0:2156833a74a8 908 direction = SCROLL_DIRECTION_NEXT;
dkato 0:2156833a74a8 909 read_next_file();
dkato 0:2156833a74a8 910 } else {
dkato 0:2156833a74a8 911 direction = SCROLL_DIRECTION_PREV;
dkato 0:2156833a74a8 912 read_prev_file();
dkato 0:2156833a74a8 913 }
dkato 0:2156833a74a8 914 for (i = 1; i <= SCROLL_STEP_NUM; i++) {
dkato 0:2156833a74a8 915 draw_image_scroll(&frame_buffer_info,
dkato 0:2156833a74a8 916 (const graphics_image_t*)efect_info.p_pic_now,
dkato 0:2156833a74a8 917 (const graphics_image_t*)efect_info.p_pic_next,
dkato 0:2156833a74a8 918 (float32_t)i / (float32_t)SCROLL_STEP_NUM, direction);
dkato 0:2156833a74a8 919 }
dkato 0:2156833a74a8 920 swap_file_buff();
dkato 0:2156833a74a8 921 break;
dkato 0:2156833a74a8 922 case EVENT_MOVE:
dkato 0:2156833a74a8 923 if ((efect_info.x_move * SCROLL_DIRECTION) >= 0) {
dkato 0:2156833a74a8 924 direction = SCROLL_DIRECTION_NEXT;
dkato 0:2156833a74a8 925 read_next_file();
dkato 0:2156833a74a8 926 } else {
dkato 0:2156833a74a8 927 direction = SCROLL_DIRECTION_PREV;
dkato 0:2156833a74a8 928 read_prev_file();
dkato 0:2156833a74a8 929 }
dkato 0:2156833a74a8 930 draw_image_scroll(&frame_buffer_info,
dkato 0:2156833a74a8 931 (const graphics_image_t*)efect_info.p_pic_now,
dkato 0:2156833a74a8 932 (const graphics_image_t*)efect_info.p_pic_next,
dkato 0:2156833a74a8 933 (float32_t)abs(efect_info.x_move) / (float32_t)LCD_PIXEL_WIDTH, direction);
dkato 0:2156833a74a8 934 break;
dkato 0:2156833a74a8 935 case EVENT_MOVE_END:
dkato 0:2156833a74a8 936 type = 0;
dkato 0:2156833a74a8 937 if ((efect_info.x_move * SCROLL_DIRECTION) >= 0) {
dkato 0:2156833a74a8 938 direction = SCROLL_DIRECTION_NEXT;
dkato 0:2156833a74a8 939 read_next_file();
dkato 0:2156833a74a8 940 } else {
dkato 0:2156833a74a8 941 direction = SCROLL_DIRECTION_PREV;
dkato 0:2156833a74a8 942 read_prev_file();
dkato 0:2156833a74a8 943 }
dkato 0:2156833a74a8 944
dkato 0:2156833a74a8 945 wk_abs_x_pos = abs(efect_info.x_move);
dkato 0:2156833a74a8 946 if (abs(efect_info.swipe_end_move) > 10) {
dkato 0:2156833a74a8 947 if ((efect_info.swipe_end_move * SCROLL_DIRECTION) >= 0) {
dkato 0:2156833a74a8 948 if (direction != SCROLL_DIRECTION_NEXT) {
dkato 0:2156833a74a8 949 type = 1;
dkato 0:2156833a74a8 950 }
dkato 0:2156833a74a8 951 } else {
dkato 0:2156833a74a8 952 if (direction != SCROLL_DIRECTION_PREV) {
dkato 0:2156833a74a8 953 type = 1;
dkato 0:2156833a74a8 954 }
dkato 0:2156833a74a8 955 }
dkato 0:2156833a74a8 956 } else {
dkato 0:2156833a74a8 957 if (wk_abs_x_pos < (LCD_PIXEL_WIDTH / 2)) {
dkato 0:2156833a74a8 958 type = 1;
dkato 0:2156833a74a8 959 }
dkato 0:2156833a74a8 960 }
dkato 0:2156833a74a8 961
dkato 0:2156833a74a8 962 if (type == 0) {
dkato 0:2156833a74a8 963 while (wk_abs_x_pos < LCD_PIXEL_WIDTH) {
dkato 0:2156833a74a8 964 wk_abs_x_pos += (LCD_PIXEL_WIDTH / SCROLL_STEP_NUM);
dkato 0:2156833a74a8 965 if (wk_abs_x_pos > LCD_PIXEL_WIDTH) {
dkato 0:2156833a74a8 966 wk_abs_x_pos = LCD_PIXEL_WIDTH;
dkato 0:2156833a74a8 967 }
dkato 0:2156833a74a8 968 draw_image_scroll(&frame_buffer_info,
dkato 0:2156833a74a8 969 (const graphics_image_t*)efect_info.p_pic_now,
dkato 0:2156833a74a8 970 (const graphics_image_t*)efect_info.p_pic_next,
dkato 0:2156833a74a8 971 (float32_t)wk_abs_x_pos / (float32_t)LCD_PIXEL_WIDTH, direction);
dkato 0:2156833a74a8 972 }
dkato 0:2156833a74a8 973 swap_file_buff();
dkato 0:2156833a74a8 974 } else {
dkato 0:2156833a74a8 975 while (wk_abs_x_pos > 0) {
dkato 0:2156833a74a8 976 wk_abs_x_pos -= (LCD_PIXEL_WIDTH / SCROLL_STEP_NUM);
dkato 0:2156833a74a8 977 if (wk_abs_x_pos < 0) {
dkato 0:2156833a74a8 978 wk_abs_x_pos = 0;
dkato 0:2156833a74a8 979 }
dkato 0:2156833a74a8 980 draw_image_scroll(&frame_buffer_info,
dkato 0:2156833a74a8 981 (const graphics_image_t*)efect_info.p_pic_now,
dkato 0:2156833a74a8 982 (const graphics_image_t*)efect_info.p_pic_next,
dkato 0:2156833a74a8 983 (float32_t)wk_abs_x_pos / (float32_t)LCD_PIXEL_WIDTH, direction);
dkato 0:2156833a74a8 984 }
dkato 0:2156833a74a8 985 }
dkato 0:2156833a74a8 986 efect_info.x_move = 0;
dkato 0:2156833a74a8 987 break;
dkato 0:2156833a74a8 988 case EVENT_NONE:
dkato 0:2156833a74a8 989 case EVENT_DISP:
dkato 0:2156833a74a8 990 default:
dkato 0:2156833a74a8 991 if ((efect_info.scale_end_move_x != 0) || (efect_info.scale_end_move_y != 0) || (wk_event_req == EVENT_DISP)) {
dkato 0:2156833a74a8 992 if ((efect_info.scale_end_move_x != 0) || (efect_info.scale_end_move_y != 0)) {
dkato 0:2156833a74a8 993 efect_info.scale_end_move_x *= 0.8f;
dkato 0:2156833a74a8 994 efect_info.scale_end_move_y *= 0.8f;
dkato 0:2156833a74a8 995 zoom_scroll(efect_info.scale_end_move_x, efect_info.scale_end_move_y);
dkato 0:2156833a74a8 996 if (abs(efect_info.scale_end_move_x) < 5) {
dkato 0:2156833a74a8 997 efect_info.scale_end_move_x = 0;
dkato 0:2156833a74a8 998 }
dkato 0:2156833a74a8 999 if (abs(efect_info.scale_end_move_y) < 5) {
dkato 0:2156833a74a8 1000 efect_info.scale_end_move_y = 0;
dkato 0:2156833a74a8 1001 }
dkato 0:2156833a74a8 1002 }
dkato 0:2156833a74a8 1003 draw_image(&frame_buffer_info,
dkato 0:2156833a74a8 1004 (const graphics_image_t*)efect_info.p_pic_now,
dkato 0:2156833a74a8 1005 efect_info.drow_pos_x,
dkato 0:2156833a74a8 1006 efect_info.drow_pos_y,
dkato 0:2156833a74a8 1007 efect_info.magnification);
dkato 0:2156833a74a8 1008 wait_time = 0;
dkato 0:2156833a74a8 1009 } else if (((file_id_now == 0xffffffff) && (wait_time >= 3000))
dkato 0:2156833a74a8 1010 || ((disp_wait_time != 0) && (wait_time >= disp_wait_time) && (mouse_info.disp_pos == false))) {
dkato 0:2156833a74a8 1011 efect_info.magnification = 1.0f;
dkato 0:2156833a74a8 1012 read_next_file();
dkato 0:2156833a74a8 1013 dissolve_seq = 1;
dkato 0:2156833a74a8 1014 } else {
dkato 0:2156833a74a8 1015 /* do nothing */
dkato 0:2156833a74a8 1016 }
dkato 0:2156833a74a8 1017 if (dissolve_seq != 0) {
dkato 0:2156833a74a8 1018 draw_image_dissolve(&frame_buffer_info,
dkato 0:2156833a74a8 1019 (const graphics_image_t*)efect_info.p_pic_now,
dkato 0:2156833a74a8 1020 (const graphics_image_t*)efect_info.p_pic_next,
dkato 0:2156833a74a8 1021 (float32_t)dissolve_seq / (float32_t)DISSOLVE_STEP_NUM);
dkato 0:2156833a74a8 1022 if (dissolve_seq >= DISSOLVE_STEP_NUM) {
dkato 0:2156833a74a8 1023 dissolve_seq = 0;
dkato 0:2156833a74a8 1024 swap_file_buff();
dkato 0:2156833a74a8 1025 } else {
dkato 0:2156833a74a8 1026 dissolve_seq++;
dkato 0:2156833a74a8 1027 }
dkato 0:2156833a74a8 1028 wait_time = 0;
dkato 0:2156833a74a8 1029 }
dkato 0:2156833a74a8 1030 break;
dkato 0:2156833a74a8 1031 }
dkato 0:2156833a74a8 1032 if ((mouse_info.disp_time != false) && (system_timer.read_ms() > 1500)) {
dkato 0:2156833a74a8 1033 mouse_info.disp_time = false;
dkato 0:2156833a74a8 1034 if ((efect_info.event_req == EVENT_NONE) && (dissolve_seq == 0)) {
dkato 0:2156833a74a8 1035 draw_image(&frame_buffer_info,
dkato 0:2156833a74a8 1036 (const graphics_image_t*)efect_info.p_pic_now,
dkato 0:2156833a74a8 1037 efect_info.drow_pos_x,
dkato 0:2156833a74a8 1038 efect_info.drow_pos_y,
dkato 0:2156833a74a8 1039 efect_info.magnification);
dkato 0:2156833a74a8 1040 }
dkato 0:2156833a74a8 1041 }
dkato 0:2156833a74a8 1042 if ((wk_event_req != EVENT_NONE) || (touch_key_in != false) || (efect_info.magnification != 1.0f) || (dissolve_seq != 0)
dkato 0:2156833a74a8 1043 || (mouse_info.disp_pos != false) || (mouse_info.disp_time != false) || (efect_info.scroll != false)) {
dkato 0:2156833a74a8 1044 wait_time = 0;
dkato 0:2156833a74a8 1045 } else {
dkato 0:2156833a74a8 1046 Thread::wait(50);
dkato 0:2156833a74a8 1047 if (wait_time < 100000) {
dkato 0:2156833a74a8 1048 wait_time += 50;
dkato 0:2156833a74a8 1049 }
dkato 0:2156833a74a8 1050 }
dkato 0:2156833a74a8 1051 }
dkato 0:2156833a74a8 1052 }