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.
UC1701.h@0:a8cfaf48d064, 2016-12-18 (annotated)
- Committer:
- Anaesthetix
- Date:
- Sun Dec 18 21:10:26 2016 +0000
- Revision:
- 0:a8cfaf48d064
- Child:
- 1:f396898c2963
Optimized for execution speed
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:a8cfaf48d064 | 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 | * Copyright (c) 2016 |
Anaesthetix | 0:a8cfaf48d064 | 11 | * |
Anaesthetix | 0:a8cfaf48d064 | 12 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Anaesthetix | 0:a8cfaf48d064 | 13 | * you may not use this file except in compliance with the License. |
Anaesthetix | 0:a8cfaf48d064 | 14 | * You may obtain a copy of the License at |
Anaesthetix | 0:a8cfaf48d064 | 15 | * |
Anaesthetix | 0:a8cfaf48d064 | 16 | * http://www.apache.org/licenses/LICENSE-2.0 |
Anaesthetix | 0:a8cfaf48d064 | 17 | * |
Anaesthetix | 0:a8cfaf48d064 | 18 | * Unless required by applicable law or agreed to in writing, software |
Anaesthetix | 0:a8cfaf48d064 | 19 | * distributed under the License is distributed on an "AS IS" BASIS, |
Anaesthetix | 0:a8cfaf48d064 | 20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Anaesthetix | 0:a8cfaf48d064 | 21 | * See the License for the specific language governing permissions and |
Anaesthetix | 0:a8cfaf48d064 | 22 | * limitations under the License. |
Anaesthetix | 0:a8cfaf48d064 | 23 | * |
Anaesthetix | 0:a8cfaf48d064 | 24 | * |
Anaesthetix | 0:a8cfaf48d064 | 25 | */ |
Anaesthetix | 0:a8cfaf48d064 | 26 | |
Anaesthetix | 0:a8cfaf48d064 | 27 | #ifndef UC1701_H |
Anaesthetix | 0:a8cfaf48d064 | 28 | #define UC1701_H |
Anaesthetix | 0:a8cfaf48d064 | 29 | |
Anaesthetix | 0:a8cfaf48d064 | 30 | #include "mbed.h" |
Anaesthetix | 0:a8cfaf48d064 | 31 | #include "font_4x5.h" |
Anaesthetix | 0:a8cfaf48d064 | 32 | #include "font_5x8.h" |
Anaesthetix | 0:a8cfaf48d064 | 33 | #include "font_6x6.h" |
Anaesthetix | 0:a8cfaf48d064 | 34 | #include "font_6x8.h" |
Anaesthetix | 0:a8cfaf48d064 | 35 | #include "font_7x7.h" |
Anaesthetix | 0:a8cfaf48d064 | 36 | #include "font_8x8.h" |
Anaesthetix | 0:a8cfaf48d064 | 37 | #include "font_8x8_1.h" |
Anaesthetix | 0:a8cfaf48d064 | 38 | #include "test_15x16.h" |
Anaesthetix | 0:a8cfaf48d064 | 39 | #include "bold_font.h" |
Anaesthetix | 0:a8cfaf48d064 | 40 | #include "font2d_hunter.h" |
Anaesthetix | 0:a8cfaf48d064 | 41 | #include "font2d_formplex12.h" |
Anaesthetix | 0:a8cfaf48d064 | 42 | #include "biohazard.h" |
Anaesthetix | 0:a8cfaf48d064 | 43 | #include "highvoltage.h" |
Anaesthetix | 0:a8cfaf48d064 | 44 | #include "einstein.h" |
Anaesthetix | 0:a8cfaf48d064 | 45 | #include "test.h" |
Anaesthetix | 0:a8cfaf48d064 | 46 | #include "copter.h" |
Anaesthetix | 0:a8cfaf48d064 | 47 | |
Anaesthetix | 0:a8cfaf48d064 | 48 | #define LCDWIDTH 128 |
Anaesthetix | 0:a8cfaf48d064 | 49 | #define LCDHEIGHT 64 |
Anaesthetix | 0:a8cfaf48d064 | 50 | #define LCDPAGES 8 |
Anaesthetix | 0:a8cfaf48d064 | 51 | |
Anaesthetix | 0:a8cfaf48d064 | 52 | class UC1701 |
Anaesthetix | 0:a8cfaf48d064 | 53 | { |
Anaesthetix | 0:a8cfaf48d064 | 54 | public: |
Anaesthetix | 0:a8cfaf48d064 | 55 | |
Anaesthetix | 0:a8cfaf48d064 | 56 | // Constructor |
Anaesthetix | 0:a8cfaf48d064 | 57 | UC1701(SPI &spi, DigitalOut &lcd_cs, DigitalOut &cd); |
Anaesthetix | 0:a8cfaf48d064 | 58 | |
Anaesthetix | 0:a8cfaf48d064 | 59 | // Initialize LCD |
Anaesthetix | 0:a8cfaf48d064 | 60 | void init(void); |
Anaesthetix | 0:a8cfaf48d064 | 61 | |
Anaesthetix | 0:a8cfaf48d064 | 62 | // Place cursor at position |
Anaesthetix | 0:a8cfaf48d064 | 63 | void setCursor(char column, char line); |
Anaesthetix | 0:a8cfaf48d064 | 64 | |
Anaesthetix | 0:a8cfaf48d064 | 65 | // Clear screen |
Anaesthetix | 0:a8cfaf48d064 | 66 | void clear(void); |
Anaesthetix | 0:a8cfaf48d064 | 67 | |
Anaesthetix | 0:a8cfaf48d064 | 68 | // Fill screen by writing each pixel -> used for optimizing. Use command 0xA5 |
Anaesthetix | 0:a8cfaf48d064 | 69 | void fill(void); |
Anaesthetix | 0:a8cfaf48d064 | 70 | |
Anaesthetix | 0:a8cfaf48d064 | 71 | // Write text to LCD where font format is a 2-dimensional array (only 96x8, 8x8 pixel fonts supported) |
Anaesthetix | 0:a8cfaf48d064 | 72 | void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size); |
Anaesthetix | 0:a8cfaf48d064 | 73 | |
Anaesthetix | 0:a8cfaf48d064 | 74 | // Write text to LCD where font format is a 1-dimensional array |
Anaesthetix | 0:a8cfaf48d064 | 75 | void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size); |
Anaesthetix | 0:a8cfaf48d064 | 76 | |
Anaesthetix | 0:a8cfaf48d064 | 77 | // Draw a 128x64 pixel bitmap |
Anaesthetix | 0:a8cfaf48d064 | 78 | void drawBitmap(const char *data); |
Anaesthetix | 0:a8cfaf48d064 | 79 | |
Anaesthetix | 0:a8cfaf48d064 | 80 | private: |
Anaesthetix | 0:a8cfaf48d064 | 81 | |
Anaesthetix | 0:a8cfaf48d064 | 82 | SPI *_lcd; |
Anaesthetix | 0:a8cfaf48d064 | 83 | DigitalOut *_lcd_cs; |
Anaesthetix | 0:a8cfaf48d064 | 84 | DigitalOut *_lcd_cd; |
Anaesthetix | 0:a8cfaf48d064 | 85 | uint8_t _lcdbuffer[LCDWIDTH*LCDPAGES]; |
Anaesthetix | 0:a8cfaf48d064 | 86 | |
Anaesthetix | 0:a8cfaf48d064 | 87 | }; |
Anaesthetix | 0:a8cfaf48d064 | 88 | |
Anaesthetix | 0:a8cfaf48d064 | 89 | #endif |