2015년 1월 3일 토요일

Re: Simple Countdown Timer Needed for App Inventor 2


I'm looking for a way to include a countdown timer as part of my app. I want the user to input the minutes and seconds then have the timer display the countdown.
I looked through the forums, but couldn't find anything that does what I need.
This post works well, but only displays seconds, not minutes and seconds. GameClock Visual Countdown for AI2 - Simplified (tutorial)
This post looks pretty close, but it's for App Inventor Classic and I can't for the life of me seem to translate it.
http://puravidaapps.com/countdown.php

countdown.aia






I've included a screen shot of what I created, but it just doesn't work. The minutes don't coincide with the seconds and I have to use three different clocks. (One for the initial seconds inputed, one for each remaining 60 seconds, and one for the minutes.)
Help would be appreciated

--
Using three clocks may be unnecessary.   Keep in mind, the default clock setting is 1000.  The value is in milliseconds.  second =1000 milliseconds. Divide milliseconds by 1000 to obtain seconds.

Why not keep the counter in milliseconds?      If user wants "2 minutes, 1 second;" convert his input to 2 minutes/second  x 1000 ms/second   and use that value;    To report, reverse the process.  Let the timer report in ms to the global variable, then convert ms to minutes, seconds, etc in the label?  Did I understand you correctly?   Keep track of time in ms.    Convert what the user wants to ms.  As the clock reports the time, convert the ms to minutes seconds.
--
This post looks pretty close, but it's for App Inventor Classic and I can't for the life of me seem to translate it.
http://puravidaapps.com/countdown.php
AI1 and AI2 is more or less the same and the few differences are explained here What's different?
hope that helps...

--
Thanks guys for the feedback. I think I got it. I've attached a screen shot of what I have for future reference.
The biggest issue I had was trying to get single digit numbers like 1,2,or 3 to display as 01,02, or 03. I wound up using an if/then/else block to determine is the number is <10 and then a join block to add an extra 0 in front. (This is not included in the screen shot).



--
Here's a more simplified version. It only requires a single timer. I use a list picker to choose the minutes and seconds.


--
I am new in the branch so i need help obvious
I have created a program to control an arduino board and i need to include a countdown timer with 2 option
1: start countdown from 15 minutes 2: start countdown from 30 minutes but here is the tricky part i need to include 2 buttons 1: for + 5 minutes wich add 5 minutes to the routing time , and another wich drops 5 minutes from running timer

--
I think you can find better countdown clock examples in this board
than this thread.  Many people have asked this question.

Review all the blocks in the Clock component, especially the ones that 
convert Instants to milliseconds.

You will need to keep a global variable with the target Instant value
when you want the alarm to fire.

Your three buttons will set and up and lower that value.

Your Clock will continually display the milliseconds between Now() and your target,
converted to minutes and seconds the usual way.

--

댓글 없음:

댓글 쓰기