/*******************************************************************************
* Function Name: InitializeSystem
********************************************************************************
* Summary:
* Start the components and initialize system.
*
* Parameters:
*  void
*
* Return:
*  void
*
*******************************************************************************/
void InitializeSystem(void)
{
	/* Enable global interrupt mask */
	CyGlobalIntEnable; 
		
	/* Start BLE component and register the CustomEventHandler function. This 
	 * function exposes the events from BLE component for application use */
    CyBle_Start(CustomEventHandler);	
    
	/* Start both the PrISM components for LED control*/
    PRS_1_Start();
    PRS_2_Start();
	
	/* The RGB LED on BLE Pioneer kit are active low. Drive HIGH on 
	 * pin for OFF and drive LOW on pin for ON*/
	PRS_1_WritePulse0(RGB_LED_OFF);
	PRS_1_WritePulse1(RGB_LED_OFF);
	PRS_2_WritePulse0(RGB_LED_OFF);
	
	/* Set Drive mode of output pins from HiZ to Strong */
	RED_SetDriveMode(RED_DM_STRONG);
	GREEN_SetDriveMode(GREEN_DM_STRONG);
	BLUE_SetDriveMode(BLUE_DM_STRONG);
	
	/* Initialize CapSense component and initialize baselines*/
	CapSense_Start();
	CapSense_InitializeAllBaselines();
}
Beispiel #2
0
int main()
{
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
    EZI2C_Init();
    EZI2C_Start();
    CapSense_Start();
    CyGlobalIntEnable;
    CapSense_InitializeAllBaselines();
    EZI2C_EzI2CSetBuffer1(BUFFER_SIZE, BUFFER_SIZE, ezi2cBuffer);
    /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
    for(;;)
    {
           /* Update all baselines */
            CapSense_UpdateEnabledBaselines();
        
   		    /* Start scanning all enabled sensors */
    	    CapSense_ScanEnabledWidgets();   
    
            /* Wait for scanning to complete */
		
            while(CapSense_IsBusy() != 0)
            {
                ; //wait for the scan to finish
            }
            
            touched = CapSense_GetTouchCentroidPos(CapSense_TOUCHPAD0__TP, pos);
            
            
            ezi2cBuffer[0] = (uint8) pos[0];
            ezi2cBuffer[1] = (uint8) pos[1];
            ezi2cBuffer[2] = touched;
            
            //ezi2cBuffer[0] = i;
            //ezi2cBuffer[1] = i+1;
            //i++;
            XY_DATAREADY_Write(1);
            
            while (!(EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_READ1))
            {
                ; //wait for the data to be read from the master
            }
            
            XY_DATAREADY_Write(0);
            
    }
}
Beispiel #3
0
void main()
{
	CYGlobalIntEnable; /* Enable global interrupts */
	
	ADC_DelSig_1_Start();/* Configure and power up ADC */
	LCD_Char_1_Start(); /* Initialize and clear the LCD */
	
	/* Move the cursor to Row 0 Column 0 */
	LCD_Char_1_Position(ROW_0,COLUMN_0); 
	/* Print Label for the pot voltage raw count */
	LCD_Char_1_PrintString("TEMP NOW:    C");
	
	LCD_Char_1_Position(ROW_1,COLUMN_0);
	LCD_Char_1_PrintString("TEMP SET:    C");
	
	ADC_DelSig_1_StartConvert(); /* Force ADC to initiate a conversion */
	
	/* Start capsense and initialize baselines and enable scan */
	CapSense_Start();
	CapSense_InitializeAllBaselines();
	CapSense_ScanEnabledWidgets();

    /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
	//Start the pwm;
	PWM_1_Start();
    for(;;)
    {
		/* If scanning is completed update the baseline count and check if sensor is active */
		while(CapSense_IsBusy());
		
		/* Update baseline for all the sensors */
		CapSense_UpdateEnabledBaselines();
		CapSense_ScanEnabledWidgets();
		
		/* Test if button widget is active */
		stateB_1 = CapSense_CheckIsWidgetActive(CapSense_BUTTON0__BTN);
		stateB_2 = CapSense_CheckIsWidgetActive(CapSense_BUTTON1__BTN);
	
        /* Wait for end of conversion */
		ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT);
		/* Get converted result */
		voltageRawCount = ADC_DelSig_1_GetResult16();
		//Change voltageRawCount to Temperature;
		temp = voltageRawCount / 3.870 * 0.1017 + 0.5;
		cold = (9999 - (temp > temp_set ? temp - temp_set : 0) * 50);
		if(cold < 1000)
			cold = 1000;
		if(cold > 9999)
			cold = 9999;
		//Change the pwm;
		PWM_1_WriteCompare(cold);
		/* Set range limit */
		if (temp > 0x7FFF)
		{
			temp = 0;
		}
		else
		{
		/* Continue on */
		}
		if(show < 10)
		{
			show++;
		}
		else
		{
			show = 0;
			UpdateDisplay(temp, 0); /* Print result on LCD */
			UpdateButtonState(stateB_1, stateB_2);
		}
    }
}