Ejemplo n.º 1
0
int YesNo(char st[])
{
  printf("%s? (Start=Y, Stop=N):\n", st);
  
  while (1)
    {
    if (start_button()) {while (start_button()); return 1;}
    if (stop_button()) {while (stop_button()); return 0;}
    }
}
void replay_controller::update_replay_ui()
{
	//check if we have all buttons - if someone messed with theme then some buttons may be missing
	//if any of the buttons is missing, we just disable every one
	if(!replay_ui_has_all_buttons()) {
		gui::button *play_b = play_button(), *stop_b = stop_button(),
		            *reset_b = reset_button(), *play_turn_b = play_turn_button(),
		            *play_side_b = play_side_button();

		if(play_b) {
			play_b->enable(false);
		}

		if(stop_b) {
			stop_b->enable(false);
		}

		if(reset_b) {
			reset_b->enable(false);
		}

		if(play_turn_b) {
			play_turn_b->enable(false);
		}

		if(play_side_b) {
			play_side_b->enable(false);
		}
	}
}
Ejemplo n.º 3
0
void LookdownTest()
{
  int cErr = 0;
  int cLook = 0;

  while (!stop_button())
    {
    cLook++;
    Lookdown();
    if (wLD < 10)
      {
      cErr++;
      }
    printf("iSight: %d wLD: %d [0-%d:%d-255] Low: %d\n", iSight, wLD, wBlack+wSlop, wWhite-wSlop, cErr);
    }
  while (stop_button());
}
Ejemplo n.º 4
0
void ServoRange()
{
  int pos;
  int portServ = 0;

  while (!stop_button())
    {
    if (start_button())
      {
      portServ = 1 - portServ;
      while (start_button());
      }
    pos = ScaleKnob(30, 3960);
    printf("Servo: %d\n", pos);
    servo(portServ, pos);
    }
  while (stop_button());
}
void replay_controller::reset_replay_ui()
{
	if(!replay_ui_has_all_buttons())
		return;

	play_button()->enable(true);
	stop_button()->enable(true);
	reset_button()->enable(true);
	play_turn_button()->enable(true);
	play_side_button()->enable(true);
}
void replay_controller::replay_ui_playback_should_stop()
{
	if(!replay_ui_has_all_buttons())
		return;

	if(!recorder.at_end()) {
		play_button()->enable(true);
		reset_button()->enable(true);
		play_turn_button()->enable(true);
		play_side_button()->enable(true);

		play_button()->release();
		play_turn_button()->release();
		play_side_button()->release();
	} else {
		reset_button()->enable(true);
		stop_button()->enable(false);
	}

	if(!is_playing_) {
		//user interrupted
		stop_button()->release();
	}
}
Ejemplo n.º 7
0
void MainMenu()
{
  func = -1;

  while (!stop_button())
    {
    funcLast = func;
    func = ScaleKnob(1, 27);

    if (FDispMenu(1, "Calibrate Lookdown")) CalibrateLookdown();
    if (FDispMenu(2, "Compete!")) Compete();
    if (FDispMenu(3, "Placebo")) Placebo();
    if (FDispMenu(4, "Dance!")) Chop(10);
    if (FDispMenu(5, "Calibrate Soft")) CalibrateSoft();
    if (FDispMenu(6, "Calibrate Hard")) CalibrateHard();
    if (FDispMenu(7, "Speed Calibration")) CalibrateSpeed();

    if (FDispMenu(8, "Lookdown Test")) LookdownTest();
    if (FDispMenu(9, "Orientation")) Orient();
    if (FDispMenu(10, "Straight 1000")) Move(1000,1000);
    if (FDispMenu(11, "Left 90 Soft")) Soft(90, 1);
    if (FDispMenu(12, "Left 90 Hard")) Hard(90);

    if (FDispMenu(13, "Find Line")) FindLine();
    if (FDispMenu(14, "Line Follow")) LineFollower();

    if (FDispMenu(15, "Record"))
      RecordMove(WSetting("Record move", 0, 9));
    if (FDispMenu(16, "Playback"))
      PlayMove(WSetting("Play move", 0, 9));

    /* hbtest.c functions */

    if (FDispMenu(17, "Servo Test")) ServoTest();
    if (FDispMenu(18, "Calibrate Gate")) CalibrateGate();
    if (FDispMenu(19, "Soft Turn Test")) SoftTest();
    if (FDispMenu(20, "Hard Turn Test")) HardTest();
    if (FDispMenu(21, "Spin Test!")) Spinner();
    if (FDispMenu(22, "Shake Test!")) Shaker();
    if (FDispMenu(23, "Bump Test")) BumpTest();

    if (FDispMenu(24, "Test Motors")) testmotors();
    if (FDispMenu(25, "Test Digitals")) testdigitals();
    if (FDispMenu(26, "Test Analogs")) testanalogs();
    if (FDispMenu(27, "Assert Enable")) AssertEnable();
    }
}
Ejemplo n.º 8
0
	bool replay_ui_has_all_buttons() {
		return play_button() && stop_button() && reset_button() &&
		       play_turn_button() && play_side_button();
	}
Ejemplo n.º 9
0
void Move(int cLMax, int cRMax)
{
  int sL;
  int sR;
  float tL;
  float tR;
  float tMax;
  int sLSet;
  int sRSet;
  long ms;
  long msLimit;

  printf("Move: %d, %d\n", cLMax, cRMax);
  if (fAssertEnable)
    StartPress();

  msLimit = mseconds() + 2000L;

  InitEncoders();
  
  if (cLMax < 0)
    {
    cLMax = -cLMax;
    sL = -pwrMax;
    }
  else
    sL = pwrMax;

  if (cRMax < 0)
    {
    cRMax = -cRMax;
    sR = -pwrMax;
    }
  else
    sR = pwrMax;

  while (cL < cLMax || cR < cRMax)
    {
    if (stop_button())
      break;
    ReadEncoders();
    if (FBallCapture())
      break;
    if (fStalled || fBlocked)
      {
      if (!fForce)
        {
        beep();beep();beep();
        printf("Abort Move\n");
        break;
        }
      ms = mseconds();
      if (ms >= msLimit)
        {
        beep();beep();beep();
        printf("Time out\n");
        break;
        }
      }

    if (cL >= cLMax)
      sL = 0;
    if (cR >= cRMax)
      sR = 0;
 /*   printf("L: %d, R: %d\n", cL, cR); */
    tL = Parametric(cL, cLMax);
    tR = Parametric(cR, cRMax);
    sRSet = sR;
    sLSet = sL;
    /* BUG: Can need less than 3/4 speed - also need not retart balanced
       motors when both can track the same! */
    if (tL > tR)
      sLSet = sL*3/4;
    else
      sRSet = sR*3/4;
    SetMotors(sLSet, sRSet);
    }

  SetMotors(0,0);
}
Ejemplo n.º 10
0
void stop_press()
{
    while (!stop_button());
    while (stop_button());
    beep();
}