#include "eyebot.h"
#include "files.inc"
#define SAFE    300
#define HORIZON 120

int main ()
{ BYTE img[QVGA_PIXELS], sob[QVGA_PIXELS];
  char fname[20];
  int k, angle=0, frame=0;

  CAMInit(QVGA);
  LCDMenu("START", "", "", "");
  KEYWait(KEY1);

  LCDMenu("LEFT", "RIGHT", "", "END");
  do
  { CAMGetGray(img);
    IPSobel(img, sob);
    LCDImageGray(sob);
    LCDLine(0, HORIZON, 319, HORIZON, RED); // horizon
    k=KEYRead();
    if (k==KEY1)        angle += 10;
      else if (k==KEY2) angle -= 10;
    LCDSetPrintf(18,0, "Curve %4d", angle);
    VWCurve(100, angle, 50); // moderate speed
    sprintf(fname, "img/%04d.pgm", frame++);
    IPWriteFileGrayCom(fname, img, angle); //write file with angle as comment
    OSWait(100); // wait 0.1 s
  } while (k != KEY4);
  return 0;
}
