Beispiel #1
0
void main( void )
{
	int k = 0;
  WDTCTL = WDTPW + WDTHOLD;
  
  XT2_Init ();
  GPIO_Init ();
  P10DIR |= BIT6;
  
  Init_timer_interrupt_10ms();
  Run_timer_interrupt();
  __enable_interrupt();

LCD_InitSPI();
LCD_Settings();
LCD_Clear();

  while(1) {
	if (testInterrupt()){
		LCD_FillArea(0,20,0,20,arrColor[(k++)%5]);

		P10OUT ^= BIT6;
		resetInterruptCounter();
	}
  }
}
void PlayDrillCommandClass::execute()
{
    if (IsExecuting())
    {
        LOGF("SKIPPING PlayDrill command");
        return;
    }

    parse();
    
    LogSteps();
    
    StopCommandClass::reset();
    PauseCommandClass::reset();
    resetInterruptCounter();
	
    LOGF("=========== Initializing Bumper ==========");
    
	bumperOn(true/*resetCounter*/);
    
    LOGF("=========== Play Drill ==========");

    s_pExecutedDrill = this;
    
    bool bContinue= true;
    char pref[10];
    
    while (true)
    {
        // handle incoming commands
        executeCommands();
        
        if (StopCommandClass::IsStopped())
        {
            m_execData.error= false;
            m_execData.feedData.result=MotorHelperClass::FR_NONE;
            break;
        }
        else if (PauseCommandClass::IsPaused())
        {
            static unsigned long    s_LedSetTime= 0;
            static bool             s_yellowLed= false;
            unsigned long currentTime= millis();
            
            if (currentTime - s_LedSetTime >= 250) {
                if (s_yellowLed) {
                    Helper::setLedColor(0,0,255); // turn the RGB LED blue
                }
                else {
                    Helper::setLedColor(255,215,0); // turn the RGB LED yellow
                }
                s_LedSetTime= currentTime;
                s_yellowLed= !s_yellowLed;
            }
            g_motorHelper.stopMotorsIfIdle();
        }
        else
        {
            Step* pStep= NULL;
            
            for (int stepIndex= 0; stepIndex < m_Steps.getUsedElems(); ++stepIndex)
            {
                if (m_execData.nextStepIndex > 0) {
                    // goto
                    stepIndex= m_execData.nextStepIndex - 1; // 1-based
                    m_execData.nextStepIndex= -1;
                }
                pStep= m_Steps[stepIndex];
                
                LOGF3("============ Executing Step [", stepIndex+1, F("] ============"));
                
                bContinue= pStep->execute(m_execData);
                
                // handle incoming commands
                executeCommands();
                
                if (StopCommandClass::IsStopped())
                {
                    m_execData.error= false;
                    m_execData.feedData.result=MotorHelperClass::FR_NONE;
                    bContinue= false;
                }
                else if (PauseCommandClass::IsPaused())
                {
                    g_motorHelper.stopMotorsIfIdle();
                    break;
                }
                
                if (!bContinue)
                    break;
					
				g_TaskQueue.executeReadyTasks();               
            }
            
            if (!bContinue)
                break;
        }
        
    } // EOF while(true)
    
    g_motorHelper.stopMotors();
    s_pExecutedDrill = NULL;
	
	bumperOff();
    
    g_serialCom.fireEvent(EVENT_EXECUTE_STOPPED);
    
    // in case of error no sound
    if (!m_execData.error)
    {
        Helper::playSound(Helper::SND_FINISHED);
    }
    
}