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
lcd128lib.h
- Committer:
- medvdv
- Date:
- 2014-02-01
- Revision:
- 1:17443d6d2740
- Parent:
- 0:6ac8f630d9a0
- Child:
- 3:c0e409cda493
File content as of revision 1:17443d6d2740:
// // MBED Application Board // Lightweight C12832 LCD library // 2014, Alexander Medvedev, @medvdv // // // BC12832 LCD // Base geometry: 128 x 32 px // X - [0..127] pixels // Y - [0..3] 8 bit rows // 512 byte total buffer size // #define LCD_X 128 #define LCD_Y 4 #define LCD_SIZE 512 // // Proportional font // typedef struct { char first_code, glyphs_total; const char* widths; const char** glyphs; } lcd128font; // // Progress bar shape // Drawed as BFFF...FFUU...UUUE // B - Begin one // F - Filled zone // U - Empty zone // E - End one // #define LCD_BAR_B 0x1c #define LCD_BAR_F 0x3e #define LCD_BAR_U 0x22 #define LCD_BAR_E 0x1c // // lcd128 class // class lcd128 { // Interface with lcd SPI spi; DigitalOut rst, cs, a0; // Current font lcd128font font; // Write options bool invert; bool bold; bool underline; // buffer char buffer[LCD_SIZE]; // Cursor position int X, Y; // Generic SPI writer void write(char byte, bool cmd = false); public: // Supply LCD connected pin's here for your design lcd128(PinName mosi= p5, PinName sclk = p7, PinName a0 = p8, PinName cs = p11, PinName rst = p6); // LCD control void Reset(); // Reset LCD, configure defaults void Power(bool power = true); // Power off / on void InverseMode(bool inverse = true); // Invert LCD off / on // Buffer -> LCD void Update(); // Update LCD from buffer, shows all actually void Clear(int row = -1); // Clear all buffer or one row // Write mode void Invert(bool invert = true); // Switch inverting of chars void Bold(bool bold = true); // Switch bold mode (repeat each char row twice) void Underline(bool underline = true); // Switch underline mode (last pixel of row always on) // Cursor void XY(int x = 0, int y = 0); // Change write position X in pixels, Y in rows // Row write void Write(char byte); // One 8bit row void Write(char byte, int count); // One 8bit row * 'count' times void Write(char* data, int size); // 'size' 8bit rows void Write2(char* data, int size); // Bold: 'size' 8bit rows * 2 // Character drawing void Character(char chr); // Draw one font character (with invert and bold opt-s) // ! automaticaly does next line if char is wider then space left int CharacterWidth(char chr); // Calculate one character width (with bold opt-n) // String drawing void String(char* str); // Draw string proportionally int StringWidth(char* str); // Calculate string width in px // Higher level drawers void Row(int Y, char* str = ""); // Clear one text row and draw string on it void Bar(int width, float fill = 0.0); // Progress bar - one row, width pixels, fill - 0.0..1.0 };