Loading...
Pages: [1]   Go Down
Author Topic: lcd troubles  (Read 355 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



  okay so ive being having some problems using a user contributed library, the LCD Bargraph Library.

http://arduino.cc/playground/Code/LcdBarGraph

the best way to show you is to show you on the example itself.

Code:
#include <LiquidCrystal.h>
#include <LcdBarGraph.h>

byte lcdNumCols = 16; // -- number of columns in the LCD
byte sensorPin = 0; // -- value for this example

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // -- creating LCD instance
LcdBarGraph lbg(&lcd, lcdNumCols);  // -- creating

void setup(){
  // -- initializing the LCD
  lcd.begin(2, lcdNumCols);
  lcd.clear();
  // -- do some delay: some time I've got broken visualization
  delay(100);
}

void loop()
{
lcd.setCursor(0,1);    // ---------<<<<<<<<<<<<<<<<< this is the only line i have added, to change the starting position of the bargraph to the second line<<<<<<<<<<<<<<<<<<<<<<<<<<

  // -- draw bar graph from the analog value readed
  lbg.drawValue( analogRead(sensorPin), 1024);
  // -- do some delay: frequent draw may cause broken visualization
  delay(100);
}


This has no effect, so I am unable to use the library to display multiple graphs, help!!

How is my grammar, LOL.  smiley-wink
Logged

Central MN, USA
Offline Offline
Faraday Member
**
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am confused. Here is how to use lcd.begin()

http://arduino.cc/en/Reference/LiquidCrystalBegin

and the library has:

lcd.begin(2, lcdNumCols);

The two arguments are entirely swapped. I don't know if the rest of the library would work at all after seeing this line in the library sample code. The library author definitely loses some credibility by screwing up the most basic thing of lcd. I suggest you use the right thing: lcd.begin(lcdNumCols, 2); and see what happens (I bet nothing different).

If what you mean by having no effect is adding the lcd.setCursor(0,1); has no effect and the bar graph is still on row 0, then the answer is simple: the library is hardwired to display bar graph on row 0 and a nuber on row 1. It's not terribly difficult to read through. Just find the location in the lib and make the change you need.
Logged


Western New York, USA
Offline Offline
Faraday Member
**
Karma: 17
Posts: 3507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The two arguments are entirely swapped.
The arguments were incorrectly swapped in one or more of the old LiquidCrystal examples and/or tutorials.  This code could have been derived from one of those early examples.  

In the case of the LiquidCrystal library this swap doesn't matter in approximately 99.44% of the cases because the library only uses the second argument and only checks to see if it is greater than 1.  


Quote
The library author definitely loses some credibility by screwing up the most basic thing of lcd.
No comment. (Which means the same as it does outside a courtroom, etc.)


Don

« Last Edit: February 18, 2012, 10:02:01 pm by floresta » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



    okay thanks for your help guys, I found the "hard coded" line lcd.setCursor(0,0); but i wish to know if there is a way that i can change the values, I've tried deleting the line but it wont compile.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Whooop second try compiling and its fixed i will message the author and make him aware of what we have found out this is now a very useful library.



     Still only works properly with one graph, ie broken visualizations, stuck pixels. But now you are able to change the position in the main sketch without having to edit the library.
Anyone with a keen eye fancy having a quick look to see if they could help optimize this.


  Cheers, neo
« Last Edit: February 18, 2012, 10:35:29 pm by overclock » Logged

Central MN, USA
Offline Offline
Faraday Member
**
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Anyone with a keen eye fancy having a quick look to see if they could help optimize this.

I vote you! You started working on it already. Give yourself some time to learn more about the programming language and come back to modify this library.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



  I just don't understand why it breaks when i use more than one graph, Its buggy as well only using one. I could really do with someone having a look,
  It may be a simple fix but I have never been taught, and only written under a couple of pages of code ever.
        Cheers
Logged

Central MN, USA
Offline Offline
Faraday Member
**
Karma: 38
Posts: 6056
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Post a different thread asking help for this library seems to be the next step. With a good title you can find people that used this library before and share some experience. Post your modification of the code.
Logged


Pages: [1]   Go Up
Print
 
Jump to: