1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
32
33
36
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
178
179
190
191
196
197
198
199
200
201
202
203
204
205
216
227
228
229
234
235
236
237
238
239
240
241
242
246
250
251
252
257
258
259
260
261
262
263
264
265
269
273
274
275
280
281
282
283
284
285
286
287
288
292
296
297
298
303
310
311
316
323
324
329
336
337
342
343
344
345
346
347
348
349
350
351
352
363
374
375
376
381
382
383
384
385
386
387
388
389
393
397
398
399
404
405
406
407
408
409
410
411
415
419
420
421
426
427
428
429
430
431
432
433
437
441
442
443
448
449
450
451
452
453
454
455
459
463
464
469
470
471
472
473
474
478
482
483
484
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
530
541
542
547
558
559
564
575
576
581
592
593
598
609
610
615
626
627
632
643
644
649
660
661
662
679
680
685
696
697
702
713
714
719
730
735
746
747
748
753
764
765
770
781
786
787
788
789
790
791
792
793
794
795
796
797
798
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
843
844
845
846
847
848
852
853
854
863
865
866
867
868
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
896
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
978
979
985
986
987
988
993
994
995
996
997
998
999
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1158
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1294
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1315
1324
1332
1340
1348
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1399
1400
1401
1402
1403
1404
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1463
1464
1465
1466
1467
1468
1469
1470
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1699
1700
1701
1702
1703
1704
1705
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1990
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2039
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2079
2080
2081
2082
2083
2084
2085
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2152
2153
2154
2155
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2199
2200
2201
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2231
2232
2233
2239
2240
2241
2242
2243
2244
2245
2249
2260
2261
2262
2265
2266
/* ... */
#include "main.h"
#include "audio_player_app.h"
#include "audio_player_res.c"
/* ... */
/* ... */
Includes
static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos);
static void FILEMGR_GetFileOnly (char *file, char *path);Private function prototypes
K_ModuleItem_Typedef audio_player_board =
{
1,
"audio player",
open_audio,
0,
Startup,
NULL,
...};
typedef union
{
uint32_t d32;
struct
{
uint32_t repeat : 2;
uint32_t pause : 1;
uint32_t play : 1;
uint32_t stop : 1;
uint32_t mute : 1;
uint32_t volume : 8;
uint32_t reserved : 18;
...}b;
...}
AudioSettingsTypeDef;Private typedef
#define REPEAT_NONE 0
#define REPEAT_ONCE 1
#define REPEAT_ALL 2
#define PLAY_INACTIVE 0x00
#define PLAY_ACTIVE 0x01
#define PAUSE_INACTIVE 0x00
#define PAUSE_ACTIVE 0x01
#define STOP_INACTIVE 0x00
#define STOP_ACTIVE 0x01
#define ID_PROCESS_TIMER 1
#define ID_PLAYLIST_TIMER 2
#define ID_FRAMEWIN_INFO (GUI_ID_USER + 0x01)
#define ID_WAVFILE_LIST (GUI_ID_USER + 0x10)
#define ID_MUTE_BUTTON (GUI_ID_USER + 0x20)
#define ID_PREVIOUS_BUTTON (GUI_ID_USER + 0x21)
#define ID_PLAY_BUTTON (GUI_ID_USER + 0x22)
#define ID_NEXT_BUTTON (GUI_ID_USER + 0x23)
#define ID_STOP_BUTTON (GUI_ID_USER + 0x24)
#define ID_PAUSE_BUTTON (GUI_ID_USER + 0x25)
#define ID_WAV_BUTTON (GUI_ID_USER + 0x26)
#define ID_PLAY_LIST_BUTTON (GUI_ID_USER + 0x27)
#define ID_ADD_BUTTON (GUI_ID_USER + 0x28)
#define ID_EQUAL_BUTTON (GUI_ID_USER + 0x29)
#define ID_EXIT_BUTTON (GUI_ID_USER + 0x2A)
#define ID_REPEAT_ALL_BUTTON (GUI_ID_USER + 0x2B)
#define ID_REPEAT_ONE_BUTTON (GUI_ID_USER + 0x2C)
#define ID_REPEAT_OFF_BUTTON (GUI_ID_USER + 0x2D)
#define ID_EXIT_EQUAL_BUTTON (GUI_ID_USER + 0x2E)
#define ID_BACKGROUND_BUTTON (GUI_ID_USER + 0x2F)
#define ID_TITLE (GUI_ID_USER + 0x40)
#define ID_ELAPSED_TIME (GUI_ID_USER + 0x41)
#define ID_TOTAL_TIME (GUI_ID_USER + 0x42)
#define ID_TEXT_ADD (GUI_ID_USER + 0x50)
#define ID_TEXT_FILE (GUI_ID_USER + 0x51)
#define ID_TEXT_OPEN (GUI_ID_USER + 0x52)
#define ID_TEXT_FOLDER (GUI_ID_USER + 0x53)
#define ID_TEXT_BACK (GUI_ID_USER + 0x54)
#define ID_TEXT_GROUND (GUI_ID_USER + 0x55)
#define ID_TEXT_WARNING (GUI_ID_USER + 0x56)
#define ID_SLIDER_VOLUME (GUI_ID_USER + 0x57)
#define ID_SLIDER_DURATION (GUI_ID_USER + 0x58)
#define ID_EQUABAR_1 (GUI_ID_USER + 0x70)
#define ID_EQUABAR_2 (GUI_ID_USER + 0x78)
#define ID_EQUABAR_3 (GUI_ID_USER + 0x79)
#define ID_EQUABAR_4 (GUI_ID_USER + 0x7A)
#define ID_EQUABAR_5 (GUI_ID_USER + 0x7B)
#define ID_EQUABAR_6 (GUI_ID_USER + 0x7C)
#define ID_LOUDBAR_1 (GUI_ID_USER + 0x7D)
#define ID_EQUABAR_TEXT_1 (GUI_ID_USER + 0x60)
#define ID_EQUABAR_TEXT_2 (GUI_ID_USER + 0x61)
#define ID_EQUABAR_TEXT_3 (GUI_ID_USER + 0x62)
#define ID_EQUABAR_TEXT_4 (GUI_ID_USER + 0x63)
#define ID_EQUABAR_TEXT_5 (GUI_ID_USER + 0x64)
#define ID_EQUABAR_TEXT_6 (GUI_ID_USER + 0x65)
54 defines
Private defines
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ WINDOW_CreateIndirect, "Audio Player", ID_FRAMEWIN_INFO, 1, 0, 800, 480, 0, 0x0, 0 },
{ LISTVIEW_CreateIndirect, "Listview", ID_WAVFILE_LIST, 300, 80, 380, 260, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Title", ID_TITLE, 300, 20, 400, 40, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "00:00", ID_ELAPSED_TIME, 660, 370, 135, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "add", ID_TEXT_ADD, 110, 315, 133, 40, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "file", ID_TEXT_FILE, 110, 335, 129, 40, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "add", ID_TEXT_OPEN, 20, 315, 145, 130, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "folder", ID_TEXT_FOLDER, 20, 335, 150, 130, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "back-", ID_TEXT_BACK, 210, 315, 80, 30, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "ground", ID_TEXT_GROUND, 210, 335, 80, 30, 0, 0x0, 0 },
...};
static WM_HWIN hMainWin;
static WM_HTIMER hProcessTimer;
static WM_HTIMER hPlaylistTimer;
static WM_HWIN hTimerWin;
static WM_HWIN hEquWin = 0;
static WAV_InfoTypedef WavInfo;
static FILELIST_FileTypeDef WavList;
static CHOOSEFILE_INFO FileInfo;
static char const *apDrives[1] = {"0:"};
static const char acMask_audio[] = ".audio";
static const char acMask_dir[] = ".dir";
static uint16_t Audio_FilePos = 0;
static AudioSettingsTypeDef PlayerSettings;
static uint8_t playlist_select = 0;
extern ICONVIEW_Handle hIcon ; Private variables
/* ... */
static int GUI_WaitForDialogExec (WM_HWIN hDialog) {
WM_DIALOG_STATUS DialogStatus = {0};
GUI_SetDialogStatusPtr(hDialog, &DialogStatus);
while (!DialogStatus.Done) {
if (!GUI_Exec()) {
GUI_Delay(100);
}if (!GUI_Exec()) { ... }
}while (!DialogStatus.Done) { ... }
return DialogStatus.ReturnValue;
}{ ... }
/* ... */
static void _OnPaint_play(BUTTON_Handle hObj, uint32_t play_status) {
int Index = 0;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
if(PlayerSettings.b.play == PLAY_INACTIVE)
{
GUI_DrawBitmap(&audio_bmplay_pressed, 0, 0);
}if (PlayerSettings.b.play == PLAY_INACTIVE) { ... }
else
{
GUI_DrawBitmap(&audio_bmplay, 0, 0);
}else { ... }
}if (Index) { ... }
else
{
if(PlayerSettings.b.play == PLAY_ACTIVE)
{
GUI_DrawBitmap(&audio_bmplay_pressed, 0, 0);
}if (PlayerSettings.b.play == PLAY_ACTIVE) { ... }
else
{
GUI_DrawBitmap(&audio_bmplay, 0, 0);
}else { ... }
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_stop(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&audio_bmstop_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&audio_bmstop, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_previous(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&audio_bmbackward_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&audio_bmbackward, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_next(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&audio_bmforeward_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&audio_bmforeward, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_add(BUTTON_Handle hObj) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
GUI_DrawBitmap(&bmopen, 0, 0);
}{ ... }
/* ... */
static void _OnPaint_background(BUTTON_Handle hObj) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
GUI_DrawBitmap(&bmbackground, 0, 0);
}{ ... }
/* ... */
static void _OnPaint_open(BUTTON_Handle hObj) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
GUI_DrawBitmap(&bmadd, 0, 0);
}{ ... }
/* ... */
static void _OnPaint_pause(BUTTON_Handle hObj, uint32_t play_status) {
int Index = 0;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
if(PlayerSettings.b.pause == PAUSE_INACTIVE)
{
GUI_DrawBitmap(&audio_bmpause_pressed, 0, 0);
}if (PlayerSettings.b.pause == PAUSE_INACTIVE) { ... }
else
{
GUI_DrawBitmap(&audio_bmpause, 0, 0);
}else { ... }
}if (Index) { ... }
else
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
GUI_DrawBitmap(&audio_bmpause_pressed, 0, 0);
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
else
{
GUI_DrawBitmap(&audio_bmpause, 0, 0);
}else { ... }
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_equal(BUTTON_Handle hObj) {
int Index;
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
Index = (WIDGET_GetState(hObj) & BUTTON_STATE_PRESSED) ? 1 : 0;
if(Index)
{
GUI_DrawBitmap(&audio_bmequal_pressed, 0, 0);
}if (Index) { ... }
else
{
GUI_DrawBitmap(&audio_bmequal, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_repeat_one(BUTTON_Handle hObj, uint32_t repeat_status) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
GUI_DrawBitmap(&audio_bmrepeat_one, 0, 0);
if(PlayerSettings.b.repeat == REPEAT_ONCE)
{
GUI_DrawBitmap(&audio_bmrepeat_one_pressed, 0, 0);
}if (PlayerSettings.b.repeat == REPEAT_ONCE) { ... }
else
{
GUI_DrawBitmap(&audio_bmrepeat_one, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_repeat_all(BUTTON_Handle hObj, uint32_t repeat_status) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
GUI_DrawBitmap(&audio_bmrepeat_all, 0, 0);
if(PlayerSettings.b.repeat == REPEAT_ALL)
{
GUI_DrawBitmap(&audio_bmrepeat_all_pressed, 0, 0);
}if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
else
{
GUI_DrawBitmap(&audio_bmrepeat_all, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_repeat_off(BUTTON_Handle hObj, uint32_t repeat_status) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
GUI_DrawBitmap(&audio_bmrepeat_off_pressed, 0, 0);
if(PlayerSettings.b.repeat == REPEAT_NONE)
{
GUI_DrawBitmap(&audio_bmrepeat_off_pressed, 0, 0);
}if (PlayerSettings.b.repeat == REPEAT_NONE) { ... }
else
{
GUI_DrawBitmap(&audio_bmrepeat_off, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_speaker(BUTTON_Handle hObj, uint32_t speaker_status) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
if(PlayerSettings.b.mute == MUTE_OFF)
{
GUI_DrawBitmap(&audio_bmspeaker, 0, 0);
}if (PlayerSettings.b.mute == MUTE_OFF) { ... }
else
{
GUI_DrawBitmap(&audio_bmspeaker1, 0, 0);
}else { ... }
}{ ... }
/* ... */
static void _OnPaint_close(BUTTON_Handle hObj) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillCircle(100, 0, 100);
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_FontLubalGraph32);
GUI_DispStringAt("Menu", 20, 20);
}{ ... }
#if defined(AUDIO_USE_SPIRIT_EQUALIZER)
/* ... */
static void _OnPaint_close_equal(BUTTON_Handle hObj) {
GUI_SetBkColor(FRAMEWIN_GetDefaultClientColor());
GUI_Clear();
GUI_SetColor(GUI_STCOLOR_LIGHTBLUE);
GUI_AA_FillCircle(100, 0, 100);
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_FontLubalGraph32);
GUI_DispStringAt("Back", 20, 20);
}_OnPaint_close_equal (BUTTON_Handle hObj) { ... }
/* ... */#endif
/* ... */
static void _cbButton_play(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_play(pMsg->hWin, PlayerSettings.b.pause);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_stop(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_stop(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_next(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_next(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_previous(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_previous(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_add(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_add(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_background(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_background(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_open(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_open(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_close(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_close(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
#if defined(AUDIO_USE_SPIRIT_EQUALIZER)
/* ... */
static void _cbButton_close_equal(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_close_equal(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}_cbButton_close_equal (WM_MESSAGE * pMsg) { ... }
/* ... */#endif
/* ... */
static void _cbButton_repeat_one(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_repeat_one(pMsg->hWin, PlayerSettings.b.repeat);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_repeat_all(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_repeat_all(pMsg->hWin, PlayerSettings.b.repeat);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_repeat_off(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_repeat_off(pMsg->hWin, PlayerSettings.b.repeat);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_speaker(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_speaker(pMsg->hWin, PlayerSettings.b.mute);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_pause(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_pause(pMsg->hWin, PlayerSettings.b.pause);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbButton_equal(WM_MESSAGE * pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
_OnPaint_equal(pMsg->hWin);
break;case WM_PAINT:
default:
BUTTON_Callback(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbAudioProcess(WM_MESSAGE * pMsg) {
uint32_t Id;
WM_HWIN hItem;
char tmp[12] = "00:00";
long progress;
uint32_t duration;
switch (pMsg->MsgId)
{
case WM_CREATE:
hProcessTimer = WM_CreateTimer(pMsg->hWin, ID_PROCESS_TIMER, 1000, 0);
break;
case WM_CREATE:
case WM_TIMER:
Id = WM_GetTimerId(pMsg->Data.v);
if(Id == ID_PROCESS_TIMER)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
progress = AUDIOPLAYER_GetProgress();
duration = progress / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
hItem = WM_GetDialogItem(hMainWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, tmp);
hItem = WM_GetDialogItem(hMainWin, ID_SLIDER_DURATION);
progress = (long)(progress/(WavInfo.FileSize/100));
SLIDER_SetValue(hItem, progress);
WM_Update(hItem);
if(hEquWin)
{
hItem = WM_GetDialogItem(hEquWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, tmp);
hItem = WM_GetDialogItem(hEquWin, ID_SLIDER_DURATION);
SLIDER_SetValue(hItem, progress);
WM_Update(hItem);
}if (hEquWin) { ... }
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_EOF)
{
hItem = WM_GetDialogItem(hMainWin, ID_SLIDER_DURATION);
SLIDER_SetValue(hItem, 100);
WM_Update(hItem);
}else if (AUDIOPLAYER_GetState() == AUDIOPLAYER_EOF) { ... }
AUDIOPLAYER_Process();
WM_RestartTimer(pMsg->Data.v, 1000);
}if (Id == ID_PROCESS_TIMER) { ... }
else if (Id == ID_PLAYLIST_TIMER)
{
playlist_select = 0;
}else if (Id == ID_PLAYLIST_TIMER) { ... }
break;
case WM_TIMER:
case WM_DELETE:
WM_DeleteTimer(hProcessTimer);
if(hPlaylistTimer)
{
WM_DeleteTimer(hPlaylistTimer);
hPlaylistTimer = 0;
}if (hPlaylistTimer) { ... }
break;
case WM_DELETE:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _AddEntireFolder(char *Foldername, int update)
{
FRESULT res;
uint32_t duration;
FILINFO fno;
DIR dir;
char *fn;
static char tmp[FILEMGR_FILE_NAME_SIZE];
WM_HWIN hItem;
res = f_opendir(&dir, Foldername);
if (res == FR_OK)
{
while (1)
{
res = f_readdir(&dir, &fno);
if (res != FR_OK || fno.fname[0] == 0)
{
break;
}if (res != FR_OK || fno.fname[0] == 0) { ... }
if (fno.fname[0] == '.')
{
continue;
}if (fno.fname[0] == '.') { ... }
fn = fno.fname;
if (WavList.ptr < FILEMGR_LIST_DEPDTH)
{
if ((fno.fattrib & AM_DIR) == 0)
{
if(((strstr(fn, ".wav")) || (strstr(fn, ".WAV"))))
{
strcpy(tmp, Foldername);
strcat(tmp, "/");
strcat(tmp, fn);
strncpy((char *)WavList.file[WavList.ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE);
if((update == 1) && (hMainWin != 0))
{
if(AUDIOPLAYER_GetFileInfo(tmp, &WavInfo) == 0)
{
hItem = WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST);
LISTVIEW_AddRow(hItem, NULL);
FILEMGR_GetFileOnly (tmp, fn);
LISTVIEW_SetItemText(hItem, 0, WavList.ptr, fn);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, WavList.ptr, tmp);
LISTVIEW_SetItemTextColor(hItem, 1, WavList.ptr, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
}if (AUDIOPLAYER_GetFileInfo(tmp, &WavInfo) == 0) { ... }
}if ((update == 1) && (hMainWin != 0)) { ... }
WavList.ptr++;
}if (((strstr(fn, ".wav")) || (strstr(fn, ".WAV")))) { ... }
}if ((fno.fattrib & AM_DIR) == 0) { ... }
}if (WavList.ptr < FILEMGR_LIST_DEPDTH) { ... }
}while (1) { ... }
}if (res == FR_OK) { ... }
f_closedir(&dir);
}{ ... }
/* ... */
static void _PlayFile(char *filename)
{
uint32_t duration;
static char tmp[FILEMGR_FILE_NAME_SIZE];
WM_HWIN hItem;
if(haudio.out.state == AUDIOPLAYER_STOP)
{
if(AUDIOPLAYER_GetFileInfo(filename, &WavInfo) == 0)
{
FILEMGR_GetFileOnly (tmp, filename);
TEXT_SetText(WM_GetDialogItem(hMainWin, ID_TITLE), tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
hItem = WM_GetDialogItem(hMainWin, ID_TOTAL_TIME);
TEXT_SetText(hItem, tmp);
if(AUDIOPLAYER_SelectFile(filename) == 0)
{
AUDIOPLAYER_Play(WavInfo.SampleRate);
if(PlayerSettings.b.mute == MUTE_ON)
{
AUDIOPLAYER_Mute(MUTE_ON);
}if (PlayerSettings.b.mute == MUTE_ON) { ... }
}if (AUDIOPLAYER_SelectFile(filename) == 0) { ... }
}if (AUDIOPLAYER_GetFileInfo(filename, &WavInfo) == 0) { ... }
else
{
TEXT_SetText(WM_GetDialogItem(hMainWin, ID_TITLE), "Unknown");
hItem = WM_GetDialogItem(hMainWin, ID_TOTAL_TIME);
TEXT_SetText(hItem, "--:--");
}else { ... }
}if (haudio.out.state == AUDIOPLAYER_STOP) { ... }
}{ ... }
/* ... */
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_NotifyEndOfFile(void)
{
WM_HWIN hItem;
AUDIOPLAYER_Stop();
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
if(PlayerSettings.b.repeat != REPEAT_NONE)
{
if (PlayerSettings.b.repeat == REPEAT_ALL)
{
if(Audio_FilePos < (WavList.ptr - 1))
{
Audio_FilePos++;
LISTVIEW_SetSel(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST), Audio_FilePos);
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
}if (Audio_FilePos < (WavList.ptr - 1)) { ... }
else
{
Audio_FilePos = 0;
LISTVIEW_SetSel(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST), Audio_FilePos);
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
}else { ... }
}if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
_PlayFile((char *)WavList.file[Audio_FilePos].name);
}if (PlayerSettings.b.repeat != REPEAT_NONE) { ... }
else
{
PlayerSettings.b.play = PLAY_INACTIVE;
hItem = WM_GetDialogItem(hMainWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}else { ... }
return AUDIOPLAYER_ERROR_NONE;
}{ ... }
/* ... */
static void _cbMediaConnection(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
static WM_HTIMER hStatusTimer;
static uint8_t prev_usb_status = 0;
int ItemNbr;
uint32_t duration;
static char tmp[40];
switch (pMsg->MsgId)
{
case WM_CREATE:
prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
hStatusTimer = WM_CreateTimer(pMsg->hWin, 0, 500, 0);
break;
case WM_CREATE:
case WM_TIMER:
if(prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT))
{
prev_usb_status = k_StorageGetStatus(USB_DISK_UNIT);
if(prev_usb_status == 0)
{
PlayerSettings.b.play = PLAY_INACTIVE;
PlayerSettings.b.pause = PAUSE_INACTIVE;
WavList.ptr = 0;
Audio_FilePos = 0;
AUDIOPLAYER_Stop();
hItem = WM_GetDialogItem(hMainWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(hMainWin, ID_TITLE);
TEXT_SetText(hItem, "No available wav files");
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(hMainWin, ID_SLIDER_DURATION);
SLIDER_SetValue(hItem, 0);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(hMainWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(hMainWin, ID_PAUSE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST);
ItemNbr = LISTVIEW_GetNumRows(hItem);
while(ItemNbr--)
{
LISTVIEW_DeleteRow(hItem, ItemNbr);
}while (ItemNbr--) { ... }
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (prev_usb_status == 0) { ... }
else
{
_AddEntireFolder("0:", 0);
_AddEntireFolder("0:/Audio", 0);
Audio_FilePos = 0;
ItemNbr = 0;
if(WavList.ptr > 0)
{
hItem = WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST);
while(ItemNbr < WavList.ptr)
{
if(AUDIOPLAYER_GetFileInfo((char *)WavList.file[ItemNbr].name, &WavInfo) == 0)
{
LISTVIEW_AddRow(hItem, NULL);
FILEMGR_GetFileOnly (tmp, (char *)WavList.file[ItemNbr].name);
LISTVIEW_SetItemText(hItem, 0,ItemNbr, tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, ItemNbr, tmp);
LISTVIEW_SetItemTextColor(hItem, 1, ItemNbr, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
ItemNbr++;
}if (AUDIOPLAYER_GetFileInfo((char *)WavList.file[ItemNbr].name, &WavInfo) == 0) { ... }
else
{
WavList.ptr = ItemNbr;
break;
}else { ... }
}while (ItemNbr < WavList.ptr) { ... }
LISTVIEW_SetSel(hItem, 0);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(hMainWin, ID_TITLE);
FILEMGR_GetFileOnly (tmp, (char *)WavList.file[0].name);
TEXT_SetText(hItem, tmp);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (WavList.ptr > 0) { ... }
}else { ... }
}if (prev_usb_status != k_StorageGetStatus(USB_DISK_UNIT)) { ... }
WM_RestartTimer(pMsg->Data.v, 500);
break;
case WM_TIMER:
case WM_DELETE:
if(hStatusTimer != 0)
{
WM_DeleteTimer(hStatusTimer);
hStatusTimer = 0;
}if (hStatusTimer != 0) { ... }
break;
case WM_DELETE:
default:
WM_DefaultProc(pMsg);default
}switch (pMsg->MsgId) { ... }
}{ ... }
#if defined(AUDIO_USE_SPIRIT_EQUALIZER)
/* ... */
static void _cbEqualDialog(WM_MESSAGE * pMsg) {
int NCode;
int Id;
WM_HWIN hItem;
char tmp[] = "00:00";
uint32_t volume, progress, duration;
switch (pMsg->MsgId) {
case WM_CREATE:
progress = (long)(AUDIOPLAYER_GetProgress()/(WavInfo.FileSize/100));
hItem = SLIDER_CreateEx(10, 366, 640, 25, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDER_DURATION);
SLIDER_SetFocusColor(hItem, 0x00969696);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, progress);
SLIDER_SetWidth(hItem, 0);
SLIDER_SetSTSkin(hItem);
WM_DisableWindow(hItem);
duration = AUDIOPLAYER_GetProgress() / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
hItem = TEXT_CreateEx(660, 370, 135, 30, pMsg->hWin, WM_CF_SHOW, 0, ID_ELAPSED_TIME, tmp);
TEXT_SetFont(hItem, GUI_FONT_20B_ASCII);
TEXT_SetTextColor(hItem, 0x00969696);
hItem = TEXT_CreateEx(20, 19, 35, 16, pMsg->hWin, WM_CF_SHOW, 0, ID_EQUABAR_TEXT_1, "1 KHz");
TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
hItem = SLIDER_CreateEx(25, 55, 40, 300, pMsg->hWin, WM_CF_SHOW, SLIDER_CF_VERTICAL, ID_EQUABAR_1);
SLIDER_SetFocusColor(hItem, GUI_STCOLOR_LIGHTBLUE);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, 100 - EQUI_DB_TO_PERC(k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU1_BKP)));
SLIDER_SetWidth(hItem, 20);
SLIDER_SetSTSkin(hItem);
hItem = TEXT_CreateEx(120, 19, 35, 16, pMsg->hWin, WM_CF_SHOW, 0, ID_EQUABAR_TEXT_2, "2 KHz");
TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
hItem = SLIDER_CreateEx(125, 55, 40, 300, pMsg->hWin, WM_CF_SHOW, SLIDER_CF_VERTICAL, ID_EQUABAR_2);
SLIDER_SetFocusColor(hItem, GUI_STCOLOR_LIGHTBLUE);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, 100 - EQUI_DB_TO_PERC(k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU2_BKP)));
SLIDER_SetWidth(hItem, 20);
SLIDER_SetSTSkin(hItem);
hItem = TEXT_CreateEx(225, 19, 35, 16, pMsg->hWin, WM_CF_SHOW, 0, ID_EQUABAR_TEXT_3, "5 KHz");
TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
hItem = SLIDER_CreateEx(230, 55, 40, 300, pMsg->hWin, WM_CF_SHOW, SLIDER_CF_VERTICAL, ID_EQUABAR_3);
SLIDER_SetFocusColor(hItem, GUI_STCOLOR_LIGHTBLUE);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, 100 - EQUI_DB_TO_PERC(k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU3_BKP)));
SLIDER_SetWidth(hItem, 20);
SLIDER_SetSTSkin(hItem);
hItem = TEXT_CreateEx(330, 19, 50, 16, pMsg->hWin, WM_CF_SHOW, 0, ID_EQUABAR_TEXT_4, "10 KHz");
TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
hItem = SLIDER_CreateEx(335, 55, 40, 300, pMsg->hWin, WM_CF_SHOW, SLIDER_CF_VERTICAL, ID_EQUABAR_4);
SLIDER_SetFocusColor(hItem, GUI_STCOLOR_LIGHTBLUE);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, 100 - EQUI_DB_TO_PERC(k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU4_BKP)));
SLIDER_SetWidth(hItem, 20);
SLIDER_SetSTSkin(hItem);
hItem = TEXT_CreateEx(435, 19, 50, 16, pMsg->hWin, WM_CF_SHOW, 0, ID_EQUABAR_TEXT_5, "15 KHz");
TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
hItem = SLIDER_CreateEx(440, 55, 40, 300, pMsg->hWin, WM_CF_SHOW, SLIDER_CF_VERTICAL, ID_EQUABAR_5);
SLIDER_SetFocusColor(hItem, GUI_STCOLOR_LIGHTBLUE);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, 100 - EQUI_DB_TO_PERC(k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_EQU5_BKP)));
SLIDER_SetWidth(hItem, 20);
SLIDER_SetSTSkin(hItem);
hItem = TEXT_CreateEx(565, 19, 100, 16, pMsg->hWin, WM_CF_SHOW, 0, ID_EQUABAR_TEXT_6, "Loudness");
TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
hItem = SLIDER_CreateEx(580, 55, 40, 300, pMsg->hWin, WM_CF_SHOW, SLIDER_CF_VERTICAL, ID_LOUDBAR_1);
SLIDER_SetFocusColor(hItem, GUI_STCOLOR_LIGHTBLUE);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, 100 - k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_LOUD_BKP));
SLIDER_SetWidth(hItem, 20);
SLIDER_SetSTSkin(hItem);
hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_EXIT_EQUAL_BUTTON);
WM_SetCallback(hItem, _cbButton_close_equal);
break;
case WM_CREATE:
case WM_PAINT:
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
GUI_DrawBitmap(&audio_bmbackward_des, 10, 405);
GUI_DrawBitmap(&audio_bmpause_des, 75, 405);
GUI_DrawBitmap(&audio_bmplay_des, 150, 405);
GUI_DrawBitmap(&audio_bmstop_des, 215, 405);
GUI_DrawBitmap(&audio_bmforeward_des, 280, 405);
GUI_DrawBitmap(&audio_bmrepeat_all_des, 360, 405);
GUI_DrawBitmap(&audio_bmrepeat_one_des, 430, 405);
GUI_DrawBitmap(&audio_bmrepeat_off_des, 500, 405);
GUI_DrawBitmap(&audio_bmequal_pressed, 590, 405);
GUI_SetColor(0x00969696);
volume = AUDIOPLAYER_GetVolume();
GUI_DrawRect(730, 105, 760, 415);
GUI_FillRect(731, 105 + 314 * (100 - volume)/100, 759, 414);
if(PlayerSettings.b.mute == MUTE_OFF)
{
GUI_DrawBitmap(&audio_bmspeaker_des, 720, 415);
}if (PlayerSettings.b.mute == MUTE_OFF) { ... }
else
{
GUI_DrawBitmap(&audio_bmspeaker_des1, 720, 415);
}else { ... }
break;
case WM_PAINT:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_EQUABAR_1:
if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUABAR_1);
AUDIO_SetEq(0, 100 - SLIDER_GetValue(hItem));
}if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... }
break;
case ID_EQUABAR_1:
case ID_EQUABAR_2:
if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUABAR_2);
AUDIO_SetEq(1, 100 - SLIDER_GetValue(hItem));
}if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... }
break;
case ID_EQUABAR_2:
case ID_EQUABAR_3:
if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUABAR_3);
AUDIO_SetEq(2, 100- SLIDER_GetValue(hItem));
}if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... }
break;
case ID_EQUABAR_3:
case ID_EQUABAR_4:
if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUABAR_4);
AUDIO_SetEq(3, 100- SLIDER_GetValue(hItem));
}if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... }
break;
case ID_EQUABAR_4:
case ID_EQUABAR_5:
if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_EQUABAR_5);
AUDIO_SetEq(4, 100- SLIDER_GetValue(hItem));
}if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... }
break;
case ID_EQUABAR_5:
case ID_LOUDBAR_1:
if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_LOUDBAR_1);
AUDIO_SetLoudnessGain(100- SLIDER_GetValue(hItem));
}if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... }
break;
case ID_LOUDBAR_1:
case ID_EXIT_EQUAL_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
osDelay(100);
hItem = WM_GetDialogItem(pMsg->hWin, ID_LOUDBAR_1);
AUDIO_SetEqParams(100- SLIDER_GetValue(hItem));
GUI_EndDialog(pMsg->hWin, 0);
hEquWin = 0;
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;case ID_EXIT_EQUAL_BUTTON:
}switch (Id) { ... }
break;case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break;default
}switch (pMsg->MsgId) { ... }
}_cbEqualDialog (WM_MESSAGE * pMsg) { ... }
/* ... */#else
#if 0
/* ... */
static void _cbHintEqNotAvailable(WM_MESSAGE * pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(0x00DCA939);
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font20_ASCII);
GUI_DispStringHCenterAt("Audio equalizer feature not supported", 155 , 25);
GUI_DispStringHCenterAt("with this demo version ...", 155 , 55);
GUI_SetFont(GUI_DEFAULT_FONT);
break;
case WM_PAINT:
default:
WM_DefaultProc(pMsg);
break; default
}switch (pMsg->MsgId) { ... }
}_cbHintEqNotAvailable (WM_MESSAGE * pMsg) { ... }
/* ... */#endif /* ... */
#endif
/* ... */
static void _cbMainDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id, ItemNbr, r;
uint32_t duration, index;
static char tmp[40];
static GUI_PID_STATE TS_State = {0, 0, 0, 0};
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
LISTVIEW_AddColumn(hItem, 290, "Track", GUI_TA_VCENTER | GUI_TA_LEFT);
LISTVIEW_AddColumn(hItem, 60, "Duration ", GUI_TA_VCENTER | GUI_TA_RIGHT);
LISTVIEW_SetGridVis(hItem, 0);
LISTVIEW_SetAutoScrollV(hItem, 1);
LISTVIEW_SetHeaderHeight(hItem, 0);
LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_UNSEL, GUI_WHITE);
LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
LISTVIEW_SetFont(hItem, &GUI_FontLubalGraph24B);
LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE);
LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_SEL, GUI_WHITE);
LISTVIEW_SetRowHeight(hItem, 30);
LISTVIEW_SetBkColor(hItem, LISTVIEW_CI_SELFOCUS, GUI_STCOLOR_LIGHTBLUE);
LISTVIEW_SetTextColor(hItem, LISTVIEW_CI_SELFOCUS, GUI_WHITE);
WIDGET_SetEffect(hItem, &WIDGET_Effect_None);
ItemNbr = 0;
if(WavList.ptr > 0)
{
while(ItemNbr < WavList.ptr)
{
if(AUDIOPLAYER_GetFileInfo((char *)WavList.file[ItemNbr].name, &WavInfo) == 0)
{
LISTVIEW_AddRow(hItem, NULL);
FILEMGR_GetFileOnly (tmp, (char *)WavList.file[ItemNbr].name);
LISTVIEW_SetItemText(hItem, 0,ItemNbr, tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, ItemNbr, tmp);
LISTVIEW_SetItemTextColor(hItem, 1, ItemNbr, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
ItemNbr++;
}if (AUDIOPLAYER_GetFileInfo((char *)WavList.file[ItemNbr].name, &WavInfo) == 0) { ... }
else
{
WavList.ptr = ItemNbr;
break;
}else { ... }
}while (ItemNbr < WavList.ptr) { ... }
LISTVIEW_SetSel(hItem, 0);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE);
FILEMGR_GetFileOnly (tmp, (char *)WavList.file[0].name);
TEXT_SetText(hItem, tmp);
}if (WavList.ptr > 0) { ... }
else
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE);
TEXT_SetText(hItem, "No available wav files");
}else { ... }
TEXT_SetFont(hItem, &GUI_FontLubalGraph24B);
TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TITLE);
TEXT_SetFont(hItem, &GUI_FontLubalGraph32B);
TEXT_SetTextColor(hItem,GUI_STCOLOR_DARKBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
TEXT_SetFont(hItem, &GUI_FontLubalGraph20B);
TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TOTAL_TIME);
TEXT_SetText(hItem, "00:00");
TEXT_SetFont(hItem, &GUI_FontLubalGraph20B);
TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_ADD);
TEXT_SetFont(hItem, &GUI_FontLubalGraph20);
TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_FILE);
TEXT_SetFont(hItem, &GUI_FontLubalGraph20);
TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_OPEN);
TEXT_SetFont(hItem, &GUI_FontLubalGraph20);
TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_FOLDER);
TEXT_SetFont(hItem, &GUI_FontLubalGraph20);
TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_BACK);
TEXT_SetFont(hItem, &GUI_FontLubalGraph20);
TEXT_SetTextColor(hItem, GUI_STCOLOR_LIGHTBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_GROUND);
TEXT_SetFont(hItem, &GUI_FontLubalGraph20);
TEXT_SetTextColor(hItem, GUI_STCOLOR_DARKBLUE);
hItem = WM_GetDialogItem(pMsg->hWin, ID_ADD_BUTTON);
BUTTON_SetFont(hItem, &GUI_FontLubalGraph24);
PlayerSettings.b.mute = MUTE_OFF;
PlayerSettings.b.pause = PAUSE_INACTIVE;
PlayerSettings.b.play = PLAY_INACTIVE;
PlayerSettings.b.stop = STOP_INACTIVE;
hItem = BUTTON_CreateEx(10, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_PREVIOUS_BUTTON);
WM_SetCallback(hItem, _cbButton_previous);
hItem = BUTTON_CreateEx(75, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_PAUSE_BUTTON);
WM_SetCallback(hItem, _cbButton_pause);
hItem = BUTTON_CreateEx(150, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_PLAY_BUTTON);
WM_SetCallback(hItem, _cbButton_play);
hItem = BUTTON_CreateEx(215, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_STOP_BUTTON);
WM_SetCallback(hItem, _cbButton_stop);
hItem = BUTTON_CreateEx(280, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_NEXT_BUTTON);
WM_SetCallback(hItem, _cbButton_next);
hItem = BUTTON_CreateEx(360, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_ALL_BUTTON);
WM_SetCallback(hItem, _cbButton_repeat_all);
hItem = BUTTON_CreateEx(430, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_ONE_BUTTON);
WM_SetCallback(hItem, _cbButton_repeat_one);
hItem = BUTTON_CreateEx(500, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_REPEAT_OFF_BUTTON);
WM_SetCallback(hItem, _cbButton_repeat_off);
#if defined(AUDIO_USE_SPIRIT_EQUALIZER)
hItem = BUTTON_CreateEx(590, 405, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_EQUAL_BUTTON);
#else
hItem = BUTTON_CreateEx(590, 405, 60, 60, pMsg->hWin, WM_CF_HIDE, 0, ID_EQUAL_BUTTON);/* ... */
#endif
WM_SetCallback(hItem, _cbButton_equal);
hItem = BUTTON_CreateEx(720, 415, 60, 60, pMsg->hWin, WM_CF_SHOW, 0, ID_MUTE_BUTTON);
WM_SetCallback(hItem, _cbButton_speaker);
hItem = WM_GetClientWindow(pMsg->hWin);
hItem = BUTTON_CreateEx(10, 235, 85, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_WAV_BUTTON);
WM_SetCallback(hItem, _cbButton_add);
hItem = BUTTON_CreateEx(100, 235, 85, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_ADD_BUTTON);
WM_SetCallback(hItem, _cbButton_open);
hItem = BUTTON_CreateEx(202, 232, 85, 80, pMsg->hWin, WM_CF_SHOW, 0, ID_BACKGROUND_BUTTON);
WM_SetCallback(hItem, _cbButton_background);
hItem = BUTTON_CreateEx(700, 0, 100, 100, pMsg->hWin, WM_CF_SHOW, 0, ID_EXIT_BUTTON);
WM_SetCallback(hItem, _cbButton_close);
hTimerWin = WM_CreateWindowAsChild(0,
100,
10,
10,
pMsg->hWin,
WM_CF_SHOW | WM_CF_HASTRANS,
_cbAudioProcess,
0);
WM_CreateWindowAsChild(479, 252, 1, 1, pMsg->hWin, WM_CF_SHOW | WM_CF_HASTRANS, _cbMediaConnection , 0);
hItem = SLIDER_CreateEx(10, 366, 640, 25, pMsg->hWin, WM_CF_SHOW, 0, ID_SLIDER_DURATION);
SLIDER_SetFocusColor(hItem, GUI_STCOLOR_LIGHTBLUE);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, 0);
SLIDER_SetWidth(hItem, 0);
SLIDER_SetSTSkin(hItem);
hItem = SLIDER_CreateEx(729, 104, 33, 313, pMsg->hWin, WM_CF_SHOW, SLIDER_CF_VERTICAL, ID_SLIDER_VOLUME);
SLIDER_SetFocusColor(hItem, GUI_STCOLOR_DARKBLUE);
SLIDER_SetBkColor (hItem, GUI_WHITE);
SLIDER_SetValue(hItem, 100 - PlayerSettings.b.volume);
SLIDER_SetWidth(hItem, 0);
SLIDER_SetSTSkin(hItem);
break;
case WM_INIT_DIALOG:
case WM_PAINT:
GUI_DrawBitmap(&bmaudio_pochette, 7, 7);
break;
case WM_PAINT:
case WM_DELETE:
AUDIOPLAYER_DeInit();
PlayerSettings.b.mute = MUTE_OFF;
PlayerSettings.b.pause = PAUSE_INACTIVE;
PlayerSettings.b.play = PLAY_INACTIVE;
PlayerSettings.b.stop = STOP_INACTIVE;
k_BkupSaveParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP, PlayerSettings.d32);
break;
case WM_DELETE:
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_REPEAT_ALL_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
PlayerSettings.b.repeat = REPEAT_ALL;
hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_ONE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_OFF_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_REPEAT_ALL_BUTTON:
case ID_REPEAT_ONE_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
PlayerSettings.b.repeat = REPEAT_ONCE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_OFF_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_ALL_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_REPEAT_ONE_BUTTON:
case ID_REPEAT_OFF_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
PlayerSettings.b.repeat = REPEAT_NONE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_ALL_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, ID_REPEAT_ONE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_REPEAT_OFF_BUTTON:
case ID_MUTE_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_MUTE_BUTTON);
if(PlayerSettings.b.mute == MUTE_OFF)
{
AUDIOPLAYER_Mute(MUTE_ON);
PlayerSettings.b.mute = MUTE_ON;
}if (PlayerSettings.b.mute == MUTE_OFF) { ... }
else
{
AUDIOPLAYER_Mute(MUTE_OFF);
PlayerSettings.b.mute = MUTE_OFF;
}else { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_MUTE_BUTTON:
case ID_SLIDER_VOLUME:
if(NCode == WM_NOTIFICATION_VALUE_CHANGED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_VOLUME);
AUDIOPLAYER_SetVolume(100 - SLIDER_GetValue(hItem));
PlayerSettings.b.volume = AUDIOPLAYER_GetVolume();
if(PlayerSettings.b.mute == MUTE_ON)
{
AUDIOPLAYER_Mute(MUTE_OFF);
PlayerSettings.b.mute = MUTE_OFF;
}if (PlayerSettings.b.mute == MUTE_ON) { ... }
}if (NCode == WM_NOTIFICATION_VALUE_CHANGED) { ... }
break;
case ID_SLIDER_VOLUME:
case ID_SLIDER_DURATION:
if(NCode == WM_NOTIFICATION_CLICKED)
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
AUDIOPLAYER_SetPosition(SLIDER_GetValue(hItem));
if(PlayerSettings.b.mute == MUTE_ON)
{
AUDIOPLAYER_Mute(MUTE_ON);
}if (PlayerSettings.b.mute == MUTE_ON) { ... }
}if (NCode == WM_NOTIFICATION_CLICKED) { ... }
break;
case ID_SLIDER_DURATION:
case ID_WAVFILE_LIST:
if(NCode == WM_NOTIFICATION_CLICKED)
{
GUI_PID_GetCurrentState(&TS_State);
if((TS_State.y > 80) & (TS_State.y < (80 + 30*(WavList.ptr))))
{
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
index = LISTVIEW_GetSel(hItem);
if(index < WavList.ptr)
{
if(playlist_select == 0)
{
hPlaylistTimer = WM_CreateTimer(hTimerWin, ID_PLAYLIST_TIMER, 500, 0);
playlist_select = (index + 1);
}if (playlist_select == 0) { ... }
else if(playlist_select == (index + 1))
{
WM_DeleteTimer(hPlaylistTimer);
hPlaylistTimer = 0;
playlist_select = 0;
if(index < WavList.ptr)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
AUDIOPLAYER_Stop();
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
PlayerSettings.b.pause = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
Audio_FilePos = index;
_PlayFile((char *)WavList.file[index].name);
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
LISTVIEW_SetItemTextColor(hItem ,0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
PlayerSettings.b.play = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
PlayerSettings.b.pause = PAUSE_INACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PAUSE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (index < WavList.ptr) { ... }
}else if (playlist_select == (index + 1)) { ... }
}if (index < WavList.ptr) { ... }
}if ((TS_State.y > 80) & (TS_State.y < (80 + 30*(WavList.ptr)))) { ... }
}if (NCode == WM_NOTIFICATION_CLICKED) { ... }
break;
case ID_WAVFILE_LIST:
case ID_PLAY_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP)
{
if(WavList.ptr > 0)
{
_PlayFile((char *)WavList.file[Audio_FilePos].name);
PlayerSettings.b.play = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
LISTVIEW_SetSel(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST), Audio_FilePos);
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
}if (WavList.ptr > 0) { ... }
else
{
FileInfo.pfGetData = k_GetData;
FileInfo.pMask = acMask_audio;
hItem = ST_CHOOSEFILE_Create(pMsg->hWin, 120, 40, 550, 350, apDrives, GUI_COUNTOF(apDrives), 0, "Open an audio file", 0, &FileInfo);
WM_MakeModal(hItem);
r = GUI_WaitForDialogExec(hItem);
if (r == 0)
{
if((strstr(FileInfo.pRoot, ".wav")) || (strstr(FileInfo.pRoot, ".WAV")))
{
if(AUDIOPLAYER_GetFileInfo(FileInfo.pRoot, &WavInfo) == 0)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
AUDIOPLAYER_Stop();
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, 0, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
WavList.ptr = 0;
Audio_FilePos = 0;
strcpy((char *)WavList.file[WavList.ptr].name, FileInfo.pRoot);
FILEMGR_GetFileOnly (tmp, FileInfo.pRoot);
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
strcpy((char *)WavList.file[WavList.ptr].name, FileInfo.pRoot);
ItemNbr = LISTVIEW_GetNumRows(hItem);
while(ItemNbr--)
{
LISTVIEW_DeleteRow(hItem, ItemNbr);
}while (ItemNbr--) { ... }
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetItemText(hItem, 0, WavList.ptr, tmp);
TEXT_SetText(WM_GetDialogItem(hMainWin, ID_TITLE), tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, WavList.ptr, tmp);
LISTVIEW_SetItemTextColor(hItem, 1, WavList.ptr, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
WavList.ptr++;
LISTVIEW_SetSel(hItem, 0);
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, 0, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
_PlayFile(FileInfo.pRoot);
PlayerSettings.b.play = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (AUDIOPLAYER_GetFileInfo(FileInfo.pRoot, &WavInfo) == 0) { ... }
}if ((strstr(FileInfo.pRoot, ".wav")) || (strstr(FileInfo.pRoot, ".WAV"))) { ... }
}if (r == 0) { ... }
}else { ... }
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_STOP) { ... }
else if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
PlayerSettings.b.pause = PAUSE_INACTIVE;
PlayerSettings.b.play = PLAY_ACTIVE;
AUDIOPLAYER_Resume();
hItem = WM_GetDialogItem(pMsg->hWin, ID_PAUSE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
}else if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_PLAY_BUTTON:
case ID_PAUSE_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_INACTIVE)
{
PlayerSettings.b.pause = PAUSE_ACTIVE;
PlayerSettings.b.play = PAUSE_INACTIVE;
AUDIOPLAYER_Pause();
hItem = WM_GetDialogItem(pMsg->hWin, ID_PAUSE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (PlayerSettings.b.pause == PAUSE_INACTIVE) { ... }
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_PAUSE_BUTTON:
case ID_EQUAL_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
#if defined(AUDIO_USE_SPIRIT_EQUALIZER)
hEquWin = WM_CreateWindowAsChild(0, 0, 800, 480, pMsg->hWin, WM_CF_SHOW, _cbEqualDialog , 0);
#else
#if 0
WM_HWIN Hint = WM_CreateWindowAsChild(240,
200,
320, 100,
pMsg->hWin,
WM_CF_SHOW ,
_cbHintEqNotAvailable,
0);
WM_Update(Hint);
GUI_Delay(2000);
WM_DeleteWindow(Hint);/* ... */
#endif /* ... */
#endif
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_EQUAL_BUTTON:
case ID_STOP_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
PlayerSettings.b.pause = PAUSE_INACTIVE;
PlayerSettings.b.play = PLAY_INACTIVE;
AUDIOPLAYER_Stop();
hItem = WM_GetDialogItem(pMsg->hWin, ID_ELAPSED_TIME);
TEXT_SetText(hItem, "00:00");
hItem = WM_GetDialogItem(pMsg->hWin, ID_SLIDER_DURATION);
SLIDER_SetValue(hItem, 0);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, ID_PAUSE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
LISTVIEW_SetItemTextColor(hItem, 0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_STOP_BUTTON:
case ID_NEXT_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if( WavList.ptr > 0)
{
if(Audio_FilePos < (WavList.ptr - 1))
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos + 1, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
Audio_FilePos++;
LISTVIEW_SetSel(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST), Audio_FilePos);
}if (Audio_FilePos < (WavList.ptr - 1)) { ... }
else if(PlayerSettings.b.repeat == REPEAT_ALL)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, 0, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
Audio_FilePos = 0;
LISTVIEW_SetSel(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST), Audio_FilePos);
}else if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
PlayerSettings.b.pause = PAUSE_INACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PAUSE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
PlayerSettings.b.play = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
AUDIOPLAYER_Stop();
_PlayFile((char *)WavList.file[Audio_FilePos].name);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (WavList.ptr > 0) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_NEXT_BUTTON:
case ID_PREVIOUS_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
if( WavList.ptr > 0)
{
if(Audio_FilePos > 0)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos - 1, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
Audio_FilePos--;
LISTVIEW_SetSel(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST), Audio_FilePos);
}if (Audio_FilePos > 0) { ... }
else if(PlayerSettings.b.repeat == REPEAT_ALL)
{
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, (WavList.ptr - 1), LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
Audio_FilePos = (WavList.ptr - 1);
LISTVIEW_SetSel(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST), Audio_FilePos);
}else if (PlayerSettings.b.repeat == REPEAT_ALL) { ... }
if(AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY)
{
if(PlayerSettings.b.pause == PAUSE_ACTIVE)
{
PlayerSettings.b.pause = PAUSE_INACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PAUSE_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
PlayerSettings.b.play = PLAY_ACTIVE;
hItem = WM_GetDialogItem(pMsg->hWin, ID_PLAY_BUTTON);
WM_InvalidateWindow(hItem);
WM_Update(hItem);
}if (PlayerSettings.b.pause == PAUSE_ACTIVE) { ... }
AUDIOPLAYER_Stop();
LISTVIEW_SetItemTextColor(WM_GetDialogItem(hMainWin, ID_WAVFILE_LIST),0, Audio_FilePos, LISTVIEW_CI_UNSEL, GUI_STCOLOR_LIGHTBLUE);
_PlayFile((char *)WavList.file[Audio_FilePos].name);
}if (AUDIOPLAYER_GetState() == AUDIOPLAYER_PLAY) { ... }
}if (WavList.ptr > 0) { ... }
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_PREVIOUS_BUTTON:
case ID_WAV_BUTTON:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;case WM_NOTIFICATION_CLICKED:
case WM_NOTIFICATION_RELEASED:
FileInfo.pfGetData = k_GetData;
FileInfo.pMask = acMask_dir;
hItem = ST_CHOOSEFILE_Create(pMsg->hWin, 120, 40, 550, 350, apDrives, GUI_COUNTOF(apDrives), 0, "Add a folder", 0, &FileInfo);
WM_MakeModal(hItem);
r = GUI_WaitForDialogExec(hItem);
if (r == 0)
{
_AddEntireFolder(FileInfo.pRoot, 1);
}if (r == 0) { ... }
break;
case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_WAV_BUTTON:
case ID_ADD_BUTTON:
switch(NCode) {
case WM_NOTIFICATION_RELEASED:
FileInfo.pfGetData = k_GetData;
FileInfo.pMask = acMask_audio;
hItem = ST_CHOOSEFILE_Create(pMsg->hWin, 120, 40, 550, 350, apDrives, GUI_COUNTOF(apDrives), 0, "Add to playlist", 0, &FileInfo);
WM_MakeModal(hItem);
r = GUI_WaitForDialogExec(hItem);
if (r == 0)
{
if((strstr(FileInfo.pRoot, ".wav")) || (strstr(FileInfo.pRoot, ".WAV")))
{
if(WavList.ptr < FILEMGR_LIST_DEPDTH)
{
strcpy((char *)WavList.file[WavList.ptr].name, FileInfo.pRoot);
FILEMGR_GetFileOnly (tmp, FileInfo.pRoot);
hItem = WM_GetDialogItem(pMsg->hWin, ID_WAVFILE_LIST);
if(AUDIOPLAYER_GetFileInfo(FileInfo.pRoot, &WavInfo) == 0)
{
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetItemText(hItem, 0, WavList.ptr, tmp);
duration = WavInfo.FileSize / WavInfo.ByteRate;
sprintf((char *)tmp , "%02lu:%02lu", duration/60, duration%60 );
LISTVIEW_SetItemText(hItem, 1, WavList.ptr, tmp);
LISTVIEW_SetItemTextColor(hItem, 1, WavList.ptr, LISTVIEW_CI_UNSEL, GUI_STCOLOR_DARKBLUE);
WavList.ptr++;
}if (AUDIOPLAYER_GetFileInfo(FileInfo.pRoot, &WavInfo) == 0) { ... }
}if (WavList.ptr < FILEMGR_LIST_DEPDTH) { ... }
}if ((strstr(FileInfo.pRoot, ".wav")) || (strstr(FileInfo.pRoot, ".WAV"))) { ... }
}if (r == 0) { ... }
break;case WM_NOTIFICATION_RELEASED:
}switch (NCode) { ... }
break;
case ID_ADD_BUTTON:
case ID_EXIT_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
GUI_EndDialog(pMsg->hWin, 0);
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break;
case ID_EXIT_BUTTON:
case ID_BACKGROUND_BUTTON:
if(NCode == WM_NOTIFICATION_RELEASED)
{
WM_HideWindow(pMsg->hWin);
module_prop[k_ModuleGetIndex(&audio_player_board)].win_state = 1;
ST_AnimatedIconView_SetItemText(hIcon,k_ModuleGetIndex(&audio_player_board),"audio player[B]");
ST_AnimatedIconView_SetDualTextColor(hIcon, ICONVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE, GUI_STCOLOR_DARKBLUE);
}if (NCode == WM_NOTIFICATION_RELEASED) { ... }
break; case ID_BACKGROUND_BUTTON:
}switch (Id) { ... }
break;
case WM_NOTIFY_PARENT:
default:
WM_DefaultProc(pMsg);
break; default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void _cbHint(WM_MESSAGE * pMsg)
{
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_STCOLOR_LIGHTBLUE);
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font20_ASCII);
GUI_DispStringHCenterAt("Audio Initialization ...", 155 , 25);
GUI_SetFont(GUI_DEFAULT_FONT);
break;
case WM_PAINT:
default:
WM_DefaultProc(pMsg);
break; default
}switch (pMsg->MsgId) { ... }
}{ ... }
/* ... */
static void Startup(WM_HWIN hWin, uint16_t xpos, uint16_t ypos)
{
WM_HWIN Hint;
if(module_prop[k_ModuleGetIndex(&audio_player_board)].win_state == 0)
{
PlayerSettings.d32 = k_BkupRestoreParameter(CALIBRATION_AUDIOPLAYER_SETTING_BKP);
if(WavList.ptr == 0)
{
_AddEntireFolder("0:", 0);
_AddEntireFolder("0:/Audio", 0);
}if (WavList.ptr == 0) { ... }
Audio_FilePos = 0;
if(PlayerSettings.b.volume == 0)
{
PlayerSettings.b.volume = DEFAULT_AUDIO_VOLUME;
}if (PlayerSettings.b.volume == 0) { ... }
Hint = WM_CreateWindowAsChild(250,
200,
300, 80,
hWin,
WM_CF_SHOW ,
_cbHint,
0);
WM_Update(Hint);
AUDIOPLAYER_Init(PlayerSettings.b.volume);
WM_DeleteWindow(Hint);
hMainWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbMainDialog, hWin, xpos, ypos);
}if (module_prop[k_ModuleGetIndex(&audio_player_board)].win_state == 0) { ... }
else
{
WM_ShowWindow(hMainWin);
ST_AnimatedIconView_SetItemText(hIcon,k_ModuleGetIndex(&audio_player_board),"audio player");
ST_AnimatedIconView_SetDualTextColor(hIcon, ICONVIEW_CI_SEL, GUI_STCOLOR_LIGHTBLUE, GUI_STCOLOR_DARKBLUE);
}else { ... }
}{ ... }
/* ... */
static void FILEMGR_GetFileOnly (char *file, char *path)
{
char *baseName1, *baseName2;
baseName1 = strrchr(path,'/');
baseName2 = strrchr(path,':');
if(baseName1++)
{
strcpy(file, baseName1);
}if (baseName1++) { ... }
else
{
if (baseName2++)
{
strcpy(file, baseName2);
}if (baseName2++) { ... }
else
{
strcpy(file, path);
}else { ... }
}else { ... }
}{ ... }
/* ... */
/* ... */