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_22_hdmi_disp_ssif.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:
- 1:13d09ce5b51a
Modified EP952 Parameters.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 1 | /******************************************************************************* |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 2 | * DISCLAIMER |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 4 | * intended for use with Renesas products. No other uses are authorized. This |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 6 | * all applicable laws, including copyright laws. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 16 | * Renesas reserves the right, without notice, to make changes to this software |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 17 | * and to discontinue the availability of this software. By using this software, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 18 | * you agree to the additional terms and conditions found by accessing the |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 19 | * following link: |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 20 | * http://www.renesas.com/disclaimer |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 21 | * |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 22 | * Copyright (C) 2019 Renesas Electronics Corporation. All rights reserved. |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 23 | *******************************************************************************/ |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 24 | #include "sample_select.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 25 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 26 | #if (SAMPLE_PROGRAM_NO == 22) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 27 | // SAMPLE_PROGRAM_NO 22 : HDMI output & SSIF wav playback Sample |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 28 | // |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 29 | // Requirements |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 30 | // RZ/A2M Evaluation Board Kit : Display Output Board |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 31 | // SBEV-RZ/A2M : LVDS To HDMI Board |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 32 | // SEMB1402 : LVDS To HDMI Board |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 33 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 34 | #if defined(TARGET_SEMB1402) || defined(TARGET_RZ_A2M_SBEV) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 35 | #error "Audio is not supported." |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 36 | #endif |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 37 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 38 | #include "mbed.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 39 | #include "FATFileSystem.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 40 | #include "SdUsbConnect.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 41 | #include "EasyPlayback.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 42 | #include "EasyDec_WavCnv2ch.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 43 | #include "EasyAttach_CameraAndLCD.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 44 | #include "dcache-control.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 45 | #include "AsciiFont.h" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 46 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 47 | static EasyPlayback AudioPlayer; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 48 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 49 | #define FILE_NAME_LEN (64) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 50 | #define MOUNT_NAME "storage" |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 51 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 52 | static InterruptIn skip_btn(USER_BUTTON0); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 53 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 54 | static void skip_btn_fall(void) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 55 | AudioPlayer.skip(); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 56 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 57 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 58 | /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128 |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 59 | in accordance with the frame buffer burst transfer mode. */ |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 60 | #define VIDEO_PIXEL_HW (640) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 61 | #define VIDEO_PIXEL_VW (480) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 62 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 63 | #define DATA_SIZE_PER_PIC (1u) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 64 | #define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 65 | #define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 66 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 67 | #define DRP_FLG_CAMER_IN (0x00000100) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 68 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 69 | static DisplayBase Display; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 70 | static uint8_t fbuf_clat8[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((aligned(32))); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 71 | static uint8_t fbuf_overlay[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(32))); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 72 | static Thread drpTask(osPriorityHigh); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 73 | static Thread hdmiTask(osPriorityHigh); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 74 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 75 | static const uint32_t clut_data_resut[] = {0x00000000, 0xff00ff00}; // ARGB8888 |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 76 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 77 | static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 78 | drpTask.flags_set(DRP_FLG_CAMER_IN); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 79 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 80 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 81 | static void Start_LCD_Display(void) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 82 | DisplayBase::rect_t rect; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 83 | DisplayBase::clut_t clut_param; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 84 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 85 | rect.vs = 0; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 86 | rect.vw = VIDEO_PIXEL_VW; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 87 | rect.hs = 0; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 88 | rect.hw = VIDEO_PIXEL_HW; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 89 | Display.Graphics_Read_Setting( |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 90 | DisplayBase::GRAPHICS_LAYER_0, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 91 | (void *)fbuf_clat8, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 92 | FRAME_BUFFER_STRIDE, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 93 | DisplayBase::GRAPHICS_FORMAT_CLUT8, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 94 | DisplayBase::WR_RD_WRSWA_32_16_8BIT, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 95 | &rect |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 96 | ); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 97 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_0); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 98 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 99 | memset(fbuf_overlay, 0, sizeof(fbuf_overlay)); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 100 | clut_param.color_num = sizeof(clut_data_resut) / sizeof(uint32_t); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 101 | clut_param.clut = clut_data_resut; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 102 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 103 | rect.vs = 0; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 104 | rect.vw = VIDEO_PIXEL_VW; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 105 | rect.hs = 0; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 106 | rect.hw = VIDEO_PIXEL_HW; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 107 | Display.Graphics_Read_Setting( |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 108 | DisplayBase::GRAPHICS_LAYER_2, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 109 | (void *)fbuf_overlay, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 110 | FRAME_BUFFER_STRIDE, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 111 | DisplayBase::GRAPHICS_FORMAT_CLUT8, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 112 | DisplayBase::WR_RD_WRSWA_32_16_8BIT, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 113 | &rect, |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 114 | &clut_param |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 115 | ); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 116 | Display.Graphics_Start(DisplayBase::GRAPHICS_LAYER_2); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 117 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 118 | ThisThread::sleep_for(50); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 119 | EasyAttach_LcdBacklight(true); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 120 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 121 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 122 | static void drp_task(void) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 123 | int i = 0; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 124 | char str[64]; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 125 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 126 | AsciiFont ascii_font(fbuf_overlay, VIDEO_PIXEL_HW, VIDEO_PIXEL_VW, FRAME_BUFFER_STRIDE, DATA_SIZE_PER_PIC); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 127 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 128 | EasyAttach_Init(Display); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 129 | Start_LCD_Display(); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 130 | // Interrupt callback function setting (Field end signal for recording function in scaler 0) |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 131 | Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 132 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 133 | while (true) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 134 | sprintf(str, "HDMI TEST %d", i); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 135 | ascii_font.DrawStr(str, 5, 5 + (AsciiFont::CHAR_PIX_HEIGHT + 1) * 0, 1, 2); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 136 | i++; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 137 | ThisThread::sleep_for(1000); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 138 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 139 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 140 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 141 | int main(void) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 142 | DIR * d; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 143 | struct dirent * p; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 144 | char file_path[sizeof("/" MOUNT_NAME "/") + FILE_NAME_LEN]; |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 145 | SdUsbConnect storage(MOUNT_NAME); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 146 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 147 | // Start DRP task |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 148 | drpTask.start(callback(drp_task)); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 149 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 150 | // decoder setting |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 151 | AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".wav"); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 152 | AudioPlayer.add_decoder<EasyDec_WavCnv2ch>(".WAV"); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 153 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 154 | AudioPlayer.outputVolume(0.5); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 155 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 156 | // button setting |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 157 | skip_btn.fall(&skip_btn_fall); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 158 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 159 | while (1) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 160 | // connect wait |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 161 | storage.wait_connect(); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 162 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 163 | // file search |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 164 | d = opendir("/" MOUNT_NAME "/"); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 165 | if (d != NULL) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 166 | while ((p = readdir(d)) != NULL) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 167 | size_t len = strlen(p->d_name); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 168 | if (len < FILE_NAME_LEN) { |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 169 | // make file path |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 170 | sprintf(file_path, "/%s/%s", MOUNT_NAME, p->d_name); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 171 | printf("%s\r\n", file_path); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 172 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 173 | // playback |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 174 | AudioPlayer.play(file_path); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 175 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 176 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 177 | closedir(d); |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 178 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 179 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 180 | } |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 181 | |
RyoheiHagimoto@os.mbed.com | 1:13d09ce5b51a | 182 | #endif |