コード例 #1
0
ファイル: main.c プロジェクト: SKYMIGHT/bosch
void main(void)
{
  WDTCTL = WDTPW + WDTHOLD; // Stop WDT
  ConfigureAdc();
  ConfigureLED();

	ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
	__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
	sample = ADC10MEM; // get ADC in value
	__delay_cycles(1150000); 	// 1 second delay

   for(;;)
  {
		__delay_cycles(1150000); 	// 1 second delay
	ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
	__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
	sample = ADC10MEM; // get ADC in value



		if (sample > 892 ) {
					P1OUT &= ~BIT0; 			//Power off
					P1OUT |= BIT6;   //Enable heater
					P2OUT |= (BIT1); //Enable RED Led
					P1OUT &= ~BIT1;  //Disable BLUE Led

		}




		if (sample < 892 ) {
			P1OUT |= BIT0; 			//Power on
    		__delay_cycles(3450000); 	// 3 second delay
     		__delay_cycles(3450000); 	// 3 second delay
     		__delay_cycles(3450000); 	// 3 second delay
     		__delay_cycles(3450000); 	// 3 second delay
     		__delay_cycles(1150000); 	// 1 second delay

			if((P1IN & BIT2) == 0  ) {
					P1OUT &= ~BIT6;   		//disable heater
					P2OUT &= ~(BIT1);     	//Disable RED Led
					P1OUT &= ~(BIT1);	  	//Disable Blue Led
					flag = 0;
				}else {

     		while(1)
			{
    			if( flag == 0 && (P1IN & BIT2) == BIT2) {
    				// Reboot
    				P1OUT &= ~BIT0;			//poweroff
    				P1OUT &= ~BIT6;   		//disable heater
    				P2OUT &= ~(BIT1);     	//Disable RED Led
    				P1OUT &= ~(BIT1);	  	//Disable Blue Led
    				__delay_cycles(3450000); 	// 3 second delay
    				P1OUT |= BIT0; 			//Power on

    				break;

    			}else{

    				while(1)
    				{

					//system off
					if((P1IN & BIT2) == 0 ) {
						P1OUT &= ~BIT6;   		//disable heater
						P2OUT &= ~(BIT1);     	//Disable RED Led
						P1OUT &= ~(BIT1);	  	//Disable Blue Led
						flag = 0;
						//break;
						ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
						__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
						sample = ADC10MEM; // get ADC in value
						__delay_cycles(1150000); 	// 1 second delay
						ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
						__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
						sample = ADC10MEM; // get ADC in value
					}

					//system on & too cold reboot
					if((P1IN & BIT2) == BIT2 && sample > 892)
						break;

					//keyboard reset
					if( (P1IN & BIT3) == 0 && (P1IN & BIT2) == BIT2 )
						break;

					//for Power sequence test
					if((P1OUT & BIT0) == 0)
						break;

    				}
				break;
    			}

			}
			 }
		}



  }
}
コード例 #2
0
ファイル: MenuInput.cpp プロジェクト: mahao007/DS203
/*virtual*/ void CWndMenuInput::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	// LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
	if (code == ToWord('L', 'D') )
	{
		MainWnd.m_wndGraph.ShowWindow( SwHide );
		MainWnd.m_wndZoomBar.ShowWindow( SwHide );
		MainWnd.m_wndLReferences.ShowWindow( SwHide );
		MainWnd.m_wndTReferences.ShowWindow( SwHide );
	}

	if (code == ToWord('L', 'E') )
	{
		MainWnd.m_wndGraph.ShowWindow( SwShow );
		MainWnd.m_wndZoomBar.ShowWindow( SwShow );
		MainWnd.m_wndLReferences.ShowWindow( SwShow );
		MainWnd.m_wndTReferences.ShowWindow( SwShow );
	}


	// Trigger
	if (code == ToWord('m', 'r') )
	{
		m_wndListTrigger.Create( this );
		m_wndListTrigger.StartModal(&m_wndListTrigger.m_itmLevel);
	}
	if ( code == ToWord('o', 'k') && pSender->m_pParent == &m_wndListTrigger )
	{
		// done
		m_wndListTrigger.StopModal();
	}
	if ( code == ToWord('e', 'x') && pSender == &m_wndListTrigger )
	{
		// cancel
		m_wndListTrigger.StopModal();
	}
	if ( code == ToWord('u', 'p') && pSender->m_pParent == &m_wndListTrigger )
	{
		if ( pSender == &m_wndListTrigger.m_itmLevel )
			MainWnd.m_wndLReferences.Invalidate();
		if ( pSender == &m_wndListTrigger.m_itmTime )
			MainWnd.m_wndTReferences.Invalidate();

		ConfigureTrigger();
		Settings.Trig.nLastChange = BIOS::GetTick();
		// update
		CWnd::m_arrModals.GetLast().m_pPrevFocus->Invalidate();
	}

	// window
	if ( code == ToWord('w', 'u') )
	{
		MainWnd.m_wndTReferences.Invalidate();
		MainWnd.m_wndZoomBar.Invalidate();
	}

	// Timebase
	if (code == ToWord('m', 't') )	// more timebase
	{
		m_wndComboSelector.Create( GetFocus()->m_pszId, WsVisible | WsModal, 
			CRect( 30, 100, 370, 140), RGB565(ffffff), (CValueProvider*)(NATIVEPTR)data, this);

		m_wndComboSelector.StartModal();
	}

	// Digital
	if (code == ToWord('m', 'd') )	// more input digital
	{
		m_wndListDInput.Create( (CSettings::DigitalChannel*)(NATIVEPTR)data, this );
		m_wndListDInput.StartModal( &m_wndListDInput.m_itmPosition );
	}
	if ( code == ToWord('o', 'k') && pSender->m_pParent == &m_wndListDInput )
	{
		// done
		m_wndListDInput.StopModal();
	}
	if ( code == ToWord('e', 'x') && pSender == &m_wndListDInput )
	{
		// cancel
		m_wndListDInput.StopModal();
	}

	// Analog
	if (code == ToWord('m', 'a') )	// more input analog
	{
		m_wndListAInput.Create( (CSettings::AnalogChannel*)(NATIVEPTR)data, this );
		m_wndListAInput.StartModal( &m_wndListAInput.m_itmResolution );
	}
	if ( code == ToWord('o', 'k') && pSender->m_pParent == &m_wndListAInput )
	{
		// done
		m_wndListAInput.StopModal();
	}
	if ( code == ToWord('e', 'x') && pSender == &m_wndListAInput )
	{
		m_wndListAInput.StopModal();
	}
	if ( code == ToWord('u', 'p') && pSender->m_pParent == &m_wndListAInput )
	{
		if ( pSender == &m_wndListAInput.m_itmRed ||
			pSender == &m_wndListAInput.m_itmGrn ||
			pSender == &m_wndListAInput.m_itmBlu )
		{
			m_wndListAInput.m_itmColour.Invalidate();
		}
		if ( pSender == &m_wndListAInput.m_itmPosition )
		{
			MainWnd.m_wndLReferences.Invalidate();
		}
		// update
		CWnd::m_arrModals.GetLast().m_pPrevFocus->Invalidate();
		ConfigureAdc();
	}
	if ( code == ToWord('u', 'p') && pSender->m_pParent == &m_wndListDInput )
	{
		if ( pSender == &m_wndListDInput.m_itmRed ||
			pSender == &m_wndListDInput.m_itmGrn ||
			pSender == &m_wndListDInput.m_itmBlu )
		{
			m_wndListDInput.m_itmColour.Invalidate();
		}
		if ( pSender == &m_wndListDInput.m_itmPosition )
		{
			MainWnd.m_wndLReferences.Invalidate();
		}
		// update
		CWnd::m_arrModals.GetLast().m_pPrevFocus->Invalidate();
	}
	// Selector
	if ( code == ToWord('l', 'e') )	// provider selector combo box
	{
		CValueProvider* pProvider = (CValueProvider*)(NATIVEPTR)data;
		if ( pProvider->Get() == 0 )
		{
			// TODO: remove? used only for button element testing
			// button ?
			MainWnd.m_wndMessage.Show( this, "Message", ((CProviderBtn*)pProvider)->m_pName, RGB565(ffff00));
			return;
		} else
		{
			m_wndComboSelector.Create( GetFocus()->m_pszId, WsVisible | WsModal, 
				CRect( 30, 100, 370, 140), RGB565(ffffff), pProvider, this);
		}
		m_wndComboSelector.StartModal();
	}
	if ( code == ToWord('o', 'k') && pSender == &m_wndComboSelector )
	{
		// done
		m_wndComboSelector.StopModal();
	}
	if ( code == ToWord('e', 'x') && pSender == &m_wndComboSelector )
	{
		// cancel
		m_wndComboSelector.StopModal();
	}
	if ( code == ToWord('i', 'u') )
	{
		ConfigureAdc();
	}
	if ( code == ToWord('r', 'u') )
	{
		Settings.Trig.nLastChange = BIOS::GetTick();
		MainWnd.m_wndLReferences.Invalidate();
		ConfigureTrigger();
	}
}