2017년 3월 27일 월요일

BACKLIGHT


The backlight do go off when the app is in progress and the user just leaves it for a few minutes. How can I set the backlight to be on when the game is in progress?

--
Please what's the name of the Extension OR How do I go about it?

-- 
what about following the link I provided in my previous answer?

-- 
I saw it but I don't know how to go about extensions

-- 
See the App Inventor Extensions document about how to use an App InventorExtension.
this is btw. the first sentence you see on the mentioned webpage https://puravidaapps.com/file.php ...

and in case your question is "how to download the extension", then you might want to scroll down on that page https://puravidaapps.com/file.php until you find the Download chapter
hope that helps

-- 

Client Socket Extension made, testers wanted to be continued


I tested this extension.. working with no problem when server is ok.. but..
1. when host in disabled (or connection lost etc. ) I have big  error (with "end application" button)
"connection time out" and application crash.. "Connection error -
socket creation - falied to connect to xxx.xxx.xxx.xxx port yyyy"
should be any error handling (even enough indicator that the error
occurred or error number or error message )..
- I have screen1.erroroccurred enabled - unfortunately, does not assume these errors



Can I ask about adding such a feature so that the system does not communicate FAULTS?

2. Secont thing.. 
Connect Timeout - is very long - when server or network is unavailable i have message - "application is not responding. Close ?" - should only status change etc.

-- 
Same here: crash on connection loss.
I connect to a Wifi AP (ESP8266) and open a connection using this extension and the example app. I'm able to exchange messages which is great, but as soon as the AP is turned off or goes out of wifi range, the app crashes.

Thank you Jean-Rodolphe for your hard work, and can you please fix this issue?

-- 
Thanks for your report, I have been able to reproduce the first problem you described problem and I am actually triing to solve it. It must be a kind of exception that i don't raise, but I can't find which ...

For the second problem, the timeout for a connection that doesn't work is 5 seconds, it's odd that it says "application not responding" ... is it before 5 seconds ?
-- 
Yes, the problem must be the same as Artur, I am currently triing to solve it but not with success for now ... And the compilation and a new try when I make changes is very long ... Will continue to try and as it is easily reproducable, when I will find a workaround, will post here a new version.
-- 
it's possible for you to make an UDP client to send/receive data with UDP?
Also join/dejoing multicast and broadcast adresses?!

That would be very great! There are a lot of guys that would need them!

-- 

Run time error when creating sonar using Arduino ultrasonic sensor and app inventors


I'm trying to create sonar using Arduino ultrasonic sensor and app inventors. I'm running into a huge problem.
I'm trying to draw points on the canvas based on reading from ultrasonic sonar, I'm getting data from sonar using Bluetooth. But sometimes Bluetooth is passing 2 values next to each other resulting in the runtime error. How can I catch this error or is there ay another way to avoid this? 

--
Your circle centerY is trying to use global value distance which is set to [52 52] butit should be a number.
You need to extract the value as number.

-- 
How can I do that? When I try to receive signed/unsignedbyte number it receiving random number totally from to the ones on arguing console 

-- 
the value in the local variable distance is changing every 250 ms. It's getting this data from Arduino, but from time to time its passing 2 numbers instead of just one 

-- 
You need to send each number with a delimiter, 
typically using println(), and tell AI2 to pull in only
one message at a time by watching for that delimiter.

The Designer BlueTooth component has a Delimiter attribute,
which you can set to 10 (decimal of LF),
and the BlueToothClient.ReceiveText block should ask for -1 bytes,
which should deliver exactly one message.

Expect  some lag as the messages pile up in an AI2 buffer
if you are reading much slower than your Arduino is transmitting.

That's the price to pay for the Delimiter convenience.

-- 
thanks for replay. Wow that sound good, unfortunately I don't understand how to set this up. Could you try to explain how to set it up please. Much appreciate 

-- 
THANK YOU very much Its worked fine!. Understand what you meant. I did what you have suggested. In designer tab I put Bluetooth Delimiter attribute to 10 and set to receive bites by -1,. HoweverI had to change the speed of sending data and clock interval to 500 from 250 miliseconds in order to stop drawing wrong circles. Is there any other method of achieving this without slowing down sending of data ? 
-- 
Understand what you mean by lag now it is noticeable. The object has to be in front of sonar for at least 3 seconds in order to draw the circle in the different point. this is working solution but the project I'm doing should catch the fast moving object that is passing through the ultrasonic sonar. Any other suggestions ? 

-- 
Regarding the lag, it can be made visible on the AI2 side by copying the BytesAvailable value to a label.Text.

Maybe if it gets too high, the AI2 Clock could be speeded up to lower the backlog,
either manually by slider or automatically by some kind of sofwate feedback loop.

-- 
I looked closer at your blocls.
Did you lose the Bytes Available > 0 test?

You need to have

IF Connected then
    Say Connected
    IF Bytes Avaliable > 0 then
       Receive -1 bytes and process it
       ...
Else
  Say Disconnected

in your Timer.

-- 
Thank you very much mate you deserve a beer! I did what you said I put to set the label to byte available to receive. I notice that it keep growing by 4 until 128. Meaning that its loading buffer with data that's why it was very slow to receive correct data. Then I created if else function to check if bytes available to receive are > 4 and if so to set times to 100 else to 250. I notice that It was working but circles were drawn in kind of lag matter. (like it draw 5 circles smoothly and then wait for a bit and draw another 5). So I got read of if else function and just change the clock timer to 200. So my Arduino send data every 250 ms and app clock goes every 200 ms. That way there is no buffer overload and circles are drawn smoothly. 

-- 
Thanks for the feedback!

The AI2 docs don't discuss the buffering that happens behind the scenes when 
a Delimiter is used, and there's not much discussion out there about how to set
relative clock frequencies on the sending and receiving sides.

-- 

Arduino Arithmetic Operators


This week on Adventures in Science, we look at the various arithmetic operators in C and C++, specifically, as they're used in the Arduino environment. There are only 6 main operators: assignment, addition, subtraction, multiplication, division, and modulo. We also look at compound assignment operators; how they can be used to perform a math operation on a variable and then store the result back in the same variable.





Language Reference:
Arduino programs can be divided in three main parts: structurevalues (variables and constants), and functions.

Structure

Control Structures

Further Syntax

Arithmetic Operators

  • = (assignment operator)
  •  (addition)
  • - (subtraction)
  • * (multiplication)
  • / (division)
  • % (modulo)

Comparison Operators

  • == (equal to)
  • != (not equal to)
  • < (less than)
  • > (greater than)
  • <= (less than or equal to)
  • >= (greater than or equal to)

Boolean Operators

  • && (and)
  • || (or)
  • ! (not)

Pointer Access Operators

Bitwise Operators

  • & (bitwise and)
  • | (bitwise or)
  • ^ (bitwise xor)
  • ~ (bitwise not)
  • << (bitshift left)
  • >> (bitshift right)

Compound Operators

  • ++ (increment)
  • -- (decrement)
  • += (compound addition)
  • -= (compound subtraction)
  • *= (compound multiplication)
  • /= (compound division)
  • %= (compound modulo)
  • &= (compound bitwise and)
  • |= (compound bitwise or)

Variables

Constants

Data Types

Conversion

Variable Scope & Qualifiers

Utilities

Functions

Digital I/O

Analog I/O

Due & Zero only

Advanced I/O

Time

Math

Trigonometry

Characters

Random Numbers

Bits and Bytes

External Interrupts

Interrupts

Communication

USB (32u4 based boards and Due/Zero only)

Looking for something else?

See the libraries page for interfacing with particular types of hardware. Try the list of community-contributed code. The Arduino language is based on C/C++. It links against AVR Libc and allows the use of any of its functions; see its user manualfor details.

Countdown Timer


Is iit possibile to add an hour to countdown Timer. Because I need to play the lecture and it takes around two hours and half.


--
sure, that's possible


first you should understand, how that example is working
and after that, it should be no problem for you to add a global variable intHoursLeft...
remember: and hour has 60 minutes...
see also these general tips 

-- 
I tried so many times but I couldn't understand the how is working.Please help me.



-- 
how many milliseconds are there in 1 hour?



-- 
alternatively now you also can use the new clock methods
DurationToHours
DurationToMinutes
DurationToSeconds

-- 
I tried again but it doesn't work. It is very difficult.

countdowntimer.png 표시 중

-- 
I tried again but the timer it doesn't move.


countdowntimer.png 표시 중

-- 
the second screenshot looks better
after having calculated intHoursLeft, you have to calculate the remaining millis like this
  intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc

-- 
I tried to do what have said, but unfortunately, it doesn't work



-- 
If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...


To download the aia file, upload it to  App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...

--
Thank you Taifun for your help.
Please tell me what can I do. 


 -- 
this was the correct calculation of the hours



after having calculated intHoursLeft, you have to calculate the remaining millis like this
  intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc

-- 
Please see attached image.
I really appreciate of you support and help.



-- 
I think, it's important to understand, what you are doing...
therefore let's take an example and let's calculate it manually

let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours

then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds

now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds

-- 
I have been trying to calculate this equations you had mentioned since yesterday. Now,I understand more than before, but please learn me more.

countdowntimer.png 표시 중

-- 
Can you check this calculation if it is more correct?



-- 

let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds


after calculation of the hours, where are the remaining milliseconds now in your blocks?

also you forgot to answer these questions
now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds




also use Do it to debug your blocks, see tip 4 here 



-- 
Sorry, I can't find the remaining milliseconds in block. but what I know that it is 1842000


-- 
as already said
after having calculated intHoursLeft, you have to calculate the remaining millis like this
  intMillisLeft = intMillisLeft - ( intHoursLeft * 3600000 )
and then continue with the calculation of the minutes etc


-- 
Please check the calculation



-- 
it is YOU who should check the calculation...
and the tool to use is as already said Do it, see tip 4 here
Top 5 Tips: How to learn App Inventor



why do you use the LeadingZeros procedure for the remaining milliseconds?



let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds


you still forgot to answer these questions

now let's calculate the minutes
1: how to calculate the minutes?
2: how many remaining milliseconds do you get?
and in the last step we then calculate the seconds

what about providing some answers now?

1842000 milliseconds
how many minutes do you get? how many seconds do you get?

protip: take a look at the original solution here https://puravidaapps.com/countdown.php

-- 
1842000 / 60000  = 30 minutes


-- 
Yes, I have got it now. Thank you Taifun.
But the problem is that the timer doesn't start countdown until become less than one hour.


-- 
I think, you have to subtract additionally the hours




use Do it to debug your blocks

--
Yes, you are right.
Now is working.
Thank you so much Taifun for your learning me.
I want to know is there an example for count-up instead?






-- 

 is there an example for count-up instead?
I don't know
probably you can find an example after doing a search in the forum?

also what about just trying to build it yourself?
you learned how to count down... to count up should be similar...


-- 
Can you please give me a hint how to start and I will complete the calculation.

-- 
I need your help to tell me what can I do to start the calculation in correct way.



-- 
sorry, I do not have time currently, you might want to try something yourself or someone else might chime in

-- 
What is the difference between count-up and count-down? Just reverse the numbers and get the difference in time. You know already how to calculate that difference.

-- 
Thank you Ghica,
I will be happy if you give me an example in reverse of this example for countdown timer :
let's assume, we have 9042000 milliseconds
first we calculate the hours, which is milliseconds divided by the number of milliseconds in an hour
9042000 / 3600000 = 2 hours
then we calculate the remaining milliseconds
9042000 - (2 x 3600000) = 1842000 milliseconds

-- 
this thread was about count down timer and has been answered
your thread about count up timer is here: Count-up Timer

--