This lib is supposed to be used as a sensor's calibration or control program. This makes Cubic Spline Model from some sample plots(sets of (value, voltage)), and then discretize the model (dividing the range of voltage into some steps) in order to use the calibrated model data without getting the INVERSE function.
Diff: TRP105FS_SPIWrapper.cpp
- Revision:
- 11:d60fb729eacf
- Parent:
- 8:9eaa9772e1e7
- Child:
- 12:db5110d9d494
--- a/TRP105FS_SPIWrapper.cpp Mon Jun 06 15:41:44 2016 +0000 +++ b/TRP105FS_SPIWrapper.cpp Mon Jun 06 19:49:20 2016 +0000 @@ -1,9 +1,10 @@ #include "TRP105FS_SPIWrapper.h" +#include "CODE_SELECTIVE.h" // // Make instance of static member // -SPI +SPI SPI_TRP105FS::spi(p5, p6, p7); // mosi(out), miso(in), sclk(clock) DigitalOut @@ -12,7 +13,7 @@ // // For SPI, Define static method // -int +int SPI_TRP105FS::ADread(int channel) { int command_high=0x06|((channel&0x04)>>2); @@ -43,37 +44,37 @@ ,filename("\0") {} -void +void SPI_TRP105FS::setSample(unsigned short arg_x) { trp.setSample(arg_x, (unsigned short)ADread(channel)); } -void +void SPI_TRP105FS::calibrate() { trp.calibrate(); } -unsigned short +unsigned short SPI_TRP105FS::getDistance() { return trp.getDistance((unsigned short)ADread(channel)); } -unsigned int +unsigned int SPI_TRP105FS::getChannel() { return channel; } -unsigned int +unsigned int SPI_TRP105FS::getNsample() { return nsample; } -void +void SPI_TRP105FS::savedata() { if (filename[0] == '\0') @@ -81,16 +82,18 @@ trp.saveSetting(filename); } -void +void SPI_TRP105FS::loaddata() { if (filename[0] == '\0') sprintf(filename, "SENSOR%02d.SAV", channel); trp.loadSetting(filename); } -void +void SPI_TRP105FS::printCalibrationiLOG() { trp.printOutData("ADLOG.TXT"); +#if defined(HAS_COM_TO_CONSOLE) trp.printThresholds(); +#endif } \ No newline at end of file