Author Topic: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font  (Read 11021 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #45 on: December 05, 2020, 04:36:43 pm »
Of course I found another problem LOL. Now when it is earlier than 10am or 10pm, the 1 digit moves over to the left and everything else moves over to the left too. So I did a very quick one-line fix on it, hopefully this does the trick. I just said this:
Code: QB64: [Select]
  1.  IF h < 10 THEN hour$ = "0" + hour$
  2.  

It seems to work fine so far.

Zip file has been deleted. Keep scrolling down.

« Last Edit: December 05, 2020, 06:14:59 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #46 on: December 05, 2020, 05:25:51 pm »
Here is what I managed to work up for drawing 7 Segment characters, mostly digits:
Code: QB64: [Select]
  1. _TITLE "7 Segments Digital Date and Time Clock" ' b+ 2020-12-05
  2. DIM SHARED xmax, ymax
  3. xmax = 1074: ymax = 105
  4. SCREEN _NEWIMAGE(xmax, ymax, 32)
  5. DIM ampm$, testHeight, offset, testColr AS _UNSIGNED LONG, shadow AS _UNSIGNED LONG, face AS LONG, t$, d$
  6. testHeight = 100
  7. offset = 15
  8. shadow = &H17FFFFFF
  9. testColr = &HFFEEEEFF
  10. face = _NEWIMAGE(xmax, ymax, 32)
  11. print7 "8888-88-88 A 88:88:88", offset, offset, testHeight, shadow
  12. _PUTIMAGE , 0, face
  13. WHILE _KEYDOWN(27) = 0
  14.     _PUTIMAGE , face, 0
  15.     t$ = TIME$
  16.     d$ = RIGHT$(DATE$, 4) + "-" + LEFT$(DATE$, 2) + MID$(DATE$, 3, 3)
  17.     IF VAL(MID$(t$, 1, 2)) > 12 THEN
  18.         ampm$ = " P ": MID$(t$, 1, 2) = RIGHT$("00" + _TRIM$(STR$(VAL(MID$(t$, 1, 2)) - 12)), 2)
  19.     ELSE
  20.         ampm$ = " A "
  21.     END IF
  22.     print7 d$ + ampm$ + t$, offset, offset, testHeight, testColr
  23.     _LIMIT 10
  24.     _DISPLAY
  25.  
  26. SUB print7 (text$, x, y, height, c AS _UNSIGNED LONG)
  27.     ' char cells will be like 8 x 16 scaled st 16 pixel height would fit into default char cell
  28.  
  29.     DIM f AS SINGLE, i AS LONG
  30.     f = height / 16 ' proportion of height to standard height
  31.  
  32.     FOR i = 1 TO LEN(text$)
  33.         draw7Segmented MID$(text$, i, 1), x + (i - 1) * f * 8, y, height, c
  34.     NEXT
  35.  
  36. SUB draw7Segmented (char$, x AS LONG, y AS LONG, height AS SINGLE, colr AS _UNSIGNED LONG) ' digit = 0, 1, 2... 9
  37.     DIM f AS SINGLE, sr AS SINGLE, c AS _UNSIGNED LONG, digit AS LONG, c$, m AS LONG, i AS SINGLE
  38.     f = height / 16
  39.     sr = 11 / 5.5 * f
  40.     IF INSTR("0123456789", char$) THEN
  41.         digit = VAL(char$)
  42.         c$ = MID$("1110111000001101111100011111100101110111011111101001001111111111011011", digit * 7 + 1, 7)
  43.     ELSEIF INSTR(":-PA", char$) THEN
  44.         c$ = MID$("0010100000100011110101111011", INSTR(":-PA", char$) * 7 - 6, 7)
  45.     ELSE
  46.         c$ = "0000000" 'draw a space
  47.     END IF
  48.     FOR m = 1 TO 7
  49.         IF VAL(MID$(c$, m, 1)) THEN
  50.             FOR i = .5 * sr TO 0 STEP -.25
  51.                 c = Ink~&(colr, &H00000088, (i / (.5 * sr)) ^ .65)
  52.                 SELECT CASE m
  53.                     CASE 1: LINE (x + .5 * sr - i, y + .5 * sr + i)-(x + .5 * sr + i, y + 2.5 * sr - i), c, BF 'LT
  54.                     CASE 2: LINE (x + .5 * sr - i, y + 2.5 * sr + i)-(x + .5 * sr + i, y + 5.0 * sr - i), c, BF 'LB
  55.                     CASE 3: LINE (x + .5 * sr + i, y + .5 * sr + i)-(x + 2.5 * sr - 2 - i, y + .5 * sr - i), c, BF 'MT
  56.                     CASE 4: LINE (x + .5 * sr + i, y + 2.5 * sr + i)-(x + 2.5 * sr - 2 - i, y + 2.5 * sr - i), c, BF 'MM
  57.                     CASE 5: LINE (x + .5 * sr + i, y + 5.0 * sr + i)-(x + 2.5 * sr - 2 - i, y + 5.0 * sr - i), c, BF 'MB
  58.                     CASE 6: LINE (x + 2.5 * sr - i, y + .5 * sr + i)-(x + 2.5 * sr + i, y + 2.5 * sr - i), c, BF 'RT
  59.                     CASE 7: LINE (x + 2.5 * sr - i, y + 2.5 * sr + i)-(x + 2.5 * sr + i, y + 5.0 * sr - i), c, BF 'RB
  60.                 END SELECT
  61.             NEXT
  62.         END IF
  63.     NEXT
  64.  
  65. SUB cAnalysis (c AS _UNSIGNED LONG, outRed, outGrn, outBlu, outAlp)
  66.     outRed = _RED32(c): outGrn = _GREEN32(c): outBlu = _BLUE32(c): outAlp = _ALPHA32(c)
  67.  
  68. FUNCTION Ink~& (c1 AS _UNSIGNED LONG, c2 AS _UNSIGNED LONG, fr##)
  69.     DIM R1, G1, B1, A1, R2, G2, B2, A2
  70.     cAnalysis c1, R1, G1, B1, A1
  71.     cAnalysis c2, R2, G2, B2, A2
  72.     Ink~& = _RGB32(R1 + (R2 - R1) * fr##, G1 + (G2 - G1) * fr##, B1 + (B2 - B1) * fr##, A1 + (A2 - A1) * fr##)
  73.  

Tried for Neon Coloring:
 
7 Segments Digital Date and Time.PNG

Marked as best answer by SierraKen on December 05, 2020, 01:14:30 pm

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #47 on: December 05, 2020, 06:14:15 pm »
Here is another fix. I just realized that TIME$ starts with hour 0, not hour 12. So I believe I fixed that.

There is another attachment below.
* Alarm Clock VFD - 12-5-2020 update 7.zip (Filesize: 7.17 KB, Downloads: 191)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #48 on: December 05, 2020, 06:16:02 pm »
Yours is incredible B+. I like the neon glow look you added to it.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #49 on: December 05, 2020, 06:32:08 pm »
Woah...nice one, bplus.  That neon glowing effect looks just like a liquid crystal display clock. 

- Dav

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #50 on: December 05, 2020, 06:44:07 pm »
Thanks guys, if you copy the 4 procedures you can port to your app and just:

Code: QB64: [Select]
  1. print7 text$, x, y, height (pixels), color (for center line)

unless you are using Screen 0 ;-))

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #51 on: December 05, 2020, 07:05:18 pm »
I just attempted a way around making new fonts and used a double loop with POINT to match every pixel for the neon SUB we used. It just freezes up the computer. LOL For me anyway. hehe The funny thing is that it tried to do it, showing the time and date in neon, but then everything just stopped and the computer froze. lol

But thanks for making that B+. I saved it and will experiment with it I think soon.
« Last Edit: December 05, 2020, 07:11:58 pm by SierraKen »

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #52 on: December 06, 2020, 12:28:45 pm »
Thanks guys, if you copy the 4 procedures you can port to your app and just:

Code: QB64: [Select]
  1. print7 text$, x, y, height (pixels), color (for center line)

unless you are using Screen 0 ;-))

Cool. I think I would like to borrow this for a metronome I'm working on, if that would be okay...

- Dav

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #53 on: December 06, 2020, 01:12:46 pm »
Cool. I think I would like to borrow this for a metronome I'm working on, if that would be okay...

- Dav

You don't have to ask but I like it :) definitely OK! BTW the segment font idea was borrowed and modified from Richard Frost, or possibly [banned user] or Petr, I suspect Richard Frost when we were doing clocks he picked up on plasma I the segmented digits.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #54 on: December 06, 2020, 01:37:04 pm »
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2. f = _LOADFONT("LCD.ttf", 72, "monospace")
  3.     CLS
  4.     COLOR &H77AAAA00, 0
  5.     PRINT " 88:88:88"
  6.     PRINT "88-88-8888"
  7.     COLOR -1, 0
  8.     LOCATE 1, 1
  9.     PRINT " "; TIME$
  10.     PRINT DATE$
  11.     _DISPLAY
  12.     _LIMIT 1

Use font below.  All lines up and displays easily, as illustrated above.

I finally got home from watching mom, so this is the first chance I had to grab and test a decent LCD font.  ;)
* LCD.ttf (Filesize: 16.73 KB, Downloads: 193)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #55 on: December 06, 2020, 02:50:59 pm »
Ah! I see they made same decision for colon as I.

I started to consider this for other text but 7 segments aren't enough. They do do digits really well though.
« Last Edit: December 06, 2020, 02:52:24 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Vacuum Fluorescent Display (VFD) Alarm Clock Using LCD Font
« Reply #56 on: December 06, 2020, 02:53:53 pm »
I should have used Lcd.ttf as monospace, but never tried it on that particular one. lol