API

class TouchlabComms

Touchlab communication main class.

Public Functions

TouchlabComms()

Construct a new Touchlab Comms object.

virtual ~TouchlabComms()

Destroy the Touchlab Comms object.

void init(const std::string &filename = "")

Init comm.

Parameters:

filename – path to the sensor param binary file

void connect(const std::string &port)

Connect to the sensor.

Parameters:

port – Serial port name, e.g. COM1, or /dev/ttyACM0.

void read_raw(std::vector<double> &data, int64_t timeout = 500.0)

Read raw signal.

Parameters:
  • data – Returned raw data vector from the latest data packet

  • timeout – Timeout in ms

void read(std::vector<double> &data, int64_t timeout = 500.0)

Read calibrated data.

Parameters:
  • data – Return data calibrated by the model defined by the SensorParameters class

  • timeout – Timeout in ms

void read_register(uint16_t device, uint16_t reg, std::vector<uint8_t> &data, int64_t timeout = 500.0)

Read a value of a register This method is not intended for end users and it will fail with an exception.

Parameters:
  • device – Device ID

  • reg – Register address

  • data – Output data vector

  • timeout – Timeout in ms

void write_register(uint16_t device, uint16_t reg, const std::vector<uint8_t> &data, int64_t timeout = 500.0)

Write a value to a register This method is not intended for end users and it will fail with an exception.

Parameters:
  • device – Device ID

  • reg – Register address

  • data – Data vector to write

  • timeout – Timeout in ms

bool is_connected()

Returns if the sensor is connected and communicating.

Returns:

std::string True if connected

void zero(const std::vector<int> &ind = {})

Zero out sensor offset.

Parameters:

ind – Optional vector of sensor indices to zero out. If empty, all taxels will be zeroed.

void zero(const std::vector<std::vector<double>> &data, const std::vector<int> &ind = {})

Zero out sensor offset with custom data.

Parameters:
  • data – Custom data used to zero the sensor. Inner vector should have one element for each taxel. The outer vector should contain n samples of input data.

  • ind – Optional vector of sensor indices to zero out. If empty, all taxels will be zeroed.

void translate(const std::vector<double> &raw, std::vector<double> &calibrated)

Translate raw data sample into calibrated values.

Parameters:
  • raw – Input raw data

  • calibrated – Output calibrated data

Public Static Functions

static std::string get_version()

Get the version of the API.

Returns:

std::string Version string