then everything works with no errors?
You could also try comparing text instead of numbers, just in case the text coming through is being seen as text and not a number (you can also test for this....
As my example shows there is nothing wrong with the blocks, so it must be to do with what is coming through, or something else is going on we can't see, maybe a timing issue?
TimAI2, you are awesome!!!
The compare text function works GREAT!
Not sure why the mathematical way wouldn't work.
I guess the label is actually not a number so the greater than symbol confuses Android 6.
There is one problem,
5 of the labels display the color change and alarm sound perfectly.
The 5 that work are all set at 41 (cooler max temp) to make the change.
The one that isn't working correctly is for the freezer (Clock2), it is set at 32 (freezer max) to make the change.
I did see it work briefly but then It shows red and sets the alarm off.
Even when the temp displayed is well below the set point.
I replaced the label with a new one, tried moving it to different locations in the clock.
Checked the clocks to make sure they aren't firing at the same time.
Nothing I do seems to make the color change work correctly.
I've tried 56 different combinations test apps. UGG!
So I just set the label text to black in the design view and disabled the color change in the blocks for the freezer.
The temps that are displayed are all working fine, including the freezer.
I have attached the clocks if anyone wants to take a look...
TimAI2, you are the bomb!!!
Thank you, Thank you, and Thank you!
-Rob
Take the "number" coming from bluetooth
trim to remove any excess characters either end
split characters into a list (the text box is blank)
test for a "-", take it out to build the number, then put it back if there is one, otherwise just rebuild the number
check it is a number
show it
Works for positive...
and negative numbers...
OK guys,
First I would like to say thank you for all of the help.
The 5 other sensors work perfectly due to the double digit temps being displayed.
Thanks TimAI2!
I still am having problems with the freezer temperature label color change.
I'm sure it is the single digit temperature being displayed that is the culprit.
I have stripped the program down to bare bones and have attached it.
I have used SteveJG's example for leading zeros and was able to display 2 digits with a leading zero.
However the same problem from the start of this post occurs. This example uses math and not text to do the operation.
As before this does not work. TimAI2 suggested using math to do the comparison and it worked great on the 5 listed above.
Is there a way to convert SteveJG example from math to text comparison? 07.99 Not 7.99
I am hoping that this fix the issue…
My apologies for the lack of knowledge in this area,
I am learning, just not fast enough!
-Rob
Text comparison of numbers can be tricky when they have a different number of digits.
That being said, I would expect MIT App Inventor 2 to know that
9.35 is less than 10.35 without having to do anything to the code.
Hi TimAI2,
First, thanks for all your help.
This app displays all the temps perfectly (freezer and coolers) at all times.
I just thought it would be nice to have the text change color but, not necessary.
I have attached the .aia file and image.
Working off of your recommendations, the color changes perfectly until single digits are displayed.
The only way the app will load without errors is by using the “red” compare text argument and it works great as long as single digits are in play.
When the “blue” math argument is used an error occurs when app is launched.
“The operation cannot accept the argument”.
I tried to use your sledgehammer example and could not get it to work (way past my current abilities).
I also tried to using Taifun’s example for adding zeros and started to get the same errors as above.
There are the several different ways that I have tried.
4 ways are in the blocks.
2 of the ways cause an error when the app starts.
2 of the ways cause no error when the app starts and works until single digits.
Nice thoughts ABG,
However the not connected text label could not be the problem because I have stripped down versions that I am working with that have only the Bluetooth connect call and nothing else in the function (No label text in the code). The problem is still present.
To be clear, the not connected reference is not in many of the builds that I use and the problem is still present.
I just happened to be working on the build at the time that has the not connected label text when I made the post.
The not connected labels are only called on if the connection was not made to the Bluetooth device that was specified, there is no event called when the connection has been made. Also, the text in the designer is set blank.
The clock timer runs from the start, and is set to fire at one second intervals.
Should I change the way it is initialized? If so please explain how if change it would work to cure the color change issue.
I really think the problem lies in the interpretation of the single digits temperature that displays when the temperature drops from 10.00 to 9.99.
Reason: The temp color change works great until this and only this event takes place.
To test my theory I have been trying to add a zero, break apart the data and rebuild it, and many other ideas that have been brought to my attention in this forum. I just do not have the coding skills to make any of them work without getting argument errors when the app is started (thank you to all that have blesses with your ideas).
Thanks ABG,
-Rob
getting argument errors when the app is started
OMG!!! WOW!!!
That was the trick!!!
What a Thanksgiving!!!
I think,
the Bluetooth module transmits a decimal point or something unseen in the data that is not considered a number.
Thus confusing the comparison.
Thank you all for the continued support!
Thank you, Thank you, Thank you!!!
Complete and solved!!!
-Rob
I now am going to add a too cold text color change to the coolers and set it at
label1.text < 32
label1.text.color = Red
Should I mark this as solved and create a new thread or continue in this thread?