Reference

Library

Download and install the TMF8×01 Library. (About how to install the library?)

API Description

int begin();

/**
 * @brief sleep sensor by software, the sensor enter sleep mode(bootloader). Need to call wakeup function to wakeup sensor to enter APP0
 */
  void sleep();
/**
 * @brief wakeup device from sleep mode, it will running app0
 * @return enter app0 return true, or return false.
 */
  bool wakeup();

/**
 * @brief get a unique number of sensor .Each sensor has a unique identifier.
 * @return return 4bytes unique number:
 * @n  the byte0 of return: serial_number_0
 * @n  the byte1 of return: serial_number_1
 * @n  the byte2 of return: identification_number_1
 * @n  the byte2 of return: identification_number_0
 */
  uint32_t getUniqueID();
/**
 * @brief get sensor's model.
 * @return return a String:
 * @n  TMF8801: the sensor is TMF8801
 * @n  TMF8701: the sensor is TMF8701
 * @n  unknown : unknown device
 */
  String getSensorModel();
/**
 * @brief get software version of patch.
 * @return return string of device software version,format:
 * @n major.minor.patch numbers.chip id version
 */
  String getSoftwareVersion();
/**
 * @brief Get 14 bytes of calibration data.
 * @param data Cache for storing calibration data
 * @param len The bytes of calibration data,its value can only be 14 bytes
 * @return Vail data return true, or return false.
 */
  bool getCalibrationData(uint8_t *data, uint8_t len = SENSOR_MTF8x01_CALIBRATION_SIZE);
/**
 * @brief set 14 bytes of calibration data.
 * @param data Pointer to calibration data.
 * @param len The bytes of calibration data,its value can only be 14 bytes
 * @return set sucess return true, or return false.
 */
  bool setCalibrationData(uint8_t *data, uint8_t len = SENSOR_MTF8x01_CALIBRATION_SIZE);

/**
 * @brief disable measurement config. Need to call startMeasurement before using this function. 
 */
  void stopMeasurement();
/**
 * @brief Waiting for data ready.
 * @return if data is valid, return true, or return false.
 */
  bool isDataReady();
/**
 * @brief get distance, unit mm. Before using this function, you need to call isDataReady().
 * @return return distance value, unit mm.
 */
  uint16_t getDistance_mm();
/**
 * @brief enable INT pin. If you call this function,which will report a interrupt
 * @n signal to host by INT pin when measure data is ready.
 */
  void enableIntPin();
/**
 * @brief disable INT pin.
 */
  void disableIntPin();
/**
 * @brief power on sensor when power down sensor by EN pin.
 * @return sucess return True, or return False
 */
  bool powerOn();
/**
 * @brief power down sensor by EN pin.
 * @return sucess return True, or return False
 */
  bool powerDown();

/**
 * @brief get I2C address.
 * @return return 7 bits I2C address
 */
  uint8_t getI2CAddress();
/**
 * @brief Config the pin of sensor.
 * @param pin: The pin of sensor, example PIN0 and PIN1,which is an enumerated variable of ePin_t.
 * @n     ePIN0:  The PIN0 of sensor config.
 * @n     ePIN1:  The PIN1 of sensor.
 * @n     eGPIOTotal:  both of PIN0 and PIN1.
 * @param config:  The config of pin, which is an enumerated variable of ePinControl_t.
 */
  void pinConfig(ePin_t pin, ePinControl_t config);

Was this article helpful?

ON THIS PAGE

TOP