0

LiquidTWI Compiler errors with Arduino 1.0
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

LiquidTWI Compiler errors with Arduino 1.0

by uncle_dave on Sat Jan 21, 2012 7:04 pm

Does anyone have an update on when LiquidTWI.h and LiquidTWI.cpp will be modified to compile with Arduino 1.0??
I have an Adafruit i2c LCD backpack and it's a great solution, but the original LiquidCrystal libraries are very slow.

There was another thread running on this topic but it came to an abrupt end since the original post turned out to be using a non-Adafruit i2c board.
I took a look at the LiquidTWI library code and found several things that are not Arduino 1.0 compatible, but I'm not a skilled C++ programmer and so I can't interpret all of the compiler errors.

If the original author of LiquidTWI isn't available to make the changes, is there a member who is a competent C++ programmer who could fix this? I suspect it's a 10 minute task for someone with the right background.

Thanks for your help!!
uncle_dave
 
Posts: 2
Joined: Fri Jan 20, 2012 2:09 am

Re: LiquidTWI Compiler errors with Arduino 1.0

by stephanie on Sun Jan 22, 2012 9:33 am

Hi Uncle_Dave,

I have modified LiquidTWI to work with 1.0. My version is not backwards compatible, as I was in a hurry to get it working so I just changed it for 1.0 and dropped the legacy stuff.

It does work fine, I'm using it myself, just be aware that this version does not work with the older Arduino IDEs.

My version also includes the patch to fix the start-up / init bug that was in the original release.

You can grab a copy here:
http://planetstephanie.net/blog/wp-cont ... no_1.0.zip

Cheers!
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: LiquidTWI Compiler errors with Arduino 1.0

by D9W on Tue Jan 24, 2012 4:35 am

Hi guys,

I am still getting the same errors as before >>

In file included from sketch_jan23b.cpp:18:

C:\Users\Test\Documents\Arduino\arduino-1.0-windows\arduino-1.0\libraries\LiquidTWI/LiquidTWI.h:87: error: conflicting return type specified for 'virtual void LiquidTWI::write(uint8_t)'

C:\Users\Test\Documents\Arduino\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'


I am playing with the 1.0 IDE and Stephanie's Zip file. I spent most of the day going through the cpp file and the header file. Any ideas?

Just for fun I copied the LiquidTWI.cpp file into the 1.0 IDE and compiled to see what errors would come up (Yeah I new it would throw a fit) and here is what it spit out at me >>

In file included from sketch_jan23a.cpp:1:

C:\Users\Test\Documents\Arduino\arduino-1.0-windows\arduino-1.0\libraries\LiquidTWI/LiquidTWI.h:87: error: conflicting return type specified for 'virtual void LiquidTWI::write(uint8_t)'

C:\Users\Test\Documents\Arduino\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'

sketch_jan23a:256: error: prototype for 'size_t LiquidTWI::write(uint8_t)' does not match any in class 'LiquidTWI'

C:\Users\Test\Documents\Arduino\arduino-1.0-windows\arduino-1.0\libraries\LiquidTWI/LiquidTWI.h:87: error: candidate is: virtual void LiquidTWI::write(uint8_t)
D9W
 
Posts: 38
Joined: Tue Oct 26, 2010 4:25 pm

Re: LiquidTWI Compiler errors with Arduino 1.0

by stephanie on Tue Jan 24, 2012 11:32 am

The first error you list makes me think you are not using my patched library. In my patched version, like 87 has the correct return type:
Code: Select all | TOGGLE FULL SIZE
   virtual size_t write(uint8_t);


Also, the path indicates that the LiquidTWI.h file being accessed is in your Arduino IDE's built-in libraries folder, and not the user libraries folder where one would expect to put these add-on libraries.

They should be in ~/Documents/Arduino/libraries -- on *nix at least. I don't know where exactly that translates on Windows but it's wherever your sketches get saved to.

Maybe double-check that you don't have two versions of LiquidTWI around.

Cheers!
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: LiquidTWI Compiler errors with Arduino 1.0

by arta on Tue Jan 24, 2012 2:50 pm

Stephanie, Thank you for the updated liquidTWI. It seems to work fine.

Arta
arta
 
Posts: 5
Joined: Tue Jul 27, 2010 10:55 am

Re: LiquidTWI Compiler errors with Arduino 1.0

by uncle_dave on Sat Jan 28, 2012 5:12 pm

Stephanie,
I just ran your updated library and it's great! (I posted the original topic in this thread).
There's now no visible delay in outputting characters to the screen, and in the i2c_perftest routine, time per character drops below 1ms at the highest clock speed.

Thanks for making this library available!
uncle_dave
 
Posts: 2
Joined: Fri Jan 20, 2012 2:09 am

Re: LiquidTWI Compiler errors with Arduino 1.0

by D9W on Sun Jan 29, 2012 12:47 am

Hi everyone,
Thanks for your suggestions.

If you have loaded any of the previous versions of Arduino (pre 1.0) you could have a problem with a preferences.txt file. Mine showed up in C:\Users\Test\AppData\Roaming\Arduino\preferences.txt. You can use word pad to open it up and take a look inside. I noticed that there was a number entries that pathways were linked to both the .22 IDE folder and the 1.0 IDE folder (look for last.sketch2.path=C:\..... , last.sketch1.path=C:\... or , last.sketch0.path=C:\...).

What I ended up doing was renaming the preferences.TXT file to preferences.OLD. That forced the Arduino to make a new preferences.TXT file.

The Other thing I did was to move all of my IDEs off my C drive to a USB drive so I had a copy of both (.22 and 1.0 IDE). The reason for that was I had some files associated and mixed with/in both IDEs and didn’t want to lose them. Then I did my normal Clean Disk and Disk defrag on my C hard drive. Makes sense to make sure everything is cleaned up before you down load a new copy of the IDE.

Also I did not realize that both IDEs had made links to a library Sketch folder under “My Documents”, which led to more confusion for the IDEs. So if you’re starting over you might want to rename this library to OldSketch.

I will let you know how things work when I am done.
DW

<edit>- Got it working. Thanks again.
DW
D9W
 
Posts: 38
Joined: Tue Oct 26, 2010 4:25 pm

Re: LiquidTWI Compiler errors with Arduino 1.0

by stephanie on Sun Jan 29, 2012 9:07 am

Uncle_Dave, I'm glad it's doing the trick for you - I can't take credit for the library though, it was created by forum user FalconFour - all I did was hack it to work with the latest Arduino IDE.

D9W, glad to hear you have got it working too! I've never tried running two different versions of the IDE at the same time... I'm usually anal enough to completely delete and purge the old version before installing the new one. Though that's probably overkill, hehe.

Cheers!
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: LiquidTWI Compiler errors with Arduino 1.0

by stephanie on Sun Jan 29, 2012 9:45 am

Sorry for the double-post... I (finally!) set up an account on github and set this up there so it's got a proper repository. I also added back in the legacy < 1.0 support (although I haven't tested it as I don't have an older IDE handy at the moment.)

Here's the link on Github:
https://github.com/Stephanie-Maks/Arduino-LiquidTWI

Cheers!
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: LiquidTWI Compiler errors with Arduino 1.0

by D9W on Tue Jan 31, 2012 1:07 am

One thing I would like to point out...
If you are having problems with your LCD Screen having malformed characters
(Like the number "3" and "4" being morphed together when the display flashes <ON>),
you might want to try moving >>

lcd.setBacklight(HIGH);
delay(500);

before printing information.

Like this >>

void loop() {

lcd.setBacklight(HIGH); //moved here to prevent numbers in the same line, same column from being morphed together.
delay(500);

// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0,1);
// print the number of seconds since reset:
lcd.print(millis()/1000);

lcd.setBacklight(LOW);
delay(500);
}



What was happening was the character was changing while the LED was on. I think it’s a timing issue. So try this if you’re running into problems, otherwise you can stick with the way Stephanie ‘s Zip codes it >>

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);

lcd.setBacklight(HIGH);
delay(500);
lcd.setBacklight(LOW); // << If you want to force seeing the morph happen, change the <LOW> to <HIGH> here
delay(500);
}


I do have one question: What is the correct way to talk to two LCDs? Yeah I know you start off with

// include the library code:
#include <Wire.h>
#include <LiquidTWI.h>

LiquidTWI lcd(0); // Connect via i2c, default address #0 (A2-A0 not jumpered)
LiquidTWI lcd(1); // Connect via i2c, address #1 (A2-A1 not jumpered, A0 jumpered)

void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(16, 2); // << so how do you tell the IDE which LCD(X) your talking too?
// Print a message to the LCD.
lcd.print("hello, world!"); // << so how do you tell the IDE which LCD(X) your talking too?
}



but from there what do you do?
D9W
 
Posts: 38
Joined: Tue Oct 26, 2010 4:25 pm

Re: LiquidTWI Compiler errors with Arduino 1.0

by stephanie on Tue Jan 31, 2012 8:47 am

I haven't experience the problem with the malformed characters but I'll play around with it some more and see what I can get. Thanks for the info on that.

The correct way to handle two LCDs is to name them differently, like this:
Code: Select all | TOGGLE FULL SIZE
LiquidTWI lcd_one(0); // Connect via i2c, default address #0 (A2-A0 not jumpered)
LiquidTWI lcd_two(1); // Connect via i2c, address #1 (A2-A1 not jumpered, A0 jumpered)


Then you just refer to them independantly in the code:
Code: Select all | TOGGLE FULL SIZE
lcd_one.begin(16, 2);
lcd_one.print("hello, world!")
lcd_two.begin(16, 2);
lcd_two.print("hello, world!")


Cheers!
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: LiquidTWI Compiler errors with Arduino 1.0

by D9W on Tue Jan 31, 2012 9:30 pm

Stephanie wrote:I haven't experience the problem with the malformed characters but I'll play around with it some more and see what I can get. Thanks for the info on that.
...

I need to clarify what I mean by the morphed characters. It happens when the number changes so the left side of the 4 might be mixed with the parts of the number 3. When you move the code where I suggested you don’t see any of that. You see clean crips numbers.

And thanks for explaining how to get more than two LCD to work together.
Too bad you can’t do it like lcd[0].print(“hello this is screen1”); and lcd[1].print(“hello this is screen 2”);. Point it would give you the ability to send text to either lcd’s more efficiently. You would not have write duplicate code for each of the lcd’s. You could have a generic lcd[x].print( *stringOfText, yLong);
D9W
 
Posts: 38
Joined: Tue Oct 26, 2010 4:25 pm

Re: LiquidTWI Compiler errors with Arduino 1.0

by stephanie on Fri Feb 03, 2012 9:53 am

D9W wrote:I need to clarify what I mean by the morphed characters. It happens when the number changes so the left side of the 4 might be mixed with the parts of the number 3. When you move the code where I suggested you don’t see any of that. You see clean crips numbers.

And thanks for explaining how to get more than two LCD to work together.
Too bad you can’t do it like lcd[0].print(“hello this is screen1”); and lcd[1].print(“hello this is screen 2”);. Point it would give you the ability to send text to either lcd’s more efficiently. You would not have write duplicate code for each of the lcd’s. You could have a generic lcd[x].print( *stringOfText, yLong);


I've been really busy this week and haven't had a chance to look at the morphed character problem again. In normal use in my applications I just turn the backlight on and leave it on so that might be why I've never experienced the problem in regular usage, and I haven't let the demo run for any length of time because the blinking backlight drives me a bit nutty.

Re. the two LCD screens, I don't know the exact syntax (i'm not really a c coder) but it could probably be set up as an arrayed object, then you could code it like in your example. I'm not entirely sure how that would work, but I *think* it'd just be an array of two LiquidTWI objects, instead of two separate LiquidTWI objects...
User avatar
stephanie
 
Posts: 295
Joined: Sat Dec 11, 2010 1:17 am
Location: Canada

Re: LiquidTWI Compiler errors with Arduino 1.0

by D9W on Fri Feb 03, 2012 4:26 pm

Thanks Stephanie for your reply.
I will play with it to see what I can do.
D9W
D9W
 
Posts: 38
Joined: Tue Oct 26, 2010 4:25 pm

Re: LiquidTWI Compiler errors with Arduino 1.0

by wellesley on Tue May 28, 2013 10:32 pm

I've been using LiquidTWI quite happily, but came across a problem trying to create characters recently. It seems like the lcd.createChar command hangs the sketch.

When I run the standard HelloWorld_i2c sketch, works as planned. When I run it as follows, it compiles and uploads, but the LCD is unresponsive and continues to show whatever the last thing it displayed before upload was.

Code: Select all | TOGGLE FULL SIZE
// include the library code:
#include <Wire.h>
#include <LiquidTWI.h>

// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidTWI lcd(0);

//create matrix for degree sign symbol
byte degree[8] = {
  B01110,
  B01010,
  B01110,
  B00000,
  B00000,
  B00000,
  B00000
};

void setup() {
   //create degree sign
  //degree sign is accessible as byte(0)
 lcd.createChar(0, degree);
 
  // set up the LCD's number of rows and columns:
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.print("hello, world!"); lcd.write(byte(0));
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);


Commenting out lcd.createChar(0, degree) lets the rest of the sketch work fine. Can anyone spot a problem that I'm missing?
wellesley
 
Posts: 1
Joined: Tue May 21, 2013 5:06 pm

Please be positive and constructive with your questions and comments.