Author Topic: LCD BasicUsage example will not compile  (Read 9565 times)

GoreGhoul

  • Newbie
  • *
  • Posts: 12
LCD BasicUsage example will not compile
« on: March 07, 2013, 12:51:15 pm »
Hi everybody,
...
Fresh out of the bag, the DigisparkLCD BasicUsage example will not compile for me. Here's the errors:

Code: [Select]
...\Arduino\libraries\LiquidCrystal_I2C\LiquidCrystal_I2C.cpp: In member function 'void LiquidCrystal_I2C::init_priv()':
...\Arduino\libraries\LiquidCrystal_I2C\LiquidCrystal_I2C.cpp:68: error: 'Wire' was not declared in this scope
...\Arduino\libraries\LiquidCrystal_I2C\LiquidCrystal_I2C.cpp: In member function 'void LiquidCrystal_I2C::expanderWrite(uint8_t)':
...\Arduino\libraries\LiquidCrystal_I2C\LiquidCrystal_I2C.cpp:260: error: 'Wire' was not declared in this scope

After some googling I concluded that I needed to #include<Wire.h> at the beginning of the sketch, so now the compile fails with these errors:

Code: [Select]
In file included from BasicUsage.ino:16:
C:\Program Files (x86)\Digispark Ready - Arduino 1.03\libraries\Wire/Wire.h:61: error: conflicting return type specified for 'virtual size_t TwoWire::write(const uint8_t*, size_t)'
C:\Program Files (x86)\Digispark Ready - Arduino 1.03\hardware\tiny-digispark\cores\tiny/Print.h:75: error:   overriding 'virtual void Print::write(const uint8_t*, size_t)'

From a thread on Arduino forums I think the libraries were updated and return types changed from "void" to "size_t" to return the number of bytes written, and perhaps those libraries for never updated for the ATtiny?

Am I missing something simple? I would expect the example code to compile right out of the box, even if it doesn't work exactly right with the hardware I have laying around.  I'm running 64-bit Win 7 on a Core2Duo.

Thanks!

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: LCD BasicUsage example will not compile
« Reply #1 on: March 07, 2013, 01:28:39 pm »
Have you set Tools->Board and Tools->Programmer both to Digispark?


Wire.h is not used in Digispark sketches - TinyWireM is used instead.

GoreGhoul

  • Newbie
  • *
  • Posts: 12
Re: LCD BasicUsage example will not compile
« Reply #2 on: March 07, 2013, 01:44:23 pm »
It's working!  The library for my I2C LCD from DFRobot was conflicting with the digispark libraries, I removed it from Documents/Arduino/libraries and now it compiles.  Now hopefully it works with the LCD.

GoreGhoul

  • Newbie
  • *
  • Posts: 12
Re: LCD BasicUsage example will not compile
« Reply #3 on: March 07, 2013, 02:17:26 pm »
No luck yet with the hardware.


I'll probably have to go through the library that came with the LCD and change every Wire reference to TinyWire

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: LCD BasicUsage example will not compile
« Reply #4 on: March 07, 2013, 02:49:11 pm »
That would be the procedure if you're using a different LCD then the Digistump ones - our library is pretty specific to our LCDs - hopefully we'll be able to expand its compatibility someday, but for now converting the library for your LCD is the best bet and not too hard to do.

Mark

  • Full Member
  • ***
  • Posts: 196
Re: LCD BasicUsage example will not compile
« Reply #5 on: March 08, 2013, 12:19:24 am »
@GoreGoul
You'll need to set the address of the display.
http://www.dfrobot.com/wiki/index.php/I2C/TWI_LCD1602_Module_%28Gadgeteer_Compatible%29_%28SKU:_DFR0063%29
states that with the jumpers ON its 0x20, and with them off (same as the address used by the DS version) its 0x27.

You cannot have two of the same library and you need to restart the IDE for it to pickup any new libraries that you may have copied.

Code: [Select]
//DFRobot.com
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// set the LCD address to 0x20 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x20,16,2); 
 
void setup()
{
  lcd.init();  // initialize the lcd
 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");

Their example looks very similar to the Basic Useage example to me. (except for the address)

Don't forget to select Digispark as the board before you try compiling.


Mark


GoreGhoul

  • Newbie
  • *
  • Posts: 12
Re: LCD BasicUsage example will not compile
« Reply #6 on: March 08, 2013, 07:47:43 am »
@GoreGoul
You'll need to set the address of the display.
http://www.dfrobot.com/wiki/index.php/I2C/TWI_LCD1602_Module_%28Gadgeteer_Compatible%29_%28SKU:_DFR0063%29
states that with the jumpers ON its 0x20, and with them off (same as the address used by the DS version) its 0x27.



Thanks for the heads up Mark.  I've had my LCD working before with my Mega1280 and I know the address is 0x27 so that shouldn't be a problem.