Δευτέρα 14 Σεπτεμβρίου 2020

A LED CLOCK

This is a LED clock. Using Desktop statement we can make one of standard colors (0 to 15) as transparent. Here we make Black as transparent.






Module Led_Clock{
      Escape Off
      Smooth off
      Dim D(-1 to 9)
      D(-1)=(0,0,0,0,0,0,0)
      D(0)=(1,1,1,0,1,1,1)
      D(1)=(0,0,1,0,0,1,0)
      D(2)=(1,0,1,1,1,0,1)
      D(3)=(1,0,1,1,0,1,1)
      D(4)=(0,1,1,1,0,1,0)
      D(5)=(1,1,0,1,0,1,1)
      D(6)=(1,1,0,1,1,1,1)
      D(7)=(1,0,1,0,0,1,0)
      D(8)=(1,1,1,1,1,1,1)
      D(9)=(1,1,1,1,0,1,1)
      N=180
      XX=(scale.x-N*75) div 2
      YY=scale.y-N*22
      NN=N
      BackColor=0
      CLS BackColor,0
      desktop 255, BackColor
      Forecolor=12
      C=BackColor-Forecolor
      pen BackColor
      for i=0 to 9: cc=d(i): cc*=c:next
      m=1
      move XX+N*23.2, YY+N*5.2
      polygon BackColor-C, N,-N, N,N, -N, N, -N, -N
      move XX+N*23.2,YY+N*13.2
      polygon BackColor-C, N,-N, N,N, -N, N, -N, -N
      move XX+N*49.2,YY+N*5.2
      polygon BackColor-C, N,-N, N,N, -N, N, -N, -N
      move XX+N*49.2,YY+N*13.2
      polygon BackColor-C, N,-N, N,N, -N, N, -N, -N
      dsk=True
      every 1000/2 {
            k=now
            k1=val(str$(k, "hh"))
            k2=val(str$(k, "nn"))
            k3=val(str$(k, "ss"))
            LED(XX, D(k1 div 10))
            LED(XX+N*12, D(k1 mod 10))
            LED(XX+N*26, D(k2 div 10))
            LED(XX+N*38, D(k2 mod 10))
            LED(XX+N*52, D(k3 div 10))
            LED(XX+N*64, D(k3 mod 10))
            refresh 1000
            if keypress(32) then
                  dsk~
                  if dsk then       desktop 255 else desktop 255, BackColor
            end if
            if keypress(27) or mouse=2 then exit
      }
      desktop 255
      pen 14
      refresh 50
      wait 1000
      Escape On
      sub LED(XX, S())
            move XX+N*1.2, YY+NN
            \\ LED  - UPPER
            polygon BackColor-S(0), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N
            \\ LED | LEFT UPPER
            move XX+N*1.2-N*1.2, YY+N*1.2+NN
            polygon BackColor-S(1), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6
            move XX+N*1.2+N*7.2, YY+N*1.2+NN
            \\ LED | RIGHT UPPER
            polygon BackColor-S(2), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6
            move XX+N*1.2, YY+N*8.4+NN
            \\ LED - MIDDLE
            polygon BackColor-S(3), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N
            \\ LED | LEFT BOTTOM
            move XX+N*1.2-N*1.2, YY+N*9.6+NN
            polygon BackColor-S(4), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6
            \\ LED | RIGHT BOTTOM
            move XX+N*1.2+N*7.2, YY+N*9.6+NN
            polygon BackColor-S(5), N,-N,N,N,0,N*6,-N, N, -N, -N, 0, -N*6
            \\ LED - BOTTOM
            move XX+N*1.2, YY+N*16.8+NN
            polygon BackColor-S(6), N,-N,N*6,0, N,N, -N, N,-N*6,0, -N, -N
      end sub
}
Led_Clock


 

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.