Hello World for RGA(Renesas Graphics Architecture). RGA is the Graphics Library of RZ/A1. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Dependencies:   GR-PEACH_video GraphicsFramework R_BSP LCD_shield_config

Note

For a sample program of with GR-PEACH 4.3 inch LCD Shield, please refer to RGA_HelloWorld_4_3inch.

GR-PEACH 4.3 inch LCD Shield用のサンプルプログラムについては、 RGA_HelloWorld_4_3inchを参照ください。

License

When you use this program, we judge you have agreed to the following contents.

本プログラムを使用する際は、以下の内容に合意した事になります。

https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Trouble shooting

There is a problem with Exporter currently, the compilation fails if you export to DS-5 or e2 studio.
The compilation successes if you export with GCC (ARM Embedded) or import it with mbed CLI.
Please refer to the below link for workaround.
Compilation fails after Export to DS-5 or e2 studio


現在Exporterで問題があり、DS-5又はe2 studioにExportするとコンパイルが失敗します。
GCC(ARM Embedded)でExportするか、mbed CLIでimportすればコンパイルは成功します。
回避策は以下のリンクを参照下さい。
Compilation fails after Export to DS-5 or e2 studio

Information

Japanese version is available in lower part of this page.

このページの後半に日本語版が用意されています.

What is this ?

RGA(Renesas Graphics Architecture) sample program using GR-PEACH.
The following lists features of the RGA.

  • Allows high-speed drawing using the hardware acceleration.
  • The API created based on the W3C standard HTML Canvas 2D Context achieves easy learning.
    In addition, the RGA provides C++API that is operable as an interface that is backward compatible with HTML Canvas 2D Context.
  • The memory area was defined by the application is available as a drawing destination or for input images.
  • Allows drawing of translucent images and translucent drawing using an alpha mask.

Please refer to the following link about RGA.
https://www.renesas.com/en-us/software/D3018075.html
This sample program draws in the frame buffer by using the buffer drawing mode of RGA.
In addition, supporting compiler is ARMCC, GCC ARM and IAR.

Composition

GR-PEACH and LCD Shield.
/media/uploads/1050186/gr-peach-lcd_shield_01.jpg /media/uploads/1050186/gr-peach-lcd_shield_02.jpg

How to use

  1. Please connect GR-PEACH and LCD Shield. Then turn on the power to GR-PEACH.
  2. Please press the reset button of GR-PEACH.
  3. The top screen which "RGA Library Sample" is drawn is displayed on the LCD.
    /media/uploads/1050186/rga_sample_top.jpg
  4. There are seven touch buttons at the bottom of the top screen.When you press each button, the function of RGA that have been linked to the panel is executed, and the output image will be displayed on the LCD.
    Please refer to the "Drawing using the RGA" below about the function of RGA that have been linked to the panel.
  5. When RGA of the execution is completed, "Return Top Screen" button displaies at the top right of the screen. When you press it, the top screen is displayed.

Drawing using the RGA

Touch ButtonDiscriptions
Drawing of RectangleDrawing the rectangle.
The sample program draws a rectangle in the range that you swaipe on the LCD.
/media/uploads/1050186/drawing_of_rectangle3.jpg
Drawing of ImageDraw the image.
The sample program draws by overlapping the two images(flower and crystal image).
In addition, the sample program draws a picture of Crystal to the swipe position on the LCD.
/media/uploads/1050186/drawing_of_image.jpg
DissolutionDissolve by carry out the fade-in and the fade-out at the same time.
The sample program draws by overlapping the two images. And the sample program draws while changing the transparency of the two images by the swipe operation of sideways on the LCD.
/media/uploads/1050186/dissolution4.jpg
ScrollScroll the image.
The sample program draws while shifting the position of cutting out of the rendering source by the swipe operation of sideways on the LCD while fixing the display position of the drawing destination.
/media/uploads/1050186/scroll3.jpg
ZoomZoom the image.
The sample program draws while changing the size of cutting out of the rendering source by the swipe operation of sideways on the LCD while fixing the display position of the drawing destination.
/media/uploads/1050186/zoom3.jpg
RotationRotate the image.
The sample draws the image while changing the tilt by the swipe operation of sideways on the LCD.
/media/uploads/1050186/rotation4.jpg
AccelerationMovement of the image along with the acceleration.
The sample program draws while moving the image from right to left along with the acceleration.
You can select the type of the following acceleration in LCD touch operation.
- ease ...... Move smoothly the start and the end (default)
- linear ...... Move constant speed
- ease-in ...... Move slowly the start
- ease-out ...... Move slowly the end
- ease-in-out ...... Move slowly the start and the end
/media/uploads/1050186/acceleration3.jpg

About image to be drawn

Image files that are used in the sample program is easily possible replacement by using the "Convert Image to Binary Table" tool below.
This tool generates "BinaryImage_RZ_A1H.c" and "BinaryImage_RZ_A1H.h" in the Images folder and converts each image file to binary. Then, this tool outputs the data to "RGA_Sample_BinaryImage" table of "BinaryImage_RZ_A1H.c" and defines the macro name indicating the offset position in the table to "BinaryImage_RZ_A1H.h".
The sample program executes with reference to this macro name for offset.

Convert Image to Binary Table

File Description

Folder and FileDiscriptions
Images folder
BinaryImage_RZ_A1H.c[Output File]
Source file which binary table is generated
BinaryImage_RZ_A1H.h[Output File]Header file which macro name for the offset is defined
BinaryImageConfigRGAH.image.xmlSetting file
*.jpg, *.png, *.bmp[Input File]
Image files for drawing
scriptlib folder
Files omittedCommand files called from a script
RGA_Tools.vbsScript file
BinaryImageMakeRGAH.batExecute file

How to use

  1. Please download the "Convert Image to Binary Table" tool and unzip it.
  2. Please put the image file to the Images folder and edit "BinaryImageConfigRGAH.image.xml".
  3. Please execute "BinaryImageMakeRGAH.bat". Then, "BinaryImage_RZ_A1H.c" and "BinaryImage_RZ_A1H.h" is generated.
  4. Please replace "BinaryImage_RZ_A1H.c" and "BinaryImage_RZ_A1H.h" in your program to the generated files.
  5. If necessary, please change macro name for the offset that is referenced in your program.
  6. Please build your program


概要

GR-PEACHを使ったRGA(ルネサスグラフィックスライブラリ)サンプルプログラムです。
RGAの特徴は以下の通りです。

  • ハードウェア アクセラレーションを使って高速に描画
  • W3C 標準である HTML Canvas 2D Context をベースに作成した API のため、学習が容易。
    また HTML Canvas 2D Context の下位互換として動作できる C++API を提供
  • アプリケーション側で用意したメモリー領域を描画先、または、入力画像として使用可能
  • 半透明な画像の描画と、アルファマスクを使った任意の形状の描画

RGAの詳細については、以下を参照下さい。
https://www.renesas.com/ja-jp/software/D3018074.html
本サンプルプログラムでは、RGAのバッファー描画モードを使ってフレームバッファに描画しています。
なお、対応するコンパイラはARMCC、GCC ARM、IARです。

構成

GR-PEACH、LCDシールド
/media/uploads/1050186/gr-peach-lcd_shield_01.jpg /media/uploads/1050186/gr-peach-lcd_shield_02.jpg

使い方

  1. GR-PEACHとLCDシールドを接続し、GR-PEACHに電源を入れます。
  2. GR-PEACHのリセットボタンを押します。
  3. "RGA Library Sample"というトップ画面がLCDに表示されます。
    /media/uploads/1050186/rga_sample_top.jpg
  4. 画面下に7個のタッチボタンがあり、それぞれを押すと、各パネルに紐付けられたRGAの機能が実行され、その出力画像がLCDに表示されます。
    パネルに紐付けられたRGAの機能については、下記"RGAを使った描画"を参照下さい。
  5. RGA機能の実行が終わると、画面右上に"Return Top Screen"のボタンが表示されますので、押すとトップ画面に戻ります。

RGAを使った描画

タッチボタン説明
Drawing of Rectangle四角形の描画を行ないます。
サンプルでは、LCD上をスワイプさせた範囲に四角形を描画します。
/media/uploads/1050186/drawing_of_rectangle3.jpg
Drawing of Image画像を描画を行ないます。
サンプルでは、2つの画像(花とクリスタルの画像)を重ねて描画します。
LCD上をスワイプした位置にクリスタルの画像を描画します。
/media/uploads/1050186/drawing_of_image.jpg
Dissolutionフェードインとフェードアウトを同時に行うことでディゾルブを行ないます。
サンプルでは、2つの画像を重ねて表示して、LCD上の横方向のスワイプ操作によって2つの画像の透明度を変化させながら描画します。
/media/uploads/1050186/dissolution4.jpg
Scroll画像のスクロールを行ないます。
サンプルでは、描画先の表示位置は固定のまま、LCD上の横方向のスワイプ操作によって描画元の取り出す位置をずらしながら描画します。
/media/uploads/1050186/scroll3.jpg
Zoom画像のズームを行ないます。
サンプルでは、描画先の表示位置は固定のまま、LCD上の横方向のスワイプ操作によって描画元の取り出すサイズを変化させながら描画します。
/media/uploads/1050186/zoom3.jpg
Rotation画像の回転を行ないます。
サンプルでは、LCD上の横方向のスワイプ操作によって傾きを変化させながら画像を描画します。
/media/uploads/1050186/rotation4.jpg
Acceleration加速を伴って画像の移動を行ないます。
サンプルでは、加速を伴って、画像を右から左に移動させながら描画します。
LCDのタッチ操作で以下の加速の種類を選択できます。
- ease …… 開始と終了が滑らかに動く(デフォルト)
- linear …… 一定の速度
- ease-in …… 開始がゆっくり動く
- ease-out …… 終了がゆっくり動く
- ease-in-out …… 開始と終了がゆっくり動く
/media/uploads/1050186/acceleration3.jpg

描画する画像について

サンプルプログラムで使用している画像ファイルは、下記の"Convert Image to Binary Table"ツールを利用する事で、簡単に差し替えが可能です。
このツールは、Imagesフォルダ内にBinaryImage_RZ_A1H.c ファイルと BinaryImage_RZ_A1H.h ファイルを生成し、各画像ファイルをバイナリ変換します。そして、そのデータをBinaryImage_RZ_A1H.c ファイルのRGA_Sample_BinaryImageテーブルに出力し、BinaryImage_RZ_A1H.h ファイルにテーブル内のオフセット位置を示すマクロ名を定義します。
サンプルプログラムでは、オフセット用のマクロ名を参照して動作します。

Convert Image to Binary Table

ファイル説明

フォルダ、ファイル説明
Imagesフォルダ
BinaryImage_RZ_A1H.c[出力ファイル]
バイナリテーブルが生成されるソースファイル
BinaryImage_RZ_A1H.h[出力ファイル]
オフセット用のマクロ名が定義されるヘッダファイル
BinaryImageConfigRGAH.image.xml設定ファイル
*.jpg, *.png, *.bmp[入力ファイル]
描画用の画像ファイル
scriptlibフォルダ
・・・ファイル省略・・・スクリプトから呼ばれるコマンドファイル
RGA_Tools.vbsスクリプトファイル
BinaryImageMakeRGAH.bat実行ファイル

使い方

  1. "Convert Image to Binary Table"ツールをダウンロードして解凍します
  2. Imagesフォルダ内に画像ファイルを入れ、BinaryImageConfigRGAH.image.xmlを編集します
  3. BinaryImageMakeRGAH.batを実行し、BinaryImage_RZ_A1H.cとBinaryImage_RZ_A1H.hを生成します
  4. 生成されたファイルをプログラム内のBinaryImage_RZ_A1H.cとBinaryImage_RZ_A1H.hと置き換えます
  5. 必要であれば、プログラム内で参照しているオフセット用のマクロ名を変更します
  6. プログラムをビルドします

Committer:
Osamu Nakamura
Date:
Mon Apr 24 16:40:18 2017 +0900
Revision:
11:a21861228739
Parent:
7:8fd684e60d66
Update GraphicsFramework and mbed OS to the stable ones

Who changed what in which revision?

UserRevisionLine numberNew contents of line
1050186 0:84e4649e7707 1 /*
1050186 0:84e4649e7707 2 Permission is hereby granted, free of charge, to any person obtaining a copy
1050186 0:84e4649e7707 3 of this software and associated documentation files (the "Software"), to deal
1050186 0:84e4649e7707 4 in the Software without restriction, including without limitation the rights
1050186 0:84e4649e7707 5 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1050186 0:84e4649e7707 6 copies of the Software, and to permit persons to whom the Software is
1050186 0:84e4649e7707 7 furnished to do so, subject to the following conditions:
1050186 0:84e4649e7707 8
1050186 0:84e4649e7707 9 The above copyright notice and this permission notice shall be included in
1050186 0:84e4649e7707 10 all copies or substantial portions of the Software.
1050186 0:84e4649e7707 11
1050186 0:84e4649e7707 12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1050186 0:84e4649e7707 13 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1050186 0:84e4649e7707 14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1050186 0:84e4649e7707 15 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1050186 0:84e4649e7707 16 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1050186 0:84e4649e7707 17 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1050186 0:84e4649e7707 18 THE SOFTWARE.
1050186 0:84e4649e7707 19 */
dkato 2:c7faef0ef374 20
1050186 0:84e4649e7707 21 #include "mbed.h"
1050186 0:84e4649e7707 22 #include "rga_func.h"
1050186 0:84e4649e7707 23 #include "DisplayBace.h"
1050186 0:84e4649e7707 24 #include "rtos.h"
dkato 4:ce438477eddb 25 #include "LCD_shield_config_7_1inch.h"
1050186 0:84e4649e7707 26
dkato 4:ce438477eddb 27 #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_RGB565)
dkato 4:ce438477eddb 28 #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT)
dkato 4:ce438477eddb 29 #define TOUCH_NUM (1u)
1050186 0:84e4649e7707 30
1050186 0:84e4649e7707 31 /* FRAME BUFFER Parameter */
dkato 2:c7faef0ef374 32 #define FRAME_BUFFER_BYTE_PER_PIXEL (2)
1050186 0:84e4649e7707 33 #define FRAME_BUFFER_STRIDE (((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL) + 31u) & ~31u)
1050186 0:84e4649e7707 34
dkato 2:c7faef0ef374 35 #define DRAW_RECTANGLE_CNT_MAX (4)
dkato 2:c7faef0ef374 36
1050186 0:84e4649e7707 37 typedef enum {
dkato 2:c7faef0ef374 38 RGA_FUNC_NON,
dkato 2:c7faef0ef374 39 RGA_FUNC_DRAW_RECTANGLE,
1050186 0:84e4649e7707 40 RGA_FUNC_DRAW_IMAGE,
1050186 0:84e4649e7707 41 RGA_FUNC_DISSOLVE,
1050186 0:84e4649e7707 42 RGA_FUNC_SCROLL,
1050186 0:84e4649e7707 43 RGA_FUNC_ZOOM,
1050186 0:84e4649e7707 44 RGA_FUNC_ROTATION,
1050186 0:84e4649e7707 45 RGA_FUNC_ACCELERATE,
dkato 2:c7faef0ef374 46 RGA_FUNC_ANIME_EASE,
dkato 2:c7faef0ef374 47 RGA_FUNC_ANIME_LINEAR,
dkato 2:c7faef0ef374 48 RGA_FUNC_ANIME_EASE_IN,
dkato 2:c7faef0ef374 49 RGA_FUNC_ANIME_EASE_OUT,
dkato 2:c7faef0ef374 50 RGA_FUNC_ANIME_EASE_IN_OUT,
dkato 2:c7faef0ef374 51 RGA_FUNC_RETURN,
dkato 2:c7faef0ef374 52 RGA_FUNC_END
dkato 4:ce438477eddb 53 } func_code_t;
1050186 0:84e4649e7707 54
1050186 0:84e4649e7707 55 DigitalOut lcd_pwon(P7_15);
1050186 0:84e4649e7707 56 DigitalOut lcd_blon(P8_1);
1050186 0:84e4649e7707 57 PwmOut lcd_cntrst(P8_15);
1050186 0:84e4649e7707 58 DisplayBase Display;
1050186 0:84e4649e7707 59
1050186 0:84e4649e7707 60 typedef struct {
1050186 0:84e4649e7707 61 uint32_t pic_pos_x; /* X position of the key picture. */
1050186 0:84e4649e7707 62 uint32_t pic_pos_y; /* Y position of the key picture. */
1050186 0:84e4649e7707 63 uint32_t pic_width; /* Width of the key picture. */
1050186 0:84e4649e7707 64 uint32_t pic_height; /* Height of the key picture. */
1050186 0:84e4649e7707 65 func_code_t func_code; /* func code of the key picture. */
1050186 0:84e4649e7707 66 } key_pic_info_t;
1050186 0:84e4649e7707 67
dkato 4:ce438477eddb 68 #if defined(__ICCARM__)
dkato 4:ce438477eddb 69 #pragma data_alignment=32
dkato 4:ce438477eddb 70 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
1050186 7:8fd684e60d66 71 #pragma data_alignment=32
dkato 4:ce438477eddb 72 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT];
dkato 4:ce438477eddb 73 #else
dkato 4:ce438477eddb 74 static uint8_t user_frame_buffer1[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */
dkato 2:c7faef0ef374 75 static uint8_t user_frame_buffer2[FRAME_BUFFER_STRIDE * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */
dkato 4:ce438477eddb 76 #endif
1050186 0:84e4649e7707 77 static frame_buffer_t frame_buffer_info;
1050186 0:84e4649e7707 78 static volatile int32_t vsync_count = 0;
1050186 0:84e4649e7707 79
dkato 2:c7faef0ef374 80 static const key_pic_info_t top_screen_key_tbl[] = {
dkato 2:c7faef0ef374 81 /* X Y Width Height Func code */
dkato 2:c7faef0ef374 82 { 50, 350, 120, 52, RGA_FUNC_DRAW_RECTANGLE }, /* RGA Func1 */
dkato 2:c7faef0ef374 83 { 230, 350, 120, 52, RGA_FUNC_DRAW_IMAGE }, /* RGA Func2 */
dkato 2:c7faef0ef374 84 { 410, 350, 120, 52, RGA_FUNC_DISSOLVE }, /* RGA Func3 */
dkato 2:c7faef0ef374 85 { 50, 420, 120, 52, RGA_FUNC_SCROLL }, /* RGA Func4 */
dkato 2:c7faef0ef374 86 { 230, 420, 120, 52, RGA_FUNC_ZOOM }, /* RGA Func5 */
dkato 2:c7faef0ef374 87 { 410, 420, 120, 52, RGA_FUNC_ROTATION }, /* RGA Func6 */
dkato 2:c7faef0ef374 88 { 615, 420, 120, 52, RGA_FUNC_ACCELERATE }, /* RGA Func7 */
dkato 2:c7faef0ef374 89 { 0, 0, 0, 0, RGA_FUNC_END } /* table end */
dkato 2:c7faef0ef374 90 };
dkato 2:c7faef0ef374 91
dkato 2:c7faef0ef374 92 static const key_pic_info_t return_key_tbl[] = {
dkato 2:c7faef0ef374 93 /* X Y Width Height Func code */
dkato 2:c7faef0ef374 94 { 640, 10, 150, 84, RGA_FUNC_RETURN }, /* Return Top Screen */
dkato 2:c7faef0ef374 95 { 0, 0, 0, 0, RGA_FUNC_END } /* table end */
dkato 2:c7faef0ef374 96 };
dkato 2:c7faef0ef374 97
dkato 2:c7faef0ef374 98 static const key_pic_info_t animetion_timing_key_tbl[] = {
dkato 2:c7faef0ef374 99 /* X Y Width Height Func code */
dkato 2:c7faef0ef374 100 { 640, 10, 150, 84, RGA_FUNC_RETURN }, /* Return Top Screen */
dkato 2:c7faef0ef374 101 { 17, 372, 136, 50, RGA_FUNC_ANIME_EASE }, /* ease */
dkato 2:c7faef0ef374 102 { 173, 372, 136, 50, RGA_FUNC_ANIME_LINEAR }, /* linear */
dkato 2:c7faef0ef374 103 { 330, 372, 136, 50, RGA_FUNC_ANIME_EASE_IN }, /* ease-in */
dkato 2:c7faef0ef374 104 { 487, 372, 136, 50, RGA_FUNC_ANIME_EASE_OUT }, /* ease-out */
dkato 2:c7faef0ef374 105 { 644, 372, 136, 50, RGA_FUNC_ANIME_EASE_IN_OUT }, /* ease-in-out */
dkato 2:c7faef0ef374 106 { 0, 0, 0, 0, RGA_FUNC_END } /* table end */
1050186 0:84e4649e7707 107 };
1050186 0:84e4649e7707 108
dkato 4:ce438477eddb 109 /****** LCD ******/
dkato 4:ce438477eddb 110 static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type) {
1050186 0:84e4649e7707 111 /* Interrupt callback function for Vsync interruption */
1050186 0:84e4649e7707 112 if (vsync_count > 0) {
1050186 0:84e4649e7707 113 vsync_count--;
1050186 0:84e4649e7707 114 }
1050186 0:84e4649e7707 115 }
1050186 0:84e4649e7707 116
1050186 0:84e4649e7707 117 static void Wait_Vsync(const int32_t wait_count) {
1050186 0:84e4649e7707 118 /* Wait for the specified number of times Vsync occurs */
1050186 0:84e4649e7707 119 vsync_count = wait_count;
1050186 0:84e4649e7707 120 while (vsync_count > 0) {
1050186 0:84e4649e7707 121 /* Do nothing */
1050186 0:84e4649e7707 122 }
1050186 0:84e4649e7707 123 }
1050186 0:84e4649e7707 124
dkato 4:ce438477eddb 125 static void Init_LCD_Display(void) {
1050186 0:84e4649e7707 126 DisplayBase::graphics_error_t error;
1050186 0:84e4649e7707 127 DisplayBase::lcd_config_t lcd_config;
1050186 0:84e4649e7707 128 PinName lvds_pin[8] = {
1050186 0:84e4649e7707 129 /* data pin */
1050186 0:84e4649e7707 130 P5_7, P5_6, P5_5, P5_4, P5_3, P5_2, P5_1, P5_0
1050186 0:84e4649e7707 131 };
1050186 0:84e4649e7707 132
1050186 0:84e4649e7707 133 lcd_pwon = 0;
1050186 0:84e4649e7707 134 lcd_blon = 0;
1050186 0:84e4649e7707 135 Thread::wait(100);
1050186 0:84e4649e7707 136 lcd_pwon = 1;
1050186 0:84e4649e7707 137 lcd_blon = 1;
1050186 0:84e4649e7707 138
dkato 4:ce438477eddb 139 Display.Graphics_Lvds_Port_Init(lvds_pin, 8);
1050186 0:84e4649e7707 140
1050186 0:84e4649e7707 141 /* Graphics initialization process */
dkato 4:ce438477eddb 142 lcd_config = LcdCfgTbl_LCD_shield;
1050186 0:84e4649e7707 143 error = Display.Graphics_init(&lcd_config);
1050186 0:84e4649e7707 144 if (error != DisplayBase::GRAPHICS_OK) {
1050186 0:84e4649e7707 145 printf("Line %d, error %d\n", __LINE__, error);
dkato 4:ce438477eddb 146 mbed_die();
1050186 0:84e4649e7707 147 }
1050186 0:84e4649e7707 148
1050186 0:84e4649e7707 149 /* Interrupt callback function setting (Vsync signal output from scaler 0) */
dkato 4:ce438477eddb 150 error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, IntCallbackFunc_LoVsync);
1050186 0:84e4649e7707 151 if (error != DisplayBase::GRAPHICS_OK) {
1050186 0:84e4649e7707 152 printf("Line %d, error %d\n", __LINE__, error);
dkato 4:ce438477eddb 153 mbed_die();
1050186 0:84e4649e7707 154 }
dkato 4:ce438477eddb 155 }
1050186 0:84e4649e7707 156
dkato 4:ce438477eddb 157 static void Start_LCD_Display(uint8_t * p_buf) {
dkato 4:ce438477eddb 158 DisplayBase::rect_t rect;
dkato 4:ce438477eddb 159
1050186 0:84e4649e7707 160 rect.vs = 0;
1050186 0:84e4649e7707 161 rect.vw = LCD_PIXEL_HEIGHT;
1050186 0:84e4649e7707 162 rect.hs = 0;
1050186 0:84e4649e7707 163 rect.hw = LCD_PIXEL_WIDTH;
1050186 0:84e4649e7707 164 Display.Graphics_Read_Setting(
1050186 0:84e4649e7707 165 DisplayBase::GRAPHICS_LAYER_0,
dkato 4:ce438477eddb 166 (void *)p_buf,
1050186 0:84e4649e7707 167 FRAME_BUFFER_STRIDE,
dkato 4:ce438477eddb 168 GRAPHICS_FORMAT,
dkato 4:ce438477eddb 169 WR_RD_WRSWA,
1050186 0:84e4649e7707 170 &rect
1050186 0:84e4649e7707 171 );
1050186 0:84e4649e7707 172 Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0);
1050186 0:84e4649e7707 173 }
1050186 0:84e4649e7707 174
dkato 2:c7faef0ef374 175 static void Update_LCD_Display(frame_buffer_t * frmbuf_info) {
dkato 2:c7faef0ef374 176 Display.Graphics_Read_Change(DisplayBase::GRAPHICS_LAYER_0,
dkato 2:c7faef0ef374 177 (void *)frmbuf_info->buffer_address[frmbuf_info->draw_buffer_index]);
1050186 0:84e4649e7707 178 Wait_Vsync(1);
1050186 0:84e4649e7707 179 }
1050186 0:84e4649e7707 180
dkato 4:ce438477eddb 181 static void Swap_FrameBuffer(frame_buffer_t * frmbuf_info) {
dkato 4:ce438477eddb 182 if (frmbuf_info->draw_buffer_index == 1) {
dkato 4:ce438477eddb 183 frmbuf_info->draw_buffer_index = 0;
dkato 4:ce438477eddb 184 } else {
dkato 4:ce438477eddb 185 frmbuf_info->draw_buffer_index = 1;
1050186 0:84e4649e7707 186 }
1050186 0:84e4649e7707 187 }
1050186 0:84e4649e7707 188
dkato 4:ce438477eddb 189 /****** Touch ******/
dkato 2:c7faef0ef374 190 static func_code_t Scan_Key(const key_pic_info_t * key_tbl, const uint32_t pos_x, const uint32_t pos_y) {
1050186 0:84e4649e7707 191 func_code_t ret = RGA_FUNC_NON;
1050186 0:84e4649e7707 192
dkato 2:c7faef0ef374 193 while (ret == RGA_FUNC_NON) {
dkato 2:c7faef0ef374 194 if (key_tbl->func_code == RGA_FUNC_END) {
dkato 2:c7faef0ef374 195 break;
dkato 2:c7faef0ef374 196 }
1050186 0:84e4649e7707 197 /* Check the range of the X position */
dkato 2:c7faef0ef374 198 if ((pos_x >= key_tbl->pic_pos_x) && (pos_x <= (key_tbl->pic_pos_x + key_tbl->pic_width))) {
1050186 0:84e4649e7707 199 /* Check the range of the Y position */
dkato 2:c7faef0ef374 200 if ((pos_y >= key_tbl->pic_pos_y) && (pos_y <= (key_tbl->pic_pos_y + key_tbl->pic_height))) {
1050186 0:84e4649e7707 201 /* Decide the func code. */
dkato 2:c7faef0ef374 202 ret = key_tbl->func_code;
1050186 0:84e4649e7707 203 }
1050186 0:84e4649e7707 204 }
dkato 2:c7faef0ef374 205 key_tbl++;
1050186 0:84e4649e7707 206 }
1050186 0:84e4649e7707 207
1050186 0:84e4649e7707 208 return ret;
1050186 0:84e4649e7707 209 }
1050186 0:84e4649e7707 210
dkato 4:ce438477eddb 211 /****** Efect ******/
dkato 4:ce438477eddb 212 static void Exe_RGA_Func(func_code_t func_name, frame_buffer_t* frmbuf_info, TouckKey_LCD_shield * p_touch) {
dkato 2:c7faef0ef374 213 uint8_t touch_num = 0;
dkato 4:ce438477eddb 214 TouchKey::touch_pos_t touch_pos[TOUCH_NUM];
1050186 0:84e4649e7707 215
1050186 0:84e4649e7707 216 switch (func_name) {
1050186 0:84e4649e7707 217 case RGA_FUNC_DRAW_RECTANGLE:
1050186 6:6a8ce6f7767b 218 {
dkato 2:c7faef0ef374 219 bool key_on = false;
dkato 2:c7faef0ef374 220 int cnt;
dkato 2:c7faef0ef374 221 int color_cnt = 0;
dkato 2:c7faef0ef374 222 int x_0 = 0;
dkato 2:c7faef0ef374 223 int y_0 = 0;
dkato 2:c7faef0ef374 224 draw_rectangle_pos_t pos_tbl[DRAW_RECTANGLE_CNT_MAX] = {0};
dkato 2:c7faef0ef374 225
dkato 2:c7faef0ef374 226 pos_tbl[0].style = "#FF0000"; /* red */
dkato 2:c7faef0ef374 227 pos_tbl[1].style = "#00FF00"; /* green */
dkato 2:c7faef0ef374 228 pos_tbl[2].style = "#0000FF"; /* blue */
dkato 2:c7faef0ef374 229 pos_tbl[3].style = "#000000"; /* black */
dkato 2:c7faef0ef374 230
dkato 2:c7faef0ef374 231 while (1) {
dkato 2:c7faef0ef374 232 /* Get coordinates */
dkato 4:ce438477eddb 233 touch_num = p_touch->GetCoordinates(TOUCH_NUM, touch_pos);
dkato 2:c7faef0ef374 234 if (touch_num != 0) {
dkato 4:ce438477eddb 235 if (Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) {
dkato 2:c7faef0ef374 236 break;
dkato 2:c7faef0ef374 237 }
dkato 2:c7faef0ef374 238 if (key_on == false) {
dkato 2:c7faef0ef374 239 key_on = true;
dkato 2:c7faef0ef374 240 if (color_cnt == 0) {
dkato 2:c7faef0ef374 241 for (cnt = 0; cnt < DRAW_RECTANGLE_CNT_MAX; cnt++) {
dkato 2:c7faef0ef374 242 pos_tbl[cnt].x = 0;
dkato 2:c7faef0ef374 243 pos_tbl[cnt].y = 0;
dkato 2:c7faef0ef374 244 pos_tbl[cnt].w = 0;
dkato 2:c7faef0ef374 245 pos_tbl[cnt].h = 0;
dkato 2:c7faef0ef374 246 }
dkato 2:c7faef0ef374 247 }
dkato 4:ce438477eddb 248 x_0 = touch_pos[0].x;
dkato 4:ce438477eddb 249 y_0 = touch_pos[0].y;
dkato 2:c7faef0ef374 250 }
dkato 4:ce438477eddb 251 if (x_0 < touch_pos[0].x) {
dkato 2:c7faef0ef374 252 pos_tbl[color_cnt].x = x_0;
dkato 4:ce438477eddb 253 pos_tbl[color_cnt].w = touch_pos[0].x - x_0;
dkato 2:c7faef0ef374 254 } else {
dkato 4:ce438477eddb 255 pos_tbl[color_cnt].x = touch_pos[0].x;
dkato 4:ce438477eddb 256 pos_tbl[color_cnt].w = x_0 - touch_pos[0].x;
dkato 2:c7faef0ef374 257 }
dkato 4:ce438477eddb 258 if (y_0 < touch_pos[0].y) {
dkato 2:c7faef0ef374 259 pos_tbl[color_cnt].y = y_0;
dkato 4:ce438477eddb 260 pos_tbl[color_cnt].h = touch_pos[0].y - y_0;
dkato 2:c7faef0ef374 261 } else {
dkato 4:ce438477eddb 262 pos_tbl[color_cnt].y = touch_pos[0].y;
dkato 4:ce438477eddb 263 pos_tbl[color_cnt].h = y_0 - touch_pos[0].y;
dkato 2:c7faef0ef374 264 }
dkato 2:c7faef0ef374 265 } else {
dkato 2:c7faef0ef374 266 if (key_on != false) {
dkato 2:c7faef0ef374 267 color_cnt++;
dkato 2:c7faef0ef374 268 if (color_cnt == DRAW_RECTANGLE_CNT_MAX) {
dkato 2:c7faef0ef374 269 color_cnt = 0;
dkato 2:c7faef0ef374 270 }
dkato 2:c7faef0ef374 271 }
dkato 2:c7faef0ef374 272 key_on = false;
dkato 2:c7faef0ef374 273 }
dkato 2:c7faef0ef374 274 /* Draw screen */
dkato 2:c7faef0ef374 275 Swap_FrameBuffer(frmbuf_info);
dkato 2:c7faef0ef374 276 RGA_Func_DrawRectangle(frmbuf_info, pos_tbl, DRAW_RECTANGLE_CNT_MAX);
dkato 2:c7faef0ef374 277 Update_LCD_Display(frmbuf_info);
dkato 2:c7faef0ef374 278 }
1050186 6:6a8ce6f7767b 279 }
1050186 6:6a8ce6f7767b 280 break;
1050186 0:84e4649e7707 281 case RGA_FUNC_DRAW_IMAGE:
1050186 6:6a8ce6f7767b 282 {
dkato 2:c7faef0ef374 283 int center_pos_x = 320;
dkato 2:c7faef0ef374 284 int center_pos_y = 110;
dkato 2:c7faef0ef374 285 while (1) {
dkato 2:c7faef0ef374 286 /* Get coordinates */
dkato 4:ce438477eddb 287 touch_num = p_touch->GetCoordinates(TOUCH_NUM, touch_pos);
dkato 2:c7faef0ef374 288 if (touch_num != 0) {
dkato 4:ce438477eddb 289 if (Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) {
dkato 2:c7faef0ef374 290 break;
dkato 2:c7faef0ef374 291 }
dkato 4:ce438477eddb 292 center_pos_x = touch_pos[0].x;
dkato 4:ce438477eddb 293 center_pos_y = touch_pos[0].y;
dkato 2:c7faef0ef374 294 }
dkato 2:c7faef0ef374 295 /* Draw screen */
dkato 2:c7faef0ef374 296 Swap_FrameBuffer(frmbuf_info);
dkato 2:c7faef0ef374 297 RGA_Func_DrawImage(frmbuf_info, center_pos_x, center_pos_y);
dkato 2:c7faef0ef374 298 Update_LCD_Display(frmbuf_info);
dkato 2:c7faef0ef374 299 }
1050186 6:6a8ce6f7767b 300 }
1050186 6:6a8ce6f7767b 301 break;
1050186 0:84e4649e7707 302 case RGA_FUNC_DISSOLVE:
1050186 6:6a8ce6f7767b 303 {
dkato 2:c7faef0ef374 304 float32_t work_alpha = 0.0f;
dkato 2:c7faef0ef374 305 while (1) {
dkato 2:c7faef0ef374 306 /* Get coordinates */
dkato 4:ce438477eddb 307 touch_num = p_touch->GetCoordinates(TOUCH_NUM, touch_pos);
dkato 2:c7faef0ef374 308 if (touch_num != 0) {
dkato 4:ce438477eddb 309 if (Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) {
dkato 2:c7faef0ef374 310 break;
dkato 2:c7faef0ef374 311 }
dkato 4:ce438477eddb 312 work_alpha = (float32_t)touch_pos[0].x / (float32_t)(LCD_PIXEL_WIDTH);
dkato 2:c7faef0ef374 313 }
dkato 2:c7faef0ef374 314 /* Draw screen */
1050186 0:84e4649e7707 315 Swap_FrameBuffer(frmbuf_info);
1050186 0:84e4649e7707 316 RGA_Func_Dissolve(frmbuf_info, work_alpha);
dkato 2:c7faef0ef374 317 Update_LCD_Display(frmbuf_info);
1050186 0:84e4649e7707 318 }
1050186 6:6a8ce6f7767b 319 }
1050186 6:6a8ce6f7767b 320 break;
1050186 0:84e4649e7707 321 case RGA_FUNC_SCROLL:
1050186 6:6a8ce6f7767b 322 {
dkato 2:c7faef0ef374 323 int work_width_pos = 0;
dkato 2:c7faef0ef374 324 while (1) {
dkato 2:c7faef0ef374 325 /* Get coordinates */
dkato 4:ce438477eddb 326 touch_num = p_touch->GetCoordinates(TOUCH_NUM, touch_pos);
dkato 2:c7faef0ef374 327 if (touch_num != 0) {
dkato 4:ce438477eddb 328 if (Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) {
dkato 2:c7faef0ef374 329 break;
dkato 2:c7faef0ef374 330 }
dkato 4:ce438477eddb 331 work_width_pos = SCROLL_MAX_NUM * ((float32_t)touch_pos[0].x / (float32_t)(LCD_PIXEL_WIDTH));
dkato 2:c7faef0ef374 332 }
dkato 2:c7faef0ef374 333 /* Draw screen */
1050186 0:84e4649e7707 334 Swap_FrameBuffer(frmbuf_info);
1050186 0:84e4649e7707 335 RGA_Func_Scroll(frmbuf_info, work_width_pos);
dkato 2:c7faef0ef374 336 Update_LCD_Display(frmbuf_info);
1050186 0:84e4649e7707 337 }
1050186 6:6a8ce6f7767b 338 }
1050186 6:6a8ce6f7767b 339 break;
1050186 0:84e4649e7707 340 case RGA_FUNC_ZOOM:
1050186 6:6a8ce6f7767b 341 {
dkato 2:c7faef0ef374 342 int work_height_pos = ZOOM_MAX_NUM;
dkato 2:c7faef0ef374 343 while (1) {
dkato 2:c7faef0ef374 344 /* Get coordinates */
dkato 4:ce438477eddb 345 touch_num = p_touch->GetCoordinates(TOUCH_NUM, touch_pos);
dkato 2:c7faef0ef374 346 if (touch_num != 0) {
dkato 4:ce438477eddb 347 if (Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) {
dkato 2:c7faef0ef374 348 break;
dkato 2:c7faef0ef374 349 }
dkato 4:ce438477eddb 350 work_height_pos = ZOOM_MAX_NUM * ((float32_t)touch_pos[0].x / (float32_t)(LCD_PIXEL_WIDTH));
dkato 2:c7faef0ef374 351 }
dkato 2:c7faef0ef374 352 /* Draw screen */
1050186 0:84e4649e7707 353 Swap_FrameBuffer(frmbuf_info);
dkato 2:c7faef0ef374 354 RGA_Func_Zoom(frmbuf_info, work_height_pos);
dkato 2:c7faef0ef374 355 Update_LCD_Display(frmbuf_info);
1050186 0:84e4649e7707 356 }
1050186 6:6a8ce6f7767b 357 }
1050186 6:6a8ce6f7767b 358 break;
1050186 0:84e4649e7707 359 case RGA_FUNC_ROTATION:
1050186 6:6a8ce6f7767b 360 {
dkato 2:c7faef0ef374 361 graphics_matrix_float_t work_angle = 0;
dkato 2:c7faef0ef374 362 while (1) {
dkato 2:c7faef0ef374 363 /* Get coordinates */
dkato 4:ce438477eddb 364 touch_num = p_touch->GetCoordinates(TOUCH_NUM, touch_pos);
dkato 2:c7faef0ef374 365 if (touch_num != 0) {
dkato 4:ce438477eddb 366 if (Scan_Key(return_key_tbl, touch_pos[0].x, touch_pos[0].y) == RGA_FUNC_RETURN) {
dkato 2:c7faef0ef374 367 break;
dkato 2:c7faef0ef374 368 }
dkato 4:ce438477eddb 369 work_angle = ROTATION_MAX_NUM * ((float32_t)touch_pos[0].x / (float32_t)(LCD_PIXEL_WIDTH));
dkato 2:c7faef0ef374 370 }
dkato 2:c7faef0ef374 371 /* Draw screen */
1050186 0:84e4649e7707 372 Swap_FrameBuffer(frmbuf_info);
1050186 0:84e4649e7707 373 RGA_Func_Rotation(frmbuf_info, work_angle);
dkato 2:c7faef0ef374 374 Update_LCD_Display(frmbuf_info);
1050186 0:84e4649e7707 375 }
1050186 6:6a8ce6f7767b 376 }
1050186 6:6a8ce6f7767b 377 break;
1050186 0:84e4649e7707 378 case RGA_FUNC_ACCELERATE:
1050186 6:6a8ce6f7767b 379 {
dkato 2:c7faef0ef374 380 int acce_frame_num = 0;
dkato 2:c7faef0ef374 381 int animation_timing = 0;
1050186 0:84e4649e7707 382 float32_t work_relative_pos;
dkato 2:c7faef0ef374 383 while (1) {
dkato 2:c7faef0ef374 384 /* Get coordinates */
dkato 4:ce438477eddb 385 touch_num = p_touch->GetCoordinates(TOUCH_NUM, touch_pos);
dkato 2:c7faef0ef374 386 if (touch_num != 0) {
dkato 2:c7faef0ef374 387 func_code_t func_code;
dkato 2:c7faef0ef374 388
dkato 4:ce438477eddb 389 func_code = Scan_Key(animetion_timing_key_tbl, touch_pos[0].x, touch_pos[0].y);
dkato 2:c7faef0ef374 390 if (func_code == RGA_FUNC_RETURN) {
dkato 2:c7faef0ef374 391 break;
dkato 2:c7faef0ef374 392 }
dkato 2:c7faef0ef374 393 switch (func_code) {
dkato 2:c7faef0ef374 394 case RGA_FUNC_ANIME_EASE:
dkato 2:c7faef0ef374 395 animation_timing = 0;
dkato 2:c7faef0ef374 396 acce_frame_num = 0;
dkato 2:c7faef0ef374 397 break;
dkato 2:c7faef0ef374 398 case RGA_FUNC_ANIME_LINEAR:
dkato 2:c7faef0ef374 399 animation_timing = 1;
dkato 2:c7faef0ef374 400 acce_frame_num = 0;
dkato 2:c7faef0ef374 401 break;
dkato 2:c7faef0ef374 402 case RGA_FUNC_ANIME_EASE_IN:
dkato 2:c7faef0ef374 403 animation_timing = 2;
dkato 2:c7faef0ef374 404 acce_frame_num = 0;
dkato 2:c7faef0ef374 405 break;
dkato 2:c7faef0ef374 406 case RGA_FUNC_ANIME_EASE_OUT:
dkato 2:c7faef0ef374 407 animation_timing = 3;
dkato 2:c7faef0ef374 408 acce_frame_num = 0;
dkato 2:c7faef0ef374 409 break;
dkato 2:c7faef0ef374 410 case RGA_FUNC_ANIME_EASE_IN_OUT:
dkato 2:c7faef0ef374 411 animation_timing = 4;
dkato 2:c7faef0ef374 412 acce_frame_num = 0;
dkato 2:c7faef0ef374 413 break;
dkato 2:c7faef0ef374 414 default:
dkato 2:c7faef0ef374 415 /* Do Nothing */
dkato 2:c7faef0ef374 416 break;
dkato 2:c7faef0ef374 417 }
dkato 2:c7faef0ef374 418 }
dkato 2:c7faef0ef374 419 work_relative_pos = acce_frame_num / (float32_t)ACCELERATE_MAX_NUM;
dkato 2:c7faef0ef374 420 acce_frame_num++;
dkato 2:c7faef0ef374 421 if (acce_frame_num > ACCELERATE_MAX_NUM) {
dkato 2:c7faef0ef374 422 acce_frame_num = 0;
dkato 2:c7faef0ef374 423 }
dkato 2:c7faef0ef374 424 /* Draw screen */
1050186 0:84e4649e7707 425 Swap_FrameBuffer(frmbuf_info);
dkato 2:c7faef0ef374 426 RGA_Func_Accelerate(frmbuf_info, animation_timing, work_relative_pos);
dkato 2:c7faef0ef374 427 Update_LCD_Display(frmbuf_info);
1050186 0:84e4649e7707 428 }
1050186 6:6a8ce6f7767b 429 }
1050186 6:6a8ce6f7767b 430 break;
1050186 0:84e4649e7707 431 default :
1050186 0:84e4649e7707 432 /* Do nothing */
1050186 0:84e4649e7707 433 break;
1050186 0:84e4649e7707 434 }
1050186 0:84e4649e7707 435 }
1050186 0:84e4649e7707 436
1050186 0:84e4649e7707 437 int main(void) {
1050186 0:84e4649e7707 438 func_code_t func_code;
1050186 0:84e4649e7707 439 uint8_t touch_num = 0;
dkato 4:ce438477eddb 440 TouchKey::touch_pos_t touch_pos[TOUCH_NUM];
1050186 0:84e4649e7707 441
dkato 4:ce438477eddb 442 /* Initialization of LCD */
dkato 4:ce438477eddb 443 Init_LCD_Display(); /* When using LCD, please call before than Init_Video(). */
dkato 4:ce438477eddb 444
dkato 4:ce438477eddb 445 memset(user_frame_buffer1, 0, sizeof(user_frame_buffer1));
1050186 0:84e4649e7707 446 memset(user_frame_buffer2, 0, sizeof(user_frame_buffer2));
dkato 4:ce438477eddb 447 frame_buffer_info.buffer_address[0] = user_frame_buffer1;
1050186 0:84e4649e7707 448 frame_buffer_info.buffer_address[1] = user_frame_buffer2;
1050186 0:84e4649e7707 449 frame_buffer_info.buffer_count = 2;
1050186 0:84e4649e7707 450 frame_buffer_info.show_buffer_index = 0;
1050186 0:84e4649e7707 451 frame_buffer_info.draw_buffer_index = 0;
1050186 0:84e4649e7707 452 frame_buffer_info.width = LCD_PIXEL_WIDTH;
1050186 0:84e4649e7707 453 frame_buffer_info.byte_per_pixel = FRAME_BUFFER_BYTE_PER_PIXEL;
1050186 0:84e4649e7707 454 frame_buffer_info.stride = LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL;
1050186 0:84e4649e7707 455 frame_buffer_info.height = LCD_PIXEL_HEIGHT;
1050186 0:84e4649e7707 456 frame_buffer_info.pixel_format = PIXEL_FORMAT_RGB565;
1050186 0:84e4649e7707 457
1050186 0:84e4649e7707 458 /* Display Top Screen */
dkato 2:c7faef0ef374 459 Set_RGAObject(&frame_buffer_info);
dkato 2:c7faef0ef374 460 RGA_Func_DrawTopScreen(&frame_buffer_info);
dkato 4:ce438477eddb 461
dkato 4:ce438477eddb 462 /* Start of LCD */
dkato 4:ce438477eddb 463 Start_LCD_Display(frame_buffer_info.buffer_address[0]);
dkato 4:ce438477eddb 464
dkato 4:ce438477eddb 465 /* Backlight on */
dkato 4:ce438477eddb 466 Thread::wait(200);
dkato 4:ce438477eddb 467 lcd_cntrst.write(1.0);
dkato 4:ce438477eddb 468
dkato 4:ce438477eddb 469 /* Reset touch IC */
dkato 4:ce438477eddb 470 TouckKey_LCD_shield touch(P4_0, P2_13, I2C_SDA, I2C_SCL);
dkato 4:ce438477eddb 471 touch.Reset();
1050186 0:84e4649e7707 472
1050186 0:84e4649e7707 473 while (1) {
dkato 2:c7faef0ef374 474 /* Get Coordinates */
dkato 4:ce438477eddb 475 touch_num = touch.GetCoordinates(TOUCH_NUM, touch_pos);
1050186 0:84e4649e7707 476 if (touch_num != 0) {
dkato 4:ce438477eddb 477 func_code = Scan_Key(top_screen_key_tbl, touch_pos[0].x, touch_pos[0].y);
1050186 0:84e4649e7707 478 if (func_code != RGA_FUNC_NON) {
dkato 2:c7faef0ef374 479 /* Wait key off */
dkato 2:c7faef0ef374 480 while (1) {
dkato 4:ce438477eddb 481 touch_num = touch.GetCoordinates(TOUCH_NUM, touch_pos);
dkato 2:c7faef0ef374 482 if (touch_num == 0) {
dkato 2:c7faef0ef374 483 break;
dkato 2:c7faef0ef374 484 }
dkato 4:ce438477eddb 485 Thread::wait(20);
dkato 2:c7faef0ef374 486 }
dkato 2:c7faef0ef374 487
1050186 0:84e4649e7707 488 /* Execute RGA functions */
dkato 4:ce438477eddb 489 Exe_RGA_Func(func_code, &frame_buffer_info, &touch);
dkato 2:c7faef0ef374 490
1050186 0:84e4649e7707 491 /* Return Top Screen */
dkato 2:c7faef0ef374 492 Swap_FrameBuffer(&frame_buffer_info);
dkato 2:c7faef0ef374 493 RGA_Func_DrawTopScreen(&frame_buffer_info);
dkato 2:c7faef0ef374 494 Update_LCD_Display(&frame_buffer_info);
1050186 0:84e4649e7707 495 }
1050186 0:84e4649e7707 496 }
dkato 4:ce438477eddb 497 Thread::wait(20);
1050186 0:84e4649e7707 498 }
1050186 0:84e4649e7707 499 }