Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By TassyJim
#35934 Here is an updated version.
It has been tested on a ESP-01 with 1M ram

I changed the maths a bit to display part minutes and part hours.
I also made one call to time() and used that result to get the hours and minutes.
If you make seperate calls to time() for hours and minutes it is possible to have misleading results if one call is just prior to the hour and the other call just after the hour.
instead of 14:59:59 you could have 14 hours and 0 minutes or 15 hours and 59 minutes etc.

I have also added a face to the clock.

Code: Select allonload [drawClock]
wprint "<meta http-equiv='refresh' content='5;URL=/input?'>"
print "Graphic Clock"
print
graphics 500 500
[drawClock]
gosub [dotime]
gcls
gosub [drawface]
gosub [drawhour]
gosub [drawminute]
wait

[drawhour]
x = myhour * 30
x = x / 57.29577951
xx = sin(x)
xx = xx * 150
xx = 250 + xx
yy = cos(x)
yy = yy * 150
yy = 250 - yy
line 250 250 xx yy
return

[drawminute]
x = mymin * 6
x = x / 57.29577951
xx = sin(x)
xx = xx * 200
xx = 250 + xx
yy = cos(x)
yy = yy * 200
yy = 250 - yy
line 250 250 xx yy 12
return

[drawface]
circle 250 250 210 3
circle 250 250 205 15
for t = 1 to 12
x = t * 30
x = x / 57.29577951
xx = sin(x)
xx = xx * 205
xx = 250 + xx
yy = cos(x)
yy = yy * 205
yy = 250 - yy
circle xx yy 4 3
next t
return

[dotime]
mytime = time()
myhour = mid(mytime,12,2)
mymin = mid(mytime,15,2)
mysec = mid(mytime,18,2)
partmin = mysec / 60
mymin = mymin + partmin
parthour = mymin / 60
myhour = myhour + parthour
return


Jim
User avatar
By Mmiscool
#35937 That is frigging awesome.

I never wood have imagined the graphics engine would be used this way. Simple graphs and stuff but a working animating clock.
You do not have the required permissions to view the files attached to this post.
User avatar
By cwilt
#35938 You beat me to it. Nice update. I would add memclear and timesetup to the top of the code.

I had no idea this would draw attention.