Teensyduino 1.23 Beta #2 Available

Status
Not open for further replies.
Hello,

Don't know if it's my code or the new Teensy beta applied on Arduino IDE 1.6.4/MacOS X 10.7.5, but I got this error message after my first attempt to compile:

/Applications/Arduino1.6.4+Teensy1.2.3.app/Contents/Java/hardware/teensy/avr/cores/teensy3/Print.h:66:9: note: no known conversion for argument 1 from 'double(double)' to 'long unsigned int'
Erreur lors de la compilation.


Code:
#include <Wire.h>

#define DEVICE1 (0x53) // Device address as specified in data sheet (SDO set to GND)
#define DEVICE2 (0x1D) // Second Device address as specified in data sheet (SDO set to +3.3V)

byte _buff[6];
char POWER_CTL = 0x2D;    //Power Control Register
char DATA_FORMAT = 0x31;
char DATAX0 = 0x32;    //X-Axis Data 0
char DATAX1 = 0x33;    //X-Axis Data 1
char DATAY0 = 0x34;    //Y-Axis Data 0
char DATAY1 = 0x35;    //Y-Axis Data 1
char DATAZ0 = 0x36;    //Z-Axis Data 0
char DATAZ1 = 0x37;    //Z-Axis Data 1
int x1, y1, z1; // variables to hold final data for accel 1

void setup()
{

  Wire.begin(); // join i2c bus (address optional for master)
  Serial.begin(19200); // start serial for output. Make sure you set your Serial Monitor to the same!
  Serial.println("init");
  //Put the ADXL345 1 into +/- 4G range by writing the value 0x01 to the DATA_FORMAT register.
  newWriteTo(DATA_FORMAT, 0x01, DEVICE1);
  //Put the ADXL345 1 into Measurement Mode by writing 0x08 to the POWER_CTL register.
  newWriteTo(POWER_CTL, 0x08, DEVICE1);
  //Put the ADXL345 1 into +/- 4G range by writing the value 0x01 to the DATA_FORMAT register.
  newWriteTo(DATA_FORMAT, 0x01, DEVICE2);
  //Put the ADXL345 1 into Measurement Mode by writing 0x08 to the POWER_CTL register.
  newWriteTo(POWER_CTL, 0x08, DEVICE2);
}

void loop()
{
  newReadAccel(); // read the x/y/z tilt on accelerometer
  delay(50); // read every 50 ms only
}

// function to read accelerometer data from chosen device using Wire library and send them to serial port
void newReadAccel() {
  uint8_t howManyBytesToRead = 6;
  newReadFrom(DATAX0, howManyBytesToRead, _buff, DEVICE1); //function call to read the acceleration data from the ADXL345
  // each axis reading comes in 10 bit resolution, ie 2 bytes. Least Significat Byte first!!
  // thus we are converting both bytes in to one int
  x1 = (((int)_buff[1]) << 8) | _buff[0];
  y1 = (((int)_buff[3]) << 8) | _buff[2];
  z1 = (((int)_buff[5]) << 8) | _buff[4];

  Serial.print("x1: ");
  Serial.print( x1 );
  Serial.print(" y1: ");
  Serial.print( y1 );
  Serial.print(" z1: ");
  Serial.print( z1 );

  delay(2);
}

// newWriteTo function to write data into I2C devices with chosen device address
void newWriteTo(byte address, byte val, char device) {
  Wire.beginTransmission(device); // start transmission to device
  Wire.write(address); // send register address
  Wire.write(val); // send value to write
  Wire.endTransmission(); // end transmission
}

// newReadFrom Function to read num bytes starting from address register on chosen device in to _buff array
void newReadFrom(byte address, int num, byte _buff[], char mydevice) {
  Wire.beginTransmission(mydevice); // start transmission to device
  Wire.write(address); // sends address to read from
  Wire.endTransmission(); // end transmission
  Wire.beginTransmission(mydevice); // start transmission to device
  Wire.requestFrom(mydevice, num); // request 6 bytes from device
  int i = 0;
  while(Wire.available()) // device may send less than requested (abnormal)
  {
    _buff[i] = Wire.read(); // receive a byte
    i++;
  }
  Wire.endTransmission(); // end transmission
}

// low-pass (smooth) function
int smooth(int data, float filterVal, float smoothedVal){


  if (filterVal > 1){      // check to make sure param's are within range
    filterVal = .99;
  }
  else if (filterVal <= 0){
    filterVal = 0;
  }

  smoothedVal = (data * (1 - filterVal)) + (smoothedVal  *  filterVal);

  return (int)smoothedVal;
}
 
I have tried to compile the same code on an older IDE (Arduino 1.06 and Teensy 1.21ß3).

The error messages are much more precise:

MebiiiSpring2015-TestAccelerometer.ino:30:9: error: 'int y1' redeclared as different kind of symbol
In file included from /Applications/Arduino106+Teensy121.app/Contents/Resources/Java/hardware/teensy/cores/teensy3/WProgram.h:6:0,
from /Applications/Arduino106+Teensy121.app/Contents/Resources/Java/hardware/teensy/cores/teensy3/Arduino.h:1,
from /Applications/Arduino106+Teensy121.app/Contents/Resources/Java/libraries/Wire/Wire.h:26,
from MebiiiSpring2015-TestAccelerometer.ino:17:
/Applications/Arduino106+Teensy121.app/Contents/Resources/Java/hardware/tools/arm/arm-none-eabi/include/math.h:469:15: error: previous declaration of 'double y1(double)'
extern double y1 _PARAMS((double));
^
MebiiiSpring2015-TestAccelerometer.ino: In function 'void newReadAccel()':
MebiiiSpring2015-TestAccelerometer.ino:57:6: error: assignment of function 'double y1(double)'
MebiiiSpring2015-TestAccelerometer.ino:57:6: error: cannot convert 'int' to 'double(double)' in assignment


The line pointed to is this one:
Code:
y1 = (((int)_buff[3]) << 8) | _buff[2];

I still don't know whether it's my code or the IDE, but I am almost sure it ran flawlessly on another board previously (Arduino Pro Mini).
 
That error seems to say you've also got a function named "y1" in the rest of your code (which you didn't post).

Obviously, if you name a variable the same as a function, that's going to confuse the compiler when you try to use the variable.
 
That error seems to say you've also got a function named "y1" in the rest of your code (which you didn't post).

Obviously, if you name a variable the same as a function, that's going to confuse the compiler when you try to use the variable.

The complete code is in the previous message and I don't see where I define y1 as a function...

???
 
Try reading the error message it states where it can be found
previous declaration of 'double y1(double)'
y1 is one of the bessel functions
 
Actually it is defined internal to the compiler. If you look at the error message:
from Test.ino:1:
c:\arduino-1.6.4\hardware\tools\arm\arm-none-eabi\include\math.h:469:15: error: previous declaration of 'double y1(double)'
extern double y1 _PARAMS((double));
^

And if you look at math.h it defines several externs, like:
extern double y0 _PARAMS((double));
extern double y1 _PARAMS((double));
extern double yn _PARAMS((int, double));
extern double j0 _PARAMS((double));
extern double j1 _PARAMS((double));
extern double jn _PARAMS((int, double));
 
Oh, yes, I didn't catch that. Looks like math.h defines y1.

But avr-libc's math.h doesn't define this (and a LOT of other stuff).

Maybe Teensyduino should trim some of the math.h stuff that's so likely to conflict? The other common conflict seems to be "gamma".
 
Actually it is defined internal to the compiler. If you look at the error message:


And if you look at math.h it defines several externs, like:

So it's just a conflicting variable name ?

By the way why is Arduino IDE 1.0.6 so much more talkative about compilation errors than 1.6.4 ?
 
1.0.x and 1.6.x use separate prefs. Look at File > Preferences on both. Perhaps you have different settings? Maybe the "verbose info while compiling" setting?
 
Status
Not open for further replies.
Back
Top