Hydromea:
Hi, thanks for this great library. I got it working successfully using an Arduino Leonardo, running IDE v1.0.1, with your modified version of the library attached on an above post. However, I've been playing around with the bars function and can't figure out: How could I use your library to display the value (graphical) of some analog inputs? Suppose I have 3 analog inputs. I read them, re-map or convert them, and display those values with a bar, with the highest possible value creating a full bar, and the lowest possible value giving an empty bar. Any help or suggestions would be great.
The barGraph method is fairly straight-forward, the syntax is as follows:
bitmap.barGraph(bars, *graph, color, update);
is the number of bar graphs you want to display.
is an array of height values (these values are in pixels, with the range from 0 to 16).
is either ON or OFF.
is etiher UPDATE or NO_UPDATE (in the next release, v1.5, all functions default to NO_UPDATE if not specified).
So, if you want 3 bar graphs for your 3 analog sensors, you would do something like this:
#include <LiquidCrystal.h>
#include <LCDBitmap.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LCDBitmap bitmap(&lcd, 0, 0); // Set the bitmap to the &lcd display at character position 0,0.
byte graph[3]; // Bar graph with 3 columns.
int analogPin1 = A1;
int analogPin2 = A2;
int analogPin3 = A3;
void setup() {
lcd.begin(16,2); // Initalize the LCD display, do this before you initalize LCDBitmap.
bitmap.begin(); // Then initalize the LCD bitmap.
}
void loop() {
// analogRead returns values from 0 to 1023, the barGraph displays values from 0 to 16 (1023+13)/61=16.98.
// This does the conversion without using floating point math keeping your compiled code small.
graph[0] = (analogRead(analogPin1) + 13) / 61;
graph[1] = (analogRead(analogPin2) + 13) / 61;
graph[2] = (analogRead(analogPin3) + 13) / 61;
bitmap.barGraph(3, graph, ON, UPDATE); // Display the bar graph.
delay(50);
}
Note: code compiles, but is untested.
Tim