Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: JosJuice on November 14, 2010, 06:06:48 am

Title: TimeTools
Post by: JosJuice on November 14, 2010, 06:06:48 am
TimeTools is a small TI-BASIC program I've been working on for a while. It displays the current time (both digital and analog display), and also has a timer that has the ability to continue even when TimeTools is not running. It only runs on TI-84+(SE) since the clock is used.
I've tried to optimize this as much as I could. The screen is only updated when needed, and the whole program is about 1 kB. Usually, it runs at about 5 FPS.

(http://www.ticalc.org/archives/files/ss/817/81796.gif)


http://www.ticalc.org/archives/files/fileinfo/433/43347.html (http://www.ticalc.org/archives/files/fileinfo/433/43347.html)
Title: Re: TimeTools
Post by: jnesselr on November 14, 2010, 10:20:42 am
The hands are done via sin( and cos( in degree mode.  At zstandard, Lsin(A) gives the y coordinate for a hand L long and at the angle A.  A goes from 0-360, so for the second hand, it goes 60 times in a minutes or 360 degrees, which means it goes 1 time in a second or 360/60=60 degrees.  Also note that the pair (cos(0),sin(0)) produces (1,0) which means that you are going to have to shift the degrees by 90.  So that way, at 0 seconds, it would be (cos(0+90),sin(0+90)) which is (0,1) the correct start of the clock.  To have an offset, just add the x and y coordinates outside the sine and cosine.  Also note that that click will go counterclockwise, so you must negate the entire angle measure inside the cos( and sin( brackets.  Good luck. I would try a simple clock the size of the screen first, though.
Title: Re: TimeTools
Post by: Deep Toaster on November 14, 2010, 11:28:21 am
Also note that the pair (cos(0),sin(0)) produces (1,0) which means that you are going to have to shift the degrees by 90.  So that way, at 0 seconds, it would be (cos(0+90),sin(0+90)) which is (0,1) the correct start of the clock.

Actually, that would make it go backwards (counterclockwise). An easier (and smaller) way to do it is sin( for X and cos( for Y.

This project looks pretty nice, especially for a first project. 5 FPS is a pretty good speed for BASIC :D
Title: Re: TimeTools
Post by: DJ Omnimaga on November 14, 2010, 01:05:09 pm
Interesting, I'm curious how this will turn out. :)
Title: Re: TimeTools
Post by: JosJuice on November 17, 2010, 10:02:54 am
I've managed to draw the hands of the clock, but everything isn't done yet. I need to make the hands I drew the previous minute disappear, and some other stuff :P
Is it possible to recall a Pic when in Horiz mode? It doesn't seem to work for me.
Title: Re: TimeTools
Post by: Deep Toaster on November 17, 2010, 10:34:59 am
It should work, but it only shows the top half. The bottom half gets cut off, unfortunately.
Title: Re: TimeTools
Post by: Munchor on November 17, 2010, 12:59:48 pm
(http://i152.photobucket.com/albums/s183/JosJuice/random135.png)

Looks great, so, we need to set time i the 'Mode' button before using the program?

EDIT: Just tried it in Wabbit, yes we do, indeed, maybe add an option for us to set time, if possible?

EDIT2: Also, it displays "ednesday" instead of "Wednesday" :s
Title: Re: TimeTools
Post by: AngelFish on November 17, 2010, 01:06:55 pm
If you want to set the time, then you can use the setTime( command in TI-OS. It takes Hour, minute, and second as the arguments. You might just want to trim it to Hour and minute.
Title: Re: TimeTools
Post by: Munchor on November 17, 2010, 01:07:42 pm
If you want to set the time, then you can use the setTime( command in TI-OS. It takes Hour, minute, and second as the arguments. You might just want to trim it to Hour and minute.

I prefer to go to Mode :), it's much simpler and lets tou set date format and everything!
Title: Re: TimeTools
Post by: ASHBAD_ALVIN on November 17, 2010, 01:26:31 pm
If you want to set the time, then you can use the setTime( command in TI-OS. It takes Hour, minute, and second as the arguments. You might just want to trim it to Hour and minute.

I prefer to go to Mode :), it's much simpler and lets tou set date format and everything!

This looks better in my opinion :P

I see how you have decent timer controls in there, great, becuase I used to have to make a BASIC program every time I wanted to use a timer function.  And even then, that timer isn't fully accurate.

Great work so far!  Keep up the great work!  When it's finished I will probably put it on my real calc too ;)

NOOO I DON'T HAVE 666 POSTS ANYMOREZ :( I HAD THART FOR ONE WHOLE DAY TOO :P

EDIT: and 5 fps is fine for a BASIC prog.  if it were asm however, we'd be expecting a fps of >9000.  ;)
Title: Re: TimeTools
Post by: AngelFish on November 17, 2010, 01:29:58 pm
If you want to set the time, then you can use the setTime( command in TI-OS. It takes Hour, minute, and second as the arguments. You might just want to trim it to Hour and minute.

I prefer to go to Mode :), it's much simpler and lets tou set date format and everything!

The setTime( and the SetDate( functions are the same ones that TI-OS uses in the Mode menu :P
Title: Re: TimeTools
Post by: JosJuice on November 17, 2010, 01:36:55 pm
I fixed the ednesday glitch earlier today (didn't notice it earlier, because the current screen erasing routine was written on Thursday last week...) The fix isn't uploaded yet, though (TI-Connect refuses to connect with my calc right now).

Also, adding an option to set the time might be a bit tricky. The code is not designed for going to a second screen while the program is running and then go back, but I'll see if it's possible to make something anyway.
Title: Re: TimeTools
Post by: Munchor on November 17, 2010, 03:26:21 pm
I fixed the ednesday glitch earlier today (didn't notice it earlier, because the current screen erasing routine was written on Thursday last week...) The fix isn't uploaded yet, though (TI-Connect refuses to connect with my calc right now).

Also, adding an option to set the time might be a bit tricky. The code is not designed for going to a second screen while the program is running and then go back, but I'll see if it's possible to make something anyway.

Great, hope you can make it, though!
Title: Re: TimeTools
Post by: Builderboy on November 18, 2010, 01:31:28 am
This is sounding and looking great :) Great job!
Title: Re: TimeTools
Post by: ztrumpet on November 18, 2010, 01:09:27 pm
This looks cool.  Good luck getting 'settime' to work. :)
Title: Re: TimeTools
Post by: Munchor on November 18, 2010, 01:28:24 pm
This looks cool.  Good luck getting 'settime' to work. :)

That would be sweet :)
Title: Re: TimeTools
Post by: zzCoRRoDe on November 18, 2010, 01:30:32 pm
That looks very nice. If it was possible to make it on the TI-83+ it would be greatly appreciated.
Title: Re: TimeTools
Post by: ASHBAD_ALVIN on November 18, 2010, 01:36:04 pm
To make an accurate clock/timer on an 83+ you would need to utilize assembly by making an interrupt system that would constantly update the clock.  And then you would have to make sire nothing MESSES with that interrupt in the OS.  So it's possible, but not in a BASIC program.
Title: Re: TimeTools
Post by: zzCoRRoDe on November 18, 2010, 01:37:01 pm
Ah i see. Thanks man.
Title: Re: TimeTools
Post by: JosJuice on November 18, 2010, 03:17:55 pm
The analog clock is getting close to completion. Everything that's left are just some optimizations.
I'm making some progress on the set time function, but it's not usable yet. I might try to make a "countdown to" function after that, but the code was never designed for that so it's definitely going to be a bit tricky.
Title: Re: TimeTools
Post by: Munchor on November 18, 2010, 03:22:31 pm
The analog clock is getting close to completion. Everything that's left are just some optimizations.
I'm making some progress on the set time function, but it's not usable yet. I might try to make a "countdown to" function after that, but the code was never designed for that so it's definitely going to be a bit tricky.

Cool the analog is going good, it would be impossible for me :s
Title: Re: TimeTools
Post by: JosJuice on November 28, 2010, 01:18:47 pm
1.0 has been released (it's in the first post of the topic). The analog clock is completed, but the set time feature is not included in this version. I might make a 1.1 version that includes this, but I'm not too sure.
Title: Re: TimeTools
Post by: Munchor on November 29, 2010, 08:56:58 am
1.0 has been released (it's in the first post of the topic). The analog clock is completed, but the set time feature is not included in this version. I might make a 1.1 version that includes this, but I'm not too sure.

It would be cool! Make it easier than the 'Mode' button please.
Title: Re: TimeTools
Post by: JosJuice on November 29, 2010, 08:58:20 am
What do you mean by easier? The actual input of time and date is pretty simple... Is the problem that navigation to the correct menu item is required before the clock can be set? s:
Title: Re: TimeTools
Post by: Munchor on November 29, 2010, 09:03:16 am
What do you mean by easier? The actual input of time and date is pretty simple... Is the problem that navigation to the correct menu item is required before the clock can be set? s:

In Mode, you have to scroll down many options to set time, in your program that won't be needed, I hope. WAIT; THE ANALOG CLOCK IS FINISHED! Very well!
Title: Re: TimeTools
Post by: JosJuice on November 29, 2010, 09:08:01 am
The way I've planned it, pressing F4 will open the set time screen immediately (well, as immediately as things can be in TI-BASIC...)
Title: Re: TimeTools
Post by: Munchor on November 29, 2010, 09:08:50 am
The way I've planned it, pressing F4 will open the set time screen immediately (well, as immediately as things can be in TI-BASIC...)

Ohh, that's good as well! yeah, basic can't run that fast :(
Title: Re: TimeTools
Post by: JosJuice on April 20, 2011, 03:47:57 am
Here's version 1.1. I finished it a really long time ago, so I've forgotten what's new in this version... Probably just optimizations.

http://www.ticalc.org/archives/files/fileinfo/433/43347.html (http://www.ticalc.org/archives/files/fileinfo/433/43347.html)
Title: Re: TimeTools
Post by: Munchor on April 20, 2011, 09:36:31 am
Here's version 1.1. I finished it a really long time ago, so I've forgotten what's new in this version... Probably just optimizations.

http://www.ticalc.org/archives/files/fileinfo/433/43347.html (http://www.ticalc.org/archives/files/fileinfo/433/43347.html)

Thanks, this is a very cool project. Is there way the analog can move? Not sure if it can be done.
Title: Re: TimeTools
Post by: JosJuice on April 20, 2011, 09:44:51 am
Is there way the analog can move? Not sure if it can be done.
What do you mean by that?
Title: Re: TimeTools
Post by: Munchor on April 20, 2011, 09:46:01 am
Is there way the analog can move? Not sure if it can be done.
What do you mean by that?

When I run it, it displays the analog clock, but does it move while the program is running? When I tried V1.0 in my 84+ Keypad, I don't think it did. If you think it does, I'll try again.
Title: Re: TimeTools
Post by: JosJuice on April 20, 2011, 09:48:14 am
Is there way the analog can move? Not sure if it can be done.
What do you mean by that?

When I run it, it displays the analog clock, but does it move while the program is running? When I tried V1.0 in my 84+ Keypad, I don't think it did. If you think it does, I'll try again.
The analog clock should change every minute in both 1.0 and 1.1.
Title: Re: TimeTools
Post by: Munchor on April 20, 2011, 09:48:31 am
Is there way the analog can move? Not sure if it can be done.
What do you mean by that?

When I run it, it displays the analog clock, but does it move while the program is running? When I tried V1.0 in my 84+ Keypad, I don't think it did. If you think it does, I'll try again.
The analog clock should change every minute in both 1.0 and 1.1.

I'll try again then.

EDIT: Yes, it works! You just have to wait some time so that you can notice it of course.