Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 23:54 04 Oct 2022 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : ClockClock24

     Page 1 of 3    
Author Message
Bleep
Regular Member

Joined: 09/01/2022
Location: United Kingdom
Posts: 95
Posted: 02:18pm 25 Jul 2022
Copy link to clipboard 
Print this post


 
Attached is my implimintation of a ClockClock24, this is currently running on a PicoMite with a 480*340 ILI9481 LCD display, for which it has been optimised.
I am running the Pico at 378MHz because this gives the smoothest screen updates, it works fine down to around 126MHz, but the updates get more steppy. The animation is running at approx 5Hz, but will go faster if required by reducing the value of 'Const update' in the drawing loop. Otherwise if anyone has some ideas about improving the animation calculations, lots of big arrays to add or multiply, or more efficient ways of updating the display then please comment.
Looking at it now I should have done this a month earlier and entered it in the competition, :-) hindsight is a wonderful thing. :-(
Regards Kevin.

clockclock24.bas.zip
Edited 2022-07-27 18:42 by Bleep
 
Bleep
Regular Member

Joined: 09/01/2022
Location: United Kingdom
Posts: 95
Posted: 08:48am 27 Jul 2022
Copy link to clipboard 
Print this post

I have created a video of the ClockClock moving, if anyone interested, my next job is to add some of the symetrical animations. :-)
ClockClock in operation.
Regards, Kevin.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 8243
Posted: 09:10am 27 Jul 2022
Copy link to clipboard 
Print this post

Very clever and cute!  
Smoke makes things work. When the smoke gets out, it stops!
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 2992
Posted: 09:53am 27 Jul 2022
Copy link to clipboard 
Print this post

Oh, I like that. :)
It has a high Geek factor!
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
scruss
Regular Member

Joined: 20/09/2021
Location: Canada
Posts: 50
Posted: 01:57am 30 Jul 2022
Copy link to clipboard 
Print this post

… and several thousand dollars cheaper than the real thing: ClockClock 24 (black)
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2636
Posted: 04:49am 30 Jul 2022
Copy link to clipboard 
Print this post

Hi Kevin,

I just loaded it up and I love it.

A little CONSTRUCTIVE criticism/enhancements (from a terrible Non-Programmer) if I may be so bold to suggest.


A little colour would not go astray.
The update speed takes a little too long (~22s) even at 378000 KHz and is a little jerky.
The hands on the angled ones seem to be tending to be triangular instead of parallel like the 90degree ones.
Can the hands be made to be fully rectangular instead of like a fatter knob on a thinner arm?
Can we add something interesting in the blank area Top and Bottom (seconds counter?) Date maybe in smaller wheels?

Honestly seeing its written in basic its very impressive. Maybe this is a candidate for a C-SUB of C-FUNCtion? Not sure if thats even an option on the PicoMite.

Great job and I am sure it would have done very well in the Competition '22.

I can't wait to see you entry for Competition '23.

Kind regards,

Mick

EDIT **

Also what are the numbers that are printed to the console output?

MBG
Edited 2022-07-30 14:52 by bigmik
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2343
Posted: 12:19pm 30 Jul 2022
Copy link to clipboard 
Print this post

  bigmik said  The hands on the angled ones seem to be tending to be triangular instead of parallel like the 90degree ones.
Can the hands be made to be fully rectangular instead of like a fatter knob on a thinner arm?


Mick--as I discovered in making a wind speed dial, it's very hard to make non-triangular hands when the hands are not either vertical or horizontal. And I assume that that is why MMBasic doesn't have a BOX command which allows for the box to be on an angle.

Also--nice job, Kevin.

~
Edited 2022-07-30 22:20 by lizby
PicoMite on fruitoftheshed
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 678
Posted: 12:33pm 30 Jul 2022
Copy link to clipboard 
Print this post

Rotatable rectangles can be made from two skinny triangles that share one side.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2343
Posted: 01:01pm 30 Jul 2022
Copy link to clipboard 
Print this post

  phil99 said  Rotatable rectangles can be made from two skinny triangles that share one side.


I guess in MMBasic that would mean drawing two polygons (which were triangles)--still a non-trivial amount of calculation required.
PicoMite on fruitoftheshed
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2636
Posted: 02:09pm 30 Jul 2022
Copy link to clipboard 
Print this post

Hi Kevin, All,

Fair enough, I can see that the angled hands will never be the same as the 90 degree ones.

My critiques were just for suggestions.

Being an ordinary programmer I can’t always see the difficulty (or impossibility) of doing some things.

This clock has really hit a high point with me I just love it.

I have this clock permanently on in my ‘cave’.

I love it.

Did I say “I LOVE IT”?

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 6511
Posted: 02:53pm 30 Jul 2022
Copy link to clipboard 
Print this post

  Quote  I guess in MMBasic that would mean drawing two polygons (which were triangles)


Not difficult as per second hand in this

Option explicit
Option default integer
Dim integer small,nt=4 'Number of triangles being updated
Dim integer xx0(nt*2-1),yy0(nt*2-1),xx1(nt*2-1),yy1(nt*2-1)
dim integer xx2(nt*2-1),yy2(nt*2-1),tcol(nt*2-1),secs,mins,hours
CLS
small=MM.HRes:If MM.VRes < small Then small=MM.VRes
'RTC gettime
SetTick 600000,timecorrect
secs=Val(Right$(Time$,2))
mins=Val(Mid$(Time$,4,2))
hours=Val(Left$(Time$,2))
Do
secs=Val(Right$(Time$,2))
mins=Val(Mid$(Time$,4,2))
hours=Val(Left$(Time$,2))
hands(secs,mins,hours,(small\2-small\12),small\2, small\2)
Do
Loop While Val(Right$(Time$,2))=secs
Loop
End
'
Sub timecorrect
'  RTC gettime
End Sub

Sub hands(seconds , minutes ,  hours , size , x , y )
  Local integer x1,y1,x2,y2,x0,y0,i
  Local float angle=seconds*6
  rotate(2,RGB(RED),angle,x,y,-3,50,3,50,-3,-size)
'make up the second hand with two triangles
  rotate(3,RGB(RED),angle,x,y,3,-size,3,50,-3,-size)
  angle=minutes*6 + seconds/10
  rotate(0,RGB(BLUE),angle,x,y,-size/15,0,size/15,0,0,-size*0.8)
  angle=hours*30 + minutes/2
  rotate(1,RGB(GREEN),angle,x,y,-size/12,0,size/12,0,0,-size*0.5)
  Triangle xx0(), yy0(), xx1(), yy1(), xx2(), yy2() ,tcol(), tcol()
  Circle x,y, size\12, 0, , RGB(red), RGB(red))
  Circle x,y, size\15, 0, , 0, 0
  Circle x,y, size\20, 0, , RGB(gray), RGB(gray)
End Sub

Sub rotate(n , col , angle As float, x ,y , x0 , y0 , x1 , y1 , x2 , y2 )
 Local float sine=Sin(Rad(angle)),cosine=Cos(Rad(angle))
 Local integer x0a,y0a,x1a,y1a,x2a,y2a
 x0a= x0*cosine - y0 * sine + x
 y0a= y0*cosine + x0 * sine + y
 x1a= x1*cosine - y1 * sine + x
 y1a= y1*cosine + x1 * sine + y
 x2a= x2*cosine - y2 * sine + x
 y2a= y2*cosine + x2 * sine + y
 xx0(n)=xx0(n+nt)
 yy0(n)=yy0(n+nt)
 xx1(n)=xx1(n+nt)
 yy1(n)=yy1(n+nt)
 xx2(n)=xx2(n+nt)
 yy2(n)=yy2(n+nt)
 xx0(n+nt)=x0a
 yy0(n+nt)=y0a
 xx1(n+nt)=x1a
 yy1(n+nt)=y1a
 xx2(n+nt)=x2a
 yy2(n+nt)=y2a
 tcol(n)=0
 tcol(n+nt)=col
End Sub

Edited 2022-07-31 01:11 by matherp
 
Bleep
Regular Member

Joined: 09/01/2022
Location: United Kingdom
Posts: 95
Posted: 05:04pm 30 Jul 2022
Copy link to clipboard 
Print this post

Hi All,
As most of you have probably noticed this is an animation of 24 analogue clocks, which work in unison to produce a digital clock, usually with some nice extra animation between each minute, so the fact it takes 23 seconds to do the animation is all part of the effect. ;-) As I mentioned in my first post, you can make it faster, by removing the Pause at line 158, (9 seconds on my PicoMite, or 3.9 on the VGA).
Unfortunately I accidentally left one of my "Print timer" commands, where I was trying to optimise the speed, if you comment out the "Print timer" at line 157 that will get rid of the console output.
If you look at the code, you will see that I have done all the coding for both Triangular and Rectangular hands, using the Polygon command, however to do one frame, you have to first erase 48 clock hands, then draw back 48 new clock hands, doing this as a rectangle takes roughly a third more time and this is what causes the flicker, the time gap between erasing all the hands and re drawing all the hands, so rectangular hands do work, at the expense of more flicker. :-( Currently, flat out this is calculating the coordinates for and drawing about 1280 filled triangles 'and' 320 small filled circles a second, not bad for a Basic program! Presumably a PicoMiteVGA would be even faster, as it doesn't have the LCD communication bottle neck. (Ok I've just checked and it comes out at......calculating the coordinates for and drawing about 3000 filled triangles 'and' 730 small filled circles a second!!!)

Peter, for some reason I had missed the fact that you can batch up Triangles, like I have with the Polygons, so theoretically would using "Triangle" be quicker for triangular hands than using "Polygon"? Similarly, would drawing 2 triangles with "Triangle", instead of a rectangular "Polygon" be faster? I can modify the code to test, but that'll take me a while, so if you have a feeling for which would be quicker, that would potentially save me fruitless effort. :-)

As I said earlier, if anyone has any ideas for optimising, particularly the flicker between erasing and re-drawing all the hands, (maybe using Triangle, or something else) then please comment. :-)
Regards, Kevin.
Edited 2022-07-31 04:42 by Bleep
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2636
Posted: 11:15pm 30 Jul 2022
Copy link to clipboard 
Print this post

Hi Kevin,

I can see how easy it would be to bog down with this, so graphic intensive.

Simple idea with a very complex working.

Please do NOT take my words as anything but constructive. If you can implement easily enough then great if not… still great.

The one thing I do think it does need is colour but then that brings up a can of worms as everyone would like their own colour selections.

I will rem out the line 157 and try to remove or lower the pause. I actually love the effect so even 23 seconds is not a problem.
The concept of this clock is so unique it is a great talking point.

Keep up the great work

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1553
Posted: 12:04am 31 Jul 2022
Copy link to clipboard 
Print this post

Fantastic !!    Would it be possible to erase the hands on the clocks not in use instead of parking them at 7 o'clock.
Also if we had some colour as suggested by BIGMIK the colours could be CONSTANTS and could be changed by the user.
Very well done pity it is not in the competition.

Edit... I should have looked first the colours are there I will change them and see what I get.
Edited 2022-07-31 10:17 by palcal
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1553
Posted: 12:36am 31 Jul 2022
Copy link to clipboard 
Print this post

Changed the colours to Blue background and Yellow hands, looks great.
I tried putting the Date at the top but obviously it keeps getting erased.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 4907
Posted: 12:41am 31 Jul 2022
Copy link to clipboard 
Print this post

Comment out lines 8 and 48 and it runs in MMB4W

A good example of the portability of the code.

Well done.

Jim
VK7JH
MMedit   MMBasic Help
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1553
Posted: 12:52am 31 Jul 2022
Copy link to clipboard 
Print this post

Date works OK if put after CLS at line 55
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2636
Posted: 03:43am 31 Jul 2022
Copy link to clipboard 
Print this post

Lads,

Oh My,

After playing with the COLOURS (thanks Kevin you have put a lot of thought into this)
I love the Red background with Yellow hands and black outline.

IF you are after suggestions you could add a DS18B20 and use the top line to display temperature maybe with smaller circles. And Maybe the date on the bottom area but then you will need to cater for differences in display formats eg DD/MM/YY, YY/MM/DD etc etc.

You could also just update the number that is changing, maybe the flicker wont be as obvious then, however I feel that you will lose some of the impact that the entire screen changing gives.

I have a 3.5" ILI9488 that I tried super gluing the TFT glass down as it was assembled at an angle that I now have buggered up the touch because of it. I am going to dedicate that display to this as my `cave clock' Or is it CCC Cave-clock-clock

Regards,

Mick

EDIT ***

Oh what is the c.face colour for? It doesnt seem to do anything.

MBG
Edited 2022-07-31 13:46 by bigmik
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Bleep
Regular Member

Joined: 09/01/2022
Location: United Kingdom
Posts: 95
Posted: 09:30am 31 Jul 2022
Copy link to clipboard 
Print this post

Hi Everyone,
I have had some ideas on updating the hands. The main flicker is produced by erasing all the hands and then re-drawing all the hands, I think?  as fast as this is there is still a period with no hands. One thought is that I only update batches of 'say' six hands at a time, so the time between hands blanked & hands returned should be a quarter of what it is now, this may of course introduce other visual artifacts, but I could also potentially interleave the updates so they are spread out across the screen.
This will all be experimentation and may not have any noticeable effect, plus I'm unlikely to be able to do it till Monday.
I was looking at putting the date in somewhere, so I'll do that at the same time, both formats, with an option flag, maybe colour, if you insist. ;-)  
Regards Kevin
 
Bleep
Regular Member

Joined: 09/01/2022
Location: United Kingdom
Posts: 95
Posted: 01:54pm 01 Aug 2022
Copy link to clipboard 
Print this post




Ok an update, which I think has improved the animation quit a lot, there is still a sort of ripple, but I don't think I can improve on this. I have added the date which can be UK/US there is a constant called 'uk'; all the various colours are also defined in the same place and should be fairly obvious.
Because of the improvements to the animation I have gone to rectangular hands, which now animate in 2 Degree increments; at 378Mhz, I'm using a pause value udanm=80, 40 @ 276Mhz and 0 @ 126Mhz, this makes the animation last approx 30 seconds, change as you wish.
I have added a brightness subroutine, which allows touch screens to alter the brightness, Top Left for up, Bottom Left for down. This subroutine will also reduce the brightness at dusk and brighten it up at dawn, though you will need to alter the hour values depending on where you are, it also goes very dim at 11pm, sleep, because it's had a hard day. ;-)
That's about it I think.
Regards, Kevin.


clockclock24p.BAS.zip
Edited 2022-08-02 00:13 by Bleep
 
     Page 1 of 3    
Print this page
© JAQ Software 2022