Ejemplo n.º 1
0
bool MythBDPlayer::SwitchAngle(int angle)
{
    uint total = GetNumAngles();
    if (!total || angle == GetCurrentAngle())
        return false;

    if (angle >= (int)total)
        angle = 0;

    return player_ctx->buffer->BD()->SwitchAngle(angle);
}
Ejemplo n.º 2
0
bool MythBDPlayer::PrevAngle(void)
{
    uint total = GetNumAngles();
    int prev = GetCurrentAngle() - 1;
    if (!total || total == 1)
        return false;

    if (prev < 0)
        prev = total;

    return SwitchAngle(prev);
}
Ejemplo n.º 3
0
bool MythBDPlayer::NextAngle(void)
{
    uint total = GetNumAngles();
    int next = GetCurrentAngle() + 1;
    if (!total)
        return false;

    if (next >= (int)total)
        next = 0;

    return SwitchAngle(next);
}
Ejemplo n.º 4
0
void main(void)
{
  // USER CODE BEGIN (Main,2)
  signed int ret_left;
  signed int ret_right;
  volatile signed int gyrovalue;
  unsigned char ledvalue;
  volatile signed int winkel = 0.0;
  volatile signed int val_x;
  volatile signed int val_y;
  volatile signed int val_z;

  unsigned char counter = 0;
  unsigned char timebase = 20; // * 5 ms

  // USER CODE END

  MAIN_vInit();

  // USER CODE BEGIN (Main,3)

  BalanceInit();

  // USER CODE END

  while(1)
  {

   // USER CODE BEGIN (Main,4)
   while(0 == timerevent);
   timerevent = 0;

   counter--;
   if (counter == 0)
   {
   		counter = timebase;		   
	   ReadSensorData();
	   Balance();
	   
	   // start reading the data, they will be get then
	   
	   gyrovalue = ReadSpinValue();
	   winkel = GetCurrentAngle();
	   ledvalue = ReadSpinValueRaw();
	   val_x = ReadAccelValue(DIRECTION_X) + 512;
	   val_y = ReadAccelValue(DIRECTION_Y) + 512;
	   val_z = ReadAccelValue(DIRECTION_Z) + 512;
	   
	   P10_OUT_P7 = (gyrovalue > 35) ? 0 : 1;
	   P10_OUT_P6 =	(gyrovalue > 25) ? 0 : 1;
	   P10_OUT_P5 =	(gyrovalue > 15) ? 0 : 1;
	   P10_OUT_P4 =	(gyrovalue > 5) ? 0 : 1;
	   P10_OUT_P3 =	(gyrovalue < -5) ? 0 : 1;
	   P10_OUT_P2 =	(gyrovalue < -15) ? 0 : 1;
	   P10_OUT_P1 =	(gyrovalue < -25) ? 0 : 1;
	   P10_OUT_P0 =	(gyrovalue < -35) ? 0 : 1;
	   // do some kind of stuff
	   //ret_left = 00;
	   //ret_right = 00;
	   //SetMotorSpeeds(&ret_left, &ret_right);
	   
	
	   //SetMotorSpeedsNoReturn(links_p, rechts_p);
	   // faehrt vorwärts hoffentlich
	   // und au langsam
	   //SetMotorSpeedsNoReturn(speed, speed);//20, 20);
	}
   // USER CODE END

  }

} //  End of function main
signed char CreateOrbitProgram() {
    UI_Location = UI_LOC_ORBITSETUP;
    signed char ret;

    const char *DIRECTION_1 = "CLOCKWISE\0";
    const char *DIRECTION_0 = "COUNTER CLOCKWISE\0";
    const char*DirectionMenu[2];
    DirectionMenu[0] = DIRECTION_0;
    DirectionMenu[1] = DIRECTION_1;

    const char *SpeedMODE_0 = "MANUAL\0";
    const char *SpeedMODE_1 = "PER ORBIT\0";
    const char *SpeedMODE_2 = "FOR ALL ORBITS\0";
    const char*SpeedModeMenu[3];
    SpeedModeMenu[0] = SpeedMODE_0;
    SpeedModeMenu[1] = SpeedMODE_1;
    SpeedModeMenu[2] = SpeedMODE_2;

    const char *ENDMODE_0 = "BY ORBIT COUNT\0";
    const char *ENDMODE_1 = "BY TOTAL TIME\0";
    const char *ENDMODE_2 = "NEVER ENDING\0";
    const char*EndModeMenu[3];
    EndModeMenu[0] = ENDMODE_0;
    EndModeMenu[1] = ENDMODE_1;
    EndModeMenu[2] = ENDMODE_2;

    const char *COMMAND_0 = "RUN PROGRAM\0";
    const char *COMMAND_1 = "SAVE PRESET\0";
    const char*CommandMenu[2];
    CommandMenu[0] = COMMAND_0;
    CommandMenu[1] = COMMAND_1;

labelOrigin:
    LCD_ClearDisplay();
    LCD_PrintString("MOVE TO START...\0");
    LCD_SetPosition(1, 0);
    LCD_PrintString("THEN CLICK.\0");
    bFollowMode = 1;
    ret = GetClick();
    bFollowMode = 0;
    if (ret < 0) return ret;    
    CurrentOrbitProgram.Origin_deg = (unsigned int) GetCurrentAngle();

labelDirection:
    ret = DisplayChoices(DirectionMenu, 1, "ROTATION DIRECTION:\0", CurrentOrbitProgram.IsClockWise);
    if (ret == -1) goto labelOrigin;
    if (ret == -2) return (-2);
    if (ret < 0) return ret;
    CurrentOrbitProgram.IsClockWise = ret;

labelEndMode:
    ret = DisplayChoices(EndModeMenu, 2, "PROGRAM END MODE:\0", CurrentOrbitProgram.EndMode);
    if (ret == -1) goto labelDirection;
    if (ret == -2) return (-2);
    if (ret < 0) return ret;
    CurrentOrbitProgram.EndMode = ret;
    switch (CurrentOrbitProgram.EndMode) {
        case 0: //End based on Cycle Count.
            labelCycleCount :
            if (CurrentOrbitProgram.CycleCount_rev < 1) CurrentOrbitProgram.CycleCount_rev = 1;
            if (CurrentOrbitProgram.CycleCount_rev > 999) CurrentOrbitProgram.CycleCount_rev = 999;

            ret = GetFloat("ORBIT LIMIT:\0", "", &CurrentOrbitProgram.CycleCount_rev, 1, 999, 1.0);
            if (ret == -1) goto labelEndMode;
            if (ret == -2) return (-2);
            if (ret < 0) return ret;

labelSpeedMode:
            if (CurrentOrbitProgram.CycleCount_rev > 1) ret = DisplayChoices(SpeedModeMenu, 2, "ORBIT SPEED:\0", CurrentOrbitProgram.SpeedMode);
            else ret = DisplayChoices(SpeedModeMenu, 1, "ORBIT SPEED:\0", CurrentOrbitProgram.SpeedMode);
            if (ret == -1) goto labelCycleCount;
            if (ret == -2) return (-2);
            if (ret < 0) return ret;
            switch (ret) {
                case 0:

                    if (CurrentOrbitProgram.Speed_deg_sec < 0.01) CurrentOrbitProgram.Speed_deg_sec = 0.01;
                    ret = GetFloat("SPEED\0", "\xDF/Sec\0", &CurrentOrbitProgram.Speed_deg_sec, 0.01, 90, 0.01);
                    if (ret == -1) goto labelSpeedMode;
                    if (ret == -2) return (-2);
                    break;
                case 1:
                    if (CurrentOrbitProgram.CycleTime_sec < 4) CurrentOrbitProgram.CycleTime_sec = 4;
                    ret = GetTime("TIME PER ORBIT\0", &CurrentOrbitProgram.CycleTime_sec, 4, 86400, 0b1110);
                    if (ret == -1) goto labelSpeedMode;
                    if (ret == -2) return (-2);
                    CurrentOrbitProgram.Speed_deg_sec = 360 / CurrentOrbitProgram.CycleTime_sec;
                    break;
                case 2:
                    if (CurrentOrbitProgram.CycleTime_sec < (4 * CurrentOrbitProgram.CycleCount_rev)) CurrentOrbitProgram.CycleTime_sec = 4 * CurrentOrbitProgram.CycleCount_rev;
                    ret = GetTime("TIME FOR ALL ORBITS\0", &CurrentOrbitProgram.CycleTime_sec, 4 * CurrentOrbitProgram.CycleCount_rev, 86400, 0b1110);
                    if (ret == -1) goto labelSpeedMode;
                    if (ret == -2) return (-2);
                    CurrentOrbitProgram.Speed_deg_sec = (360 * CurrentOrbitProgram.CycleCount_rev) / CurrentOrbitProgram.CycleTime_sec;
                    break;
            }
            break;
        case 1://End based on runtime.
            labelProgramRuntime :

                    ret = GetTime("TOTAL RUNTIME:\0", &CurrentOrbitProgram.ProgramRunTime_sec, 1, 86400, 0b1110);
            if (ret == -1) goto labelEndMode;
            if (ret == -2) return (-2);
            if (ret < 0) return ret;
labelSpeedMode2:

            ret = DisplayChoices(SpeedModeMenu, 1, "ORBIT SPEED:\0", CurrentOrbitProgram.SpeedMode);
            if (ret == -1) goto labelProgramRuntime;
            if (ret == -2) return (-2);
            if (ret < 0) return ret;
            switch (ret) {
                case 0:
                    if (CurrentOrbitProgram.Speed_deg_sec < 0.01) CurrentOrbitProgram.Speed_deg_sec = 0.01;
                    ret = GetFloat("SPEED\0", "\xDF/Sec\0", &CurrentOrbitProgram.Speed_deg_sec, 0.01, 90, 0.01);
                    if (ret == -1) goto labelSpeedMode2;
                    if (ret == -2) return (-2);
                    break;
                case 1:
                    if (CurrentOrbitProgram.CycleTime_sec < 4) CurrentOrbitProgram.CycleTime_sec = 4;
                    ret = GetTime("TIME PER ORBIT:\0", &CurrentOrbitProgram.CycleTime_sec, 4, 86400, 0b1110);
                    if (ret == -1) goto labelSpeedMode2;
                    if (ret == -2) return (-2);
                    CurrentOrbitProgram.Speed_deg_sec = 360 / CurrentOrbitProgram.CycleTime_sec;
                    break;
            }
            CurrentOrbitProgram.CycleCount_rev = (CurrentOrbitProgram.Speed_deg_sec * CurrentOrbitProgram.ProgramRunTime_sec) / 360;
            break;
        case 2: //NO END AT ALL
            labelSpeedMode3 :
                    ret = DisplayChoices(SpeedModeMenu, 1, "ORBIT SPEED:\0", CurrentOrbitProgram.SpeedMode);
            if (ret == -1) goto labelEndMode;
            if (ret == -2) return (-2);
            if (ret < 0) return ret;
            switch (ret) {
                case 0:
                    if (CurrentOrbitProgram.Speed_deg_sec < 0.01) CurrentOrbitProgram.Speed_deg_sec = 0.01;
                    ret = GetFloat("SPEED\0", "\xDF/Sec\0", &CurrentOrbitProgram.Speed_deg_sec, 0.01, 90, 0.01);
                    if (ret == -1) goto labelSpeedMode3;
                    if (ret == -2) return (-2);
                    if (ret < 0) return ret;
                    break;
                case 1:
                    if (CurrentOrbitProgram.CycleTime_sec < 4) CurrentOrbitProgram.CycleTime_sec = 4;
                    ret = GetTime("TIME PER ORBIT:\0", &CurrentOrbitProgram.CycleTime_sec, 4, 86400, 0b1110);
                    if (ret == -1) goto labelSpeedMode3;
                    if (ret == -2) return (-2);
                    if (ret < 0) return ret;
                    CurrentOrbitProgram.Speed_deg_sec = 360 / CurrentOrbitProgram.CycleTime_sec;
                    break;
            }
            break;

    }

labelActions:
    ret = DisplayChoices(CommandMenu, 1, "ACTION:\0", 0);
    if (ret == -1) goto labelCycleCount;
    if (ret == -2) return (-2);
    if (ret < 0) return ret;
    if (ret == 0) {
        return RunOrbitProgram();
    }

    ret = GetPresetNumber();
    if (ret == -1) goto labelActions;
    if (ret == -2) return (-2);
    if (ret < 0) return ret;

    CurrentOrbitProgram.Type = 2;
    SavePreset(ret, (unsigned char *) &CurrentOrbitProgram);
    goto labelActions;
}