Simple library for UC1701 based GLCD's

Dependents:   Opensmart_LCD_UC1701

With lots of fonts! Will include more in the future. A couple bitmaps have also been added.

Committer:
Anaesthetix
Date:
Sun Dec 18 21:17:42 2016 +0000
Revision:
2:d9e9d326c4bb
Parent:
1:f396898c2963
Child:
3:baaa16e24adc
Deleted include of non-existing header

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anaesthetix 0:a8cfaf48d064 1 /**
Anaesthetix 0:a8cfaf48d064 2 * This is a simple library for UC1701 controlled graphic LCD's.
Anaesthetix 0:a8cfaf48d064 3 * Written for a cheap OPEN-SMART 1.8" 128x64 display
Anaesthetix 0:a8cfaf48d064 4 * See http://www.dx.com/p/open-smart-1-8-128-64-lcd-display-breakout-module-w-blue-backlit-444694
Anaesthetix 1:f396898c2963 5 *
Anaesthetix 0:a8cfaf48d064 6 * Written by: Erik van de Coevering
Anaesthetix 0:a8cfaf48d064 7 * With special thanks to Tim Barr from whom I've reused some code
Anaesthetix 0:a8cfaf48d064 8 * Use this code in whatever way you like, as long as it stays free of charge!
Anaesthetix 0:a8cfaf48d064 9 */
Anaesthetix 0:a8cfaf48d064 10
Anaesthetix 0:a8cfaf48d064 11 #ifndef UC1701_H
Anaesthetix 0:a8cfaf48d064 12 #define UC1701_H
Anaesthetix 0:a8cfaf48d064 13
Anaesthetix 0:a8cfaf48d064 14 #include "mbed.h"
Anaesthetix 0:a8cfaf48d064 15 #include "font_4x5.h"
Anaesthetix 0:a8cfaf48d064 16 #include "font_5x8.h"
Anaesthetix 0:a8cfaf48d064 17 #include "font_6x6.h"
Anaesthetix 0:a8cfaf48d064 18 #include "font_6x8.h"
Anaesthetix 0:a8cfaf48d064 19 #include "font_7x7.h"
Anaesthetix 0:a8cfaf48d064 20 #include "font_8x8.h"
Anaesthetix 0:a8cfaf48d064 21 #include "font_8x8_1.h"
Anaesthetix 0:a8cfaf48d064 22 #include "bold_font.h"
Anaesthetix 0:a8cfaf48d064 23 #include "font2d_hunter.h"
Anaesthetix 0:a8cfaf48d064 24 #include "font2d_formplex12.h"
Anaesthetix 0:a8cfaf48d064 25 #include "biohazard.h"
Anaesthetix 0:a8cfaf48d064 26 #include "highvoltage.h"
Anaesthetix 0:a8cfaf48d064 27 #include "einstein.h"
Anaesthetix 0:a8cfaf48d064 28 #include "test.h"
Anaesthetix 0:a8cfaf48d064 29 #include "copter.h"
Anaesthetix 0:a8cfaf48d064 30
Anaesthetix 0:a8cfaf48d064 31 #define LCDWIDTH 128
Anaesthetix 0:a8cfaf48d064 32 #define LCDHEIGHT 64
Anaesthetix 0:a8cfaf48d064 33 #define LCDPAGES 8
Anaesthetix 0:a8cfaf48d064 34
Anaesthetix 0:a8cfaf48d064 35 class UC1701
Anaesthetix 0:a8cfaf48d064 36 {
Anaesthetix 0:a8cfaf48d064 37 public:
Anaesthetix 0:a8cfaf48d064 38
Anaesthetix 0:a8cfaf48d064 39 // Constructor
Anaesthetix 0:a8cfaf48d064 40 UC1701(SPI &spi, DigitalOut &lcd_cs, DigitalOut &cd);
Anaesthetix 0:a8cfaf48d064 41
Anaesthetix 0:a8cfaf48d064 42 // Initialize LCD
Anaesthetix 0:a8cfaf48d064 43 void init(void);
Anaesthetix 0:a8cfaf48d064 44
Anaesthetix 0:a8cfaf48d064 45 // Place cursor at position
Anaesthetix 0:a8cfaf48d064 46 void setCursor(char column, char line);
Anaesthetix 0:a8cfaf48d064 47
Anaesthetix 0:a8cfaf48d064 48 // Clear screen
Anaesthetix 0:a8cfaf48d064 49 void clear(void);
Anaesthetix 0:a8cfaf48d064 50
Anaesthetix 0:a8cfaf48d064 51 // Fill screen by writing each pixel -> used for optimizing. Use command 0xA5
Anaesthetix 0:a8cfaf48d064 52 void fill(void);
Anaesthetix 0:a8cfaf48d064 53
Anaesthetix 0:a8cfaf48d064 54 // Write text to LCD where font format is a 2-dimensional array (only 96x8, 8x8 pixel fonts supported)
Anaesthetix 0:a8cfaf48d064 55 void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size);
Anaesthetix 0:a8cfaf48d064 56
Anaesthetix 0:a8cfaf48d064 57 // Write text to LCD where font format is a 1-dimensional array
Anaesthetix 0:a8cfaf48d064 58 void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size);
Anaesthetix 0:a8cfaf48d064 59
Anaesthetix 0:a8cfaf48d064 60 // Draw a 128x64 pixel bitmap
Anaesthetix 0:a8cfaf48d064 61 void drawBitmap(const char *data);
Anaesthetix 0:a8cfaf48d064 62
Anaesthetix 0:a8cfaf48d064 63 private:
Anaesthetix 0:a8cfaf48d064 64
Anaesthetix 0:a8cfaf48d064 65 SPI *_lcd;
Anaesthetix 0:a8cfaf48d064 66 DigitalOut *_lcd_cs;
Anaesthetix 0:a8cfaf48d064 67 DigitalOut *_lcd_cd;
Anaesthetix 0:a8cfaf48d064 68 uint8_t _lcdbuffer[LCDWIDTH*LCDPAGES];
Anaesthetix 0:a8cfaf48d064 69
Anaesthetix 0:a8cfaf48d064 70 };
Anaesthetix 0:a8cfaf48d064 71
Anaesthetix 0:a8cfaf48d064 72 #endif