![](/media/cache/profiles/090a24f78cd36ddf8f89779fc5ab22a8.jpg.50x50_q85.png)
use VS1033(MP3 decoder) and UL024TF(TFTLCD)
Dependencies: FastIO SDFileSystem TFTLCDwithFastIO TouchPanel VS1033 mbed
Fork of 11U68_MP3Player with TFTLCD by
main.cpp@8:198b69e78c39, 2015-07-30 (annotated)
- Committer:
- nameless129
- Date:
- Thu Jul 30 02:36:18 2015 +0000
- Revision:
- 8:198b69e78c39
- Parent:
- 7:fc65d965a569
- Child:
- 9:96b053c0865e
????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nameless129 | 7:fc65d965a569 | 1 | #pragma O3 |
nameless129 | 7:fc65d965a569 | 2 | |
nameless129 | 8:198b69e78c39 | 3 | #include "FastIO.h" |
nameless129 | 0:5f0e931ae677 | 4 | #include "ili9328.h" |
nameless129 | 5:a493361aead2 | 5 | #include "stdio.h" |
nameless129 | 5:a493361aead2 | 6 | #include "string.h" |
nameless129 | 2:0090839c8276 | 7 | #include "SDFileSystem.h" |
nameless129 | 2:0090839c8276 | 8 | #include "VS1053.h" |
nameless129 | 3:67e97c846cec | 9 | #include "image.h" |
nameless129 | 3:67e97c846cec | 10 | #include "TouchPanel.h" |
nameless129 | 3:67e97c846cec | 11 | #include "mbed.h" |
nameless129 | 2:0090839c8276 | 12 | |
nameless129 | 0:5f0e931ae677 | 13 | // prepare the data bus for writing commands and pixel data |
nameless129 | 0:5f0e931ae677 | 14 | // create the lcd instance |
nameless129 | 0:5f0e931ae677 | 15 | //(PinName CS, PinName RESET, PinName RS, PinName WR, BusOut *DATA_PORT, PinName BL=NC, PinName RD=NC, backlight_t blType=Constant, float defaultBackLightLevel=1.0) |
nameless129 | 8:198b69e78c39 | 16 | ILI9328_LCD lcd( P0_12, P0_11, P0_13, P0_14, NULL, NC, P1_9 ); // control pins and data bus |
nameless129 | 2:0090839c8276 | 17 | |
nameless129 | 8:198b69e78c39 | 18 | SDFileSystem sd(/*MOSI*/ P0_9, /*MISO*/ P0_8, /*SCK*/ P1_29, /*CS*/ P0_2, /*Mountpoint*/ "sd", NC, SDFileSystem::SWITCH_NONE, 10000000); |
nameless129 | 2:0090839c8276 | 19 | VS1053 mp3(/*MOSI*/ P1_22 , /*MISO*/ P1_21, /*SCK*/ P1_20, /*CS*/ P1_23, |
nameless129 | 7:fc65d965a569 | 20 | /*BSYNC*/ P2_17, /*DREQ*/ P2_16, /*RST*/ P2_18, /*SPI freq.*/ 5000000); |
nameless129 | 5:a493361aead2 | 21 | Ticker Int100ms; |
nameless129 | 3:67e97c846cec | 22 | |
nameless129 | 3:67e97c846cec | 23 | Serial pc(P0_19,P0_18); |
nameless129 | 8:198b69e78c39 | 24 | #define SD_READ_BLOCK_SIZE (512) |
nameless129 | 2:0090839c8276 | 25 | |
nameless129 | 3:67e97c846cec | 26 | #define BOTTON_PREV_XPOS (15) |
nameless129 | 7:fc65d965a569 | 27 | #define BOTTON_PREV_YPOS (180) |
nameless129 | 3:67e97c846cec | 28 | #define BOTTON_PLAY_XPOS (91) |
nameless129 | 7:fc65d965a569 | 29 | #define BOTTON_PLAY_YPOS (180) |
nameless129 | 3:67e97c846cec | 30 | #define BOTTON_STOP_XPOS (168) |
nameless129 | 7:fc65d965a569 | 31 | #define BOTTON_STOP_YPOS (180) |
nameless129 | 3:67e97c846cec | 32 | #define BOTTON_NEXT_XPOS (245) |
nameless129 | 7:fc65d965a569 | 33 | #define BOTTON_NEXT_YPOS (180) |
nameless129 | 3:67e97c846cec | 34 | #define BOTTON_VOLUP_XPOS (245) |
nameless129 | 3:67e97c846cec | 35 | #define BOTTON_VOLUP_YPOS (10) |
nameless129 | 3:67e97c846cec | 36 | #define BOTTON_VOLDOWN_XPOS (245) |
nameless129 | 3:67e97c846cec | 37 | #define BOTTON_VOLDOWN_YPOS (80) |
nameless129 | 3:67e97c846cec | 38 | |
nameless129 | 3:67e97c846cec | 39 | bool checkTouchBotton_prev(int32_t xpos,int32_t ypos) |
nameless129 | 3:67e97c846cec | 40 | { |
nameless129 | 3:67e97c846cec | 41 | bool result = 0; |
nameless129 | 6:74271fce2368 | 42 | if( ( (xpos >= BOTTON_PREV_XPOS+5) && (xpos <= BOTTON_PREV_XPOS+55) ) && |
nameless129 | 6:74271fce2368 | 43 | ( (ypos >= BOTTON_PREV_YPOS+5) && (ypos <= BOTTON_PREV_YPOS+55) ) ) |
nameless129 | 3:67e97c846cec | 44 | { |
nameless129 | 3:67e97c846cec | 45 | result = 1; |
nameless129 | 3:67e97c846cec | 46 | } |
nameless129 | 3:67e97c846cec | 47 | return result; |
nameless129 | 3:67e97c846cec | 48 | } |
nameless129 | 3:67e97c846cec | 49 | |
nameless129 | 3:67e97c846cec | 50 | bool checkTouchBotton_play(int32_t xpos,int32_t ypos) |
nameless129 | 3:67e97c846cec | 51 | { |
nameless129 | 3:67e97c846cec | 52 | bool result = 0; |
nameless129 | 6:74271fce2368 | 53 | if( ( (xpos >= BOTTON_PLAY_XPOS+5) && (xpos <= BOTTON_PLAY_XPOS+55) ) && |
nameless129 | 6:74271fce2368 | 54 | ( (ypos >= BOTTON_PLAY_YPOS+5) && (ypos <= BOTTON_PLAY_YPOS+55) ) ) |
nameless129 | 3:67e97c846cec | 55 | { |
nameless129 | 3:67e97c846cec | 56 | result = 1; |
nameless129 | 3:67e97c846cec | 57 | } |
nameless129 | 3:67e97c846cec | 58 | return result; |
nameless129 | 3:67e97c846cec | 59 | } |
nameless129 | 3:67e97c846cec | 60 | |
nameless129 | 3:67e97c846cec | 61 | bool checkTouchBotton_stop(int32_t xpos,int32_t ypos) |
nameless129 | 3:67e97c846cec | 62 | { |
nameless129 | 3:67e97c846cec | 63 | bool result = 0; |
nameless129 | 6:74271fce2368 | 64 | if( ( (xpos >= BOTTON_STOP_XPOS+5) && (xpos <= BOTTON_STOP_XPOS+55) ) && |
nameless129 | 6:74271fce2368 | 65 | ( (ypos >= BOTTON_STOP_XPOS+5) && (ypos <= BOTTON_STOP_XPOS+55) ) ) |
nameless129 | 3:67e97c846cec | 66 | { |
nameless129 | 3:67e97c846cec | 67 | result = 1; |
nameless129 | 3:67e97c846cec | 68 | } |
nameless129 | 3:67e97c846cec | 69 | return result; |
nameless129 | 3:67e97c846cec | 70 | } |
nameless129 | 3:67e97c846cec | 71 | |
nameless129 | 3:67e97c846cec | 72 | bool checkTouchBotton_next(int32_t xpos,int32_t ypos) |
nameless129 | 3:67e97c846cec | 73 | { |
nameless129 | 3:67e97c846cec | 74 | bool result = 0; |
nameless129 | 6:74271fce2368 | 75 | if( ( (xpos >= BOTTON_NEXT_XPOS+5) && (xpos <= BOTTON_NEXT_XPOS+55) ) && |
nameless129 | 6:74271fce2368 | 76 | ( (ypos >= BOTTON_NEXT_YPOS+5) && (ypos <= BOTTON_NEXT_YPOS+55) ) ) |
nameless129 | 3:67e97c846cec | 77 | { |
nameless129 | 3:67e97c846cec | 78 | result = 1; |
nameless129 | 3:67e97c846cec | 79 | } |
nameless129 | 3:67e97c846cec | 80 | return result; |
nameless129 | 3:67e97c846cec | 81 | } |
nameless129 | 3:67e97c846cec | 82 | |
nameless129 | 3:67e97c846cec | 83 | bool checkTouchBotton_volup(int32_t xpos,int32_t ypos) |
nameless129 | 3:67e97c846cec | 84 | { |
nameless129 | 3:67e97c846cec | 85 | bool result = 0; |
nameless129 | 6:74271fce2368 | 86 | if( ( (xpos >= BOTTON_VOLUP_XPOS+5) && (xpos <= BOTTON_VOLUP_XPOS+55) ) && |
nameless129 | 6:74271fce2368 | 87 | ( (ypos >= BOTTON_VOLUP_YPOS+5) && (ypos <= BOTTON_VOLUP_YPOS+55) ) ) |
nameless129 | 3:67e97c846cec | 88 | { |
nameless129 | 3:67e97c846cec | 89 | result = 1; |
nameless129 | 3:67e97c846cec | 90 | } |
nameless129 | 3:67e97c846cec | 91 | return result; |
nameless129 | 3:67e97c846cec | 92 | } |
nameless129 | 3:67e97c846cec | 93 | |
nameless129 | 3:67e97c846cec | 94 | bool checkTouchBotton_voldown(int32_t xpos,int32_t ypos) |
nameless129 | 3:67e97c846cec | 95 | { |
nameless129 | 3:67e97c846cec | 96 | bool result = 0; |
nameless129 | 6:74271fce2368 | 97 | if( ( (xpos >= BOTTON_VOLDOWN_XPOS+5) && (xpos <= BOTTON_VOLDOWN_XPOS+55) ) && |
nameless129 | 6:74271fce2368 | 98 | ( (ypos >= BOTTON_VOLDOWN_YPOS+5) && (ypos <= BOTTON_VOLDOWN_YPOS+55) ) ) |
nameless129 | 3:67e97c846cec | 99 | { |
nameless129 | 3:67e97c846cec | 100 | result = 1; |
nameless129 | 3:67e97c846cec | 101 | } |
nameless129 | 3:67e97c846cec | 102 | return result; |
nameless129 | 3:67e97c846cec | 103 | } |
nameless129 | 3:67e97c846cec | 104 | |
nameless129 | 6:74271fce2368 | 105 | #define TOUCHPANEL_BOTTON_TOUCH_STOP (0) |
nameless129 | 6:74271fce2368 | 106 | #define TOUCHPANEL_BOTTON_TOUCH_PLAY (1) |
nameless129 | 6:74271fce2368 | 107 | #define TOUCHPANEL_BOTTON_TOUCH_NEXT (2) |
nameless129 | 6:74271fce2368 | 108 | #define TOUCHPANEL_BOTTON_TOUCH_PREV (3) |
nameless129 | 6:74271fce2368 | 109 | #define TOUCHPANEL_BOTTON_TOUCH_VOLUP (4) |
nameless129 | 6:74271fce2368 | 110 | #define TOUCHPANEL_BOTTON_TOUCH_VOLDOWN (5) |
nameless129 | 6:74271fce2368 | 111 | #define TOUCHPANEL_BOTTON_NOT_TOUCH (-1) |
nameless129 | 6:74271fce2368 | 112 | #define TOUCHPANEL_OTHER_TOUCH (-2) |
nameless129 | 6:74271fce2368 | 113 | |
nameless129 | 6:74271fce2368 | 114 | int8_t detectTouchBotton(int32_t xpos,int32_t ypos) |
nameless129 | 6:74271fce2368 | 115 | { |
nameless129 | 6:74271fce2368 | 116 | int8_t result = 0; |
nameless129 | 6:74271fce2368 | 117 | |
nameless129 | 6:74271fce2368 | 118 | if( checkTouchBotton_stop(xpos,ypos) ) |
nameless129 | 6:74271fce2368 | 119 | { |
nameless129 | 6:74271fce2368 | 120 | result = TOUCHPANEL_BOTTON_TOUCH_STOP; |
nameless129 | 6:74271fce2368 | 121 | } |
nameless129 | 6:74271fce2368 | 122 | else if( checkTouchBotton_play(xpos,ypos) ) |
nameless129 | 6:74271fce2368 | 123 | { |
nameless129 | 6:74271fce2368 | 124 | result = TOUCHPANEL_BOTTON_TOUCH_PLAY; |
nameless129 | 6:74271fce2368 | 125 | } |
nameless129 | 6:74271fce2368 | 126 | else if( checkTouchBotton_prev(xpos,ypos) ) |
nameless129 | 6:74271fce2368 | 127 | { |
nameless129 | 6:74271fce2368 | 128 | result = TOUCHPANEL_BOTTON_TOUCH_PREV; |
nameless129 | 6:74271fce2368 | 129 | } |
nameless129 | 6:74271fce2368 | 130 | else if( checkTouchBotton_next(xpos,ypos) ) |
nameless129 | 6:74271fce2368 | 131 | { |
nameless129 | 6:74271fce2368 | 132 | result = TOUCHPANEL_BOTTON_TOUCH_NEXT; |
nameless129 | 6:74271fce2368 | 133 | } |
nameless129 | 6:74271fce2368 | 134 | else if( checkTouchBotton_volup(xpos,ypos) ) |
nameless129 | 6:74271fce2368 | 135 | { |
nameless129 | 6:74271fce2368 | 136 | result = TOUCHPANEL_BOTTON_TOUCH_VOLUP; |
nameless129 | 6:74271fce2368 | 137 | } |
nameless129 | 6:74271fce2368 | 138 | else if( checkTouchBotton_voldown(xpos,ypos) ) |
nameless129 | 6:74271fce2368 | 139 | { |
nameless129 | 6:74271fce2368 | 140 | result = TOUCHPANEL_BOTTON_TOUCH_VOLDOWN; |
nameless129 | 6:74271fce2368 | 141 | } |
nameless129 | 6:74271fce2368 | 142 | else if( (xpos == -1) || (ypos == -1) ) |
nameless129 | 6:74271fce2368 | 143 | { |
nameless129 | 6:74271fce2368 | 144 | result = TOUCHPANEL_BOTTON_NOT_TOUCH; |
nameless129 | 6:74271fce2368 | 145 | } |
nameless129 | 6:74271fce2368 | 146 | else |
nameless129 | 6:74271fce2368 | 147 | { |
nameless129 | 6:74271fce2368 | 148 | result = TOUCHPANEL_OTHER_TOUCH; |
nameless129 | 6:74271fce2368 | 149 | } |
nameless129 | 6:74271fce2368 | 150 | |
nameless129 | 6:74271fce2368 | 151 | return result; |
nameless129 | 6:74271fce2368 | 152 | } |
nameless129 | 6:74271fce2368 | 153 | |
nameless129 | 5:a493361aead2 | 154 | uint8_t g_mp3Player_State = 0; |
nameless129 | 5:a493361aead2 | 155 | uint16_t g_mp3Player_Volume = 0; |
nameless129 | 5:a493361aead2 | 156 | bool gf_mp3Playwe_VolmeUpdate = 0; |
nameless129 | 6:74271fce2368 | 157 | bool gf_TimerInt = 0; |
nameless129 | 5:a493361aead2 | 158 | |
nameless129 | 5:a493361aead2 | 159 | void Int100msFunc() |
nameless129 | 5:a493361aead2 | 160 | { |
nameless129 | 6:74271fce2368 | 161 | gf_TimerInt = 1; |
nameless129 | 5:a493361aead2 | 162 | } |
nameless129 | 2:0090839c8276 | 163 | |
nameless129 | 0:5f0e931ae677 | 164 | int main() |
nameless129 | 0:5f0e931ae677 | 165 | { |
nameless129 | 2:0090839c8276 | 166 | static FILE *fp = NULL; |
nameless129 | 3:67e97c846cec | 167 | uint8_t SDFileOpenFailCnt = 0; |
nameless129 | 3:67e97c846cec | 168 | size_t mp3_ReadFileSize = 0; |
nameless129 | 3:67e97c846cec | 169 | size_t mp3_totalSizeSent=0; |
nameless129 | 3:67e97c846cec | 170 | size_t mp3_fileSize=0; |
nameless129 | 3:67e97c846cec | 171 | bool f_mp3Playwe_Playing = 0; |
nameless129 | 2:0090839c8276 | 172 | uint8_t buf[SD_READ_BLOCK_SIZE]; |
nameless129 | 3:67e97c846cec | 173 | char str[100]; |
nameless129 | 3:67e97c846cec | 174 | int32_t XReadPos = 0,YReadPos = 0; |
nameless129 | 6:74271fce2368 | 175 | bool touchPanel_Touched = 0; |
nameless129 | 7:fc65d965a569 | 176 | uint32_t totalPlay = 0; |
nameless129 | 7:fc65d965a569 | 177 | int dot1_FileSize = 0; |
nameless129 | 7:fc65d965a569 | 178 | int dot_XPos = 0,old_dot_XPos = 0; |
nameless129 | 8:198b69e78c39 | 179 | int lcd_FileViewPage = 0,old_lcd_FileViewPage = 0; |
nameless129 | 8:198b69e78c39 | 180 | int lcd_FileViewListEnd = 0; |
nameless129 | 8:198b69e78c39 | 181 | |
nameless129 | 3:67e97c846cec | 182 | //Format,Xsize,Ysize,PixelData |
nameless129 | 3:67e97c846cec | 183 | const bitmap_t img_button_play = { RGB16, 60, 60, &bmp_button_play }; |
nameless129 | 3:67e97c846cec | 184 | const bitmap_t img_button_stop = { RGB16, 60, 60, &bmp_button_stop }; |
nameless129 | 3:67e97c846cec | 185 | const bitmap_t img_button_next = { RGB16, 60, 60, &bmp_button_next }; |
nameless129 | 3:67e97c846cec | 186 | const bitmap_t img_button_prev = { RGB16, 60, 60, &bmp_button_prev }; |
nameless129 | 8:198b69e78c39 | 187 | const bitmap_t img_button_pause = { RGB16, 60, 60, &bmp_button_pause }; |
nameless129 | 8:198b69e78c39 | 188 | |
nameless129 | 6:74271fce2368 | 189 | // const bitmap_t img_button_volup = { RGB16, 60, 60, &bmp_button_volup }; |
nameless129 | 6:74271fce2368 | 190 | // const bitmap_t img_button_voldown = { RGB16, 60, 60, &bmp_button_voldown }; |
nameless129 | 5:a493361aead2 | 191 | |
nameless129 | 5:a493361aead2 | 192 | pc.baud(921600); |
nameless129 | 5:a493361aead2 | 193 | printf("Power ON\r\n"); |
nameless129 | 2:0090839c8276 | 194 | |
nameless129 | 5:a493361aead2 | 195 | Int100ms.attach_us(&Int100msFunc, 100000); |
nameless129 | 2:0090839c8276 | 196 | |
nameless129 | 3:67e97c846cec | 197 | //SD Init.(本来ならいらないけど、SDカードによっちゃもう1回リセットしないとダメポ |
nameless129 | 3:67e97c846cec | 198 | sd.disk_initialize(); |
nameless129 | 3:67e97c846cec | 199 | |
nameless129 | 2:0090839c8276 | 200 | //LCD Init. |
nameless129 | 0:5f0e931ae677 | 201 | lcd.Initialize(LANDSCAPE,RGB16); |
nameless129 | 2:0090839c8276 | 202 | |
nameless129 | 2:0090839c8276 | 203 | /* for sine test mode */ |
nameless129 | 2:0090839c8276 | 204 | // mp3.sine_test_activate(SineWave_10k); |
nameless129 | 2:0090839c8276 | 205 | // while(1); |
nameless129 | 3:67e97c846cec | 206 | |
nameless129 | 2:0090839c8276 | 207 | //MP3 decoder Init. |
nameless129 | 2:0090839c8276 | 208 | mp3.hardwareReset(); |
nameless129 | 2:0090839c8276 | 209 | mp3.sci_init(); |
nameless129 | 2:0090839c8276 | 210 | mp3.sdi_init(); |
nameless129 | 2:0090839c8276 | 211 | wait(0.1); |
nameless129 | 2:0090839c8276 | 212 | |
nameless129 | 2:0090839c8276 | 213 | printf("init CMPL.\r\n"); |
nameless129 | 2:0090839c8276 | 214 | |
nameless129 | 0:5f0e931ae677 | 215 | lcd.SetBackground(COLOR_BLUE); |
nameless129 | 0:5f0e931ae677 | 216 | lcd.FillScreen(-1); |
nameless129 | 5:a493361aead2 | 217 | lcd.SetFont( &TerminusBigFont ); |
nameless129 | 2:0090839c8276 | 218 | |
nameless129 | 5:a493361aead2 | 219 | //for Caliblation |
nameless129 | 5:a493361aead2 | 220 | while(0) |
nameless129 | 5:a493361aead2 | 221 | { |
nameless129 | 5:a493361aead2 | 222 | int32_t XReadPos = 0,YReadPos = 0; |
nameless129 | 5:a493361aead2 | 223 | lcd.DrawCircle(40,40,10,COLOR_WHITE); |
nameless129 | 5:a493361aead2 | 224 | lcd.DrawCircle(280,200,10,COLOR_WHITE); |
nameless129 | 5:a493361aead2 | 225 | XReadPos = getTouchPanelPosX(); |
nameless129 | 5:a493361aead2 | 226 | YReadPos = getTouchPanelPosY(); |
nameless129 | 5:a493361aead2 | 227 | printf("X:%d Y:%d\r\n",XReadPos,YReadPos); |
nameless129 | 5:a493361aead2 | 228 | wait_ms(500); |
nameless129 | 5:a493361aead2 | 229 | } |
nameless129 | 5:a493361aead2 | 230 | |
nameless129 | 3:67e97c846cec | 231 | //Xpos, Ypos, ImageData(type:bitmap_t), Scale |
nameless129 | 3:67e97c846cec | 232 | lcd.DrawBitmap( BOTTON_PREV_XPOS, BOTTON_PREV_YPOS, (const bitmap_t*)&img_button_prev, 1 ); |
nameless129 | 3:67e97c846cec | 233 | lcd.DrawBitmap( BOTTON_PLAY_XPOS, BOTTON_PLAY_YPOS, (const bitmap_t*)&img_button_play, 1 ); |
nameless129 | 3:67e97c846cec | 234 | lcd.DrawBitmap( BOTTON_STOP_XPOS, BOTTON_STOP_YPOS, (const bitmap_t*)&img_button_stop, 1 ); |
nameless129 | 3:67e97c846cec | 235 | lcd.DrawBitmap( BOTTON_NEXT_XPOS, BOTTON_STOP_YPOS, (const bitmap_t*)&img_button_next, 1 ); |
nameless129 | 8:198b69e78c39 | 236 | |
nameless129 | 6:74271fce2368 | 237 | // lcd.DrawBitmap( BOTTON_VOLUP_XPOS, BOTTON_VOLUP_YPOS, (const bitmap_t*)&img_button_volup, 1 ); |
nameless129 | 6:74271fce2368 | 238 | // lcd.DrawBitmap( BOTTON_VOLDOWN_XPOS, BOTTON_VOLDOWN_YPOS, (const bitmap_t*)&img_button_voldown, 1 ); |
nameless129 | 2:0090839c8276 | 239 | |
nameless129 | 5:a493361aead2 | 240 | //////////////////////////////////////////////////////////// |
nameless129 | 5:a493361aead2 | 241 | /* SDCard GetFileList Section */ |
nameless129 | 5:a493361aead2 | 242 | //////////////////////////////////////////////////////////// |
nameless129 | 5:a493361aead2 | 243 | #define SD_MAX_FILENAME_LENGTH (256) //MAX 256 |
nameless129 | 8:198b69e78c39 | 244 | #define SD_MAX_FILE_COUNT (50) |
nameless129 | 5:a493361aead2 | 245 | |
nameless129 | 5:a493361aead2 | 246 | char SDFileList[SD_MAX_FILE_COUNT][SD_MAX_FILENAME_LENGTH]={0}; |
nameless129 | 5:a493361aead2 | 247 | char SDFileList_short[SD_MAX_FILE_COUNT][SD_MAX_FILENAME_LENGTH]={0}; |
nameless129 | 5:a493361aead2 | 248 | char SDFileList_cnt = 0; |
nameless129 | 5:a493361aead2 | 249 | char mp3PlayingFileName[SD_MAX_FILENAME_LENGTH]={0}; |
nameless129 | 5:a493361aead2 | 250 | uint8_t mp3PlayingFileNo = 0; |
nameless129 | 5:a493361aead2 | 251 | int i = 0; |
nameless129 | 5:a493361aead2 | 252 | DIR *d; |
nameless129 | 5:a493361aead2 | 253 | struct dirent *p; |
nameless129 | 5:a493361aead2 | 254 | |
nameless129 | 5:a493361aead2 | 255 | d = opendir("/sd"); |
nameless129 | 5:a493361aead2 | 256 | if ( d != NULL ) |
nameless129 | 5:a493361aead2 | 257 | { |
nameless129 | 5:a493361aead2 | 258 | while ( (p = readdir(d)) != NULL ) |
nameless129 | 5:a493361aead2 | 259 | { |
nameless129 | 5:a493361aead2 | 260 | char *ret; |
nameless129 | 5:a493361aead2 | 261 | ret = strstr(p->d_name,"System"); //System Vol..フォルダは除外 |
nameless129 | 5:a493361aead2 | 262 | if(ret == 0) |
nameless129 | 5:a493361aead2 | 263 | { |
nameless129 | 5:a493361aead2 | 264 | sprintf((char *)(SDFileList_short[i]+0),"%s",(const char *)p->d_name); |
nameless129 | 5:a493361aead2 | 265 | sprintf((char *)(SDFileList[i]+0),"/sd/%s",(const char *)p->d_name); |
nameless129 | 8:198b69e78c39 | 266 | printf("FileFound:%d,%s\r\n",i,SDFileList[i]); |
nameless129 | 5:a493361aead2 | 267 | i+=1; |
nameless129 | 5:a493361aead2 | 268 | } |
nameless129 | 5:a493361aead2 | 269 | } |
nameless129 | 5:a493361aead2 | 270 | SDFileList_cnt = i; |
nameless129 | 5:a493361aead2 | 271 | } |
nameless129 | 5:a493361aead2 | 272 | closedir(d); |
nameless129 | 5:a493361aead2 | 273 | |
nameless129 | 5:a493361aead2 | 274 | //g_mp3Player_Stateに対して↓ |
nameless129 | 3:67e97c846cec | 275 | #define MP3_STATE_STOPPING (0) |
nameless129 | 3:67e97c846cec | 276 | #define MP3_STATE_STOPREQ (1) |
nameless129 | 3:67e97c846cec | 277 | #define MP3_STATE_PLAYREQ (2) |
nameless129 | 3:67e97c846cec | 278 | #define MP3_STATE_PLAYING (3) |
nameless129 | 3:67e97c846cec | 279 | #define MP3_STATE_NEXTREQ (4) |
nameless129 | 3:67e97c846cec | 280 | #define MP3_STATE_PREVREQ (5) |
nameless129 | 3:67e97c846cec | 281 | #define MP3_STATE_VOLCHANGEREQ (6) |
nameless129 | 5:a493361aead2 | 282 | #define MP3_STATE_REPLAY (7) |
nameless129 | 5:a493361aead2 | 283 | #define MP3_STATE_FILECHANGE (8) |
nameless129 | 8:198b69e78c39 | 284 | #define MP3_STATE_PAUSEREQ (9) |
nameless129 | 8:198b69e78c39 | 285 | #define MP3_STATE_PAUSEING (10) |
nameless129 | 8:198b69e78c39 | 286 | #define MP3_STATE_RESUMEREQ (11) |
nameless129 | 6:74271fce2368 | 287 | |
nameless129 | 6:74271fce2368 | 288 | printf("file count=%d\r\n",SDFileList_cnt); |
nameless129 | 6:74271fce2368 | 289 | mp3PlayingFileNo = 0; |
nameless129 | 6:74271fce2368 | 290 | g_mp3Player_State = MP3_STATE_FILECHANGE; |
nameless129 | 6:74271fce2368 | 291 | f_mp3Playwe_Playing = 0; |
nameless129 | 3:67e97c846cec | 292 | |
nameless129 | 6:74271fce2368 | 293 | while(1) |
nameless129 | 6:74271fce2368 | 294 | { |
nameless129 | 6:74271fce2368 | 295 | |
nameless129 | 6:74271fce2368 | 296 | ////////////////////////////////////////////////////////////// |
nameless129 | 6:74271fce2368 | 297 | /* TouchPanel GetStatas Section */ |
nameless129 | 6:74271fce2368 | 298 | ////////////////////////////////////////////////////////////// |
nameless129 | 6:74271fce2368 | 299 | if(gf_TimerInt == 1) |
nameless129 | 3:67e97c846cec | 300 | { |
nameless129 | 6:74271fce2368 | 301 | XReadPos = getTouchPanelPosX(); |
nameless129 | 6:74271fce2368 | 302 | YReadPos = getTouchPanelPosY(); |
nameless129 | 6:74271fce2368 | 303 | // printf("X:%d Y:%d\r\n",XReadPos,YReadPos); |
nameless129 | 6:74271fce2368 | 304 | switch( detectTouchBotton(XReadPos,YReadPos) ) |
nameless129 | 3:67e97c846cec | 305 | { |
nameless129 | 6:74271fce2368 | 306 | case TOUCHPANEL_BOTTON_TOUCH_PREV: |
nameless129 | 6:74271fce2368 | 307 | if(touchPanel_Touched == 0) |
nameless129 | 6:74271fce2368 | 308 | { |
nameless129 | 6:74271fce2368 | 309 | printf("prev touch\r\n"); |
nameless129 | 6:74271fce2368 | 310 | g_mp3Player_State = MP3_STATE_PREVREQ; |
nameless129 | 6:74271fce2368 | 311 | touchPanel_Touched = 1; |
nameless129 | 6:74271fce2368 | 312 | } |
nameless129 | 6:74271fce2368 | 313 | break; |
nameless129 | 6:74271fce2368 | 314 | case TOUCHPANEL_BOTTON_TOUCH_PLAY: |
nameless129 | 6:74271fce2368 | 315 | if(touchPanel_Touched == 0) |
nameless129 | 6:74271fce2368 | 316 | { |
nameless129 | 6:74271fce2368 | 317 | printf("play touch\r\n"); |
nameless129 | 8:198b69e78c39 | 318 | if( (g_mp3Player_State == MP3_STATE_STOPPING) ) |
nameless129 | 6:74271fce2368 | 319 | { |
nameless129 | 6:74271fce2368 | 320 | g_mp3Player_State = MP3_STATE_PLAYREQ; |
nameless129 | 8:198b69e78c39 | 321 | printf("MP3_STATE_PLAYREQ\r\n"); |
nameless129 | 6:74271fce2368 | 322 | } |
nameless129 | 8:198b69e78c39 | 323 | if( g_mp3Player_State == MP3_STATE_PLAYING ) |
nameless129 | 8:198b69e78c39 | 324 | { |
nameless129 | 8:198b69e78c39 | 325 | g_mp3Player_State = MP3_STATE_PAUSEREQ; |
nameless129 | 8:198b69e78c39 | 326 | printf("MP3_STATE_PAUSEREQ\r\n"); |
nameless129 | 8:198b69e78c39 | 327 | } |
nameless129 | 8:198b69e78c39 | 328 | if( g_mp3Player_State == MP3_STATE_PAUSEING ) |
nameless129 | 8:198b69e78c39 | 329 | { |
nameless129 | 8:198b69e78c39 | 330 | g_mp3Player_State = MP3_STATE_RESUMEREQ; |
nameless129 | 8:198b69e78c39 | 331 | printf("MP3_STATE_RESUMEREQ\r\n"); |
nameless129 | 8:198b69e78c39 | 332 | } |
nameless129 | 8:198b69e78c39 | 333 | |
nameless129 | 6:74271fce2368 | 334 | touchPanel_Touched = 1; |
nameless129 | 6:74271fce2368 | 335 | } |
nameless129 | 6:74271fce2368 | 336 | break; |
nameless129 | 6:74271fce2368 | 337 | case TOUCHPANEL_BOTTON_TOUCH_STOP: |
nameless129 | 6:74271fce2368 | 338 | if(touchPanel_Touched == 0) |
nameless129 | 6:74271fce2368 | 339 | { |
nameless129 | 6:74271fce2368 | 340 | printf("stop touch\r\n"); |
nameless129 | 6:74271fce2368 | 341 | if( (g_mp3Player_State != MP3_STATE_STOPPING) && (g_mp3Player_State != MP3_STATE_STOPREQ) ) |
nameless129 | 6:74271fce2368 | 342 | { |
nameless129 | 6:74271fce2368 | 343 | g_mp3Player_State = MP3_STATE_STOPREQ; |
nameless129 | 6:74271fce2368 | 344 | } |
nameless129 | 6:74271fce2368 | 345 | touchPanel_Touched = 1; |
nameless129 | 6:74271fce2368 | 346 | } |
nameless129 | 6:74271fce2368 | 347 | break; |
nameless129 | 6:74271fce2368 | 348 | case TOUCHPANEL_BOTTON_TOUCH_NEXT: |
nameless129 | 6:74271fce2368 | 349 | if(touchPanel_Touched == 0) |
nameless129 | 6:74271fce2368 | 350 | { |
nameless129 | 6:74271fce2368 | 351 | printf("next touch\r\n"); |
nameless129 | 6:74271fce2368 | 352 | g_mp3Player_State = MP3_STATE_NEXTREQ; |
nameless129 | 6:74271fce2368 | 353 | touchPanel_Touched = 1; |
nameless129 | 6:74271fce2368 | 354 | } |
nameless129 | 6:74271fce2368 | 355 | break; |
nameless129 | 6:74271fce2368 | 356 | case TOUCHPANEL_OTHER_TOUCH: |
nameless129 | 6:74271fce2368 | 357 | printf("otherTouch\r\n"); |
nameless129 | 6:74271fce2368 | 358 | printf("X:%d Y:%d\r\n",XReadPos,YReadPos); |
nameless129 | 6:74271fce2368 | 359 | break; |
nameless129 | 6:74271fce2368 | 360 | case TOUCHPANEL_BOTTON_NOT_TOUCH: |
nameless129 | 6:74271fce2368 | 361 | // printf("notTouch\r\n"); |
nameless129 | 6:74271fce2368 | 362 | touchPanel_Touched = 0; |
nameless129 | 6:74271fce2368 | 363 | break; |
nameless129 | 6:74271fce2368 | 364 | default : |
nameless129 | 6:74271fce2368 | 365 | break; |
nameless129 | 3:67e97c846cec | 366 | } |
nameless129 | 3:67e97c846cec | 367 | } |
nameless129 | 5:a493361aead2 | 368 | |
nameless129 | 3:67e97c846cec | 369 | ////////////////////////////////////////////////////////////// |
nameless129 | 3:67e97c846cec | 370 | /* MP3 Player Control Section */ |
nameless129 | 3:67e97c846cec | 371 | ////////////////////////////////////////////////////////////// |
nameless129 | 5:a493361aead2 | 372 | if(g_mp3Player_State == MP3_STATE_PLAYREQ) |
nameless129 | 3:67e97c846cec | 373 | { |
nameless129 | 5:a493361aead2 | 374 | printf("FileOpen:%s\r\n",mp3PlayingFileName); |
nameless129 | 5:a493361aead2 | 375 | fp = fopen(mp3PlayingFileName, "rb"); |
nameless129 | 3:67e97c846cec | 376 | SDFileOpenFailCnt = 0; |
nameless129 | 3:67e97c846cec | 377 | while(!fp) |
nameless129 | 3:67e97c846cec | 378 | { |
nameless129 | 3:67e97c846cec | 379 | SDFileOpenFailCnt+=1; |
nameless129 | 3:67e97c846cec | 380 | if(SDFileOpenFailCnt >= 3) |
nameless129 | 3:67e97c846cec | 381 | { |
nameless129 | 3:67e97c846cec | 382 | printf("Fail SD init\r\n"); |
nameless129 | 3:67e97c846cec | 383 | printf("System Stop.\r\n"); |
nameless129 | 6:74271fce2368 | 384 | NVIC_SystemReset(); |
nameless129 | 3:67e97c846cec | 385 | } |
nameless129 | 3:67e97c846cec | 386 | printf("Fail file open n=%d\r\n",SDFileOpenFailCnt); |
nameless129 | 3:67e97c846cec | 387 | sd.disk_initialize(); |
nameless129 | 5:a493361aead2 | 388 | fp = fopen(mp3PlayingFileName, "rb"); |
nameless129 | 3:67e97c846cec | 389 | wait(1); |
nameless129 | 3:67e97c846cec | 390 | } |
nameless129 | 3:67e97c846cec | 391 | |
nameless129 | 3:67e97c846cec | 392 | //Get file size |
nameless129 | 3:67e97c846cec | 393 | fseek( fp, 0, SEEK_END ); |
nameless129 | 3:67e97c846cec | 394 | mp3_fileSize = ftell( fp ); |
nameless129 | 3:67e97c846cec | 395 | printf("FileOpen. size=%dbit\r\n",mp3_fileSize); |
nameless129 | 7:fc65d965a569 | 396 | |
nameless129 | 3:67e97c846cec | 397 | //move file pointer to top. |
nameless129 | 3:67e97c846cec | 398 | rewind(fp); |
nameless129 | 7:fc65d965a569 | 399 | clearerr(fp); |
nameless129 | 3:67e97c846cec | 400 | mp3_totalSizeSent = 0; |
nameless129 | 7:fc65d965a569 | 401 | lcd.Print("Playing ",15,145); |
nameless129 | 7:fc65d965a569 | 402 | |
nameless129 | 7:fc65d965a569 | 403 | lcd.DrawRect(135,155,310,165,COLOR_WHITE); |
nameless129 | 7:fc65d965a569 | 404 | lcd.FillRect(136,156,309,164,COLOR_BLUE); |
nameless129 | 8:198b69e78c39 | 405 | dot1_FileSize = mp3_fileSize/175; |
nameless129 | 7:fc65d965a569 | 406 | |
nameless129 | 5:a493361aead2 | 407 | g_mp3Player_State = MP3_STATE_PLAYING; |
nameless129 | 8:198b69e78c39 | 408 | lcd.DrawBitmap( BOTTON_PLAY_XPOS, BOTTON_PLAY_YPOS, (const bitmap_t*)&img_button_pause, 1 ); |
nameless129 | 7:fc65d965a569 | 409 | |
nameless129 | 7:fc65d965a569 | 410 | totalPlay++; |
nameless129 | 7:fc65d965a569 | 411 | printf("PlayCount=%d\r\n",totalPlay); |
nameless129 | 3:67e97c846cec | 412 | } |
nameless129 | 5:a493361aead2 | 413 | if( g_mp3Player_State == MP3_STATE_PLAYING ) |
nameless129 | 3:67e97c846cec | 414 | { |
nameless129 | 7:fc65d965a569 | 415 | |
nameless129 | 3:67e97c846cec | 416 | if(mp3_totalSizeSent>=mp3_fileSize) //play song end |
nameless129 | 3:67e97c846cec | 417 | { |
nameless129 | 6:74271fce2368 | 418 | f_mp3Playwe_Playing = 1; |
nameless129 | 6:74271fce2368 | 419 | g_mp3Player_State = MP3_STATE_NEXTREQ; //next song |
nameless129 | 3:67e97c846cec | 420 | } |
nameless129 | 3:67e97c846cec | 421 | else //transmit from SDCard to VS1033 |
nameless129 | 3:67e97c846cec | 422 | { |
nameless129 | 7:fc65d965a569 | 423 | if( mp3.checkDREQ() == 1 ) |
nameless129 | 7:fc65d965a569 | 424 | { |
nameless129 | 7:fc65d965a569 | 425 | mp3_ReadFileSize = fread(buf, sizeof(uint8_t), SD_READ_BLOCK_SIZE, fp); |
nameless129 | 7:fc65d965a569 | 426 | mp3_totalSizeSent += mp3.sendDataBlock(buf, mp3_ReadFileSize); |
nameless129 | 7:fc65d965a569 | 427 | dot_XPos = mp3_totalSizeSent / dot1_FileSize; |
nameless129 | 7:fc65d965a569 | 428 | if(old_dot_XPos != dot_XPos) |
nameless129 | 7:fc65d965a569 | 429 | { |
nameless129 | 7:fc65d965a569 | 430 | lcd.DrawLine(135+dot_XPos, 156, 135+dot_XPos, 164); //x1:135 y1:155 x2:310 y3:165 |
nameless129 | 7:fc65d965a569 | 431 | } |
nameless129 | 7:fc65d965a569 | 432 | old_dot_XPos = dot_XPos; |
nameless129 | 8:198b69e78c39 | 433 | // printf("SendedSize:%d LinePos:%d\r\n",mp3_totalSizeSent,dot_XPos); |
nameless129 | 7:fc65d965a569 | 434 | // printf(" HDAT0:0x%x HDAT1:0x%x\r\n",mp3.readReg(mp3.SCI_HDAT0),mp3.readReg(mp3.SCI_HDAT1)); |
nameless129 | 7:fc65d965a569 | 435 | |
nameless129 | 7:fc65d965a569 | 436 | } |
nameless129 | 6:74271fce2368 | 437 | |
nameless129 | 3:67e97c846cec | 438 | f_mp3Playwe_Playing = 1; |
nameless129 | 3:67e97c846cec | 439 | } |
nameless129 | 3:67e97c846cec | 440 | } |
nameless129 | 8:198b69e78c39 | 441 | |
nameless129 | 8:198b69e78c39 | 442 | if( g_mp3Player_State == MP3_STATE_PAUSEREQ ) |
nameless129 | 8:198b69e78c39 | 443 | { |
nameless129 | 8:198b69e78c39 | 444 | lcd.DrawBitmap( BOTTON_PLAY_XPOS, BOTTON_PLAY_YPOS, (const bitmap_t*)&img_button_play, 1 ); |
nameless129 | 8:198b69e78c39 | 445 | g_mp3Player_State = MP3_STATE_PAUSEING; |
nameless129 | 8:198b69e78c39 | 446 | } |
nameless129 | 8:198b69e78c39 | 447 | if( g_mp3Player_State == MP3_STATE_PAUSEING ) |
nameless129 | 8:198b69e78c39 | 448 | { |
nameless129 | 8:198b69e78c39 | 449 | } |
nameless129 | 8:198b69e78c39 | 450 | if( g_mp3Player_State == MP3_STATE_RESUMEREQ ) |
nameless129 | 8:198b69e78c39 | 451 | { |
nameless129 | 8:198b69e78c39 | 452 | lcd.DrawBitmap( BOTTON_PLAY_XPOS, BOTTON_PLAY_YPOS, (const bitmap_t*)&img_button_pause, 1 ); |
nameless129 | 8:198b69e78c39 | 453 | g_mp3Player_State = MP3_STATE_PLAYING; |
nameless129 | 8:198b69e78c39 | 454 | } |
nameless129 | 5:a493361aead2 | 455 | if( (g_mp3Player_State == MP3_STATE_STOPREQ) || (g_mp3Player_State == MP3_STATE_REPLAY) ) |
nameless129 | 3:67e97c846cec | 456 | { |
nameless129 | 4:28900cff8f48 | 457 | uint16_t returnCode=0; |
nameless129 | 4:28900cff8f48 | 458 | uint16_t stopFailCnt = 0; |
nameless129 | 4:28900cff8f48 | 459 | do |
nameless129 | 4:28900cff8f48 | 460 | { |
nameless129 | 4:28900cff8f48 | 461 | returnCode = mp3.stop(); |
nameless129 | 4:28900cff8f48 | 462 | printf("STOP\r\nSTOP CODE:%d\r\n",returnCode); |
nameless129 | 8:198b69e78c39 | 463 | printf(" HDAT0:0x%x HDAT1:0x%x\r\n",mp3.readReg(mp3.SCI_HDAT0),mp3.readReg(mp3.SCI_HDAT1)); |
nameless129 | 4:28900cff8f48 | 464 | |
nameless129 | 4:28900cff8f48 | 465 | if(returnCode != 0) |
nameless129 | 4:28900cff8f48 | 466 | { |
nameless129 | 4:28900cff8f48 | 467 | stopFailCnt++; |
nameless129 | 4:28900cff8f48 | 468 | } |
nameless129 | 5:a493361aead2 | 469 | if(stopFailCnt >= 20) |
nameless129 | 4:28900cff8f48 | 470 | { |
nameless129 | 6:74271fce2368 | 471 | printf("ERROR! impossible of stop\r\nVS1033 Reset\r\n"); |
nameless129 | 6:74271fce2368 | 472 | mp3.hardwareReset(); |
nameless129 | 6:74271fce2368 | 473 | mp3.sci_init(); |
nameless129 | 6:74271fce2368 | 474 | mp3.sdi_init(); |
nameless129 | 7:fc65d965a569 | 475 | wait(1); |
nameless129 | 6:74271fce2368 | 476 | stopFailCnt = 0; |
nameless129 | 7:fc65d965a569 | 477 | returnCode = 0; |
nameless129 | 4:28900cff8f48 | 478 | } |
nameless129 | 4:28900cff8f48 | 479 | }while(returnCode != 0); |
nameless129 | 7:fc65d965a569 | 480 | |
nameless129 | 2:0090839c8276 | 481 | fclose(fp); |
nameless129 | 2:0090839c8276 | 482 | fp = NULL; |
nameless129 | 3:67e97c846cec | 483 | f_mp3Playwe_Playing = 0; |
nameless129 | 7:fc65d965a569 | 484 | lcd.Print("STOP ",15,145); |
nameless129 | 7:fc65d965a569 | 485 | |
nameless129 | 5:a493361aead2 | 486 | if(g_mp3Player_State == MP3_STATE_STOPREQ) |
nameless129 | 5:a493361aead2 | 487 | { |
nameless129 | 5:a493361aead2 | 488 | g_mp3Player_State = MP3_STATE_STOPPING; |
nameless129 | 5:a493361aead2 | 489 | } |
nameless129 | 5:a493361aead2 | 490 | if(g_mp3Player_State == MP3_STATE_REPLAY) |
nameless129 | 5:a493361aead2 | 491 | { |
nameless129 | 5:a493361aead2 | 492 | g_mp3Player_State = MP3_STATE_PLAYREQ; |
nameless129 | 5:a493361aead2 | 493 | } |
nameless129 | 2:0090839c8276 | 494 | } |
nameless129 | 5:a493361aead2 | 495 | |
nameless129 | 5:a493361aead2 | 496 | if( g_mp3Player_State == MP3_STATE_STOPPING ) |
nameless129 | 5:a493361aead2 | 497 | { |
nameless129 | 5:a493361aead2 | 498 | f_mp3Playwe_Playing = 0; |
nameless129 | 5:a493361aead2 | 499 | } |
nameless129 | 5:a493361aead2 | 500 | |
nameless129 | 5:a493361aead2 | 501 | if( g_mp3Player_State == MP3_STATE_NEXTREQ ) |
nameless129 | 2:0090839c8276 | 502 | { |
nameless129 | 5:a493361aead2 | 503 | if( mp3PlayingFileNo >= (SDFileList_cnt -1) ) |
nameless129 | 5:a493361aead2 | 504 | { |
nameless129 | 5:a493361aead2 | 505 | mp3PlayingFileNo = 0; |
nameless129 | 5:a493361aead2 | 506 | } |
nameless129 | 5:a493361aead2 | 507 | else |
nameless129 | 5:a493361aead2 | 508 | { |
nameless129 | 5:a493361aead2 | 509 | mp3PlayingFileNo+=1; |
nameless129 | 5:a493361aead2 | 510 | } |
nameless129 | 5:a493361aead2 | 511 | g_mp3Player_State = MP3_STATE_FILECHANGE; |
nameless129 | 3:67e97c846cec | 512 | } |
nameless129 | 3:67e97c846cec | 513 | |
nameless129 | 5:a493361aead2 | 514 | if( g_mp3Player_State == MP3_STATE_PREVREQ ) |
nameless129 | 5:a493361aead2 | 515 | { |
nameless129 | 5:a493361aead2 | 516 | if( mp3PlayingFileNo <= 0 ) |
nameless129 | 5:a493361aead2 | 517 | { |
nameless129 | 5:a493361aead2 | 518 | mp3PlayingFileNo = (SDFileList_cnt - 1); |
nameless129 | 5:a493361aead2 | 519 | } |
nameless129 | 5:a493361aead2 | 520 | else |
nameless129 | 5:a493361aead2 | 521 | { |
nameless129 | 5:a493361aead2 | 522 | mp3PlayingFileNo-=1; |
nameless129 | 5:a493361aead2 | 523 | } |
nameless129 | 5:a493361aead2 | 524 | g_mp3Player_State = MP3_STATE_FILECHANGE; |
nameless129 | 5:a493361aead2 | 525 | } |
nameless129 | 5:a493361aead2 | 526 | if( g_mp3Player_State == MP3_STATE_FILECHANGE ) |
nameless129 | 3:67e97c846cec | 527 | { |
nameless129 | 5:a493361aead2 | 528 | printf("next:%d,%s\r\n",mp3PlayingFileNo,SDFileList[mp3PlayingFileNo]); |
nameless129 | 8:198b69e78c39 | 529 | |
nameless129 | 8:198b69e78c39 | 530 | lcd_FileViewPage = mp3PlayingFileNo/5; |
nameless129 | 8:198b69e78c39 | 531 | if(old_lcd_FileViewPage != lcd_FileViewPage) |
nameless129 | 8:198b69e78c39 | 532 | { |
nameless129 | 8:198b69e78c39 | 533 | lcd.FillRect(0,0,320,140,COLOR_BLUE); |
nameless129 | 8:198b69e78c39 | 534 | } |
nameless129 | 8:198b69e78c39 | 535 | old_lcd_FileViewPage = lcd_FileViewPage; |
nameless129 | 8:198b69e78c39 | 536 | |
nameless129 | 8:198b69e78c39 | 537 | if(SDFileList_cnt >= 5) |
nameless129 | 6:74271fce2368 | 538 | { |
nameless129 | 8:198b69e78c39 | 539 | if( (SDFileList_cnt-(5*lcd_FileViewPage)) >= 5 ) |
nameless129 | 8:198b69e78c39 | 540 | { |
nameless129 | 8:198b69e78c39 | 541 | lcd_FileViewListEnd = (5*lcd_FileViewPage+5); |
nameless129 | 8:198b69e78c39 | 542 | |
nameless129 | 8:198b69e78c39 | 543 | } |
nameless129 | 8:198b69e78c39 | 544 | else |
nameless129 | 8:198b69e78c39 | 545 | { |
nameless129 | 8:198b69e78c39 | 546 | lcd_FileViewListEnd = (5*lcd_FileViewPage+ ((SDFileList_cnt-(5*lcd_FileViewPage))%5) ); |
nameless129 | 8:198b69e78c39 | 547 | } |
nameless129 | 8:198b69e78c39 | 548 | printf("FilePage:%d max:%d\r\n",lcd_FileViewPage, lcd_FileViewListEnd); |
nameless129 | 8:198b69e78c39 | 549 | |
nameless129 | 8:198b69e78c39 | 550 | for(i=(5*lcd_FileViewPage); i<lcd_FileViewListEnd; i++) |
nameless129 | 8:198b69e78c39 | 551 | { |
nameless129 | 8:198b69e78c39 | 552 | sprintf(str,"%d:%s",i,SDFileList_short[i]); |
nameless129 | 8:198b69e78c39 | 553 | lcd.Print( str, LEFT, (i%5)*28 ); // align text to center horizontally and use starndard colors |
nameless129 | 8:198b69e78c39 | 554 | } |
nameless129 | 6:74271fce2368 | 555 | } |
nameless129 | 8:198b69e78c39 | 556 | else |
nameless129 | 8:198b69e78c39 | 557 | { |
nameless129 | 8:198b69e78c39 | 558 | for(i=0;i<SDFileList_cnt;i++) |
nameless129 | 8:198b69e78c39 | 559 | { |
nameless129 | 8:198b69e78c39 | 560 | sprintf(str,"%d:%s",i,SDFileList_short[i]); |
nameless129 | 8:198b69e78c39 | 561 | lcd.Print( str, LEFT, i*28 ); // align text to center horizontally and use starndard colors |
nameless129 | 8:198b69e78c39 | 562 | } |
nameless129 | 8:198b69e78c39 | 563 | } |
nameless129 | 8:198b69e78c39 | 564 | if(mp3PlayingFileNo >= 10) |
nameless129 | 8:198b69e78c39 | 565 | { |
nameless129 | 8:198b69e78c39 | 566 | lcd.Print( "**", LEFT, 28*(mp3PlayingFileNo%5) ); // align text to center horizontally and use starndard colors |
nameless129 | 8:198b69e78c39 | 567 | } |
nameless129 | 8:198b69e78c39 | 568 | else |
nameless129 | 8:198b69e78c39 | 569 | { |
nameless129 | 8:198b69e78c39 | 570 | lcd.Print( "*", LEFT, 28*(mp3PlayingFileNo%5) ); // align text to center horizontally and use starndard colors |
nameless129 | 8:198b69e78c39 | 571 | } |
nameless129 | 6:74271fce2368 | 572 | |
nameless129 | 5:a493361aead2 | 573 | sprintf(mp3PlayingFileName,"%s",SDFileList[mp3PlayingFileNo]); |
nameless129 | 5:a493361aead2 | 574 | if(f_mp3Playwe_Playing == 1) |
nameless129 | 5:a493361aead2 | 575 | { |
nameless129 | 5:a493361aead2 | 576 | g_mp3Player_State = MP3_STATE_REPLAY; |
nameless129 | 5:a493361aead2 | 577 | } |
nameless129 | 5:a493361aead2 | 578 | else |
nameless129 | 5:a493361aead2 | 579 | { |
nameless129 | 5:a493361aead2 | 580 | g_mp3Player_State = MP3_STATE_STOPPING; |
nameless129 | 5:a493361aead2 | 581 | } |
nameless129 | 5:a493361aead2 | 582 | } |
nameless129 | 2:0090839c8276 | 583 | } |
nameless129 | 0:5f0e931ae677 | 584 | } |