Author Topic: A clock...  (Read 5731 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
A clock...
« on: February 23, 2019, 06:14:04 pm »
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2.  
  3. DIM SHARED hourgear, minutegear, secondgear, center
  4. PRINT "Initializing clock..."
  5.  
  6. hourgear = DrawHourGear(&HFFFF00FF)
  7. minutegear = DrawMinuteGear(&HFFFFFF00)
  8. secondgear = DrawSecondGear(&HFF00FF00)
  9. center = CenterDisplay
  10.  
  11.     _LIMIT 60
  12.     CLS , 0
  13.     AssembleClock 80, 0, 560, _HEIGHT
  14.     ManualAdjustment
  15.     _DISPLAY
  16.  
  17.  
  18. SUB ManualAdjustment
  19.     SHARED Adjustment AS _FLOAT
  20.     A = 1
  21.     IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN A = 60
  22.     IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN A = 3600
  23.     k = _KEYHIT
  24.     SELECT CASE k
  25.         CASE 32 'space
  26.             Adjustment = 0
  27.         CASE 19200, 20480 'left / down
  28.             Adjustment = Adjustment - A
  29.         CASE 18332, 19712 'up / right
  30.             Adjustment = Adjustment + A
  31.         CASE 27 'escape to quite
  32.             SYSTEM
  33.     END SELECT
  34.  
  35. SUB AssembleClock (x1, y1, x2, y2)
  36.     SHARED Adjustment AS _FLOAT
  37.     d = _DEST
  38.     tempimage = _NEWIMAGE(480, 480, 32)
  39.     _DEST tempimage
  40.  
  41.     W = _WIDTH \ 2: h = _HEIGHT \ 2
  42.     IF W > h THEN R = h ELSE R = W
  43.  
  44.     t## = Adjustment + TIMER
  45.     hour = t## \ 3600
  46.     minute = (t## - hour * 3600) \ 60
  47.     second = t## - hour * 3600 - minute * 60
  48.     DisplayImage hourgear, 240, 240, hour * 30, 0
  49.     DisplayImage minutegear, 240, 240, minute * 6, 0
  50.     DisplayImage secondgear, 240, 240, second * 6, 0
  51.     DisplayImage center, 240, 240, 0, 0
  52.     _DEST d
  53.     _PUTIMAGE (x1, y1)-(x2, y2), tempimage, d, (0, 0)-(479, 479)
  54.     _FREEIMAGE tempimage
  55.     _DEST d
  56.  
  57.  
  58. FUNCTION CenterDisplay
  59.     STATIC oldmm
  60.     d = _DEST
  61.     OldFont = _FONT
  62.  
  63.     CenterDisplay = _NEWIMAGE(175, 100, 32)
  64.     _DEST CenterDisplay
  65.     F = _LOADFONT("courbd.ttf", 24)
  66.     F1 = _LOADFONT("courbd.ttf", 30)
  67.     IF F > 0 THEN _FONT F ELSE _FONT 16
  68.     CLS
  69.     d$ = DATE$
  70.     SELECT CASE LEFT$(d$, 2)
  71.         CASE "01": month$ = "JAN"
  72.         CASE "02": month$ = "FEB"
  73.         CASE "03": month$ = "MAR"
  74.         CASE "04": month$ = "APR"
  75.         CASE "05": month$ = "MAY"
  76.         CASE "06": month$ = "JUN"
  77.         CASE "07": month$ = "JUL"
  78.         CASE "08": month$ = "AUG"
  79.         CASE "09": month$ = "SEP"
  80.         CASE "10": month$ = "OCT"
  81.         CASE "11": month$ = "NOV"
  82.         CASE "12": month$ = "DEC"
  83.     END SELECT
  84.     mm = VAL(LEFT$(d$, 2))
  85.     dd = VAL(MID$(d$, 4))
  86.     yy = VAL(RIGHT$(d$, 4))
  87.     PRINT month$; " "; MID$(d$, 4, 2); ", "; RIGHT$(d$, 4);
  88.     day$ = GetDay$(mm, dd, yy)
  89.  
  90.     IF F1 > 0 THEN SafeLoadFont F1 ELSE SafeLoadFont 16
  91.     day$ = "Wednesday"
  92.     s$ = SPACE$((10 - LEN(day$)) \ 2)
  93.     PRINT s$ + day$;
  94.     _FONT 16
  95.     IF F > 0 THEN _FREEFONT F
  96.     IF F1 > 0 THEN _FREEFONT F1
  97.  
  98.     IF oldmm <> mm THEN 'try to update the weather every minute
  99.         rss$ = DownloadRSS("http://rss.wunderground.com/q/zmw:24138.1.99999", 5)
  100.         '<meta property="og:title" content="Pilot, VA | 37.2&deg; | Overcast" />
  101.         t$ = "<meta property=" + CHR$(34) + "og:title" + CHR$(34) + " content=" + CHR$(34)
  102.         l = INSTR(rss$, t$)
  103.         endl = INSTR(l, rss$, "/>")
  104.         temp$ = MID$(rss$, l + LEN(t$), endl - l)
  105.         _FONT 8
  106.         fs = INSTR(temp$, "|")
  107.         ss = INSTR(fs + 1, temp$, "|")
  108.         el = INSTR(ss + 1, temp$, CHR$(34))
  109.         city$ = LEFT$(temp$, fs - 1)
  110.         temp = VAL(MID$(temp$, fs + 1))
  111.         condition$ = MID$(temp$, ss + 1, el - ss - 1)
  112.         LOCATE 9, 1
  113.         PRINT city$; temp; condition$;
  114.         oldmm = mm
  115.     END IF
  116.     _FONT 16
  117.     _DEST d
  118.  
  119. FUNCTION DrawHourGear (Kolor AS _UNSIGNED LONG)
  120.     D = _DEST
  121.     DrawHourGear = _NEWIMAGE(640, 480, 32)
  122.     _DEST DrawHourGear
  123.     OldFont = _FONT
  124.     W = _WIDTH \ 2: h = _HEIGHT \ 2
  125.     F = _LOADFONT("OLDENGL.TTF", 48)
  126.     IF F > 0 THEN _FONT F ELSE _FONT 16
  127.     IF W > h THEN R = h - 1 ELSE R = W - 1
  128.     FH = _FONTHEIGHT \ 2
  129.     CircleFill W, h, R, Kolor
  130.     COLOR &HFF000000, 0
  131.     FOR i = 1 TO 12
  132.         X = W + R * .9 * COS(_D2R(i * 30 - 90))
  133.         Y = h + R * .9 * SIN(_D2R(i * 30 - 90))
  134.         t$ = _TRIM$(STR$(i))
  135.         tempimage = TextToImage&(t$, F, &HFF000000, 0, 0)
  136.         DisplayImage tempimage, X, Y, -i * 30, 0
  137.         _FREEIMAGE tempimage
  138.     NEXT
  139.     _FONT OldFont
  140.     IF F > 0 THEN _FREEFONT F
  141.     'CircleFill W, H, 10, &HFF000000
  142.     _DEST D
  143.  
  144.  
  145. FUNCTION DrawMinuteGear (Kolor AS _UNSIGNED LONG)
  146.     D = _DEST
  147.     DrawMinuteGear = _NEWIMAGE(640, 480, 32)
  148.     _DEST DrawMinuteGear
  149.     OldFont = _FONT
  150.     W = _WIDTH \ 2: h = _HEIGHT \ 2
  151.     F = _LOADFONT("OLDENGL.TTF", 18)
  152.     IF F > 0 THEN _FONT F ELSE _FONT 16
  153.     IF W > h THEN R = h * .8 ELSE R = W * .8
  154.     FH = _FONTHEIGHT \ 2
  155.     CircleFill W, h, R, Kolor
  156.     COLOR &HFF000000, 0
  157.     FOR i = 0 TO 59
  158.         X = W + R * .9 * COS(_D2R(i * 6 - 90))
  159.         Y = h + R * .9 * SIN(_D2R(i * 6 - 90))
  160.         t$ = _TRIM$(STR$(i \ 10))
  161.         tempimage = TextToImage&(t$, F, &HFF000000, 0, 0)
  162.         DisplayImage tempimage, X, Y, -i * 6, 0
  163.         _FREEIMAGE tempimage
  164.         X = W + R * .8 * COS(_D2R(i * 6 - 90))
  165.         Y = h + R * .8 * SIN(_D2R(i * 6 - 90))
  166.         t$ = _TRIM$(STR$(i MOD 10))
  167.         tempimage = TextToImage&(t$, F, &HFF000000, 0, 0)
  168.         DisplayImage tempimage, X, Y, -i * 6, 0
  169.         _FREEIMAGE tempimage
  170.     NEXT
  171.     _FONT OldFont
  172.     IF F > 0 THEN _FREEFONT F
  173.     'CircleFill W, H, 10, &HFF000000
  174.     _DEST D
  175.  
  176.  
  177.  
  178. FUNCTION DrawSecondGear (Kolor AS _UNSIGNED LONG)
  179.     D = _DEST
  180.     DrawSecondGear = _NEWIMAGE(640, 480, 32)
  181.     _DEST DrawSecondGear
  182.     OldFont = _FONT
  183.     W = _WIDTH \ 2: h = _HEIGHT \ 2
  184.     F = _LOADFONT("OLDENGL.TTF", 18)
  185.     IF F > 0 THEN _FONT F ELSE _FONT 16
  186.     IF W > h THEN R = h * .6 ELSE R = W * .6
  187.     FH = _FONTHEIGHT \ 2
  188.     CircleFill W, h, R, Kolor
  189.     COLOR &HFF000000, 0
  190.     FOR i = 0 TO 59
  191.         X = W + R * .9 * COS(_D2R(i * 6 - 90))
  192.         Y = h + R * .9 * SIN(_D2R(i * 6 - 90))
  193.         t$ = _TRIM$(STR$(i \ 10))
  194.         tempimage = TextToImage&(t$, F, &HFF000000, 0, 0)
  195.         DisplayImage tempimage, X, Y, -i * 6, 0
  196.         _FREEIMAGE tempimage
  197.         X = W + R * .8 * COS(_D2R(i * 6 - 90))
  198.         Y = h + R * .8 * SIN(_D2R(i * 6 - 90))
  199.         t$ = _TRIM$(STR$(i MOD 10))
  200.         tempimage = TextToImage&(t$, F, &HFF000000, 0, 0)
  201.         DisplayImage tempimage, X, Y, -i * 6, 0
  202.         _FREEIMAGE tempimage
  203.     NEXT
  204.     _FONT OldFont
  205.     'CircleFill W, H, 10, &HFF000000
  206.     _DEST D
  207.  
  208.  
  209. SUB CircleFill (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  210.     ' CX = center x coordinate
  211.     ' CY = center y coordinate
  212.     '  R = radius
  213.     '  C = fill color
  214.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  215.     DIM X AS INTEGER, Y AS INTEGER
  216.     Radius = ABS(R)
  217.     RadiusError = -Radius
  218.     X = Radius
  219.     Y = 0
  220.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  221.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  222.     WHILE X > Y
  223.         RadiusError = RadiusError + Y * 2 + 1
  224.         IF RadiusError >= 0 THEN
  225.             IF X <> Y + 1 THEN
  226.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  227.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  228.             END IF
  229.             X = X - 1
  230.             RadiusError = RadiusError - X * 2
  231.         END IF
  232.         Y = Y + 1
  233.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  234.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  235.     WEND
  236.  
  237. SUB DisplayImage (Image AS LONG, x AS INTEGER, y AS INTEGER, angle AS SINGLE, mode AS _BYTE)
  238.     'Image is the image handle which we use to reference our image.
  239.     'x,y is the X/Y coordinates where we want the image to be at on the screen.
  240.     'angle is the angle which we wish to rotate the image.
  241.     'mode determines HOW we place the image at point X,Y.
  242.     'Mode 0 we center the image at point X,Y
  243.     'Mode 1 we place the Top Left corner of oour image at point X,Y
  244.     'Mode 2 is Bottom Left
  245.     'Mode 3 is Top Right
  246.     'Mode 4 is Bottom Right
  247.  
  248.  
  249.     DIM px(3) AS INTEGER, py(3) AS INTEGER, w AS INTEGER, h AS INTEGER
  250.     DIM sinr AS SINGLE, cosr AS SINGLE, i AS _BYTE
  251.     w = _WIDTH(Image): h = _HEIGHT(Image)
  252.     SELECT CASE mode
  253.         CASE 0 'center
  254.             px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2
  255.             px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
  256.         CASE 1 'top left
  257.             px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
  258.             px(1) = 0: py(1) = h: px(2) = w: py(2) = h
  259.         CASE 2 'bottom left
  260.             px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
  261.             px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
  262.         CASE 3 'top right
  263.             px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
  264.             px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
  265.         CASE 4 'bottom right
  266.             px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
  267.             px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
  268.     END SELECT
  269.     sinr = SIN(angle / 57.2957795131): cosr = COS(angle / 57.2957795131)
  270.     FOR i = 0 TO 3
  271.         x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
  272.         px(i) = x2: py(i) = y2
  273.     NEXT
  274.     _MAPTRIANGLE (0, 0)-(0, h - 1)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
  275.     _MAPTRIANGLE (0, 0)-(w - 1, 0)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
  276.  
  277. FUNCTION TextToImage& (text$, font&, fc&, bfc&, mode AS _BYTE)
  278.     'text$ is the text that we wish to transform into an image.
  279.     'font& is the handle of the font we want to use.
  280.     'fc& is the color of the font we want to use.
  281.     'bfc& is the background color of the font.
  282.  
  283.     'Mode 1 is print forwards
  284.     'Mode 2 is print backwards
  285.     'Mode 3 is print from top to bottom
  286.     'Mode 4 is print from bottom up
  287.     'Mode 0 got lost somewhere, but it's OK.  We check to see if our mode is < 1 or > 4 and compensate automatically if it is to make it one (default).
  288.  
  289.     IF mode < 1 OR mode > 4 THEN mode = 1
  290.     dc& = _DEFAULTCOLOR: bgc& = _BACKGROUNDCOLOR
  291.     D = _DEST
  292.     F = _FONT
  293.     IF font& <> 0 THEN _FONT font&
  294.     IF mode < 3 THEN
  295.         'print the text lengthwise
  296.         w& = _PRINTWIDTH(text$): h& = _FONTHEIGHT
  297.     ELSE
  298.         'print the text vertically
  299.         FOR i = 1 TO LEN(text$)
  300.             IF w& < _PRINTWIDTH(MID$(text$, i, 1)) THEN w& = _PRINTWIDTH(MID$(text$, i, 1))
  301.         NEXT
  302.         h& = _FONTHEIGHT * (LEN(text$))
  303.     END IF
  304.  
  305.     TextToImage& = _NEWIMAGE(w&, h&, 32)
  306.     _DEST TextToImage&
  307.     IF font& <> 0 THEN _FONT font&
  308.     COLOR fc&, bfc&
  309.  
  310.     SELECT CASE mode
  311.         CASE 1
  312.             'Print text forward
  313.             _PRINTSTRING (0, 0), text$
  314.         CASE 2
  315.             'Print text backwards
  316.             temp$ = ""
  317.             FOR i = 0 TO LEN(text$) - 1
  318.                 temp$ = temp$ + MID$(text$, LEN(text$) - i, 1)
  319.             NEXT
  320.             _PRINTSTRING (0, 0), temp$
  321.         CASE 3
  322.             'Print text upwards
  323.             'first lets reverse the text, so it's easy to place
  324.             temp$ = ""
  325.             FOR i = 0 TO LEN(text$) - 1
  326.                 temp$ = temp$ + MID$(text$, LEN(text$) - i, 1)
  327.             NEXT
  328.             'then put it where it belongs
  329.             FOR i = 1 TO LEN(text$)
  330.                 fx = (w& - _PRINTWIDTH(MID$(temp$, i, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better
  331.                 _PRINTSTRING (fx, _FONTHEIGHT * (i - 1)), MID$(temp$, i, 1)
  332.             NEXT
  333.         CASE 4
  334.             'Print text downwards
  335.             FOR i = 1 TO LEN(text$)
  336.                 fx = (w& - _PRINTWIDTH(MID$(text$, i, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better
  337.                 _PRINTSTRING (fx, _FONTHEIGHT * (i - 1)), MID$(text$, i, 1)
  338.             NEXT
  339.     END SELECT
  340.     _DEST D
  341.     COLOR dc&, bgc&
  342.     _FONT F
  343.  
  344. FUNCTION GetDay$ (mm, dd, yyyy) 'use 4 digit year
  345.     'From Zeller's congruence: https://en.wikipedia.org/wiki/Zeller%27s_congruence
  346.     IF mm < 3 THEN mm = mm + 12: yyyy = yyyy - 1
  347.     century = yyyy MOD 100
  348.     zerocentury = yyyy \ 100
  349.     result = (dd + INT(13 * (mm + 1) / 5) + century + INT(century / 4) + INT(zerocentury / 4) + 5 * zerocentury) MOD 7
  350.     SELECT CASE result
  351.         CASE 0: GetDay$ = "Saturday"
  352.         CASE 1: GetDay$ = "Sunday"
  353.         CASE 2: GetDay$ = "Monday"
  354.         CASE 3: GetDay$ = "Tuesday"
  355.         CASE 4: GetDay$ = "Wednesday"
  356.         CASE 5: GetDay$ = "Thursday"
  357.         CASE 6: GetDay$ = "Friday"
  358.     END SELECT
  359.  
  360. SUB SafeLoadFont (font#)
  361.     'Safely loads a font without destroying our current print location and making it revert to the top left corner.
  362.  
  363.     down = CSRLIN: right = POS(0)
  364.     down = (down - 1) * _FONTHEIGHT
  365.     IF _FONTWIDTH <> 0 THEN 'weed start with a monospace font
  366.         right = (right - 1) * _PRINTWIDTH(" ") 'convert the monospace LOC to a graphic X coordinate
  367.     END IF
  368.     _FONT font#
  369.     IF _FONTWIDTH <> 0 THEN 'we swapped to a monospace font
  370.         right = (right / _PRINTWIDTH(" ")) + 1 'convert the graphic X coordinate back to a monospace LOC column
  371.     END IF
  372.     down = (down / _FONTHEIGHT) + 1
  373.     IF right < 1 THEN right = 1
  374.     LOCATE down, right
  375.  
  376. FUNCTION DownloadRSS$ (url$, timelimit)
  377.     link$ = url$
  378.     url2$ = RTRIM$(LTRIM$(link$))
  379.     url4$ = RTRIM$(LTRIM$(link$))
  380.     IF LEFT$(UCASE$(url2$), 7) = "HTTP://" THEN url4$ = MID$(url2$, 8)
  381.     x = INSTR(url4$, "/")
  382.     IF x THEN url2$ = LEFT$(url4$, x - 1)
  383.     NewsClient = _OPENCLIENT("TCP/IP:80:" + url2$)
  384.     IF NewsClient = 0 THEN EXIT FUNCTION
  385.     e$ = CHR$(13) + CHR$(10) ' end of line characters
  386.     url3$ = RIGHT$(url4$, LEN(url4$) - x + 1)
  387.     x$ = "GET " + url3$ + " HTTP/1.1" + e$
  388.     x$ = x$ + "Host: " + url2$ + e$ + e$
  389.     PUT #NewsClient, , x$
  390.  
  391.     t! = TIMER ' start time
  392.     head$ = ""
  393.     cont_type$ = ""
  394.     DO
  395.         _LIMIT 20
  396.         GET #NewsClient, , a$
  397.         IF LTRIM$(a$) > "" THEN final$ = final$ + a$
  398.         IF INSTR(a$, "</html>") THEN EXIT DO 'we hit the end of the file
  399.     LOOP UNTIL TIMER > t! + timelimit AND timelimit > 0 ' (in seconds)
  400.  
  401.     DownloadRSS$ = final$

Something a little different -- a clock which is nice enough to tell you time, date, day, and current weather conditions for my house.   

Change the line which reads rss$ = DownloadRSS("http://rss.wunderground.com/q/zmw:24138.1.99999", 5) so that the link points to your house, and you can have it tell you your current weather conditions instead.

Takes a few seconds to connect to the weather service at startup, but doesn't appear to have any issues with lag or such after.  (At least on my system, it doesn't.)  Truly, this could probably use an ON TIMER event to update the RSS feed every few moments and not disrupt the actual program itself, but who has time to sort all that out?  :P

Enjoy it as it is and have fun playing around with it.  Maybe there's something in there that other folks can use/recycle for their own projects in the future.  Code is free to use, abuse, copy, steal, and sale, with no permission and no credits needed. 

To get the weather link for your own area, just go to https://rss.wunderground.com/  Do a search, and copy the link which appears in your browser after several sloooow seconds.  (Weather Underground seems to have a serious lag to it, from my house, taking upwards of 5 - 10 seconds to get the proper weather information for me.)
Clock.jpg
* Clock.jpg (Filesize: 75.82 KB, Dimensions: 646x509, Views: 335)
« Last Edit: February 23, 2019, 06:19:05 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: A clock...
« Reply #1 on: February 23, 2019, 07:25:12 pm »
Have you considered adding an alarm feature? http://d2ydh70d4b5xgv.cloudfront.net/images/5/9/metal-scroll-rooster-shaped-wall-clock-french-country-farm-home-kitchen-decor-46d9da88588ec33072215da9256d5db4.jpg

Add that, and even your lovingunclebert would be proud, well maybe not him, but...

I like the weather update amalgam, clever! It took me a minute to figure out how to tell time with it, well, actually, according to the clock, it took me about 47 seconds. Fun playing with arrow keys to go forwards and backwards through time. Y0u might want to remind people they need that oldenglish.ttf font to run it.

One thing that surprised me is my IDE was OK with the last function, which you ended with END SUB instead of END FUNCTION. I changed that before I compiled it, but I played around with a program I was working on and noticed END SUB and END FUNCTION can be mixed up and still work. I find that odd, but oh well...

Fun program, even without a morning rooster. Now if you will excuse me, your clock is advising me that it will get down to 50 tonight. I have to change into a warmer tee-shirt.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: A clock...
« Reply #2 on: February 23, 2019, 08:03:45 pm »
Purple is hours, Yellow is minutes, and Green is seconds; just read up to down from the “12 o’clock position). 

END SUB and END FUNCTION are interchangeable as far as QB64 is concerned.  Often I’ll change my mind on what I want to use, so I start with one and swap to the other and then forget to change the end statement to match. 

I might go in and add an alarm feature for you later, but first should probably be a background download routine instead of what we currently have.  I’ll play around and see what I can come up with for it later.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: A clock...
« Reply #3 on: February 25, 2019, 06:32:37 pm »
Hi Steve
very fine clock

two questions:
1.
 is there a version with an alarm?
2.
how can I get it working on my TOSHIBA with QB64 dev version e490b1a?
I have got a cicle between error on line 304 and error on line 318 related to font management.
Here an attachment.
Thanks to share
a clock by Steve.png
* a clock by Steve.png (Filesize: 31.58 KB, Dimensions: 1042x719, Views: 357)
Programming isn't difficult, only it's  consuming time and coffee

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: A clock...
« Reply #4 on: February 25, 2019, 06:44:37 pm »
See Steve, I told you not including a link to that Old English Font would bite you in the ascii.

Steve is working on adding a rooster alarm. Stay tuned for Steve's cock clock, any day now.

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: A clock...
« Reply #5 on: February 26, 2019, 09:52:57 am »
Hi Steve
very fine clock

two questions:
1.
 is there a version with an alarm?
2.
how can I get it working on my TOSHIBA with QB64 dev version e490b1a?
I have got a cicle between error on line 304 and error on line 318 related to font management.
Here an attachment.
Thanks to share

1) No alarm yet, but I might add one in the near future.  ;)

2) Easiest solution is to download OLDENGL.ttf from the web and put it with the program so it looks all nice and pretty.  Second easiest solution is to change that line to IF font& > 0 THEN...

Somehow, I was thinking QB64 returned 0 as a failed handle for a font, and it doesn't.  Instead, it returns values > 0, according to _LOADFONT: https://qb64.org/wiki/LOADFONT

A new version should be coming soon(tm) which offers background downloading and stops the issues with the initial lag at startup.  I'll address the font <> 0 glitch then for us, as well.  :)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: A clock...
« Reply #6 on: February 26, 2019, 11:03:13 am »
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2.  
  3. DIM SHARED hourgear, minutegear, secondgear, center
  4. DIM SHARED Cour24, Cour30, OE48, OE18 'shared fonts
  5.  
  6. Cour24 = _LOADFONT("courbd.ttf", 24)
  7. Cour30 = _LOADFONT("courbd.ttf", 30)
  8. OE48 = _LOADFONT("OLDENGL.TTF", 48)
  9. OE18 = _LOADFONT("OLDENGL.TTF", 18)
  10.  
  11. PRINT "Initializing clock..."
  12.  
  13. hourgear = DrawHourGear(&HFFFF00FF)
  14. minutegear = DrawMinuteGear(&HFFFFFF00)
  15. secondgear = DrawSecondGear(&HFF00FF00)
  16. center = CenterDisplay
  17.  
  18.     _LIMIT 120
  19.     CLS , 0
  20.     AssembleClock 80, 0, 560, _HEIGHT
  21.     ManualAdjustment
  22.     _DISPLAY
  23.  
  24.  
  25. SUB ManualAdjustment
  26.     SHARED Adjustment AS _FLOAT
  27.     A = 1
  28.     IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN A = 60
  29.     IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN A = 3600
  30.     k = _KEYHIT
  31.     SELECT CASE k
  32.         CASE 32 'space
  33.             Adjustment = 0
  34.         CASE 19200, 20480 'left / down
  35.             Adjustment = Adjustment - A
  36.         CASE 18332, 19712 'up / right
  37.             Adjustment = Adjustment + A
  38.         CASE 27 'escape to quite
  39.             SYSTEM
  40.     END SELECT
  41.  
  42. SUB AssembleClock (x1, y1, x2, y2)
  43.     SHARED Adjustment AS _FLOAT
  44.     d = _DEST
  45.     tempimage = _NEWIMAGE(480, 480, 32)
  46.     _DEST tempimage
  47.  
  48.     W = _WIDTH \ 2: h = _HEIGHT \ 2
  49.     IF W > h THEN R = h ELSE R = W
  50.  
  51.     t## = Adjustment + TIMER
  52.     hour = t## \ 3600
  53.     minute = (t## - hour * 3600) \ 60
  54.     second = t## - hour * 3600 - minute * 60
  55.     DisplayImage hourgear, 240, 240, hour * 30, 0
  56.     DisplayImage minutegear, 240, 240, minute * 6, 0
  57.     DisplayImage secondgear, 240, 240, second * 6, 0
  58.     center = CenterDisplay
  59.     DisplayImage center, 240, 240, 0, 0
  60.     _DEST d
  61.     _PUTIMAGE (x1, y1)-(x2, y2), tempimage, d, (0, 0)-(479, 479)
  62.     _FREEIMAGE tempimage
  63.     _DEST d
  64.  
  65.  
  66. FUNCTION CenterDisplay
  67.     STATIC oldmm, rss$
  68.     d = _DEST
  69.  
  70.     d$ = DATE$
  71.     SELECT CASE LEFT$(d$, 2)
  72.         CASE "01": month$ = "JAN"
  73.         CASE "02": month$ = "FEB"
  74.         CASE "03": month$ = "MAR"
  75.         CASE "04": month$ = "APR"
  76.         CASE "05": month$ = "MAY"
  77.         CASE "06": month$ = "JUN"
  78.         CASE "07": month$ = "JUL"
  79.         CASE "08": month$ = "AUG"
  80.         CASE "09": month$ = "SEP"
  81.         CASE "10": month$ = "OCT"
  82.         CASE "11": month$ = "NOV"
  83.         CASE "12": month$ = "DEC"
  84.     END SELECT
  85.     mm = VAL(LEFT$(d$, 2))
  86.     dd = VAL(MID$(d$, 4))
  87.     yy = VAL(RIGHT$(d$, 4))
  88.  
  89.     IF oldmm <> mm THEN 'try to update the weather every minute
  90.         IF center THEN _FREEIMAGE center
  91.         CenterDisplay = _NEWIMAGE(175, 100, 32)
  92.         _DEST CenterDisplay
  93.         CLS
  94.         IF Cour24 > 0 THEN _FONT Cour24 ELSE _FONT 16
  95.         PRINT month$; " "; MID$(d$, 4, 2); ", "; RIGHT$(d$, 4);
  96.         day$ = GetDay$(mm, dd, yy)
  97.  
  98.         IF Cour30 > 0 THEN SafeLoadFont Cour30 ELSE SafeLoadFont 16
  99.         day$ = "Wednesday"
  100.         s$ = SPACE$((10 - LEN(day$)) \ 2)
  101.         PRINT s$ + day$;
  102.         _FONT 16
  103.  
  104.         rss$ = DownloadRSS("http://rss.wunderground.com/q/zmw:24138.1.99999", 5)
  105.         '<meta property="og:title" content="Pilot, VA | 37.2&deg; | Overcast" />
  106.         t$ = "<meta property=" + CHR$(34) + "og:title" + CHR$(34) + " content=" + CHR$(34)
  107.         l = INSTR(rss$, t$)
  108.         endl = INSTR(l, rss$, "/>")
  109.         temp$ = MID$(rss$, l + LEN(t$), endl - l)
  110.         _FONT 8
  111.         fs = INSTR(temp$, "|")
  112.         ss = INSTR(fs + 1, temp$, "|")
  113.         el = INSTR(ss + 1, temp$, CHR$(34))
  114.         IF fs AND ss AND el THEN
  115.             city$ = LEFT$(temp$, fs - 1)
  116.             temp = VAL(MID$(temp$, fs + 1))
  117.             condition$ = MID$(temp$, ss + 1, el - ss - 1)
  118.             LOCATE 9, 1
  119.             PRINT city$; temp; condition$;
  120.         END IF
  121.  
  122.         _FONT 16
  123.  
  124.         oldmm = mm
  125.     END IF
  126.  
  127.     _DEST d
  128.  
  129. FUNCTION DrawHourGear (Kolor AS _UNSIGNED LONG)
  130.     D = _DEST
  131.     DrawHourGear = _NEWIMAGE(640, 480, 32)
  132.     _DEST DrawHourGear
  133.  
  134.     W = _WIDTH \ 2: h = _HEIGHT \ 2
  135.  
  136.     IF W > h THEN R = h - 1 ELSE R = W - 1
  137.     FH = _FONTHEIGHT \ 2
  138.     CircleFill W, h, R, Kolor
  139.     COLOR &HFF000000, 0
  140.     FOR i = 1 TO 12
  141.         X = W + R * .9 * COS(_D2R(i * 30 - 90))
  142.         Y = h + R * .9 * SIN(_D2R(i * 30 - 90))
  143.         t$ = _TRIM$(STR$(i))
  144.         tempimage = TextToImage&(t$, OE48, &HFF000000, 0, 0)
  145.         DisplayImage tempimage, X, Y, -i * 30, 0
  146.         _FREEIMAGE tempimage
  147.     NEXT
  148.  
  149.     'CircleFill W, H, 10, &HFF000000
  150.     _DEST D
  151.  
  152.  
  153. FUNCTION DrawMinuteGear (Kolor AS _UNSIGNED LONG)
  154.     D = _DEST
  155.     DrawMinuteGear = _NEWIMAGE(640, 480, 32)
  156.     _DEST DrawMinuteGear
  157.     W = _WIDTH \ 2: h = _HEIGHT \ 2
  158.  
  159.     IF W > h THEN R = h * .8 ELSE R = W * .8
  160.     FH = _FONTHEIGHT \ 2
  161.     CircleFill W, h, R, Kolor
  162.     COLOR &HFF000000, 0
  163.     FOR i = 0 TO 59
  164.         X = W + R * .9 * COS(_D2R(i * 6 - 90))
  165.         Y = h + R * .9 * SIN(_D2R(i * 6 - 90))
  166.         t$ = _TRIM$(STR$(i \ 10))
  167.         tempimage = TextToImage&(t$, OE18, &HFF000000, 0, 0)
  168.         DisplayImage tempimage, X, Y, -i * 6, 0
  169.         _FREEIMAGE tempimage
  170.         X = W + R * .8 * COS(_D2R(i * 6 - 90))
  171.         Y = h + R * .8 * SIN(_D2R(i * 6 - 90))
  172.         t$ = _TRIM$(STR$(i MOD 10))
  173.         tempimage = TextToImage&(t$, OE18, &HFF000000, 0, 0)
  174.         DisplayImage tempimage, X, Y, -i * 6, 0
  175.         _FREEIMAGE tempimage
  176.     NEXT
  177.  
  178.     'CircleFill W, H, 10, &HFF000000
  179.     _DEST D
  180.  
  181.  
  182.  
  183. FUNCTION DrawSecondGear (Kolor AS _UNSIGNED LONG)
  184.     D = _DEST
  185.     DrawSecondGear = _NEWIMAGE(640, 480, 32)
  186.     _DEST DrawSecondGear
  187.     W = _WIDTH \ 2: h = _HEIGHT \ 2
  188.  
  189.     IF W > h THEN R = h * .6 ELSE R = W * .6
  190.     FH = _FONTHEIGHT \ 2
  191.     CircleFill W, h, R, Kolor
  192.     COLOR &HFF000000, 0
  193.     FOR i = 0 TO 59
  194.         X = W + R * .9 * COS(_D2R(i * 6 - 90))
  195.         Y = h + R * .9 * SIN(_D2R(i * 6 - 90))
  196.         t$ = _TRIM$(STR$(i \ 10))
  197.         tempimage = TextToImage&(t$, OE18, &HFF000000, 0, 0)
  198.         DisplayImage tempimage, X, Y, -i * 6, 0
  199.         _FREEIMAGE tempimage
  200.         X = W + R * .8 * COS(_D2R(i * 6 - 90))
  201.         Y = h + R * .8 * SIN(_D2R(i * 6 - 90))
  202.         t$ = _TRIM$(STR$(i MOD 10))
  203.         tempimage = TextToImage&(t$, F, &HFF000000, 0, 0)
  204.         DisplayImage tempimage, X, Y, -i * 6, 0
  205.         _FREEIMAGE tempimage
  206.     NEXT
  207.  
  208.     'CircleFill W, H, 10, &HFF000000
  209.     _DEST D
  210.  
  211.  
  212. SUB CircleFill (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  213.     ' CX = center x coordinate
  214.     ' CY = center y coordinate
  215.     '  R = radius
  216.     '  C = fill color
  217.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  218.     DIM X AS INTEGER, Y AS INTEGER
  219.     Radius = ABS(R)
  220.     RadiusError = -Radius
  221.     X = Radius
  222.     Y = 0
  223.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  224.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  225.     WHILE X > Y
  226.         RadiusError = RadiusError + Y * 2 + 1
  227.         IF RadiusError >= 0 THEN
  228.             IF X <> Y + 1 THEN
  229.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  230.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  231.             END IF
  232.             X = X - 1
  233.             RadiusError = RadiusError - X * 2
  234.         END IF
  235.         Y = Y + 1
  236.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  237.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  238.     WEND
  239.  
  240. SUB DisplayImage (Image AS LONG, x AS INTEGER, y AS INTEGER, angle AS SINGLE, mode AS _BYTE)
  241.     'Image is the image handle which we use to reference our image.
  242.     'x,y is the X/Y coordinates where we want the image to be at on the screen.
  243.     'angle is the angle which we wish to rotate the image.
  244.     'mode determines HOW we place the image at point X,Y.
  245.     'Mode 0 we center the image at point X,Y
  246.     'Mode 1 we place the Top Left corner of oour image at point X,Y
  247.     'Mode 2 is Bottom Left
  248.     'Mode 3 is Top Right
  249.     'Mode 4 is Bottom Right
  250.  
  251.  
  252.     DIM px(3) AS INTEGER, py(3) AS INTEGER, w AS INTEGER, h AS INTEGER
  253.     DIM sinr AS SINGLE, cosr AS SINGLE, i AS _BYTE
  254.     w = _WIDTH(Image): h = _HEIGHT(Image)
  255.     SELECT CASE mode
  256.         CASE 0 'center
  257.             px(0) = -w \ 2: py(0) = -h \ 2: px(3) = w \ 2: py(3) = -h \ 2
  258.             px(1) = -w \ 2: py(1) = h \ 2: px(2) = w \ 2: py(2) = h \ 2
  259.         CASE 1 'top left
  260.             px(0) = 0: py(0) = 0: px(3) = w: py(3) = 0
  261.             px(1) = 0: py(1) = h: px(2) = w: py(2) = h
  262.         CASE 2 'bottom left
  263.             px(0) = 0: py(0) = -h: px(3) = w: py(3) = -h
  264.             px(1) = 0: py(1) = 0: px(2) = w: py(2) = 0
  265.         CASE 3 'top right
  266.             px(0) = -w: py(0) = 0: px(3) = 0: py(3) = 0
  267.             px(1) = -w: py(1) = h: px(2) = 0: py(2) = h
  268.         CASE 4 'bottom right
  269.             px(0) = -w: py(0) = -h: px(3) = 0: py(3) = -h
  270.             px(1) = -w: py(1) = 0: px(2) = 0: py(2) = 0
  271.     END SELECT
  272.     sinr = SIN(angle / 57.2957795131): cosr = COS(angle / 57.2957795131)
  273.     FOR i = 0 TO 3
  274.         x2 = (px(i) * cosr + sinr * py(i)) + x: y2 = (py(i) * cosr - px(i) * sinr) + y
  275.         px(i) = x2: py(i) = y2
  276.     NEXT
  277.     _MAPTRIANGLE (0, 0)-(0, h - 1)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
  278.     _MAPTRIANGLE (0, 0)-(w - 1, 0)-(w - 1, h - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
  279.  
  280. FUNCTION TextToImage& (text$, font&, fc&, bfc&, mode AS _BYTE)
  281.     'text$ is the text that we wish to transform into an image.
  282.     'font& is the handle of the font we want to use.
  283.     'fc& is the color of the font we want to use.
  284.     'bfc& is the background color of the font.
  285.  
  286.     'Mode 1 is print forwards
  287.     'Mode 2 is print backwards
  288.     'Mode 3 is print from top to bottom
  289.     'Mode 4 is print from bottom up
  290.     'Mode 0 got lost somewhere, but it's OK.  We check to see if our mode is < 1 or > 4 and compensate automatically if it is to make it one (default).
  291.  
  292.     IF mode < 1 OR mode > 4 THEN mode = 1
  293.     dc& = _DEFAULTCOLOR: bgc& = _BACKGROUNDCOLOR
  294.     D = _DEST
  295.     F = _FONT
  296.     IF font& <> 0 THEN _FONT font&
  297.     IF mode < 3 THEN
  298.         'print the text lengthwise
  299.         w& = _PRINTWIDTH(text$): h& = _FONTHEIGHT
  300.     ELSE
  301.         'print the text vertically
  302.         FOR i = 1 TO LEN(text$)
  303.             IF w& < _PRINTWIDTH(MID$(text$, i, 1)) THEN w& = _PRINTWIDTH(MID$(text$, i, 1))
  304.         NEXT
  305.         h& = _FONTHEIGHT * (LEN(text$))
  306.     END IF
  307.  
  308.     TextToImage& = _NEWIMAGE(w&, h&, 32)
  309.     _DEST TextToImage&
  310.     IF font& <> 0 THEN _FONT font&
  311.     COLOR fc&, bfc&
  312.  
  313.     SELECT CASE mode
  314.         CASE 1
  315.             'Print text forward
  316.             _PRINTSTRING (0, 0), text$
  317.         CASE 2
  318.             'Print text backwards
  319.             temp$ = ""
  320.             FOR i = 0 TO LEN(text$) - 1
  321.                 temp$ = temp$ + MID$(text$, LEN(text$) - i, 1)
  322.             NEXT
  323.             _PRINTSTRING (0, 0), temp$
  324.         CASE 3
  325.             'Print text upwards
  326.             'first lets reverse the text, so it's easy to place
  327.             temp$ = ""
  328.             FOR i = 0 TO LEN(text$) - 1
  329.                 temp$ = temp$ + MID$(text$, LEN(text$) - i, 1)
  330.             NEXT
  331.             'then put it where it belongs
  332.             FOR i = 1 TO LEN(text$)
  333.                 fx = (w& - _PRINTWIDTH(MID$(temp$, i, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better
  334.                 _PRINTSTRING (fx, _FONTHEIGHT * (i - 1)), MID$(temp$, i, 1)
  335.             NEXT
  336.         CASE 4
  337.             'Print text downwards
  338.             FOR i = 1 TO LEN(text$)
  339.                 fx = (w& - _PRINTWIDTH(MID$(text$, i, 1))) / 2 + .99 'This is to center any non-monospaced letters so they look better
  340.                 _PRINTSTRING (fx, _FONTHEIGHT * (i - 1)), MID$(text$, i, 1)
  341.             NEXT
  342.     END SELECT
  343.     _DEST D
  344.     COLOR dc&, bgc&
  345.     _FONT F
  346.  
  347. FUNCTION GetDay$ (mm, dd, yyyy) 'use 4 digit year
  348.     'From Zeller's congruence: https://en.wikipedia.org/wiki/Zeller%27s_congruence
  349.     IF mm < 3 THEN mm = mm + 12: yyyy = yyyy - 1
  350.     century = yyyy MOD 100
  351.     zerocentury = yyyy \ 100
  352.     result = (dd + INT(13 * (mm + 1) / 5) + century + INT(century / 4) + INT(zerocentury / 4) + 5 * zerocentury) MOD 7
  353.     SELECT CASE result
  354.         CASE 0: GetDay$ = "Saturday"
  355.         CASE 1: GetDay$ = "Sunday"
  356.         CASE 2: GetDay$ = "Monday"
  357.         CASE 3: GetDay$ = "Tuesday"
  358.         CASE 4: GetDay$ = "Wednesday"
  359.         CASE 5: GetDay$ = "Thursday"
  360.         CASE 6: GetDay$ = "Friday"
  361.     END SELECT
  362.  
  363. SUB SafeLoadFont (font#)
  364.     'Safely loads a font without destroying our current print location and making it revert to the top left corner.
  365.  
  366.     down = CSRLIN: right = POS(0)
  367.     down = (down - 1) * _FONTHEIGHT
  368.     IF _FONTWIDTH <> 0 THEN 'weed start with a monospace font
  369.         right = (right - 1) * _PRINTWIDTH(" ") 'convert the monospace LOC to a graphic X coordinate
  370.     END IF
  371.     _FONT font#
  372.     IF _FONTWIDTH <> 0 THEN 'we swapped to a monospace font
  373.         right = (right / _PRINTWIDTH(" ")) + 1 'convert the graphic X coordinate back to a monospace LOC column
  374.     END IF
  375.     down = (down / _FONTHEIGHT) + 1
  376.     IF right < 1 THEN right = 1
  377.     LOCATE down, right
  378.  
  379. FUNCTION DownloadRSS$ (url$, timelimit)
  380.     link$ = url$
  381.     url2$ = RTRIM$(LTRIM$(link$))
  382.     url4$ = RTRIM$(LTRIM$(link$))
  383.     IF LEFT$(UCASE$(url2$), 7) = "HTTP://" THEN url4$ = MID$(url2$, 8)
  384.     x = INSTR(url4$, "/")
  385.     IF x THEN url2$ = LEFT$(url4$, x - 1)
  386.     NewsClient = _OPENCLIENT("TCP/IP:80:" + url2$)
  387.     IF NewsClient = 0 THEN EXIT FUNCTION
  388.     e$ = CHR$(13) + CHR$(10) ' end of line characters
  389.     url3$ = RIGHT$(url4$, LEN(url4$) - x + 1)
  390.     x$ = "GET " + url3$ + " HTTP/1.1" + e$
  391.     x$ = x$ + "Host: " + url2$ + e$ + e$
  392.     PUT #NewsClient, , x$
  393.  
  394.     t! = TIMER ' start time
  395.     head$ = ""
  396.     cont_type$ = ""
  397.     DO
  398.         _LIMIT 20
  399.         GET #NewsClient, , a$
  400.         IF LTRIM$(a$) > "" THEN final$ = final$ + a$
  401.         IF INSTR(a$, "</html>") THEN EXIT DO 'we hit the end of the file
  402.     LOOP UNTIL TIMER > t! + timelimit AND timelimit > 0 ' (in seconds)
  403.  
  404.     DownloadRSS$ = final$
  405.  

Font issue should be fixed in this version, in regards to ignoring missing fonts on your system.
 
CPU usage has also decreased considerably on my PC with this version, as we no longer load and unload fonts as needed.  They don't use much memory, so I just load them once and then forget about them and let them stay for the duration the program is running.

The weather update routine now does, in fact, check for weather once every minute and give you the latest weather temperature/condition.  Before, it was actually only checking at start-up and not actually refreshing as we never actually called the routine a second time.  (Whoops!  When information takes a long time to update/change, it's easy to make glitches like these and not catch them until a later date.)

I haven't corrected the issue with the background download yet, but unless one is watching closely, they won't notice when the clock "pauses" for a second or so every couple of minutes to try and refresh weather data.  Personally, I find that I'm liking the clock better without a dial to view seconds (it's almost information overload in my poor little brain), so I'm considering removing  that constant little spinner completely.  All it takes is a quick remark in the AssembleClock routine to yank it out, so you can see how it'd look without it.  ;)

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: A clock...
« Reply #7 on: February 26, 2019, 11:27:21 am »
Valid external font handles are greater than 0 (starting at 32, since emulated fonts are lower than that like 8 and 16). Checking if the handle is <> 0 is not correct. Check if it's > 0 before using the font.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: A clock...
« Reply #8 on: February 27, 2019, 03:02:45 pm »
Hi
I can say that WOW i like this clock!
And with the option >0  it works well instead with option <>0 it shows again errors to the 2 font loading tests!

Thanks
Programming isn't difficult, only it's  consuming time and coffee

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: A clock...
« Reply #9 on: March 01, 2019, 07:14:10 pm »
I had font issues with the 2nd version too.  Simply changed it to _FONT 8.
Also, there were a bunch of unrecognized  _TRIM commands that I changed to LTRIM. 
Then.....wow, I love to see new clock styles!  Cool concept!
I didn't see any weather info, even after waiting a couple minutes.  Maybe it's
some darn restriction on my WiFi.  I vill find oot eventually.


It works better if you plug it in.