Arduino 1.8.6 within the next 2 weeks

Status
Not open for further replies.
I've mentioned this before, but I'll do it again.

This isn't necessarily for 1.43, but it would be nice if Adafruit_ST7735 was updated. It looks like your version is based on the December 2013 release. The next change (Sep 5, 2014 to add 128x128 displays) is not in your tree. And then in Sep 2, 2017 they did a major re-organization, adding support for Adafruit_ST7789 as a separate device, and both 7735/7789 calling into common 77xx files.
 
Does IDE 1.8.6 present any set of changes that could help or impact Teensy usage? At least TD 1.42 got cleaned up and out in good shape without apparent issues :)
 
One Drive bug fixed?

Does IDE 1.8.6 present any set of changes that could help or impact Teensy usage? At least TD 1.42 got cleaned up and out in good shape without apparent issues :)

Hi All,
First post here.....

A feature in 1.4.3 that might be nice is to possibly allow it to install with the nightly arduino releases. Or not. ;-)

From what I gather from one of Paul's comments here, arduino V 1.8.6 will fix the 'Error compiling for board Teesy 3.x' problem with Win 10 OneDrive. I (desperately) hope 1.8.6 fixes that, and so I anxiously await 1.4.3.

Cheers,
-a
 
.... problem with Win 10 OneDrive. I (desperately) hope 1.8.6 fixes that

Any chance I could talk you into doing a couple quick Windows tests while we wait?

First, quit and restart Arduino 1.8.5. Make sure Teensy 3.2 is selected in Tools > Boards. Then open File > Examples > Audio > WavFilePlayer. Get a stopwatch or clock with seconds and time how long it takes to Verify. The idea is to see how long a Verify takes when Arduino has just started up and how no previous temporary files. Please do this first, so after messing with your Arduino install you can do it again (of course after restarting the program) to compare whether the speed changes.

Then download the latest Arduino nightly build for Windows.

While you're waiting for the download, find arduino-builder.exe. If you ran the installer, it should be in C:\Program Files (x86)\Arduino. The arduino-builder.exe file from 1.8.5 is 3291136 bytes.

Extract the nightly ZIP file (in a new/empty location - *not* on top of your 1.8.5 install). Find the extracted arduino-builder.exe. It's much larger, 12014592 byte in the copy on their site today. Delete the old arduino-builder.exe and copy the new one into your Arduino 1.8.5 folder.

Then look for the "tools-builder" folder in both copies. Arduino 1.8.5 should have only a "ctags" folder there. The new nightly should have ctags and also "arduino-preprocessor". Copy this arduino-preprocessor folder (and all its contents) from the extracted nightly into your 1.8.5's tools-builder folder.

Then restart Arduino 1.8.5. Two questions:

1: Does the speed of a first-time-compile after restarting the software change? Is the new arduino-builder.exe faster or slower, or about the same? (If the speed is different, which CPU, how much RAM, and type of harddrive ssd vs disk does your PC have?)

2: Does the new arduino-builder.exe solve the OneDrive problems on your machine when using Teensy?

I mostly use Linux and occasionally Macintosh, so I'm really depending on feedback from Windows users. Hope you might have a little time to try this and let me know the results?
 
The 1.8.5 arduino-builder was 3,291,136 bytes. I deleted it, and replaced it with the latest nightly build (downloaded about noon today EST) and it's 12,014,592 bytes.

I copied the arduino-preprocessor directory into the 1.8.5 subdir and restarted. Initial verify time for wavefileplayer was 46 seconds. New time is 27 seconds.

Not sure yet if my sketch compiles, I have a bunch of stuff screwed up from my debugging attempts. Don't waste your time on the code below, I'll wrestle with it. The basic error I'm getting is "'i2c_' was not declared in this scope", so the compiler just isn't finding the library.....no biggie.

I'm running one of the new NUC PC's.......pretty sweet I must say....... i7-8809F, 3.1GHz, 16GbRam, SSHD.

-a





Code:
#include <i2c_t3.h>
#include <LIDARLite.h>
//#include <wire.h>
#include <LiquidCrystal.h> //C:\Users\John\Downloads\arduino-1.8.3-windows\arduino-1.8.3\libraries\LiquidCrystal\src\LiquidCrystal.h
#include <Adafruit_MCP23017.h>  //For I2C to register specific for MCP23017
#include "sprites_jwb.h"
#include "pitches.h"

// Garmin LIDAR constants (register addresses) 
#define PASS (1)
#define LIDARLite_ADDRESS 0x62 // Default I2C Address of LIDAR-Lite.
#define RegisterMeasure 0x00   // Register to write to initiate ranging.
#define LIDAR_SN_HighByte 0x16               // Fetch this for unlocking
#define LIDAR_SN_LowByte 0x16                // Fetch this for unlocking
#define LIDAR_Unlock_I2C_Addr_High 0x18      // Write SN high byte to unlock.
#define LIDAR_Unlock_I2C_Addr_Low  0x19      // Write SN low byte to unlock.
#define LIDAR_New_I2C_Addr 0x1a              // Where to place new I2C addr after 'unlock'.
#define MeasureValue 0x04 // Value to initiate ranging.
#define RegisterHighLowB 0x8f // Register to get both High and Low bytes in 1 call.

#define PIN_Speaker_Out (2)
#define Pin_Lidar1_Enab (3)   // low disables Lidar
#define trigPin (5)           // For uSound
#define echoPin (6)           // For uSound
#define PIN_Teensy_Led  (13)  // on-board LED
#define analogInPin (15)      // A-D converter for potentiometer
#define analog_2_InPin (23)   // A-D converter for thermistor
#define LIDAR_DELAY (50)
#define LIDAR_SHORT_DELAY (10)
long duration;
float uS_distance, Laser_distance;


Adafruit_MCP23017 mcp;
LiquidCrystal lcd(14,16,17,12,11,20);  
elapsedMillis sincePrint;

static int bDistanceMode = 0, SpeakerON_OFF = 0;
static unsigned long T1, T2;

void setup()
{
  // Set up on-baord LED.....
  pinMode(PIN_Teensy_Led,OUTPUT);  digitalWrite(PIN_Teensy_Led, HIGH);

  //Wire.begin(); // join i2c bus
  Wire.begin(I2C_MASTER, 0, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_100, I2C_OP_MODE_DMA );

  pinMode(Pin_Lidar1_Enab, OUTPUT); 
  digitalWrite(Pin_Lidar1_Enab, LOW);  // LOW Disables Lidar1 for now 

  mcp.begin();      // use default address 0   
  // init switch and LED on port A side of MCP
  mcp.pinMode(7, OUTPUT);  // An LED   at MCP23017 pin 28, Port A, bit 7 
  mcp.pinMode(6, INPUT); mcp.pullUp(6, HIGH);   // A switch at MCP23017 pin 3,  Port B, bit 2
  // init switch and LED on port B side of MCP
  mcp.pinMode(8, OUTPUT);  // An LED   at MCP23017 pin 1,  Port B, bit 0
  mcp.pinMode(9, INPUT);  mcp.pullUp(9, HIGH);    // A switch at MCP23017 pin 2,  Port B, bit 1
  //Start with LED's off......
  mcp.digitalWrite(8, LOW); mcp.digitalWrite(7, LOW); 

  Serial.begin(115200);    //while(!Serial){ Serial.print("Serial good"); }
  
  // Get LCD going......
  lcd.begin(20, 4);    lcd.clear();   lcd.print("Push buttons");        
  for ( int n=0; n<=7; n++){   // make the 8 sprites supported by the LCD for bar graph.
    lcd.createChar(n, lcd_sprite[n]);
  }

  //uSound pins;
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  
  digitalWrite(Pin_Lidar1_Enab, HIGH);  
  delay(100); // give the lidar 100mS to startup
//  while(PASS !=  Move_Lidar_1_Address()){  // PASS/FAIL 
//    lcd.printf("I2C Addr FAILED");
//  }
  digitalWrite(PIN_Teensy_Led, LOW);
}


void loop(){
int out ; 
float voltage, V_Thermistor;
int FrequencyOffset = 5000, n;
static int AvgADreading, VoltReadings[25], AccumVoltReads;

  ServiceUserSwitches();


/* Now that we have read the user switches, do what the program can do.
   *  
   */
  if (bDistanceMode != 0){  // Pulse and read the ultrasound xducer/
    // First, get all the data......will print later.
    // Get the ultrasound distance.......
    digitalWrite(trigPin, LOW);    delayMicroseconds(2);  //Make sure Xducer trigger is low long enough to recognize the next pulse.
    digitalWrite(trigPin, HIGH);   delayMicroseconds(10);   digitalWrite(trigPin, LOW);    // Sets the trigPin on HIGH state for 10 micro seconds
    duration = pulseIn(echoPin, HIGH);  // Reads the echoPin, returns the sound wave travel time in microseconds
    uS_distance= (float)(duration*0.034/2)/100;         // Convert to meters from uS.
    // Then get the laser distance.....

    Laser_distance = (float)readDistance()/100;  //convert cm to meters.

    //    lcd.setCursor(0,0);  lcd.printf("T-return:%6d", duration);     lcd.setCursor(18,0); lcd.printf("uS");  
    //lcd.setCursor(0,1);  lcd.printf("%5.3f", uS_distance);  
    //lcd.setCursor(9,1);  lcd.printf("%5.3f", Laser_distance);  
    //lcd.setCursor(19,1); lcd.printf("m"); 
    
    // (get rid of this crap.....)
    // 'smooth out that noisy pot/A-D by taking a running average of 25 readings.
    AccumVoltReads = 0;    
    for (n=0; n<=23; n++){
      AccumVoltReads += VoltReadings[n];  // might as well accumulate the voltage for an average while we're stepping through.
      VoltReadings[n] = VoltReadings[n+1];  // shift the past 23 readings down by one.
    }
    VoltReadings[24] = analogRead(analog_2_InPin);
    AccumVoltReads += VoltReadings[24];   // add on that last new reading.
    AvgADreading = AccumVoltReads / 25;   // Get the average over the last 25.
    FrequencyOffset =  AvgADreading*20; // 0-20460 Hz range

    lcd.setCursor(0,0);
    switch (SpeakerON_OFF){
      case 0: lcd.printf("Speaker OFF");  noTone(PIN_Speaker_Out);  break;
      case 1: lcd.printf("Speaker uSound Mode");                    
              tone(PIN_Speaker_Out, FrequencyOffset - (float)uS_distance * 1000 );  break;
      case 2: lcd.printf("Speaker LIDAR Mode");                    
              tone(PIN_Speaker_Out, FrequencyOffset - (float)Laser_distance * 1000);        break;
      default: SpeakerON_OFF = 0;  
               lcd.printf("Speaker OFF");  noTone(PIN_Speaker_Out); break;
    }

    PrintBar(1, 'm', 5, uS_distance);
    PrintBar(2, 'm', 5, Laser_distance);
    if(SpeakerON_OFF == 2){ tone(PIN_Speaker_Out, FrequencyOffset - (float)Laser_distance * 1000);}   
    lcd.setCursor(0,3); lcd.printf("dT=     uS"); 
    lcd.setCursor(3,3); lcd.printf("%4u", T2-T1); 
    lcd.setCursor(10,3); lcd.printf(" Fo=      Hz"); 
    lcd.setCursor(14,3); lcd.printf("%5u", FrequencyOffset); 

    //lcd.setCursor(0,3);  lcd.printf("A2D:%4d  Foff:%5d", VoltReadings[24], AvgADreading*10);  // write to the LCD
    //lcd.setCursor(16,3); lcd.printf(" m"); 
  
  }else{ //This is the 'regular' mode which just displays the thermistor output and the voltage of the potentiometer
    noTone(PIN_Speaker_Out);
    V_Thermistor = (float)(analogRead(analogInPin) * 5.0 / 1023.0);   //Read Thermistor
    voltage = (float)(analogRead(analog_2_InPin) * 5.0 / 1023.0);   //Read Potentiometer
    PrintBar(2, 'V', 5.0, voltage);
    PrintBar(3, 'T', 1.5, V_Thermistor);
  }


  /*  Laser data to serial monitor (keep for debugging?)
  Serial.print(sincePrint);
  sincePrint = 0;

  Serial.print(">");
  Serial.println(out = readDistance());

  if (out == 0){
  Serial.println("Getting sick");
  }  */

}

/*
int Move_Lidar_1_Address(){
 LIDARLite_ADDRESS 0x62 // Default I2C Address of LIDAR-Lite.
 RegisterMeasure 0x00   // Register to write to initiate ranging.
  LIDAR_SN_HighByte 0x16               // Fetch this for unlocking
  LIDAR_SN_LowByte 0x16                // Fetch this for unlocking
  LIDAR_Unlock_I2C_Addr_High 0x18      // Write SN high byte to unlock.
  LIDAR_Unlock_I2C_Addr_Low  0x19      // Write SN low byte to unlock.
  LIDAR_New_I2C_Addr 0x1a              // Where to place new I2C addr after 'unlock'. 
*/
/**********************************
uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses
  T1 = micros();
  lcd.println("Reassigning.");
  while (nackack != 0){ // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
  // Wait 1 ms to prevent overpolling

  Wire.beginTransmission(LIDARLite_ADDRESS);
 
  Wire.read(RegisterMeasure);
  Wire.write(MeasureValue);
  nackack = Wire.endTransmission(I2C_STOP,1000);
    if (nackack!=0){
      delayMicroseconds(LIDAR_SHORT_DELAY);
    }
  }
  
  nackack = 100;
  while (nackack != 0){
    Wire.beginTransmission(LIDARLite_ADDRESS);
    Wire.write(RegisterHighLowB);    // sets register pointer to (0x8f)
    nackack = Wire.endTransmission(I2C_STOP,1000);
    if (nackack!=0){
      delayMicroseconds(LIDAR_SHORT_DELAY);
    }
    Wire.requestFrom(LIDARLite_ADDRESS,2,I2C_STOP,1000 );
    //delayMicroseconds(LIDAR_DELAY);
  }
    
  int reading = Wire.readByte() ;
  reading = reading << 8;
  reading |= Wire.readByte();
  T2 = micros();
  delayMicroseconds(100);
  return reading;      
  *************************************/

//}

int readDistance(){
uint8_t nackack = 100; // Setup variable to hold ACK/NACK resopnses
  T1 = micros();
  while (nackack != 0){ // While NACK keep going (i.e. continue polling until sucess message (ACK) is received )
  // Wait 1 ms to prevent overpolling
  Wire.beginTransmission(LIDARLite_ADDRESS);
  Wire.write(RegisterMeasure);
  Wire.write(MeasureValue);
  nackack = Wire.endTransmission(I2C_STOP,1000);
    if (nackack!=0){
      delayMicroseconds(LIDAR_SHORT_DELAY);
    }
  }
  
  nackack = 100;
  while (nackack != 0){
    Wire.beginTransmission(LIDARLite_ADDRESS);
    Wire.write(RegisterHighLowB);    // sets register pointer to (0x8f)
    nackack = Wire.endTransmission(I2C_STOP,1000);
    if (nackack!=0){
      delayMicroseconds(LIDAR_SHORT_DELAY);
    }
    Wire.requestFrom(LIDARLite_ADDRESS,2,I2C_STOP,1000 );
    //delayMicroseconds(LIDAR_DELAY);
  }
    
  int reading = Wire.readByte() ;
  reading = reading << 8;
  reading |= Wire.readByte();
  T2 = micros();
  delayMicroseconds(100);
  return reading;

}


/* Routing to print a bar graph representation of a floating point value.
 *    arguments are:
 *      int Bar_LCD_Row        -- which area of the LCD for the bar graph.  0-3.
 *      char Unit              -- a sincle charachter which is a unit of measure.  S = seconds, V = volts, etc.
 *      float FullscaleValue   -- The maximum expected range.
 *      float ValueToPlot
 */    
void PrintBar(int Bar_LCD_Row, char Unit, float FullscaleValue, float ValueToPlot){
  int BarsNeeded,CellsNeeded, n, remainder;
  lcd.setCursor(0,Bar_LCD_Row);  lcd.print("                    "); //Clear plot area
  lcd.setCursor(0,Bar_LCD_Row); lcd.printf("%3.2f%c",ValueToPlot,Unit);  //Value and unit charachter
  BarsNeeded = (ValueToPlot*15*5/FullscaleValue);  //Plot over 16 cells on LCD.  5 bars per cell.
  CellsNeeded = (BarsNeeded/5);
  remainder = BarsNeeded - (CellsNeeded * 5);
  if (BarsNeeded <= 75){
    for (n=0; n<CellsNeeded; n++){         //if(CellsNeeded > 0) 
      lcd.write(byte(4)); //sprite for a cell with all 5 bars on   
    }
    if(remainder>0 && remainder<=5)lcd.write(byte(remainder-1));   // plot leftover bars
  }
}

/*  This silly routine just plays 'shave and a haircut'.
 *  But......right now it also toggles the programs two main modes!  
 */
void PlayTheTune(int scale){    
   if (scale >= 2) scale = 2;
   for (int thisNote = 0; thisNote < 8; thisNote++) {        // to calculate the note duration, take one second divided by the note type. e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
     int noteDuration = 750 / noteDurations[thisNote];
     if(melody[scale*8+thisNote] > 1){ // a 0 in the array of frequencies (tones, or notes) means no note to be played, a 'rest' in music.
       tone(PIN_Speaker_Out, melody[scale*8+thisNote], noteDuration);        // to distinguish the notes, set a minimum time between them.      // the note's duration + 30% seems to work well:
     }
     int pauseBetweenNotes = 1.5* noteDuration;
     if(melody[scale*8+thisNote] > 1){digitalWrite(PIN_Teensy_Led, HIGH); 
     }  delay(pauseBetweenNotes/2);
       digitalWrite(PIN_Teensy_Led, LOW);  delay(pauseBetweenNotes/2);      
       noTone(PIN_Speaker_Out);     // stop the tone playing:
   }   //......  END of 'Shave and a Haircut'
}


void ServiceUserSwitches(){  // Check MCP for user input
  
  if(mcp.digitalRead(9) == 0){ //This is the 'mode' switch
    mcp.digitalWrite(8, HIGH); // Turn on the LED by the switch
    lcd.clear(); //lcd.setCursor(0,0);
    if (bDistanceMode != 1){ bDistanceMode = 1; 
        lcd.printf("Mode: Distance");  // write to the LCD
        PlayTheTune(2);
    }else{  bDistanceMode = 0;  
        lcd.printf("Mode: Volt-Temp");  // write to the LCD
        PlayTheTune(1);
    }
    //PlayTheTune(2);
    while(mcp.digitalRead(9) == 0){    // First, check port 9, which is on pin 2.  // The switch is low active, it is logically 1 when closed (low)
      lcd.setCursor(19,3);  lcd.write(byte(2));     // Write the confused face sprite.....
    } 
    lcd.clear(); mcp.digitalWrite(8, LOW);
  } 

  // Check the other switch which turns the sound on and off
  if(mcp.digitalRead(6) == 0){ 
    lcd.clear();      mcp.digitalWrite(7, HIGH);  
    SpeakerON_OFF += 1;  
    if ( SpeakerON_OFF > 2) SpeakerON_OFF = 0;
    while(mcp.digitalRead(6) == 0){   
      lcd.setCursor(19,3);  lcd.write(byte(2));     // Write the confused face sprite.....
    }  
    lcd.clear(); mcp.digitalWrite(7, LOW); 
  }
}



// * [URL]https://os.mbed.com/teams/Impact-Echo/code/LidarLite_Multi-Unit/file/a01dc8b52be4/LidarLite.cpp/[/URL]
 /* =============================================================================
  Configure
  Sets the configuration for the sensor, typically this is done in the begin()
  command, but sometimes (especially for multi-sensor applications) you will
  need to do this separately.
  Parameters
  ------------------------------------------------------------------------------
  - configuration: set the configuration for the sensor
    - default or 0 = equivelent to writing 0x00 to 0x00, i.e. full reset of
      sensor, if you write nothing for configuration or 0, the sensor will init-
      iate normally
    - 1 = high speed setting, set the aquisition count to 1/3 the default (works
      great for stronger singles) can be a little noisier
============================================================================= */




/*
void LidarLite::configure(int configuration, char LidarLiteI2cAddress){
  uint8_t nackack = 1;
  switch (configuration){
    case 0: //  Default configuration
        nackack=i2c_.write(LidarLiteI2cAddress);        //device address with write condition
        if(nackack != 1)break;                       //No Ack, return False
        nackack=i2c_.write(0x00);                       //device ram address where obj value is present
        if(nackack != 1)break;                       //No Ack, return False
        //ack=i2c_.write(LidarLiteI2cAddress|0x00);   //device address with write condition (read is 0x01)
        //if(!ack)return false;                       //No Ack, return False
        i2c_.write(0x00);                              
    break;
  
    case 1: //  Set aquisition count to 1/3 default value, faster reads, slightly
            //  noisier values
      write(0x04,0x00,LidarLiteI2cAddress);
    break;
    case 2: //  Low noise, low sensitivity: Pulls decision criteria higher
            //  above the noise, allows fewer false detections, reduces
            //  sensitivity
      write(0x1c,0x20,LidarLiteI2cAddress);
    break;
    case 3: //  High noise, high sensitivity: Pulls decision criteria into the
            //  noise, allows more false detections, increses sensitivity
      write(0x1c,0x60,LidarLiteI2cAddress);
    break;
   
  }
}*/
 
 
 
/* =============================================================================
  Change I2C Address for Single Sensor
  LIDAR-Lite now has the ability to change the I2C address of the sensor and
  continue to use the default address or disable it. This function only works
  for single sensors. When the sensor powers off and restarts this value will
  be lost and will need to be configured again.
  There are only certain address that will work with LIDAR-Lite so be sure to
  review the "Notes" section below
  Process
  ------------------------------------------------------------------------------
  1.  Read the two byte serial number from register 0x96
  2.  Write the low byte of the serial number to 0x18
  3.  Write the high byte of the serial number to 0x19
  4.  Write the new address you want to use to 0x1a
  5.  Choose whether to use the default address or not (you must do one of the
      following to commit the new address):
      1.  If you want to keep the default address, write 0x00 to register 0x1e
      2.  If you do not want to keep the default address write 0x08 to 0x1e
  Parameters
  ------------------------------------------------------------------------------
  - newI2cAddress: the hex value of the I2C address you want the sensor to have
  - disablePrimaryAddress (optional): true/false value to disable the primary
    address, default is false (i.e. leave primary active)
  - currentLidarLiteAddress (optional): the default is 0x62, but can also be any
    value you have previously set (ex. if you set the address to 0x66 and dis-
    abled the default address then needed to change it, you would use 0x66 here)
  Example Usage
  ------------------------------------------------------------------------------
  1.  //  Set the value to 0x66 with primary address active and starting with
      //  0x62 as the current address
      myLidarLiteInstance.changeAddress(0x66);
  Notes
  ------------------------------------------------------------------------------
    Possible Address for LIDAR-Lite
    7-bit address in binary form need to end in "0". Example: 0x62 = 01100010 so
    that works well for us. Essentially any even numbered hex value will work
    for 7-bit address.
    8-bit read address in binary form need to end in "00". Example: the default
    8-bit read address for LIDAR-Lite is 0xc4 = 011000100. Essentially any hex
    value evenly divisable by "4" will work.
  =========================================================================== */
void changeAddress(char newI2cAddress,  bool disablePrimaryAddress, char currentLidarLiteAddress){
  //  Array to save the serial number
  char serialNumber[2];
  char serialAdr[1] = {0x96};
  //char newI2cAddressArray[1];
  uint8_t nackack = 1;
 
  //  Read two bytes from 0x96 to get the serial number
  //read(0x96,2,serialNumber,false,currentLidarLiteAddress);
    while(nackack !=0)
    {
        //wait_ms(1);
        nackack = i2c_.write((currentLidarLiteAddress<<1), serialAdr, 1);
    }
    nackack = 1; 
    while(nackack !=0)
    {
        wait_ms(1);
        nackack = i2c_.read((currentLidarLiteAddress<<1)|0x01, serialNumber, 2);
    }
  
  //  Write the low byte of the serial number to 0x18
  //write(0x18,serialNumber[0],currentLidarLiteAddress);
    char lowbyte[2] = {0x18, serialNumber[0]};
    nackack=1;
    while(nackack !=0)
    {
        wait_ms(1);
        nackack = i2c_.write((currentLidarLiteAddress<<1), lowbyte, 2);
    } 
  //  Write the high byte of the serial number of 0x19
  //write(0x19,serialNumber[1],currentLidarLiteAddress); 
    char highbyte[2] = {0x19, serialNumber[1]};
    nackack=1;
    while(nackack !=0)
    {
        wait_ms(1);
        nackack = i2c_.write((currentLidarLiteAddress<<1), highbyte, 2);
    }
    char newaddress[2] = {0x1a, newI2cAddress};
    nackack=1;
    while(nackack !=0)
    {
        wait_ms(1);
        nackack = i2c_.write((currentLidarLiteAddress<<1), newaddress, 2);
    }
  
  printf("WIN!");
  //  Choose whether or not to use the default address of 0x62
  if(disablePrimaryAddress){
    char disable[2] = {0x1e, 0x08};
    nackack=1;
    while(nackack !=0)
    {
        wait_ms(1);
        nackack = i2c_.write((currentLidarLiteAddress<<1), disable, 2);
    }
  }else{
    //write(0x1e,0x00,currentLidarLiteAddress);
    char enable[2] = {0x1e, 0x00};
    nackack=1;
    while(nackack !=0)
    {
        wait_ms(1);
        nackack = i2c_.write((currentLidarLiteAddress<<1), enable, 2);
    } 
  }
  return;
}
  
   
void changeAddressMultiPwrEn(int numOfSensors, char *i2cAddressArray, char currentAddress){
    for (int i = 0; i < numOfSensors; i++){
      changeAddress(i2cAddressArray[i],true,currentAddress); // We have to turn off the party line to actually get these to load
    }
}
 
Last edited:
If you're using Adafruit_MCP23017.h then you're going to need Wire.h rather than i2c_t3.h, because Adafruit's libs are all written to use ordinary Wire.h.
 
Thanks Paul. :) And anti-thanks to uSoft for OneDrive. Another good idea for taking over the world gone wrong.......who'd a thunkit?
-a
 
I think it did fix the one drive problem, because WaveFilePlayer compiled. But I must say I had also deleted the Arduino sketch folder from OneDrive, and did a few other random acts of OneDrive dis-ablement, so the test was not entierly pure.

Would very much like to include a driver for the MCP23017 that is compatible with i2c_t3.h. I've liked that chip since using it's predecessor 23016 with the PIC 16F877 a decade back. I tried to include i2c_t3.h in Adafruit_MCP23017.h instead of wire.h, but the compiler complains: 'i2c_' was not declared in this scope

Will keep putzing on......... :eek:
-a
 
It can't be long now....... ;-) But perhaps what I'm doing wrong is more fundamental. Should I be able to include i2c_t3.h instead of wire.h and compile? I went back to basics, blink.ino, added a few things in to try to compile, and sadly i2c_t3.h won't compile. What's weird is that I've used i2c_t3 this for other examples and it works great. My code is just this.....
#include <i2c_t3.h>
//#include <Wire.h>
//#include <WireKinetis.h>

#include "pitches.h"
#include <LIDARLite_v3HP.h>
#define PIN_Teensy_LED (13)
#define PIN_Speaker_Out (2)
int noteDuration;
int loopctr;

// Garmin LIDAR constants (register addresses)
#define PASS (1)
#define LIDARLite_ADDRESS 0x62 // Default I2C Address of LIDAR-Lite.
#define RegisterMeasure 0x00 // Register to write to initiate ranging.
#define LIDAR_SN_HighByte 0x16 // Fetch this for unlocking
#define LIDAR_SN_LowByte 0x16 // Fetch this for unlocking
#define LIDAR_Unlock_I2C_Addr_High 0x18 // Write SN high byte to unlock.
#define LIDAR_Unlock_I2C_Addr_Low 0x19 // Write SN low byte to unlock.
#define LIDAR_New_I2C_Addr 0x1a // Where to place new I2C addr after 'unlock'.
#define MeasureValue 0x04 // Value to initiate ranging.
#define RegisterHighLowB 0x8f // Register to get both High and Low bytes in 1 call.

void setup() {
pinMode(PIN_Teensy_LED, OUTPUT);
Serial.begin(115200);
Wire.begin(); // join i2c bus
// Wire.begin(I2C_MASTER, 0, I2C_PINS_18_19, I2C_PULLUP_EXT, I2C_RATE_100, I2C_OP_MODE_DMA );
PlayTheTune(2);
}

void loop() {
digitalWrite(PIN_Teensy_LED, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.print(loopctr); Serial.println(" ON");
delay(100);
digitalWrite(PIN_Teensy_LED, LOW); // turn the LED off by making the voltage LOW
delay(100);
Serial.print(loopctr); Serial.println(" OFF");
++loopctr;
}

void PlayTheTune(int scale){
if (scale >= 2) scale = 2;
for (int thisNote = 0; thisNote < 8; thisNote++) { // to calculate the note uSound_duration, take one second divided by the note type. e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
noteDuration = 750 / noteDurations[thisNote];
if(melody[scale*8+thisNote] > 1){ // a 0 in the array of frequencies (tones, or notes) means no note to be played, a 'rest' in music.
tone(PIN_Speaker_Out, melody[scale*8+thisNote], noteDuration); // to distinguish the notes, set a minimum time between them. // the note's uSound_duration + 30% seems to work well:
}
int pauseBetweenNotes = 1.5* noteDuration;
if(melody[scale*8+thisNote] > 1){digitalWrite(PIN_Teensy_LED, HIGH);
} delay(pauseBetweenNotes/2);
digitalWrite(PIN_Teensy_LED, LOW); delay(pauseBetweenNotes/2);
noTone(PIN_Speaker_Out); // stop the tone playing:
} //...... END of 'Shave and a Haircut'
}
 
But what's inside LIDARLite_v3HP.h, and all the files in that library? If any include Wire.h, those would conflict.

Duh! Slapping myself upside the head. You're right. wire.h is included in LIDARLite_v3HP.cpp
I'm wondering how to get LIDARLite_v3HP.cpp to recompile with i2c_t3.h included? I'm not finding i2c_t3.obj anywhere, so I may be incorrectly assuming LIDARLite_v3HP.cpp should be recompiled and linked by the Arduino compiler. I'm guessing there is a build-library utility somewhere perhaps? Can you suggest a reference on these mechanics?
Thank You,
-a
 
Just edit those LIDARLite_v3H files. Arduino is supposed to notice you've changed them and automatically recompile the code when you click Verify.

As a quick sanity check, usually the first thing I do is add a syntax error and click Verify, just to make sure I'm really editing the correct file. If you have more than 1 copy on your PC, it can be really frustrating to try lots of changes which have no effect, only to learn you've been editing a different copy than Arduino actually uses.
 
Arduino *finally* released 1.8.6.

I'm downloading it now. Did a dry run last night to resolve merge conflicts, so will have a beta Teensyduino installer for 1.8.6 in a couple hours.
 
Ugh, going to take a little longer. They're using Java 8u171 to build this version. Looks like 171 won't run on XP in a virtual machine (which is how I've run all prior versions).
 
Status
Not open for further replies.
Back
Top