Example #1
0
/*******************************************************************************
* Function Name: HandleCapSenseSlider
********************************************************************************
* Summary:
* This function scans for finger position on CapSense slider, and if the  
* position is different, triggers separate routine for BLE notification.
*
* Parameters:
*  void
*
* Return:
*  void
*
*******************************************************************************/
void HandleCapSenseSlider(void)
{
	/* Last read CapSense slider position value */
	static uint16 lastPosition;	
	
	/* Present slider position read by CapSense */
	uint16 sliderPosition;
		
	/* Update CapSense baseline for next reading*/
	CapSense_UpdateEnabledBaselines();	
		
	/* ADD_CODE to scan the slider widget */
	CapSense_ScanEnabledWidgets();			
	
	/* Wait for CapSense scanning to be complete. This could take about 5 ms */
	while(CapSense_IsBusy());
	
	/* ADD_CODE to read the finger position on the slider */
	sliderPosition = CapSense_GetCentroidPos(CapSense_LINEARSLIDER0__LS);	

	/*If finger is detected on the slider*/
	if((sliderPosition != NO_FINGER) && (sliderPosition <= SLIDER_MAX_VALUE))
	{
        /* If finger position on the slider is changed then send data as BLE 
         * notifications */
        if(sliderPosition != lastPosition)
		{
			/* Update global variable with present finger position on slider*/
			lastPosition = sliderPosition;

			SendCapSenseNotification((uint8)sliderPosition);

		}	
	}	
}
Example #2
0
int main()
{
    CyGlobalIntEnable;
    CapSense_Start();
    CapSense_InitializeEnabledBaselines();
    CapSense_ScanEnabledWidgets();

    for(;;)
    {
        if(!CapSense_IsBusy())
        {
            LED0_Write(!CapSense_CheckIsWidgetActive(CapSense_BUTTON0__BTN));
            LED1_Write(!CapSense_CheckIsWidgetActive(CapSense_BUTTON1__BTN));
            CapSense_UpdateEnabledBaselines();
            CapSense_ScanEnabledWidgets();
        }
    }
}
Example #3
0
File: main.c Project: spiricom/Birl
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);
            
    }
}
Example #4
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);
		}
    }
}