Closed tbaumann closed 5 years ago
IAS.addField(sensorNames[0], "Sensor 0", 16, 'L');
IAS.addField(sensorNames[1], "Sensor 1", 16, 'L');
IAS.addField(sensorNames[2], "Sensor 2", 16, 'L');
Crashes equally. Const-ness of the label isn't even the problem here.
I'm quite confused now.
Hi @tbaumann, you are using this function in a way it was never intended for. But I get where you are comming from... as a programmer you do not want to repeat things... and rather setup a loop for this. We will definitely look into this.
For now you will have to use it like in the examples: char LEDpin = "2"; char blinkTime = "1000";
IAS.addField(LEDpin, "ledpin", 2, 'P'); IAS.addField(blinkTime, "Blinktime(mS)", 5, 'N');
So in your case: char sensorName0 = "Example 1"; char sensorName1 = "Example 2"; char* sensorName2 = "Example 3";
IAS.addField(sensorName0, "Sensor 0", 16, 'L'); IAS.addField(sensorName1, "Sensor 1", 16, 'L'); IAS.addField(sensorName2, "Sensor 2", 16, 'L');
(sensor name value, html field name, max char that can be saved from html, fieldtype)
Thanks Onno, I can certainly do it that way. No problem. The code repetition was in the end not really too bad. Perhaps I do it one day in preprocessor if I can actually be bothered.
Good to know I didn't just do something trivially wrong, thanks. I don't so C very often. 😄
Great, good luck with your projects! And if your question is answered please close this issue. (it's better for the stats if the issue opener closes it)
I have the feeling addField() somehow gets all confused if I use heap variables.
I suspect that the
const
forlabel
is meant seriously?Apart from the fact that I deeply dislike that solution. It also doesn't work. (Guru meditation)
No mallocs and strcpy this time.
I'm no expert. But that looks const enough to me.
Is
const char *fieldLabel
indeed the problem here?Can I perhaps mark it const and promise I won't change the value at runtime but initialise it dynamically?