Ted Grosch / Mbed 2 deprecated Nucleo_TOF_I2C

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OPT3101PhaseOffset.cpp Source File

OPT3101PhaseOffset.cpp

Go to the documentation of this file.
00001 /*!
00002 * \file OPT3101PhaseOffset.cpp
00003 * \author  Karthik Rajagopal <krthik@ti.com>
00004 * \version 0.9.1
00005 *
00006 * \section COPYRIGHT
00007 * TEXAS INSTRUMENTS TEXT FILE LICENSE
00008 * Copyright (c) 2018 Texas Instruments Incorporated
00009 * All rights reserved not granted herein.
00010 * Limited License.
00011 * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive license under copyrights and patents it now or hereafter owns or controls to make, have made, use, import, offer to sell and sell ("Utilize") this software subject to the terms herein.  With respect to the foregoing patent license, such license is granted  solely to the extent that any such patent is necessary to Utilize the software alone.  The patent license shall not apply to any combinations which include this software, other than combinations with devices manufactured by or for TI ("TI Devices").  No hardware patent is licensed hereunder.
00012 * Redistributions must preserve existing copyright notices and reproduce this license (including the above copyright notice and the disclaimer and (if applicable) source code license limitations below) in the documentation and/or other materials provided with the distribution
00013 * Redistribution and use in binary form, without modification, are permitted provided that the following conditions are met:
00014 * * No reverse engineering, decompilation, or disassembly of this software is permitted with respect to any software provided in binary form.
00015 * * any redistribution and use are licensed by TI for use only with TI Devices.
00016 * * Nothing shall obligate TI to provide you with source code for the software licensed and provided to you in object code.
00017 * If software source code is provided to you, modification and redistribution of the source code are permitted provided that the following conditions are met:
00018 * * any redistribution and use of the source code, including any resulting derivative works, are licensed by TI for use only with TI Devices.
00019 * * any redistribution and use of any object code compiled from the source code and any resulting derivative works, are licensed by TI for use only with TI Devices.
00020 * Neither the name of Texas Instruments Incorporated nor the names of its suppliers may be used to endorse or promote products derived from this software without specific prior written permission.
00021 * DISCLAIMER.
00022 * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00023 *
00024 * \section DESCRIPTION
00025 * This file contains the method definitions for class OPT3101::phaseOffsetC
00026 */
00027 
00028 #include "OPT3101PhaseOffset.h "
00029 #include "hostController.h "
00030 
00031 
00032 OPT3101::phaseOffsetC::phaseOffsetC()
00033 {
00034     /// <b>Algorithm of the method is as follows</b>
00035     this->phaseOffset = 0; ///* Initializes all members to 0
00036     this->referenceDistanceInCodes = 0; 
00037     this->illumScale = 0; 
00038     this->illumDac=0; 
00039     this->illumDCdac = 0; 
00040     this->freqCount = 0; 
00041     this->shiftIllumPhase=0; 
00042 }
00043 
00044 void OPT3101::phaseOffsetC::report()
00045 {
00046     host.printf("-------------------------\r\n");
00047     host.printf("Phase Offset Class Report\r\n");
00048     host.printf("-------------------------\r\n"); ///* Prints all the members and values of members on screen.
00049     host.printf("phaseOffset=%d\r\n", this->phaseOffset);
00050     host.printf("referenceDistanceInCodes=%d\r\n", this->referenceDistanceInCodes);
00051     host.printf("illumScale=%d\r\n", this->illumScale);
00052     host.printf("illumDac=%d\r\n", this->illumDac);
00053     host.printf("illumDCdac=%d\r\n", this->illumDCdac);
00054     host.printf("freqCount=%d\r\n", this->freqCount);
00055     host.printf("shiftIllumPhase=%d\r\n", this->shiftIllumPhase);
00056     host.printf("data=\r\n");
00057     this->data.report();
00058     host.printf("-------------------------\r\n"); ///* Prints all the members and values of members on screen.
00059 }
00060 
00061 void OPT3101::phaseOffsetC::printHeader()
00062 {
00063     host.printfSetColor(0b001);
00064     host.printf("\r\nPhOfft,");
00065     host.printf("rfDCod,");
00066     host.printf("ilmScl,");
00067     host.printf("ilmDac,");
00068     host.printf(" fqCnt\r\n");
00069     host.printfSetColor(0xFF);
00070 }
00071 void OPT3101::phaseOffsetC::print()
00072 {
00073     host.printfSetColor(0b001);
00074     host.printf("%06u,",this->phaseOffset);
00075     host.printf("%06u,",this->referenceDistanceInCodes);
00076     host.printf("     %01u,",this->illumScale);
00077     host.printf("    %02u,",this->illumDac);
00078     host.printf(" %05u,\r\n",this->freqCount);
00079     host.printfSetColor(0xFF);
00080     this->data.printHeader();
00081     this->data.print();
00082 }
00083 
00084 
00085 #ifdef OPT3101_USE_STDIOLIB
00086 void OPT3101::phaseOffsetC::storeToFile(char * fileName)
00087 {
00088 #ifdef OPT3101_USE_STREAMLIB
00089     /// <b>Algorithm of the method is as follows</b>
00090     std::ofstream ofs(fileName);
00091     ofs << this;
00092     ofs.close(); ///* User needs to implement file storage based on host. 
00093 #endif
00094 }
00095 #endif
00096 
00097 #ifdef OPT3101_USE_STDIOLIB
00098 void OPT3101::phaseOffsetC::loadFromFile(char * fileName)
00099 {
00100 #ifdef OPT3101_USE_STREAMLIB
00101     /// <b>Algorithm of the method is as follows</b>
00102     std::ifstream ifs(fileName);
00103     ifs >> this;
00104     ifs.close(); ///* User needs to implement file load/restore based on host. 
00105 #endif
00106 }
00107 #endif
00108 
00109 #ifdef OPT3101_USE_STREAMLIB
00110 std::ostream & OPT3101::operator<<(std::ostream & os, const phaseOffsetC * data)
00111 {
00112     /// <b>Algorithm of the method is as follows</b>
00113     os << data->phaseOffset<<'\n'; ///* Serializes all the members and returns to the stream 
00114     os << data->referenceDistanceInCodes << '\n';
00115     os << data->illumScale << '\n';
00116     os << data->illumDac << '\n';
00117     os << data->illumDCdac << '\n';
00118     os << data->freqCount << '\n';
00119     os << data->shiftIllumPhase << '\n';
00120     os << &data->data << '\n';
00121     return os;
00122 }
00123 #endif
00124 
00125 #ifdef OPT3101_USE_STREAMLIB
00126 std::istream & OPT3101::operator>>(std::istream & is, phaseOffsetC * data)
00127 {
00128     /// <b>Algorithm of the method is as follows</b>
00129     is >> data->phaseOffset; ///* Reads from stream and de-serializes all the members 
00130     is >> data->referenceDistanceInCodes;
00131     is >> data->illumScale;
00132     is >> data->illumDac;
00133     is >> data->illumDCdac;
00134     is >> data->freqCount;
00135     is >> data->shiftIllumPhase;
00136     is >> &data->data;
00137     return is;
00138 }
00139 #endif
00140