?? main.c
字號:
//----------------------------------------------------------------------------
// C main line
// Project to measure sensitivity on each switch
// Output 3 switches timer data counts to LCD
//----------------------------------------------------------------------------
#include <m8c.h> // part specific constants and macros
#include "PSoCAPI.h" // PSoC API definitions for all User Modules
int baseline0 = 0;
int baseline1 = 0;
int position = 0;
int buttonselect = 0;
void main()
{
CSR_1_Start(); //Start the User modules
LCD_1_Start();
M8C_EnableGInt; //Enable global interrupts
CSR_1_SetDacCurrent(0x80,0); //Set the DAC current to low range and 80h
CSR_1_SetScanSpeed(80); // Set the scan speed to 80
CSR_1_StartScan(0,11,1); // Scan 8 switches; starting switch 0; continously
LCD_1_Position(00,01);
LCD_1_PrCString("PSoC CapSence ");
LCD_1_Position(01,06);
LCD_1_PrCString("PTCC ");
while(1) //Stay in this loop forever
{
//LCD_1_Position(00,00); //Set LCD position to row 0 and column 0
while(!(CSR_1_GetScanStatus() & CSR_1_SCAN_SET_COMPLETE)); //Is scan complete?
baseline0 =CSR_1_bUpdateBaseline(0);
baseline1 =CSR_1_bUpdateBaseline(1);
//This function returns a '1' if there was a finger present on any of the switches
if (baseline0) // If a finger is detected,
{
LCD_1_Position(00,00);
if (CSR_1_iaSwDiff[0] > 8) // Was it switch number 0?
{
//LCD_1_PrHexByte(1); //Display '1'
LCD_1_PrCString("- Channel +");
//LCD_1_PrHexInt(CSR_1_iaSwDiff[0]);
buttonselect = 23;
}
else if (CSR_1_iaSwDiff[1] > 8) // Was it switch number 1?
{
//LCD_1_PrHexByte(2); //Display '2'
LCD_1_PrCString("- Volume +");
//LCD_1_PrHexInt(CSR_1_iaSwDiff[1]);
buttonselect = 25;
}
else if (CSR_1_iaSwDiff[2] > 8) // Was it switch number 2?
{
//LCD_1_PrHexByte(3); //Display '3'
LCD_1_PrCString("- Bright +");
//LCD_1_PrHexInt(CSR_1_iaSwDiff[2]);
buttonselect = 27;
}
else
{
// LCD_1_PrCString("None ");
}
}
if (baseline1 & buttonselect) // If a finger is detected,
{
// LCD_1_Position(01,00);
position = CSR_1_bGetCentroidPos(1); //Get finger position
if (position!= 0xff) //Error condition check
{
LCD_1_Position(01,14);
LCD_1_PrHexByte(position); //Display the finger position
LCD_1_InitBG(LCD_1_SOLID_BG);
LCD_1_DrawBG(01,00,14,position);
}
}
} // End of normal operation loop
} // End of main
/*int baseline_switches = 0;
void main()
{
int ncount;
CSR_1_Start();
LCD_1_Start(); // Start the User modules
M8C_EnableGInt; // Enable global interrupts
CSR_1_SetDacCurrent(0x80,0); //Sets DAC current to low range value 80h
CSR_1_SetScanSpeed(80); // Sets the scan speed to 80
CSR_1_StartScan(0,3,1); // Scan 7 switches starting from switch 0
while(1)
{
LCD_1_Position(00,00); //Sets LCD position to row 0 and column 0
while(!(CSR_1_GetScanStatus() & CSR_1_SCAN_SET_COMPLETE)); // Are scans complete?
baseline_switches = CSR_1_bUpdateBaseline(0);
//This funtion returns a '1' if any switches are depressed.
if (baseline_switches ) // If a switch is pressed,
{
if (CSR_1_iaSwDiff[0] > 8) // Was it switch number 0?
{
LCD_1_PrHexInt(0); //Display '0'
}
else if (CSR_1_iaSwDiff[1] > 8) // Was it switch number 1?
{
LCD_1_PrHexInt(1); //Display '1'
}
else if (CSR_1_iaSwDiff[2] > 8) // Was it switch number 2?
{
LCD_1_PrHexInt(2); //Display '2'
}
else
{
LCD_1_PrCString("None");
}
}
} // End of normal operation loop
} // End of main
*/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -