parameters: (epd, settings)
docstring: draw a clock
docstring_summary: draw a clock
docstring_tokens: draw a clock
function: def demo(epd, settings):
      """draw a clock"""
  
      # initially set all white background
      image = Image.new('1', epd.size, WHITE)
  
      # prepare for drawing
      draw = ImageDraw.Draw(image)
      width, height = image.size
  
      clock_font = ImageFont.truetype(FONT_FILE, settings.CLOCK_FONT_SIZE)
      date_font = ImageFont.truetype(FONT_FILE, settings.DATE_FONT_SIZE)
      weekday_font = ImageFont.truetype(FONT_FILE, settings.WEEKDAY_FONT_SIZE)
  
      # initial time
      now = datetime.today()
  
      while True:
          # clear the display buffer
          draw.rectangle((0, 0, width, height), fill=WHITE, outline=WHITE)
  
          # border
          draw.rectangle((1, 1, width - 1, height - 1), fill=WHITE, outline=BLACK)
          draw.rectangle((2, 2, width - 2, height - 2), fill=WHITE, outline=BLACK)
  
          # date
          draw.text((settings.DATE_X, settings.DATE_Y), '{y:04d}-{m:02d}-{d:02d}'.format(y=now.year, m=now.month, d=now.day), fill=BLACK, font=date_font)
          # day
          draw.text((settings.WEEKDAY_X, settings.WEEKDAY_Y), '{w:s}'.format(w=DAYS[now.weekday()]), fill=BLACK, font=weekday_font)
  
          # hours
          draw.text((settings.X_OFFSET, settings.Y_OFFSET), '{h:02d}'.format(h=now.hour), fill=BLACK, font=clock_font)
  
          # colon
          colon_x1 = width / 2 - settings.COLON_SIZE
          colon_x2 = width / 2 + settings.COLON_SIZE
          colon_y1 = settings.CLOCK_FONT_SIZE / 2 + settings.Y_OFFSET - settings.COLON_SIZE
          colon_y2 = settings.CLOCK_FONT_SIZE / 2 + settings.Y_OFFSET + settings.COLON_SIZE
          draw.rectangle((colon_x1, colon_y1 - settings.COLON_GAP, colon_x2, colon_y2 - settings.COLON_GAP), fill=BLACK, outline=BLACK)
          draw.rectangle((colon_x1, colon_y1 + settings.COLON_GAP, colon_x2, colon_y2 + settings.COLON_GAP), fill=BLACK, outline=BLACK)
  
          # minutes
          draw.text((settings.X_OFFSET + width / 2, settings.Y_OFFSET), '{m:02d}'.format(m=now.minute), fill=BLACK, font=clock_font)
  
          # display image on the panel
          epd.display(image)
          epd.update()
  
          # wait for next minute
          while True:
              now = datetime.today()
              if now.second == 0:
                  break
              time.sleep(0.5)
function_tokens: def demo ( epd , settings ) : # initially set all white background image = Image . new ( '1' , epd . size , WHITE ) # prepare for drawing draw = ImageDraw . Draw ( image ) width , height = image . size clock_font = ImageFont . truetype ( FONT_FILE , settings . CLOCK_FONT_SIZE ) date_font = ImageFont . truetype ( FONT_FILE , settings . DATE_FONT_SIZE ) weekday_font = ImageFont . truetype ( FONT_FILE , settings . WEEKDAY_FONT_SIZE ) # initial time now = datetime . today ( ) while True : # clear the display buffer draw . rectangle ( ( 0 , 0 , width , height ) , fill = WHITE , outline = WHITE ) # border draw . rectangle ( ( 1 , 1 , width - 1 , height - 1 ) , fill = WHITE , outline = BLACK ) draw . rectangle ( ( 2 , 2 , width - 2 , height - 2 ) , fill = WHITE , outline = BLACK ) # date draw . text ( ( settings . DATE_X , settings . DATE_Y ) , '{y:04d}-{m:02d}-{d:02d}' . format ( y = now . year , m = now . month , d = now . day ) , fill = BLACK , font = date_font ) # day draw . text ( ( settings . WEEKDAY_X , settings . WEEKDAY_Y ) , '{w:s}' . format ( w = DAYS [ now . weekday ( ) ] ) , fill = BLACK , font = weekday_font ) # hours draw . text ( ( settings . X_OFFSET , settings . Y_OFFSET ) , '{h:02d}' . format ( h = now . hour ) , fill = BLACK , font = clock_font ) # colon colon_x1 = width / 2 - settings . COLON_SIZE colon_x2 = width / 2 + settings . COLON_SIZE colon_y1 = settings . CLOCK_FONT_SIZE / 2 + settings . Y_OFFSET - settings . COLON_SIZE colon_y2 = settings . CLOCK_FONT_SIZE / 2 + settings . Y_OFFSET + settings . COLON_SIZE draw . rectangle ( ( colon_x1 , colon_y1 - settings . COLON_GAP , colon_x2 , colon_y2 - settings . COLON_GAP ) , fill = BLACK , outline = BLACK ) draw . rectangle ( ( colon_x1 , colon_y1 + settings . COLON_GAP , colon_x2 , colon_y2 + settings . COLON_GAP ) , fill = BLACK , outline = BLACK ) # minutes draw . text ( ( settings . X_OFFSET + width / 2 , settings . Y_OFFSET ) , '{m:02d}' . format ( m = now . minute ) , fill = BLACK , font = clock_font ) # display image on the panel epd . display ( image ) epd . update ( ) # wait for next minute while True : now = datetime . today ( ) if now . second == 0 : break time . sleep ( 0.5 )