Example programs for GR-MANGO
Dependencies: opencv-lib mbed-http
This is a collection of sample programs that work on RZ/A2M boards. You can try Mbed OS for RZ/A2M with GR-MANGO board.
Overview
Sample program files are located under the sample_programs
folder.
You can try each sample program by changing the following macro in sample_select.h
.
insample_select.h
#define SAMPLE_PROGRAM_NO 0
No. | Program file | Description |
---|---|---|
0 | sample_00_led_rtc_analogin.cpp | DigitalOut, InterruptIn, RTC, Timer and AnalogIn |
1 | sample_01_flash_write.cpp | FlashAPI sample |
2 | sample_02_ssif_loop_back.cpp | SSIF loop back sample |
4 | sample_04_ssif_wav_playback.cpp | SSIF wav playback sample (use USB memory or SD card) |
7 | sample_07_usb_func_serial.cpp | USBSerial (CDC) sample |
8 | sample_08_usb_func_mouse.cpp | USBMouse sample |
9 | sample_09_usb_func_keyboard.cpp | USBKeyboard sample |
10 | sample_10_usb_func_midi.cpp | USBMIDI sample |
11 | sample_11_usb_func_audio_1.cpp | USBAudio sample |
12 | sample_12_usb_func_audio_2.cpp | USBAudio and SSIF sample |
13 | sample_13_ether_http.cpp | Ether HTTP sample |
14 | sample_14_ether_https.cpp | Ether HTTPS sample |
16 | sample_16_usb_func_msd_1.cpp | USBMSD and FlashAPI sample |
17 | sample_17_usb_func_msd_2.cpp | USBMSD and FlashAPI sample advanced version |
18 | sample_18_mipi_drp_lcd.cpp | MIPI, DRP and LCD sample |
19 | sample_19_mipi_drp_diplayapp.cpp | MIPI, DRP and USBSerial (CDC) sample (use "DisplayApp") |
20 | sample_20_drp_dynamic_loading.cpp | DRP Dynamic Loading Sample |
21 | sample_21_deep_standby_alarm.cpp | Deep standby and RTC alarm sample |
22 | sample_22_hdmi_disp_ssif.cpp | HDMI output and SSIF wav playback Sample |
23 | sample_23_mipi_hdmi.cpp | HDMI output and MIPI Sample |
24 | sample_24_facedetection.cpp | HDMI output and face detection using OpenCV |
25 | sample_25_hdmi_mouse.cpp | HDMI output and Mouse Sample |
Notice
sample_24_facedetection.cpp
only can be compiled with GNU Compiler Collection.
About sample_24_facedetection.cpp
, this is a demonstration that can detect the face of a person without a mask. It will surround the face of a person without a mask with a red rectangle and sound alarm at the same time. To use OpenCV for face recognition, you need to prepare the followings:
・USB drive or SD card
・ Raspberry Pi Camera Module V2
・ HDMI monitor
Perform the following steps to complete face recognition sample.
1. Copy the lbpcascade_frontalface.xml to the root folder of USB drive or SD card and save it.
2. Copy the alarm.wav to the root folder of USB drive or SD card and save it.
3. Set "camera-type" value to "CAMERA_RASPBERRY_PI_832X480" in mbed_app.json
About custom boot loaders
This sample uses custom bootloader
revision 5
, and you can drag & drop the "xxxx_application.bin" file to write the program. Please see here for the detail.
How to write program
When using DAPLink
, please use xxxx.bin
as following.
- Connect the
micro USB type B terminal
to the PC using a USB cable. - You can find the
MBED
directory. - Drag & drop
xxxx.bin
to theMBED
directory. - When writing is completed, press the reset button.
When using custom bootloader
, please use xxxx_application.bin
as following.
- Connect the
USB type C terminal
to the PC using a USB cable. - Hold down
USB0
and press the reset button. - You can find the
GR-MANG
directory. - Drag & drop xxxx_application.bin to the GR-MANGO directory.
When writing is completed, press the reset button.
Attention!
For the first time only, you need to write a custom bootloader
using DAPLink
.
Terminal setting
If you want to confirm the serial communication the terminal soft on your PC, please specify the below values.
You can change the baud rate by platform.stio-baud-rate
of mbed_app.json
.
Baud rate | 115,200 |
Data | 8bit |
Parity | none |
Stop | 1bit |
Flow control | none |
sample_programs/sample_25_hdmi_mouse.cpp@16:f4798796b4a2, 2021-03-04 (annotated)
- Committer:
- luyao@os.mbed.com
- Date:
- Thu Mar 04 18:22:21 2021 +0900
- Revision:
- 16:f4798796b4a2
- Parent:
- 9:d0996aa0a2bc
Modified EP952 Parameters.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 1 | /******************************************************************************* |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 2 | * DISCLAIMER |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 4 | * intended for use with Renesas products. No other uses are authorized. This |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 6 | * all applicable laws, including copyright laws. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 16 | * Renesas reserves the right, without notice, to make changes to this software |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 17 | * and to discontinue the availability of this software. By using this software, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 18 | * you agree to the additional terms and conditions found by accessing the |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 19 | * following link: |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 20 | * http://www.renesas.com/disclaimer |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 21 | * |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 22 | * Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 23 | *******************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 24 | #include "sample_select.h" |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 25 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 26 | #if (SAMPLE_PROGRAM_NO == 25) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 27 | // SAMPLE_PROGRAM_NO 25 : HDMI output & mouse cursor Sample |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 28 | // |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 29 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 30 | #include "mbed.h" |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 31 | #include "EasyAttach_CameraAndLCD.h" |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 32 | #include "USBHostMouse.h" |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 33 | #include "r_cache_lld_rza2m.h" |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 34 | #include "LCD_config_rgb_to_hdmi.h" |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 35 | #include "DisplayBace.h" |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 36 | #include "arrow_data.h" |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 37 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 38 | /****************************************************************************** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 39 | Macro definitions |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 40 | ******************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 41 | /* LED blinky */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 42 | #define BLINKING_RATE 500ms |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 43 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 44 | /* Frame buffer */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 45 | #define FRAME_BUFFER_BYTE_PER_PIXEL0 (2) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 46 | #define FRAME_BUFFER_STRIDE0 (((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL0) + 31u) & ~31u) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 47 | #define FRAME_BUFFER_BYTE_PER_PIXEL2 (1) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 48 | #define FRAME_BUFFER_STRIDE2 (((LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL2) + 31u) & ~31u) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 49 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 50 | /* mouse */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 51 | #define MAIN_FLG_MOUSE_IN (0x00001000) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 52 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 53 | /* mouse disp */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 54 | #define ARROW_BUFFER_AREA (32u * 32u) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 55 | #define CAUTION_WINDOW_WIDTH (576u) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 56 | #define CAUTION_WINDOW_HEIGHT (160u) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 57 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 58 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 59 | /****************************************************************************** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 60 | Typedef definitions |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 61 | ******************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 62 | /* mouse */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 63 | typedef struct { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 64 | int32_t x; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 65 | int32_t y; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 66 | uint8_t buttons; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 67 | } mouse_info_t; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 68 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 69 | /* mouse proc */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 70 | class Mouse { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 71 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 72 | public: |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 73 | /** Touch position structure */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 74 | typedef struct { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 75 | uint32_t x; /**< The position of the x-coordinate. */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 76 | uint32_t y; /**< The position of the y-coordinate. */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 77 | uint8_t buttons; /**< buttons. */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 78 | bool valid; /**< Whether a valid data.. */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 79 | } touch_pos_t; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 80 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 81 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 82 | /** Create a Mouse object |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 83 | * |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 84 | */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 85 | Mouse(void){ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 86 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 87 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 88 | /** Reset a Mouse object |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 89 | * |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 90 | * @param x :The maximum value of the x-coordinate. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 91 | * @param y :The maximum value of the y-coordinate. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 92 | */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 93 | void Reset(int32_t max_x = 800, int32_t max_y = 480); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 94 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 95 | /** Attach a function to call when touch panel int |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 96 | * |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 97 | * @param fptr A pointer to a void function, or 0 to set as none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 98 | */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 99 | void SetCallback(void (*fptr)(void)); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 100 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 101 | /** Get the coordinates |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 102 | * |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 103 | * @param touch_buff_num The number of structure p_touch. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 104 | * @param p_touch Touch position information. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 105 | * @return The number of touch points. |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 106 | */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 107 | int GetCoordinates(touch_pos_t * p_touch); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 108 | }; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 109 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 110 | /****************************************************************************** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 111 | Private global variables and functions |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 112 | ******************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 113 | /* Main task */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 114 | static Thread mainTask(osPriorityNormal,1024*8); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 115 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 116 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 117 | /* Frame buffer */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 118 | DisplayBase Display; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 119 | static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE0 * LCD_PIXEL_HEIGHT]__attribute((aligned(32))); /* 32 bytes aligned */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 120 | static volatile int32_t vsync_count = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 121 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 122 | static void Start_LCD_Display(void); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 123 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 124 | /* mouse proc */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 125 | static int32_t pos_x = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 126 | static int32_t pos_y = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 127 | static int32_t maximum_x = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 128 | static int32_t maximum_y = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 129 | static uint8_t pressed_buttons = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 130 | static void (*cbFunc)(void) = NULL; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 131 | static void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 132 | static void mouse_task(void); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 133 | static Thread mouseTask(osPriorityNormal, 1024 * 2); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 134 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 135 | /* mouse disp */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 136 | static uint32_t arrow_buffer[ARROW_BUFFER_AREA] __attribute__ ((section("NC_BSS"))); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 137 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 138 | static DisplayBase::video_spea_sklym_t arrow_size = { 32, 32}; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 139 | static DisplayBase::video_spea_skpsm_t arrow_pos = { 0, 0}; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 140 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 141 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 142 | * @fn mouse_disp_init |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 143 | * @brief Initialize mouse disp |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 144 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 145 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 146 | void mouse_disp_init(void) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 147 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 148 | DisplayBase::rect_t rect; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 149 | rect.vs = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 150 | rect.vw = LCD_PIXEL_HEIGHT; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 151 | rect.hs = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 152 | rect.hw = LCD_PIXEL_WIDTH; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 153 | Display.Graphics_Read_Setting_SPEA( |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 154 | DisplayBase::GRAPHICS_LAYER_3, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 155 | &rect |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 156 | ); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 157 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 158 | memcpy((void *)arrow_buffer, (void *)g_arrow_data, ARROW_SIZE); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 159 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 160 | Display.Graphics_Update_Window_SPEA( |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 161 | DisplayBase::GRAPHICS_LAYER_3, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 162 | DisplayBase::WINDOW_01, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 163 | DisplayBase::SPEA_ON, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 164 | &arrow_size, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 165 | &arrow_pos, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 166 | arrow_buffer |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 167 | ); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 168 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 169 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 170 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 171 | * @fn set_mouse_disp |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 172 | * @brief Receive mouse information, and move the sprite |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 173 | * @param[in] pos_x :x-coordinate |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 174 | * @param[in] pos_y :y-coordinate |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 175 | * @param[in] buttons :buttons (each bit) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 176 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 177 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 178 | void set_mouse_disp(int32_t mouse_x, int32_t mouse_y, uint8_t buttons) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 179 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 180 | arrow_pos.x = mouse_x; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 181 | arrow_pos.y = mouse_y; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 182 | Display.Graphics_Update_Window_SPEA( |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 183 | DisplayBase::GRAPHICS_LAYER_3, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 184 | DisplayBase::WINDOW_01, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 185 | DisplayBase::SPEA_ON, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 186 | &arrow_size, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 187 | &arrow_pos, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 188 | arrow_buffer |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 189 | ); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 190 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 191 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 192 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 193 | * @fn set_mouse_info |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 194 | * @brief Receive mouse information |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 195 | * @param[in] pos_x :x-coordinate |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 196 | * @param[in] pos_y :y-coordinate |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 197 | * @param[in] buttons :buttons (each bit) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 198 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 199 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 200 | static void set_mouse_info(void) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 201 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 202 | mainTask.flags_set(MAIN_FLG_MOUSE_IN); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 203 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 204 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 205 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 206 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 207 | * @fn onMouseEvent |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 208 | * @brief Callback function for mouse event |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 209 | * @param[in] buttons :buttons (each bit) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 210 | * @param[in] x :x amount of change |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 211 | * @param[in] y :y amount of change |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 212 | * @param[in] x :z amount of change |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 213 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 214 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 215 | static void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 216 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 217 | /* X */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 218 | pos_x += x; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 219 | if (pos_x < 0) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 220 | pos_x = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 221 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 222 | if (pos_x > (maximum_x - 1)) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 223 | pos_x = maximum_x - 1; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 224 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 225 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 226 | /* Y */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 227 | pos_y += y; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 228 | if (pos_y < 0) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 229 | pos_y = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 230 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 231 | if (pos_y > (maximum_x - 1)) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 232 | pos_y = (maximum_x - 1); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 233 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 234 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 235 | if( cbFunc != NULL ) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 236 | cbFunc(); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 237 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 238 | pressed_buttons = buttons; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 239 | set_mouse_disp(pos_x, pos_y, buttons); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 240 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 241 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 242 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 243 | * @fn SetCallback |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 244 | * @brief register callback function for mouse event |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 245 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 246 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 247 | void Mouse::SetCallback(void (*fptr)(void)) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 248 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 249 | cbFunc = fptr; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 250 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 251 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 252 | * @fn SetCallback |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 253 | * @brief register callback function for mouse event |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 254 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 255 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 256 | int Mouse::GetCoordinates(touch_pos_t * p_touch) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 257 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 258 | if (p_touch!=NULL) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 259 | p_touch->valid = true; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 260 | /* X */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 261 | if (pos_x > 0) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 262 | p_touch->x = pos_x; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 263 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 264 | else { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 265 | p_touch->valid = false; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 266 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 267 | /* Y */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 268 | if (pos_y > 0) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 269 | p_touch->y = pos_y; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 270 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 271 | else { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 272 | p_touch->valid = false; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 273 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 274 | p_touch->buttons = pressed_buttons; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 275 | p_touch->y = pos_y; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 276 | return 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 277 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 278 | return -1; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 279 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 280 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 281 | * @fn mouse_task |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 282 | * @brief mouse task |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 283 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 284 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 285 | static void mouse_task(void) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 286 | USBHostMouse mouse; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 287 | mouse_disp_init(); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 288 | while (1) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 289 | /* try to connect a USB mouse */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 290 | while (!mouse.connect()) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 291 | ThisThread::sleep_for(500ms); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 292 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 293 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 294 | /* when connected, attach handler called on mouse event */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 295 | mouse.attachEvent(onMouseEvent); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 296 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 297 | /* wait until the mouse is disconnected */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 298 | while (mouse.connected()) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 299 | ThisThread::sleep_for(500ms); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 300 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 301 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 302 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 303 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 304 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 305 | * @fn Mouse |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 306 | * @brief Mouse class constructor |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 307 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 308 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 309 | void Mouse::Reset(int32_t max_x, int32_t max_y) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 310 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 311 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 312 | pos_x = max_x / 2; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 313 | pos_y = max_y / 2; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 314 | maximum_x = max_x; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 315 | maximum_y = max_y; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 316 | mouseTask.start(callback(mouse_task)); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 317 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 318 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 319 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 320 | * @fn IntCallbackFunc_LoVsync |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 321 | * @brief Callback function for each Vsync |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 322 | * @param[in] int_type :not used |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 323 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 324 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 325 | static void IntCallbackFunc_LoVsync(DisplayBase::int_type_t int_type) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 326 | /* Interrupt callback function for Vsync interruption */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 327 | if (vsync_count > 0) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 328 | vsync_count--; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 329 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 330 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 331 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 332 | #if 0 /* not used */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 333 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 334 | * @fn Wait_Vsync |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 335 | * @brief Waiting Vsync |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 336 | * @param[in] wait_count :wait count |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 337 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 338 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 339 | static void Wait_Vsync(const int32_t wait_count) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 340 | /* Wait for the specified number of times Vsync occurs */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 341 | vsync_count = wait_count; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 342 | while (vsync_count > 0) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 343 | ThisThread::sleep_for(2ms); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 344 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 345 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 346 | #endif |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 347 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 348 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 349 | * @fn Start_LCD_Display |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 350 | * @brief Start HDMI display |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 351 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 352 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 353 | static void Start_LCD_Display(void) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 354 | DisplayBase::rect_t rect; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 355 | DisplayBase::graphics_error_t error; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 356 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 357 | /* Interrupt callback function setting (Vsync signal output from scaler 0) */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 358 | EasyAttach_Init(Display); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 359 | error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_LO_VSYNC, 0, IntCallbackFunc_LoVsync); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 360 | if (error != DisplayBase::GRAPHICS_OK) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 361 | printf("Line %d, error %d\n", __LINE__, error); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 362 | mbed_die(); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 363 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 364 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 365 | /* Create Layer 0 */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 366 | memset(user_frame_buffer0, 0, sizeof(user_frame_buffer0)); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 367 | /* create base graphics */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 368 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 369 | #define LATTICE_HIGHT 16 |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 370 | #define LATTICE_WIDTH 16 |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 371 | uint32_t x = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 372 | uint32_t y = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 373 | for( y = 0; y < LCD_PIXEL_HEIGHT; y++ ) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 374 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 375 | if ((y % LATTICE_HIGHT) == 0 ) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 376 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 377 | for (x = 0; x < LCD_PIXEL_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL0; x+=2) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 378 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 379 | /* PIXEL_FORMAT_RGB565 */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 380 | user_frame_buffer0[y * FRAME_BUFFER_STRIDE0 + x + 0] = 0x18; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 381 | user_frame_buffer0[y * FRAME_BUFFER_STRIDE0 + x + 1] = 0xE5; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 382 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 383 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 384 | else |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 385 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 386 | for (x = 0; x < FRAME_BUFFER_STRIDE0; x += LATTICE_WIDTH * FRAME_BUFFER_BYTE_PER_PIXEL0) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 387 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 388 | /* PIXEL_FORMAT_RGB565 */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 389 | user_frame_buffer0[y * FRAME_BUFFER_STRIDE0 + x + 0] = 0x18; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 390 | user_frame_buffer0[y * FRAME_BUFFER_STRIDE0 + x + 1] = 0xE5; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 391 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 392 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 393 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 394 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 395 | R_CACHE_L1DataCleanLine(user_frame_buffer0, sizeof(user_frame_buffer0)); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 396 | rect.vs = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 397 | rect.vw = LCD_PIXEL_HEIGHT; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 398 | rect.hs = 0; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 399 | rect.hw = LCD_PIXEL_WIDTH; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 400 | Display.Graphics_Read_Setting( |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 401 | DisplayBase::GRAPHICS_LAYER_0, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 402 | (void *)user_frame_buffer0, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 403 | FRAME_BUFFER_STRIDE0, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 404 | DisplayBase::GRAPHICS_FORMAT_RGB565, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 405 | DisplayBase::WR_RD_WRSWA_32_16_8BIT, |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 406 | &rect |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 407 | ); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 408 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 409 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 410 | ThisThread::sleep_for(50ms); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 411 | EasyAttach_LcdBacklight(true); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 412 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 413 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 414 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 415 | * @fn main_task |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 416 | * @brief Main task |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 417 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 418 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 419 | void main_task(void) |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 420 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 421 | Start_LCD_Display(); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 422 | ThisThread::sleep_for(200ms); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 423 | Mouse mouse; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 424 | mouse.Reset(LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 425 | mouse.SetCallback(set_mouse_info); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 426 | Mouse::touch_pos_t pos; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 427 | Mouse::touch_pos_t pos_last = {0}; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 428 | printf("Start sample.\n\r"); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 429 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 430 | while (true) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 431 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 432 | ThisThread::flags_wait_any_for(MAIN_FLG_MOUSE_IN, rtos::Kernel::wait_for_u32_forever); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 433 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 434 | mouse.GetCoordinates(&pos); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 435 | if (pos.valid == true) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 436 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 437 | /* print mouse information */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 438 | printf("(%03d,%03d)",(int)pos.x, (int)pos.y); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 439 | if (((pos.buttons & 0x01) == 0) && ((pos_last.buttons & 0x01) != 0)) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 440 | printf(" click off"); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 441 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 442 | else if (((pos.buttons & 0x01) != 0) && ((pos_last.buttons & 0x01) == 0)) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 443 | printf(" click on"); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 444 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 445 | printf("\n"); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 446 | /* backup mouse information */ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 447 | pos_last = pos; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 448 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 449 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 450 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 451 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 452 | /**************************************************************************//** |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 453 | * @fn main |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 454 | * @brief Wake up main task, blinks LED |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 455 | * @retval none |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 456 | *****************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 457 | int main() |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 458 | { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 459 | mainTask.start(callback(main_task)); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 460 | // Initialise the digital pin LED1 as an output |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 461 | DigitalOut led(LED1); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 462 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 463 | while (true) { |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 464 | led = !led; |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 465 | ThisThread::sleep_for(BLINKING_RATE); |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 466 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 467 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 468 | } |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 469 | |
RyoheiHagimoto@os.mbed.com | 9:d0996aa0a2bc | 470 | #endif |