Graphic Bar Chart
-
Hello Kl3m3n,
I don't know what I'm doing wrong.
What I wanted is to see the daily values graphically for a 1-month periodThat compile but show nothing
String MCHV = "1.0,4.0,9.0,16.0,25.0";
String MCHL = "10,20,30,40,50";
mqttClient.publish(&In[0], "|MBCH UID:mbch1 X:50 Y:50 MCHV:MCHV MCHL:MCHL\r\n");That not compile, show error
mqttClient.publish(&In[0], "|MBCH UID:mbch1 X:50 Y:50 W:70 H:30 OP:1 ROT:0 SHE:1 VIS:1
FSZ:1.2 BGC:#121212 FGC:#6D9DC5 BTH:0.5 T:0.1 XMA:7 YMA:7 SHG:1
MCHV:"1.0,4.0,9.0,16.0,25.0" MCHL:"day1,day2,day3,day4,day5"\r\n");That compile but show nothing
mqttClient.publish(&In[0], "|MBCH UID:mbch1 X:50 Y:50 W:70 H:30 OP:1 ROT:0 SHE:1 VIS:1
FSZ:1.2 BGC:#121212 FGC:#6D9DC5 BTH:0.5 T:0.1 XMA:7 YMA:7 SHG:1
MCHV:'1.0,4.0,9.0,16.0,25.0' MCHL:'day1,day2,day3,day4,day5'\r\n");That works, but it use the default MCHV and MCHL
mqttClient.publish(&In[0], "|MBCH UID:mbch1 X:50 Y:50 W:70 H:30 SCI:1\r\n");Can you please help?
Best regards
-
@Sato You need to escape the MCHV and MCHL payloads:
mqttClient.publish(&In[0], "|MBCH UID:mbch1 X:50 Y:50 W:70 H:30 OP:1 ROT:0 SHE:1 VIS:1 FSZ:1.2 BGC:#121212 FGC:#6D9DC5 BTH:0.5 T:0.1 XMA:7 YMA:7 SHG:1 MCHV:\"1.0,4.0,9.0,16.0,25.0\" MCHL:\"day1,day2,day3,day4,day5\"\r\n");
If you have variables MCHV and MCHL, you need to escape them also...
String MCHV = "\"1.0,4.0,9.0,16.0,25.0\"";
You can use single quotes, but you need to switch from double quotes to single quotes parsing using the TSC command (send @gse TSC:39\r\n before creating the widget).
Regards,
Klemen -
Hello @kl3m3n,
Thank you, as always your help is great!
Second question:
How can I use String variables in MCHV and MCHL?
Example:
String Monday = "0.47"
String Tuesday = "1.5"
String Wednesday = "5.6"
String MCHV = Monday + Tuesday + WednesdayType:
mqttClient.publish(&In[0], "|MBCH UID:mbch1 X:73 Y:55 W:48 H:85 SHG:1 MCHV:MCHV MCHL:"Monday,Thursday,Wednesday,Thursday,Friday,Saturday,Sunday"\r\n");Best regards
-
Hi @kl3m3n,
If you have variables MCHV and MCHL, you need to escape them also...
StringMCHV=""1.0,4.0,9.0,16.0,25.0"";The MCHL i can use it like you wrote with text separated by a comma, that's ok.
But for MCHV need that it can show dynamically the values, with int or String vars like
String textA = "47";
String textB = "15";
String textC = "56";But so far I've had no success with the methods I've used. Surely it must be possible, that's what Chart graphics are for, but I haven't figured out how to do it yet.
If anyone knows how, I'd be grateful if you could share
Thanks
Best regards -
This is not the most efficient (nor readable) way to do this... Also, you can create functions to organize the code better and in a more readable fashion... You can also use char buffer with fixed size for efficiency, etc.
String mo = "1"; String tu = "2"; String we = "3"; String th = "4"; String fr = "5"; String sa = "6"; String su = "7"; String mchv = "\"" + mo + "," + tu + "," + we + "," + th + "," + fr + "," + sa + "," + su + "\""; String cmd = "|MBCH UID:mbch1 X:73 Y:55 W:48 H:85 SHG:1 MCHV:"; cmd += mchv; cmd += " MCHL:\"Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday\"\r\n"; mqttClient.publish(&In[0], cmd.c_str());
Regards,
Klemen -
-