Skip to content

Commit 12ffd3d

Browse files
author
Tonsuke
committed
v1.11
-PCF basic latin font mplus_1c_bold_basic_latin.pcf loaded in Internal Flash -Fat make file list routine improved. nearly up to FAT directory entries files be accessible. -Filer can be able to select items by serial console -Shuffle play function added -CPU Core Temperature added -CPU Frequency Item 225MHz removed
1 parent 00a7581 commit 12ffd3d

34 files changed

+1742
-669
lines changed

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ USB_OTG_DRIVER_PATH = lib/STM32_USB_OTG_Driver
1919

2020

2121
# List C source files here. (C dependencies are automatically generated.)
22-
SRC = main.c stm32f4xx_it.c fat.c sd.c dojpeg.c mpool.c lcd.c icon.c pcf_font.c mjpeg.c aac.c mp3.c sound.c fft.c fx.c xpt2046.c settings.c xmodem.c usart.c usb_bsp.c usbd_desc.c usbd_usr.c usbd_storage_msd.c delay.c \
22+
SRC = main.c stm32f4xx_it.c fat.c sd.c dojpeg.c mpool.c lcd.c icon.c cfile.c pcf_font.c mjpeg.c aac.c mp3.c sound.c fft.c fx.c xpt2046.c settings.c xmodem.c usart.c usb_bsp.c usbd_desc.c usbd_usr.c usbd_storage_msd.c delay.c \
2323
$(JPEG_DIR)/jdapimin.c $(JPEG_DIR)/jerror.c $(JPEG_DIR)/jdatasrc.c $(JPEG_DIR)/wrppm.c $(JPEG_DIR)/jdapistd.c $(JPEG_DIR)/jmemmgr.c \
2424
$(JPEG_DIR)/jdmarker.c $(JPEG_DIR)/jdinput.c $(JPEG_DIR)/jcomapi.c $(JPEG_DIR)/jdmaster.c $(JPEG_DIR)/jmemnobs.c $(JPEG_DIR)/jutils.c \
2525
$(JPEG_DIR)/jquant1.c $(JPEG_DIR)/jquant2.c $(JPEG_DIR)/jddctmgr.c $(JPEG_DIR)/jdarith.c $(JPEG_DIR)/jdcoefct.c $(JPEG_DIR)/jdmainct.c \
@@ -70,7 +70,7 @@ CFLAGS = -g$(DEBUG)
7070
CFLAGS += $(CDEFS) $(CINCS)
7171
CFLAGS += -O$(OPT)
7272
#CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
73-
CFLAGS += -fno-strict-aliasing#-Wall -Wstrict-prototypes
73+
CFLAGS += #-Wimplicit-function-declaration#-fno-strict-aliasing #-Wall -Wstrict-prototypes
7474
#CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
7575
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
7676
CFLAGS += $(CSTANDARD)

aac.c

+39-40
Original file line numberDiff line numberDiff line change
@@ -379,29 +379,31 @@ int PlayAAC(int id)
379379
yTag += 10;
380380
}
381381

382-
if(pcf_font.isOK){
383-
putCharTmp = LCD_FUNC.putChar;
384-
putWideCharTmp = LCD_FUNC.putWideChar;
382+
putCharTmp = LCD_FUNC.putChar;
383+
putWideCharTmp = LCD_FUNC.putWideChar;
385384

385+
if(!pcf_font.c_loaded){
386386
LCD_FUNC.putChar = PCFPutChar16px;
387387
LCD_FUNC.putWideChar = PCFPutChar16px;
388-
disp_limit = 288;
388+
} else {
389+
LCD_FUNC.putChar = C_PCFPutChar16px;
390+
LCD_FUNC.putWideChar = C_PCFPutChar16px;
389391
}
392+
disp_limit = 288;
393+
390394

391395
if(nameTag[0] != 0){
392-
if(pcf_font.isOK){
393-
strLen = LCDGetStringUTF8PixelLength(nameTag, 16);
394-
if((xTag + strLen) < LCD_WIDTH){
395-
disp_limit = LCD_WIDTH - 1;
396-
} else {
397-
disp_limit = LCD_WIDTH - 20;
398-
yTag -= 8;
399-
}
396+
strLen = LCDGetStringUTF8PixelLength(nameTag, 16);
397+
if((xTag + strLen) < LCD_WIDTH){
398+
disp_limit = LCD_WIDTH - 1;
399+
} else {
400+
disp_limit = LCD_WIDTH - 20;
401+
yTag -= 8;
402+
}
400403

401-
strLen = LCDGetStringUTF8PixelLength(albumTag, 12);
402-
if((xTag + strLen) > (LCD_WIDTH - 20)){
403-
yTag -= 6;
404-
}
404+
strLen = LCDGetStringUTF8PixelLength(albumTag, 12);
405+
if((xTag + strLen) > (LCD_WIDTH - 20)){
406+
yTag -= 6;
405407
}
406408
LCDGotoXY(xTag + 1, yTag + 1);
407409
LCDPutStringUTF8(xTag + 1, disp_limit, 2, nameTag, BLACK);
@@ -412,14 +414,12 @@ int PlayAAC(int id)
412414
} else {
413415
uint8_t strNameLFN[80];
414416
if(setLFNname(strNameLFN, id, LFN_WITHOUT_EXTENSION, sizeof(strNameLFN))){
415-
if(pcf_font.isOK){
416-
strLen = LCDGetStringLFNPixelLength(strNameLFN, 16);
417-
if((xTag + strLen) < LCD_WIDTH){
418-
disp_limit = LCD_WIDTH - 1;
419-
} else {
420-
disp_limit = LCD_WIDTH - 20;
421-
yTag -= 10;
422-
}
417+
strLen = LCDGetStringLFNPixelLength(strNameLFN, 16);
418+
if((xTag + strLen) < LCD_WIDTH){
419+
disp_limit = LCD_WIDTH - 1;
420+
} else {
421+
disp_limit = LCD_WIDTH - 20;
422+
yTag -= 10;
423423
}
424424
LCDGotoXY(xTag + 1, yTag + 1);
425425
LCDPutStringLFN(xTag + 1, disp_limit, 2, strNameLFN, BLACK);
@@ -437,11 +437,9 @@ int PlayAAC(int id)
437437
yTag += 20;
438438
}
439439

440-
if(pcf_font.isOK){
441-
LCD_FUNC.putChar = putCharTmp;
442-
LCD_FUNC.putWideChar = putWideCharTmp;
443-
disp_limit = 300;
444-
}
440+
LCD_FUNC.putChar = putCharTmp;
441+
LCD_FUNC.putWideChar = putWideCharTmp;
442+
disp_limit = 300;
445443

446444
if(albumTag[0] != 0){
447445
LCDGotoXY(xTag + 1, yTag + 1);
@@ -462,7 +460,7 @@ int PlayAAC(int id)
462460
LCDPutIcon(0, 155, 320, 80, music_underbar_320x80, music_underbar_320x80_alpha);
463461

464462
char s[20];
465-
sprintf((char*)s, "%d/%d", id, fat.fileCnt - 1);
463+
SPRINTF((char*)s, "%d/%d", id, fat.fileCnt - 1);
466464
LCDGotoXY(21, MUSIC_INFO_POS_Y + 1);
467465
LCDPutString((char*)s, BLACK);
468466
LCDGotoXY(20, MUSIC_INFO_POS_Y);
@@ -480,34 +478,37 @@ int PlayAAC(int id)
480478
LCDPutString(media_info.format.numChannel == 2 ? "Stereo" : "Mono", WHITE);
481479

482480
if(media_info.bitrate.avgBitrate){
483-
sprintf(s, "%dkbps", (int)(media_info.bitrate.avgBitrate / 1000));
481+
SPRINTF(s, "%dkbps", (int)(media_info.bitrate.avgBitrate / 1000));
484482
} else {
485-
sprintf(s, "---kbps");
483+
SPRINTF(s, "---kbps");
486484
}
487485
LCDGotoXY(171, MUSIC_INFO_POS_Y + 1);
488486
LCDPutString(s, BLACK);
489487
LCDGotoXY(170, MUSIC_INFO_POS_Y);
490488
LCDPutString(s, WHITE);
491489

492490

493-
sprintf(s, "%dHz", aacFrameInfo.sampRateCore);
491+
SPRINTF(s, "%dHz", aacFrameInfo.sampRateCore);
494492
LCDGotoXY(241, MUSIC_INFO_POS_Y + 1);
495493
LCDPutString(s, BLACK);
496494
LCDGotoXY(240, MUSIC_INFO_POS_Y);
497495
LCDPutString(s, WHITE);
498496
}
499497

500-
if(pcf_font.isOK){ // Cache Play Time Glyphs
501-
putCharTmp = LCD_FUNC.putChar;
502-
putWideCharTmp = LCD_FUNC.putWideChar;
498+
putCharTmp = LCD_FUNC.putChar;
499+
putWideCharTmp = LCD_FUNC.putWideChar;
503500

501+
if(!pcf_font.c_loaded){
504502
LCD_FUNC.putChar = PCFPutCharCache;
505503
LCD_FUNC.putWideChar = PCFPutCharCache;
506504

507505
extern uint16_t cursorRAM[];
508506

509507
PCFSetGlyphCacheStartAddress((void*)cursorRAM);
510508
PCFCachePlayTimeGlyphs(12);
509+
} else {
510+
LCD_FUNC.putChar = C_PCFPutChar;
511+
LCD_FUNC.putWideChar = C_PCFPutChar;
511512
}
512513

513514
// time elapsed
@@ -940,10 +941,8 @@ int PlayAAC(int id)
940941
/* close files */
941942
my_fclose(infile);
942943

943-
if(pcf_font.isOK){
944-
LCD_FUNC.putChar = putCharTmp;
945-
LCD_FUNC.putWideChar = putWideCharTmp;
946-
}
944+
LCD_FUNC.putChar = putCharTmp;
945+
LCD_FUNC.putWideChar = putWideCharTmp;
947946

948947
TOUCH_PINIRQ_ENABLE;
949948
TouchPenIRQ_Enable();

cfile.c

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* fat.c
3+
*
4+
* Created on: 2011/02/27
5+
* Author: Tonsuke
6+
*/
7+
8+
#include "cfile.h"
9+
#include <stdlib.h>
10+
#include <string.h>
11+
12+
C_FILE* c_fopen(uint32_t fileAddr, size_t fileSize)
13+
{
14+
C_FILE *fp = malloc(sizeof(C_FILE));
15+
16+
fp->c_file_addr = fileAddr;
17+
fp->seekBytes = fileAddr;
18+
fp->fileSize = fileSize;
19+
20+
return fp;
21+
}
22+
23+
void c_fclose(C_FILE *fp)
24+
{
25+
free((void*)fp);
26+
fp = '\0';
27+
}
28+
29+
int c_fseek(C_FILE *fp, int64_t offset, int whence)
30+
{
31+
switch (whence) {
32+
case SEEK_SET:
33+
fp->seekBytes = fp->c_file_addr + offset;
34+
if(offset == 0){
35+
fp->seekBytes = fp->c_file_addr;
36+
return 0;
37+
}
38+
break;
39+
case SEEK_CUR:
40+
fp->seekBytes += offset;
41+
break;
42+
case SEEK_END:
43+
fp->seekBytes = fp->c_file_addr + fp->fileSize + offset - 1;
44+
break;
45+
default:
46+
return 1;
47+
}
48+
49+
if((fp->seekBytes - fp->c_file_addr) >= fp->fileSize){
50+
return 0;
51+
}
52+
53+
return 1;
54+
}
55+
56+
57+
size_t c_fread(void *buf, size_t size, size_t count, C_FILE *fp)
58+
{
59+
size_t n = size * count;
60+
61+
if(n <= 0){
62+
return 0;
63+
}
64+
65+
if(fp->fileSize < ((fp->seekBytes - fp->c_file_addr) + n)){ // 要求サイズがファイルサイズを超えていた場合
66+
n = fp->fileSize - (fp->seekBytes - fp->c_file_addr);
67+
}
68+
69+
memcpy((void*)buf, (void*)fp->seekBytes, n);
70+
71+
fp->seekBytes += n;
72+
73+
return ( size == 1 ? n : (n / size) );
74+
}
75+
76+

cfile.h

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* fat.h
3+
*
4+
* Created on: 2011/02/27
5+
* Author: Tonsuke
6+
*/
7+
8+
#ifndef C_FILE_H_
9+
#define C_FILE_H_
10+
11+
#include "stm32f4xx_conf.h"
12+
#include <stddef.h>
13+
14+
15+
#define SEEK_SET 0
16+
#define SEEK_CUR 1
17+
#define SEEK_END 2
18+
19+
20+
typedef volatile struct C_FILE {
21+
size_t fileSize, \
22+
seekBytes, \
23+
c_file_addr;
24+
} C_FILE;
25+
26+
extern C_FILE* c_fopen(uint32_t fileAddr, size_t fileSize);
27+
extern void c_fclose(C_FILE *fp);
28+
extern int c_fseek(C_FILE *fp, int64_t offset, int whence);
29+
extern size_t c_fread(void *buf, size_t size, size_t count, C_FILE *fp);
30+
31+
32+
33+
34+
#endif /* FAT_H_ */

dojpeg.c

+5
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ int dojpeg(int id, uint8_t djpeg_arrows, uint8_t arrow_clicked)
300300

301301
while(!ret && LCDStatusStruct.waitExitKey){
302302
while(!touch.click){
303+
if(!LCDStatusStruct.waitExitKey){
304+
ret = -1;
305+
goto EXIT_JPEG;
306+
}
303307
if(time.flags.stop_mode){
304308
LCDStatusStruct.waitExitKey = 0;
305309
break;
@@ -513,6 +517,7 @@ int dojpeg(int id, uint8_t djpeg_arrows, uint8_t arrow_clicked)
513517
while(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_4) == Bit_RESET);
514518
touch.click = 0;
515519
}
520+
EXIT_JPEG:
516521
touch.func = LCDTouchPoint;
517522

518523
if(time2sleep_cp){

0 commit comments

Comments
 (0)