0

I'm using a Teensy 3.5 to run a LidarLite v3 module and am getting the following error:

teensy no known conversion for argument 2 from 'int16_t* {aka short int*}' to 'int*'

This error is repeating for a number of different functions. How can I make the compiler use a 16-bit int instead of a 32-bit int?

Update 1:

The code run is:

#include <Arduino.h>
#include <Wire.h>
#include <I2CFunctions.h> 
#include <LidarObject.h>
#include <LidarController.h>

#define WIRE400K true
// Trigger pin, can be unplugged
#define Z1_LASER_TRIG 11
// Enable pin, IMPORTANT
#define Z1_LASER_EN 12
// Mode pin, can be unplugged
#define Z1_LASER_PIN 13
//Define address of lasers
//Thoses are written during initialisation
// default address : 0x62
#define Z1_LASER_AD 0x6E

#define NUMBER_OF_LASERS 1

// Create lasers
static LidarController Controller;
static LidarObject LZ1;

void setup()
{
  Serial.begin(115200);
  // Configure lasers
  LZ1.begin(Z1_LASER_EN, Z1_LASER_PIN, Z1_LASER_TRIG, Z1_LASER_AD, 2, DISTANCE, 'A');
  LZ1.setCallbackDistance(&distance_callback);
  // Add the laser to the Controller
  Controller.add(&LZ1, 0);

  delay(100);
  Controller.begin(WIRE400K);
  delay(100);
}

void distance_callback(LidarObject* self){
   Serial.println(self->distance);
}

void loop()
{
  Controller.spinOnce();
  // Rest of your non blocking application. 
}

Library in question located at: https://github.com/AlexisTM/LIDAREnhanced

Adam Sampson
  • 1,971
  • 1
  • 7
  • 15
  • Please post some code that reproduces the error. I'm not gonna search through half of Github to find that line. Please note that questions in self-answered Q&A is expected to hold the same quality as ordinary questions. In this case a [mcve] is needed. – Lundin Aug 24 '18 at 06:55
  • Can do. I'll have to be back on that computer to get to the code to make a minimal reproducible example. I should've included my code that didn't run at least. – Adam Sampson Aug 24 '18 at 14:19
  • I've added the code with the problem. When I get to the computer with the compiler I'll get the output of the console. – Adam Sampson Aug 24 '18 at 19:09

1 Answers1

0

As other answers on this site state, the teensy board is a 32-bit board which means that the int is 32 bits. The LIDAREnhanced library and the WIRE libraries both are assuming that in is 16 bits.

In order to fix the LIDAREnhanced library you need to go into LidarController.h and change every reference to int to int16_t. This will force the compiler to treat ever integer in the file as the same type.

In addition, for the Teensy 3.x, I also changed every #include <Wire.h> to #include <i2c_t3.h>. The i2c_t3 library was designed to handle i2c communications for teensy 3.x boards.

Adam Sampson
  • 1,971
  • 1
  • 7
  • 15