login

Author Topic: Adafruit LED Backpack library  (Read 1940 times)

0 Members and 1 Guest are viewing this topic.

Jaime Patarroyo

Adafruit LED Backpack library
« on: June 22, 2014, 08:51:03 PM »
Hello,
I'm trying to get this Adafruit library (https://github.com/adafruit/Adafruit-LED-Backpack-Library) to work with Wiring but I get an really confusing error when I try to run any of the examples. I tried compiling it in the Arduino IDE and it works fine. I'm attaching a picture of the error.

Please help!

Thanks,
Jaime.

barragan

Re: Adafruit LED Backpack library
« Reply #1 on: June 25, 2014, 05:16:19 PM »
Change tha types in the adafruit includes or example the uint16_t should be unsigned int etc.

Jaime Patarroyo

Re: Adafruit LED Backpack library
« Reply #2 on: June 27, 2014, 02:38:16 PM »
After changing all the int8_t for char, the uint8_t for unsigned char, the int16_t for int and the uint16_t for unsigned int the error kept on coming. But after learning that naming variables like that was a way for keeping the code more portable I was able to track the problem.

This function that worked in Arduino:

Code: [Select]
void Adafruit_LEDBackpack::writeDisplay(void) {
  Wire.beginTransmission(i2c_addr);
  Wire.write((uint8_t)0x00); // start at address $00

  for (uint8_t i=0; i<8; i++) {
    Wire.write(displaybuffer[i] & 0xFF);   
    Wire.write(displaybuffer[i] >> 8);   
  }
  Wire.endTransmission(); 
}

Needed some casting in Wiring:

Code: [Select]
void Adafruit_LEDBackpack::writeDisplay(void) {
  Wire.beginTransmission(i2c_addr);
  Wire.write((uint8_t)0x00); // start at address $00

  for (uint8_t i=0; i<8; i++) {
    Wire.write((uint8_t)displaybuffer[i] & 0xFF);   
    Wire.write((uint8_t)displaybuffer[i] >> 8);   
  }
  Wire.endTransmission(); 
}

It just made me wonder about the differences between the Wire library of both projects.

Thanks Hernando for the help.

barragan