from myro import *
init("com40")

def normalize(v):
  Ambient = sum(getLight())/3.0
  if (v > Ambient):
    v = Ambient
  return (1.0-v/(1.0*Ambient))*100.0

def main():
  create canvas object
  write heading
  draw line below the light meters
  write left/center/right
  draw the 3 light meter outer rectangles
  initial = True
  while True:
    if not initial:
      undraw the three green parts of indicator
      undraw the three numeric parts of indicator
    else:
      initial = False
    get light values and normalize
    paint the green part for left indicator
    paint the green part for center indicator
    paint the green part for right indicator
    write the numeric value for left indicator
    write the numeric value for center indicator
    write the numeric value for right indicator
    wait(1)