Lightweight proportional text library for C12832 LCD. Easy to modify, fast, robust and compact. Nice font, good for text driven menus, messages, etc. Fell free to use and modify in any projects.
Documentation will be here later.
Usage sample:
Import programapp-board-lcd128
Sample usage of lightweight C12832 LCD library
Diff: lcd128lib.cpp
- Revision:
- 1:17443d6d2740
- Parent:
- 0:6ac8f630d9a0
- Child:
- 2:fdea8ffb3c4f
--- a/lcd128lib.cpp Sat Feb 01 13:13:37 2014 +0000 +++ b/lcd128lib.cpp Sat Feb 01 15:37:54 2014 +0000 @@ -37,7 +37,8 @@ font.glyphs = lcd_font8p; invert = false; - bold = false; + bold = false; + underline = false; } // Start inverting chars @@ -52,6 +53,12 @@ this -> bold = bold; } +// Start bold mode (repeat twice wide) +void lcd128::Underline(bool underline) +{ + this -> underline = underline; +} + // Reset LCD, configure defaults and contrast void lcd128::Reset() { @@ -140,6 +147,7 @@ // with inversion and XY update void lcd128::Write(char byte) { + if (underline) byte |= 0x80; buffer[X+Y*LCD_X] = invert?(~byte):byte; if (++X > (LCD_X-1)) { @@ -151,13 +159,13 @@ // Write array of 8bit rows void lcd128::Write(char* data, int size) { - for(int i=0; i<size; i++) Write(data[i]); + for (int i=0; i<size; i++) Write(data[i]); } // Write array of 8bit rows, twice each void lcd128::Write2(char* data, int size) { - for(int i=0; i<size; i++) { + for (int i=0; i<size; i++) { Write(data[i]); Write(data[i]); } @@ -166,7 +174,7 @@ // Write 8bit row 'count' times void lcd128::Write(char byte, int count) { - for(int i=0; i<count; i++) Write(byte); + for (int i=0; i<count; i++) Write(byte); } // Draw one proportional font character @@ -238,3 +246,19 @@ XY(0, Y); String(str); } + +void lcd128::Bar(int width, float fill) +{ + if (width < 2) return; + if (fill < 0.0) fill = 0.0; + if (fill > 1.0) fill = 1.0; + + int a = (width - 2)*fill; + int b = width - 2 - a; + + Write(LCD_BAR_B); + Write(LCD_BAR_F, a); + Write(LCD_BAR_U, b); + Write(LCD_BAR_E); + +} \ No newline at end of file