Skip to content

Commit 59c03db

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 2b43f88 + 5eabcf8 commit 59c03db

File tree

11 files changed

+1001
-652
lines changed

11 files changed

+1001
-652
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,13 @@ Those files are not provided here. You can use any mp3, with a bitrate of 128kpb
310310

311311
### Installing Custom & Replacement Audio Files
312312

313-
As of version 1.20 of the Dash Gauges firmware, above mentioned audio files (both replacements and custom sounds) can either be copied to the SD card using a computer, or uploaded through the Config Portal.
313+
As of version 1.20 of the Dash Gauges firmware, above mentioned audio files (both replacements and custom sounds) can either be copied to the SD card using a computer (as before), or uploaded through the Config Portal.
314314

315-
Uploading through the Config Portal works exactly like [installing the default audio files](#audio-data-installation); on the main menu, click "UPDATE". Afterwards choose the file to upload in the bottom file selector, and click "UPLOAD". The firmware recognizes mp3 files, and stores them on the SD card. (Unlike with the default files, no further "installation" takes place.)
315+
Uploading through the Config Portal works exactly like [installing the default audio files](#audio-data-installation); on the main menu, click "UPDATE". Afterwards choose one or more mp3 files to upload using the bottom file selector, and click "UPLOAD". The firmware will store the uploaded mp3 files on the SD card.
316316

317317
In order to delete a file from the SD card, upload a file whose name is prefixed with "delete-". For example: To delete "key1.mp3" from the SD card, either rename your "key1.mp3" into "delete-key1.mp3", or create a new file named "delete-key1.mp3", and upload this file. The firmware detects the "delete-" part and, instead of storing the uploaded file, it throws it away and deletes "key1.mp3" from the SD card.
318318

319-
For technical reasons, the Dash Gauges must reboot after a file is uploaded in this way.
319+
For technical reasons, the Dash Gauges must reboot after mp3 files are uploaded in this way.
320320

321321
Please remember that the maximum bitrate for mp3 files is 128kbps. Also note that the uploaded file is stored to the root folder of the SD card, so this way of uploading cannot be used to upload songs for the Music Player.
322322

-992 Bytes
Binary file not shown.

src/dashgauges-A10001986.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@
115115

116116
/* Changelog
117117
*
118+
* 2025/09/19 (A10001986) [1.21]
119+
* - Extend mp3 upload by allowing multiple (max 16) mp3 files to be uploaded
120+
* at once. The DGA.bin file can be uploaded at the same time as well.
121+
* 2025/09/17 (A10001986)
122+
* - WiFi Manager: Reduce page size by removing "quality icon" styles where
123+
* not needed.
118124
* 2025/09/15 (A10001986) [1.20]
119125
* - Refine mp3 upload facility; allow deleting files from SD by prefixing
120126
* filename with "delete-".

src/dg_global.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*** Version Strings ***
1616
*************************************************************************/
1717

18-
#define DG_VERSION "V1.20"
19-
#define DG_VERSION_EXTRA "SEP152025"
18+
#define DG_VERSION "V1.21"
19+
#define DG_VERSION_EXTRA "SEP192025"
2020

2121
//#define DG_DBG // debug output on Serial
2222

src/dg_settings.cpp

Lines changed: 121 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ static const char *CONID = "DGAA";
9898
static uint32_t soa = AC_TS;
9999
static bool ic = false;
100100
static uint8_t* f(uint8_t *d, uint32_t m, int y) { return d; }
101-
static char *uploadFileName = NULL;
101+
static char *uploadFileNames[MAX_SIM_UPLOADS] = { NULL };
102+
static char *uploadRealFileNames[MAX_SIM_UPLOADS] = { NULL };
102103

103104
static const char *cfgName = "/dgconfig.json"; // Main config (flash)
104105
static const char *ipCfgName = "/dgipcfg.json"; // IP config (flash)
@@ -314,6 +315,10 @@ void settings_setup()
314315
allowCPA = check_if_default_audio_present();
315316
}
316317

318+
for(int i = 0; i < MAX_SIM_UPLOADS; i++) {
319+
uploadFileNames[i] = uploadRealFileNames[i] = NULL;
320+
}
321+
317322
// Allow user to delete static IP data by holding time travel
318323
// while booting and switching side switch twice within 10 seconds
319324
if(digitalRead(TT_IN_PIN)) {
@@ -1335,15 +1340,99 @@ static bool writeFileToFS(const char *fn, uint8_t *buf, int len)
13351340
return false;
13361341
}
13371342

1338-
bool openACFile(File& file)
1343+
static char *allocateUploadFileName(const char *fn, int idx)
1344+
{
1345+
char *t = NULL;
1346+
1347+
if(uploadFileNames[idx]) {
1348+
free(uploadFileNames[idx]);
1349+
}
1350+
if(uploadRealFileNames[idx]) {
1351+
free(uploadRealFileNames[idx]);
1352+
}
1353+
uploadFileNames[idx] = uploadRealFileNames[idx] = NULL;
1354+
1355+
if(!strlen(fn))
1356+
return NULL;
1357+
1358+
if(!(uploadFileNames[idx] = (char *)malloc(strlen(fn)+4)))
1359+
return NULL;
1360+
1361+
if(!(uploadRealFileNames[idx] = (char *)malloc(strlen(fn)+4))) {
1362+
free(uploadFileNames[idx]);
1363+
uploadFileNames[idx] = NULL;
1364+
return NULL;
1365+
}
1366+
1367+
return uploadRealFileNames[idx];
1368+
}
1369+
1370+
bool openUploadFile(String& fn, File& file, int idx, bool haveAC, int& opType, int& errNo)
13391371
{
1372+
char *uploadFileName = NULL;
1373+
bool ret = false;
1374+
13401375
if(haveSD) {
1341-
if(file = SD.open(CONFN, FILE_WRITE)) {
1342-
return true;
1376+
1377+
errNo = 0;
1378+
opType = 0; // 0=normal, 1=AC, -1=deletion
1379+
1380+
if(!(uploadFileName = allocateUploadFileName(fn.c_str(), idx))) {
1381+
errNo = UPL_MEMERR;
1382+
return false;
1383+
}
1384+
strcpy(uploadFileNames[idx], fn.c_str());
1385+
1386+
uploadFileName[0] = '/';
1387+
uploadFileName[1] = '-';
1388+
uploadFileName[2] = 0;
1389+
1390+
if(fn.length() > 4 && fn.endsWith(".mp3")) {
1391+
1392+
strcat(uploadFileName, fn.c_str());
1393+
1394+
if((strlen(uploadFileName) > 9) &&
1395+
(strstr(uploadFileName, "/-delete-") == uploadFileName)) {
1396+
1397+
uploadFileName[8] = '/';
1398+
SD.remove(uploadFileName+8);
1399+
opType = -1;
1400+
1401+
}
1402+
1403+
} else if(fn.endsWith(".bin")) {
1404+
1405+
if(!haveAC) {
1406+
strcat(uploadFileName, CONFN+1); // Skip '/', already there
1407+
opType = 1;
1408+
} else {
1409+
errNo = UPL_DPLBIN;
1410+
opType = -1;
1411+
}
1412+
1413+
} else {
1414+
1415+
errNo = UPL_UNKNOWN;
1416+
opType = -1;
1417+
// ret must be false!
1418+
13431419
}
1420+
1421+
if(opType >= 0) {
1422+
if((file = SD.open(uploadFileName, FILE_WRITE))) {
1423+
ret = true;
1424+
} else {
1425+
errNo = UPL_OPENERR;
1426+
}
1427+
}
1428+
1429+
} else {
1430+
1431+
errNo = UPL_NOSDERR;
1432+
13441433
}
13451434

1346-
return false;
1435+
return ret;
13471436
}
13481437

13491438
size_t writeACFile(File& file, uint8_t *buf, size_t len)
@@ -1356,59 +1445,46 @@ void closeACFile(File& file)
13561445
file.close();
13571446
}
13581447

1359-
void removeACFile(bool isUPLFile)
1448+
void removeACFile(int idx)
13601449
{
13611450
if(haveSD) {
1362-
if(!isUPLFile) {
1363-
SD.remove(CONFN);
1364-
} else if(uploadFileName) {
1365-
SD.remove(uploadFileName);
1451+
if(uploadRealFileNames[idx]) {
1452+
SD.remove(uploadRealFileNames[idx]);
13661453
}
13671454
}
13681455
}
13691456

1370-
bool openUploadFile(const char *fn, File& file, bool& isDel)
1457+
int getUploadFileNameLen(int idx)
13711458
{
1372-
if(haveSD) {
1373-
1374-
isDel = false;
1375-
1376-
if(!strlen(fn))
1377-
return false;
1378-
1379-
if(!(uploadFileName = (char *)malloc(strlen(fn)+4)))
1380-
return false;
1381-
1382-
uploadFileName[0] = '/';
1383-
uploadFileName[1] = '-';
1384-
uploadFileName[2] = 0;
1385-
strcat(uploadFileName, fn);
1386-
1387-
if((strlen(uploadFileName) <= 9) ||
1388-
(strstr(uploadFileName, "/-delete-") != uploadFileName)) {
1389-
1390-
if((file = SD.open(uploadFileName, FILE_WRITE))) {
1391-
isDel = false;
1392-
return true;
1393-
}
1459+
if(idx >= MAX_SIM_UPLOADS) return 0;
1460+
if(!uploadFileNames[idx]) return 0;
1461+
return strlen(uploadFileNames[idx]);
1462+
}
13941463

1395-
} else {
1464+
char *getUploadFileName(int idx)
1465+
{
1466+
if(idx >= MAX_SIM_UPLOADS) return NULL;
1467+
return uploadFileNames[idx];
1468+
}
13961469

1397-
uploadFileName[8] = '/';
1398-
SD.remove(uploadFileName+8);
1399-
isDel = true;
1400-
1470+
void freeUploadFileNames()
1471+
{
1472+
for(int i = 0; i < MAX_SIM_UPLOADS; i++) {
1473+
if(uploadFileNames[i]) {
1474+
free(uploadFileNames[i]);
1475+
uploadFileNames[i] = NULL;
1476+
}
1477+
if(uploadRealFileNames[i]) {
1478+
free(uploadRealFileNames[i]);
1479+
uploadRealFileNames[i] = NULL;
14011480
}
1402-
1403-
free(uploadFileName);
1404-
uploadFileName = NULL;
14051481
}
1406-
1407-
return false;
14081482
}
14091483

1410-
void renameUploadFile()
1484+
void renameUploadFile(int idx)
14111485
{
1486+
char *uploadFileName = uploadRealFileNames[idx];
1487+
14121488
if(haveSD && uploadFileName) {
14131489

14141490
char *t = (char *)malloc(strlen(uploadFileName)+4);
@@ -1417,11 +1493,9 @@ void renameUploadFile()
14171493
strcat(t, uploadFileName+2);
14181494

14191495
SD.remove(t);
1496+
14201497
SD.rename(uploadFileName, t);
14211498

14221499
free(t);
1423-
1424-
free(uploadFileName);
1425-
uploadFileName = NULL;
14261500
}
14271501
}

src/dg_settings.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,22 @@ void doCopyAudioFiles();
203203
bool check_allow_CPA();
204204
void delete_ID_file();
205205

206+
#define MAX_SIM_UPLOADS 16
207+
#define UPL_OPENERR 1
208+
#define UPL_NOSDERR 2
209+
#define UPL_WRERR 3
210+
#define UPL_BADERR 4
211+
#define UPL_MEMERR 5
212+
#define UPL_UNKNOWN 6
213+
#define UPL_DPLBIN 7
206214
#include <FS.h>
207-
bool openACFile(File& file);
215+
bool openUploadFile(String& fn, File& file, int idx, bool haveAC, int& opType, int& errNo);
208216
size_t writeACFile(File& file, uint8_t *buf, size_t len);
209217
void closeACFile(File& file);
210-
void removeACFile(bool isUPLFile);
211-
bool openUploadFile(const char *fn, File& file, bool& isDel);
212-
void renameUploadFile();
218+
void removeACFile(int idx);
219+
void renameUploadFile(int idx);
220+
char *getUploadFileName(int idx);
221+
int getUploadFileNameLen(int idx);
222+
void freeUploadFileNames();
213223

214224
#endif

src/dg_wifi.cpp

Lines changed: 159 additions & 82 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)