-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot set text of a TextView inside the read Callback #307
Comments
Ok... I got further on it by myself but I'm still facing some problems... 1st: I've added a read line to the serial setup, pointing to a callback:
2nd: Then I wrote the callback to get the data from Serial:
3rd: I wrote a function to understand the data received trough the callback:
4th: Every command/information received will then be handled separately by another function:
Everything seems to work fine like this. Then I tried to show/update the volume poured, measured by the Arduino:
Right after the RFID card is read, the app stops working.
I tried putting a breakpoint inside the callback and running debug, but I was unable to identify the root of the problem. |
i can recommend you to add text updates in a separate thread. |
I tought it'd be better if I posted the update in the same thread because, if someone have the same issue I had, they could benefit from de direct answer that I implemented... |
i am sorry i meant to run textupdates creating a user thread or a timer in the program to update the textview: private void startTextupdateThread() {
} i am not sure this will fix, but u can try as you said it was fine when you commented that line out. |
It Worked!
And passed reference to it inside the handleCommand function:
MyVariables object looks like this:
|
Hi friends!
Calling myself newbie at Android is too much of a complyment for me, as I don't know Jack s*it about it, but I'm adventuring myself into developing a Self Service Beer Tap sistem using Kotlin language anyways.
After struggling a bit, I've managed to make the layout for the app and somewhat setting up the serial communication with an arduino board using this UsbSerial library.
At this point I was supposed to code serial reading at the app, but I don't know how to do it.
Serial communication is set up in the code exactly as the tutorial made by "Apps in the sky":
Part 1: https://www.youtube.com/watch?v=QHa6HWTmQFs
Part 2: https://www.youtube.com/watch?v=ICjjG1VsZmw&t
The messages/commands that the android will receive will have the following format:
Ixxxxxxx> Vxxxxxx> <xxxxxx>
The first character will tell the Android what is the information being passed:
I = ID of the rfid card read by the Arduino
V = Volume measured
< = General Command or info ,like , <POURING_ENDED>, <AUTHENTICATION_FAILURE>
And the stopbit for every data line or command is ">".
Could someone help me on implementing this on the code?
Just in case someone gives up reading the header: I'm using Kotlin.
Almost forgot to mention: the app template is ItemList/Detail, but the communication will be done all in the main application(ItemListActivity).
And sorry for any bad english(I'm brazilian).
EDIT: I read #37 but couldn't translate it to my code because it's Java and the code wouldnt' use Stopbits as I intend to use.
The text was updated successfully, but these errors were encountered: