LCDBitmap Library for Arduino
Author:  Tim Eckel
Contact: tim@leethost.com


Navigation


History

ReleaseDateChanges
1.67/05/2012BITMAP_RANGE_CHK bug fix.
1.56/28/20124bit method now works without the New LiquidCrystal? library (was always supposed to work this way, oversight on my part). Update switch now optional on all functions, defaults to NO_UPDATE.
1.45/25/2012Fixed a few problems with the barGraph function. Range checking optimization.
1.35/10/2012Many preformance tweaks, line function so fast that lineHor and lineVert were deprecated. Added new barGraph function.
1.25/5/2012Optimized line function to no longer use float. Other speed tweaks, optional range checking, removed "magic numbers", and should work with 7 pixel high displays.
1.15/2/2012Cleaned up code, works more easily with New LiquidCrystal library.
1.05/1/2012Initial Release.

Description

Arduino library that allows you to create a tiny 20x16 pixel bitmap (raster) display on a normally character-only Hitachi HD44780 based LCD display. Typical drawing functions like line, rectangle, invert, etc. Control is right down to the pixel level.

Works with both the standard Liquid Crystal library as well as Francisco's New Liquid Crystal library. Works with LCD connection methods including: 4bit, shift register (2 or 3 wire), and I2C. In-depth example sketches are included with library download.

It works by creating a memory array for the 20x16 pixel bitmap that the functions work with. Then converting this bitmap to the 8 custom characters available with the HD44780 and displaying them as 2 rows of 4 characters at the location specified. As each character is 5x8 pixels and arranged in a 4x2 character array, the total addressable resolution is 20x16. As there's an 8 custom character limit with the HD44780, 20x16 is the maximum resolution that can be achieved (5*4=20, 8*2=16).

Connection via standard 4bitConnection to Teensy 2.0


Download

Download here: https://code.google.com/p/arduino-lcd-bitmap/downloads/detail?name=LCDBitmap_v1.6.zip&can=2&q=

Put the "LCDBitmap" folder in "libraries\".

In the Arduino IDE, create a new sketch (or open one) and select from the menubar "Sktech->Import Library->LCDBitmap".


Constructor

LCDBitmap bitmap(*lcd, bitmap_x, bitmap_y);

Example:
LCDBitmap bitmap(&lcd, 12, 0);

This initializes LCDBitmap to cursor position 12,0 (X,Y) on LCD display (&lcd is class from LiquidCrystal).


Methods

  • bitmap.begin(); - Initalize the LCD bitmap
  • bitmap.clear(); - Clear the bitmap display (automatically updates bitmap display) doesn't clear text
  • bitmap.inverse(); - Invert the bitmap, automatically updates the bitmap display
  • bitmap.update(); - Update bitmap display
  • bitmap.clear_text(); - Clear just the text on the display (leaves bitmap alone)
  • bitmap.home(); - Move cursor the home position (0,0). Does a lcd.setCursor(0,0), just added for convienence
  • bitmap.move(x, y); - Move the LCD bitmap position to this character position
  • bitmap.pixel(x, y, color, update); - Add pixel at (x,y), color is either ON or OFF, update is either UPDATE or NO_UPDATE
  • bitmap.line(x1, y1, x2, y2, color, update); - Draw the line from (x1,y1) to (x2,y2), color & update as in pixel
  • bitmap.rect(x1, y1, x2, y2, color, update); - Draw a rectangle from (x1,y1) to (x2,y2), color & update as in pixel
  • bitmap.rectFill(x1, y1, x2, y2, color, update); - Draw a filled rectangle from (x1,y1) to (x2,y2), color & update as in pixel
  • barGraph(bars, *graph, color, update); - Draw bar graph, bars is # of bars (1,2,4,5,10,20), graph is array containing height values, color & update as in pixel


Example

SamplebarGraph

  1. #include <LiquidCrystal.h>
  2. #include <LCDBitmap.h>
  3.  
  4. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  5.  
  6. LCDBitmap bitmap(&lcd, 0, 0);
  7.  
  8. byte graph[20];
  9. byte bars[] = { 1, 2, 4, 5, 10, 20 };
  10.  
  11. void setup() {
  12.   lcd.begin(16,2);
  13.   bitmap.begin();
  14.   lcd.setCursor(5, 0);
  15.   lcd.print("LCDBitmap");  
  16. }
  17.  
  18. void loop() {
  19.   byte curr_bars = bars[(millis()/3000)%6];
  20.   for (byte x=0; x<curr_bars; x++) {
  21.     graph[x] = random(0, BITMAP_H+1);
  22.   }
  23.   bitmap.barGraph(curr_bars, graph, ON, UPDATE);
  24.   delay(50);
  25. }


Information about this page

Last Modified: November 15, 2013, at 01:55 PM
By: tzikis

Share