๐ŸŽ„โ›„โ„๏ธ๐ŸŽ It's beginning to look a lot like ADABOX-mas! The next ADABOX from Adafruit ships soon! Get yours now, or give as a gift! ๐ŸŽ„โ›„โ„๏ธ๐ŸŽ
0

Multiline Text Block
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Multiline Text Block

by JackTheSE on Mon Oct 21, 2019 5:41 pm

Is there any way to display a multi-line text message in a text block?
I've tried inserting \r\n in a text string sent to a text block, but it is ignored.

JackTheSE
 
Posts: 22
Joined: Wed Jan 02, 2019 8:34 pm

Re: Multiline Text Block

by brubell on Tue Oct 22, 2019 10:11 am

Hi JackTheSE,

Text blocks do not have formatting options for multi-line messages. You would need to create two separate text blocks.

I think multi-line (and maybe additional formatting parameters) would be a welcome addition to the block. Could you add it to the block suggestion thread (viewtopic.php?f=56&t=130408)?

- brent r.

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Multiline Text Block

by JackTheSE on Fri Oct 25, 2019 6:42 am

Could you add it to the block suggestion thread

Ultimately it would be fantastic to be able to design my own blocks somehow, and perhaps publish them open source for others to use. First thing I would do is design a much smaller toggle button with integrated text beside it. Second would be to design a text block that would display a table from a .csv file. Being able to develop my own blocks would convince me to go to a plus account.

Submitting my block ideas to a forum with the hope that something gets done by somebody, someday, maybe, is just not good enough for me. I'm trying to develop my own home automation system with Feather ESP32s and other products, but the current blocks are too limiting for a usable web interface.

JackTheSE
 
Posts: 22
Joined: Wed Jan 02, 2019 8:34 pm

Re: Multiline Text Block

by brubell on Tue Oct 29, 2019 10:23 am

JackTheSE wrote:
Could you add it to the block suggestion thread

Ultimately it would be fantastic to be able to design my own blocks somehow, and perhaps publish them open source for others to use. First thing I would do is design a much smaller toggle button with integrated text beside it. Second would be to design a text block that would display a table from a .csv file. Being able to develop my own blocks would convince me to go to a plus account.

Submitting my block ideas to a forum with the hope that something gets done by somebody, someday, maybe, is just not good enough for me. I'm trying to develop my own home automation system with Feather ESP32s and other products, but the current blocks are too limiting for a usable web interface.


image (4).png
image (4).png (252.01 KiB) Viewed 132 times


Good news - we've added multiline text blocks to Adafruit IO and they're now live!

image (3).png
image (3).png (106.3 KiB) Viewed 132 times

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Multiline Text Block

by JackTheSE on Wed Oct 30, 2019 7:09 am

we've added multiline text blocks to Adafruit IO and they're now live!

So this is fantastic news and very timely for me. I'm right in the middle of developing dashboards for a ESP32 HAZZAH project, and this is a game changer. Some questions...
(1) Is this available just for plus users? I'm not yet a plus user, and I just tried to enter a long line in the test block like you've shown above, and I didn't get a multiline preview.
(2) Will I be able to enter \r\n in a text string to get a new line, or does it just depend on how I sized my text block? The former would be the best implementation for me. I just ran a test with a string containing \r\n, and I didn't see a new line (and I also did not see those characters in the displayed string, so there were filtered out somehow, like they should be).

Edit: True to my word, I just upgraded to a Plus account, and it still doesn't work for me. I'll await your guidance on how to get this working.

JackTheSE
 
Posts: 22
Joined: Wed Jan 02, 2019 8:34 pm

Re: Multiline Text Block

by brubell on Wed Oct 30, 2019 9:39 am

JackTheSE wrote:
we've added multiline text blocks to Adafruit IO and they're now live!

So this is fantastic news and very timely for me. I'm right in the middle of developing dashboards for a ESP32 HAZZAH project, and this is a game changer. Some questions...
(1) Is this available just for plus users? I'm not yet a plus user, and I just tried to enter a long line in the test block like you've shown above, and I didn't get a multiline preview.
(2) Will I be able to enter \r\n in a text string to get a new line, or does it just depend on how I sized my text block? The former would be the best implementation for me. I just ran a test with a string containing \r\n, and I didn't see a new line (and I also did not see those characters in the displayed string, so there were filtered out somehow, like they should be).

Edit: True to my word, I just upgraded to a Plus account, and it still doesn't work for me. I'll await your guidance on how to get this working.


This isn't a plus-only feature, we'll place a "IO PLUS ONLY" designator when features are exclusive to IO+. Thank you for upgrading to Adafruit IO Plus, though! Checking with devs...

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Multiline Text Block

by brubell on Thu Oct 31, 2019 1:45 pm

The \n character is not escaped in HTML input fields, so in your examples, Adafruit IO sees it like two characters "backslash en", rather than the single "newline" character. You'll have to input multiline data from the API for now.

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Multiline Text Block

by JackTheSE on Thu Oct 31, 2019 2:19 pm

The \n character is not escaped in HTML input fields ... You'll have to input multiline data from the API for now

Does this mean that, starting with a String in Arduino/C++ (that I would otherwise send to a text block), I have to (1) convert it into HTML, (2) embed the carriage return where I want it, and then (3) send the HTML version to the block? Please note that I have near-perfect ignorance on how to do any of this this, as I'm a semi-newbie using IO. An example of doing these steps would go a long, long way to getting me started. I have looked through the API reference, but it's way, way above my head for the moment, at least.
And in your example screen above you show a feed creation screen that has a long test input, and then displays it as multiline text in the output box. When I try to replicate that, it doesn't work. Should it?

JackTheSE
 
Posts: 22
Joined: Wed Jan 02, 2019 8:34 pm

Re: Multiline Text Block

by brubell on Thu Oct 31, 2019 3:23 pm

Does this mean that, starting with a String in Arduino/C++ (that I would otherwise send to a text block), I have to (1) convert it into HTML, (2) embed the carriage return where I want it, and then (3) send the HTML version to the block? Please note that I have near-perfect ignorance on how to do any of this this, as I'm a semi-newbie using IO. An example of doing these steps would go a long, long way to getting me started. I have looked through the API reference, but it's way, way above my head for the moment, at least.


You'd be sending data (such as "multi\nline\nblock" ) as a string to Adafruit IO via Arduino.

And in your example screen above you show a feed creation screen that has a long test input, and then displays it as multiline text in the output box. When I try to replicate that, it doesn't work. Should it?

The screenshot was taken during this block's development, it may have been removed/sanitized on the final version.

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.