Steven Braun

unread,
Jun 30, 2018, 8:08:15 PM6/30/18
to MIT App Inventor Forum
Can someone explain to me why I absolutely cannot get the text to advance a line in Textbox1?  The Android app and Arduino code work quite well except I cannot get a line feed.  The text simply writes over the previous line.  I am trying this live and have created the .apk and no-go.  I have tried every possible combination.
Screen Shot 2018-06-30 at 5.00.55 PM.png
Screen Shot 2018-06-30 at 5.01.44 PM.png
Screen Shot 2018-06-30 at 5.06.27 PM.png

Chris Ward

unread,
Jul 1, 2018, 5:27:01 AM7/1/18
to MIT App Inventor Forum
Hi Steven

While we are waiting for a response from someone that knows what they are talking about, try changing your script from BT.print to BT.println.

Chris Ward

unread,
Jul 1, 2018, 5:46:03 AM7/1/18
to MIT App Inventor Forum
...we also cannot see your Blocks? What they may need to do is add each received line of text to a text variable - when receive has completed, that text variable would then be used to populate the Text Box. Much depends on how App Inventor handles the EndOfLine bytes from the Arduino - if it doesn't like them, a string replace function can swap them out.


Steven Braun

unread,
Jul 1, 2018, 11:22:18 AM7/1/18
to MIT App Inventor Forum
Chris:

Thanks for the response.  I have included the blocks now.  Please be advised that I DO have a BT.println() function at the very end of the Arduino function.  I have tried every combination of code that I can think of. I have changed the BT.println() from println() to BT.print( '\n' ), I have tried different combinations of print and println functions, I have use BT.write() and BT.writeln(), and I have tried all manner of printer control characters such as \n, \r, and \f to gauge their effect.  Nothing seems to work.  I am assuming that ai2 just doesn't like what it is receiving but I am unaware of how to force the ai2 blocks to add a form feed. 
blocks.png

Abraham Getzler

unread,
Jul 1, 2018, 11:43:53 AM7/1/18
to MIT App Inventor Forum
This sounds like wanting to eat your cake and have it too,
where the cake is the LF character consumed by the BlueTooth
Client as a Delimiter, having served its function as a message delimiter
to supply you with complete messages.

To log all your incoming messages line by line in a .Text field,
set the .Text field to a triple JOIN of
  1.   the previous value of the .Text field
  2. a line break like \n or <br> (if html label)
  3. the newly arrived message.
I personally prefer to reverse the order, getting the latest message at the top,
because I haven't figured out how to force a scroll to the bottom.

ABG



Steven Braun

unread,
Jul 2, 2018, 1:47:57 PM7/2/18
to MIT App Inventor Forum
Excellent advice...
In the past, I have used a simple BT terminal program that passed through all of the received chars. It never ocurred to me that the ai2 background BT function was perhaps consuming the LF. Seems to work.
Thanks....

TimAI2

unread,
Jul 3, 2018, 5:40:27 PM7/3/18
to MIT App Inventor Forum
Yay ABG, finally....someone else in the world who gets that saying round the right way :)
Reply all
Reply to author
Forward
0 new messages