lcd01.py

Created by vef03715

Created on February 07, 2021

2.7 KB


from math import *
from kandinsky import *
from time import *

def lcd_dsp(lcd_t,lcd_n):
  x=40
  y=25
  w=5
  b=10
  lcd_on=color('blue')
  lcd_off=color('brown')

  for i in range(0,lcd_n):
    t=lcd_t[i]
    lcd_d=[(0,0,0)]*7
    if t==" ":
      lcd_d[0]=lcd_off
      lcd_d[1]=lcd_off
      lcd_d[2]=lcd_off

      lcd_d[3]=lcd_off
      lcd_d[4]=lcd_off
      lcd_d[5]=lcd_off
      lcd_d[6]=lcd_off
    elif t=="0":
      lcd_d[0]=lcd_on
      lcd_d[1]=lcd_off
      lcd_d[2]=lcd_on

      lcd_d[3]=lcd_on
      lcd_d[4]=lcd_on
      lcd_d[5]=lcd_on
      lcd_d[6]=lcd_on
    elif t=="1":
      lcd_d[0]=lcd_off
      lcd_d[1]=lcd_off
      lcd_d[2]=lcd_off

      lcd_d[3]=lcd_off
      lcd_d[4]=lcd_on
      lcd_d[5]=lcd_off
      lcd_d[6]=lcd_on
    elif t=="2":
      lcd_d[0]=lcd_on
      lcd_d[1]=lcd_on
      lcd_d[2]=lcd_on

      lcd_d[3]=lcd_off
      lcd_d[4]=lcd_on
      lcd_d[5]=lcd_on
      lcd_d[6]=lcd_off
    elif t=="3":
      lcd_d[0]=lcd_on
      lcd_d[1]=lcd_on
      lcd_d[2]=lcd_on

      lcd_d[3]=lcd_off
      lcd_d[4]=lcd_on
      lcd_d[5]=lcd_off
      lcd_d[6]=lcd_on
    elif t=="4":
      lcd_d[0]=lcd_off
      lcd_d[1]=lcd_on
      lcd_d[2]=lcd_off

      lcd_d[3]=lcd_on
      lcd_d[4]=lcd_on
      lcd_d[5]=lcd_off
      lcd_d[6]=lcd_on
    elif t=="5":
      lcd_d[0]=lcd_on
      lcd_d[1]=lcd_on
      lcd_d[2]=lcd_on

      lcd_d[3]=lcd_on
      lcd_d[4]=lcd_off
      lcd_d[5]=lcd_off
      lcd_d[6]=lcd_on
    elif t=="6":
      lcd_d[0]=lcd_on
      lcd_d[1]=lcd_on
      lcd_d[2]=lcd_on

      lcd_d[3]=lcd_on
      lcd_d[4]=lcd_off
      lcd_d[5]=lcd_on
      lcd_d[6]=lcd_on
    elif t=="7":
      lcd_d[0]=lcd_on
      lcd_d[1]=lcd_off
      lcd_d[2]=lcd_off

      lcd_d[3]=lcd_off
      lcd_d[4]=lcd_on
      lcd_d[5]=lcd_off
      lcd_d[6]=lcd_on
    elif t=="8":
      lcd_d[0]=lcd_on
      lcd_d[1]=lcd_on
      lcd_d[2]=lcd_on

      lcd_d[3]=lcd_on
      lcd_d[4]=lcd_on
      lcd_d[5]=lcd_on
      lcd_d[6]=lcd_on
    elif t=="9":
      lcd_d[0]=lcd_on
      lcd_d[1]=lcd_on
      lcd_d[2]=lcd_on

      lcd_d[3]=lcd_on
      lcd_d[4]=lcd_on
      lcd_d[5]=lcd_off
      lcd_d[6]=lcd_on

#    else:
    fill_rect(i*x+w*2,b,x-(w*3),w,lcd_d[0])
    fill_rect(i*x+w*2,b+y+w,x-(w*3),w,lcd_d[1])
    fill_rect(i*x+w*2,b+y*2+w*2,x-(w*3),w,lcd_d[2])

    fill_rect(i*x+w,b+w,w,y,lcd_d[3])
    fill_rect(i*x+x-w,b+w,w,y,lcd_d[4])
    fill_rect(i*x+w,b+w*2+y,w,y,lcd_d[5])
    fill_rect(i*x+x-w,b+w*2+y,w,y,lcd_d[6])

def lcd01():
  lcd_n=8
  lcd_t=[" "]*lcd_n
  fill_rect(0,0,320,222,color('black'))
  lcd_dsp(lcd_t,lcd_n)

  sleep(1)

  for i in range(0,12345678,106789):
    lcd_t=[" "]*lcd_n
    s=str(i)
    for j in range(0,9):
      if j<len(s):
        lcd_t[j]=s[j]
    lcd_dsp(lcd_t,lcd_n)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.