#!/usr/bin/perl

$t=1;
$s=127;
$d= 16; # drives pwm
$numloops = 5; # The number of times a circle is drawn.
$val;   #value used in calculating our second variable in our circle. 

for($x=0;$x < $numloops;$x++){

  for($t=-126;$t<128;$t+=$d){
    $val = 127*127 - $t*$t;
    $s = 127 + sqrt($val); 
    $t_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm0",$t + 127);
    $s_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm1",$s);
    system($t_str);  # drives pwm
    system($s_str);  # drives pwm
  }
 
  for($t=126;$t > -128;$t-=$d){
    $val = 127*127 - $t*$t;
    $s = 127 - sqrt($val);
    $t_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm0",$t + 127);
    $s_str = sprintf("echo -n -e \"\\%o\" > /dev/pwm1",$s);
    system($t_str);  # drives pwm
    system($s_str);  # drives pwm
  }
}
