Some users may wish to create their own service function to interpret the sensor's readings. The easiest way to handle this is to copy the mTouchCVD.c file from the library to your local project directory. Change the mTouchCVD.c file location in your project and make all edits to the local version.
The mTouchCVD_Decode() function is called once each sensor has been scanned. New reading values for each sensor can be accessed with the CVDGetSensor(i) macro, where i is the Sensor# as defined in the configuration file.
The majority of the default mTouch initialization function is dedicated to preparing the decode and filtering module. Since you are creating your own service function, this initialization function should be replaced with one that initializes your own variables.
To initalize the mTouch framework, make sure to include the following code blocks. function:
for (unsigned char i = 0; i < CVD_NUMBER_SENSORS; i++) { sensor_data[i] = 0x47F; // Initializes the acquisition module's sensor_data array to minimize initalization time }
CVD_SET_ADC_CLK(); // Automatically configures the ADC's clock based on your configuration file's _XTAL_FREQ value // Alternatively, you can initialize the ADC registers yourself
#if defined(CVD_DEBUG) && (CVD_DEBUG == 1) mTouchCVD_Comm_Init(); // OPTIONAL - Call this if you want to use the default mTouch comm implementation #endif
CVD_SET_TMR0IE(); // REQUIRED CVD_SET_GIE(); // REQUIRED