extractModeDefaults(): C strings instead of String

This commit is contained in:
cschwinne 2022-08-31 02:26:26 +02:00
parent 8719adef1e
commit 5b51ce9840
2 changed files with 14 additions and 8 deletions

View File

@ -665,6 +665,9 @@ void sendSysInfoUDP()
#define DDP_FLAGS1_STORAGE 0x08
#define DDP_FLAGS1_TIME 0x10
#define DDP_TYPE_RGB24 0x0A
#define DDP_TYPE_RGBW32 0x1A // proposal, this is still not an official part of the DDP spec
#define DDP_ID_DISPLAY 1
#define DDP_ID_CONFIG 250
#define DDP_ID_STATUS 251
@ -724,7 +727,7 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, uint8
// write the header
/*0*/ddpUdp.write(flags);
/*1*/ddpUdp.write(sequenceNumber++ & 0x0F); // sequence may be unnecessary unless we are sending twice (as requested in Sync settings)
/*2*/ddpUdp.write(0);
/*2*/ddpUdp.write(0); // data type, this is not fully defined by the DDP spec and thus left at "undefined" which is assumed to be 24-bit RGB
/*3*/ddpUdp.write(DDP_ID_DISPLAY);
// data offset in bytes, 32-bit number, MSB first
/*4*/ddpUdp.write(0xFF & (channel >> 24));

View File

@ -355,17 +355,20 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL
}
// extracts mode parameter defaults from last section of mode data (e.g. "Juggle@!,Trail;!,!,;!;sx=16,ix=240,1d")
int16_t extractModeDefaults(uint8_t mode, const char *segVar)
{
if (mode < strip.getModeCount()) {
String lineBuffer = FPSTR(strip.getModeData(mode));
if (lineBuffer.length() > 0) {
int16_t start = lineBuffer.lastIndexOf(';');
if (start<0) return -1;
char lineBuffer[128] = "";
strncpy_P(lineBuffer, PSTR(strip.getModeData(mode)), 127);
if (strlen(lineBuffer) > 0) {
char* startPtr = strrchr(lineBuffer, ';'); // last ";" in FX data
if (!startPtr) return -1;
int16_t stop = lineBuffer.indexOf(segVar, start+1);
if (stop<0) return -1;
return atoi(lineBuffer.substring(stop+strlen(segVar)+1).c_str());
char* stopPtr = strstr(startPtr, segVar);
if (!stopPtr) return -1;
return atoi(stopPtr);
}
}
return -1;