light text library for 5110 nokia lcd * easy to modify * proportional font, bold / inverse modes * easy to add / change fonts * fixed rows for fast update
Library finished! :-) If you use 5110 and need fast menus - try this library. No overhead - small and robust, optimized for this display type only, fast update. Nice looking font. Power management. Displays from 5110 and 3110 are cheap as dirt :-)
medvdv5110.h@0:0a6619901f2e, 2012-07-14 (annotated)
- Committer:
- medvdv
- Date:
- Sat Jul 14 17:52:11 2012 +0000
- Revision:
- 0:0a6619901f2e
- Child:
- 2:65df20ffef51
[mbed] converted /BitCrusher/medvdv5110
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
medvdv | 0:0a6619901f2e | 1 | // |
medvdv | 0:0a6619901f2e | 2 | // 5110 LCD Driver |
medvdv | 0:0a6619901f2e | 3 | // (c) 2012 medvdv.com |
medvdv | 0:0a6619901f2e | 4 | // Alexander Medvedev |
medvdv | 0:0a6619901f2e | 5 | // |
medvdv | 0:0a6619901f2e | 6 | |
medvdv | 0:0a6619901f2e | 7 | #define DEFAULT_CONTRAST 60 |
medvdv | 0:0a6619901f2e | 8 | |
medvdv | 0:0a6619901f2e | 9 | typedef struct { |
medvdv | 0:0a6619901f2e | 10 | |
medvdv | 0:0a6619901f2e | 11 | char first_code; |
medvdv | 0:0a6619901f2e | 12 | char glyphs_total; |
medvdv | 0:0a6619901f2e | 13 | const char* widths; |
medvdv | 0:0a6619901f2e | 14 | const char** glyphs; |
medvdv | 0:0a6619901f2e | 15 | |
medvdv | 0:0a6619901f2e | 16 | } lcd5110font; |
medvdv | 0:0a6619901f2e | 17 | |
medvdv | 0:0a6619901f2e | 18 | class lcd5110 { |
medvdv | 0:0a6619901f2e | 19 | |
medvdv | 0:0a6619901f2e | 20 | SPI* spi; |
medvdv | 0:0a6619901f2e | 21 | DigitalOut* rst; |
medvdv | 0:0a6619901f2e | 22 | DigitalOut* sce; |
medvdv | 0:0a6619901f2e | 23 | DigitalOut* dc; |
medvdv | 0:0a6619901f2e | 24 | |
medvdv | 0:0a6619901f2e | 25 | lcd5110font font; |
medvdv | 0:0a6619901f2e | 26 | |
medvdv | 0:0a6619901f2e | 27 | char contrast; |
medvdv | 0:0a6619901f2e | 28 | |
medvdv | 0:0a6619901f2e | 29 | bool invert; |
medvdv | 0:0a6619901f2e | 30 | bool bold; |
medvdv | 0:0a6619901f2e | 31 | |
medvdv | 0:0a6619901f2e | 32 | int X, Y; |
medvdv | 0:0a6619901f2e | 33 | |
medvdv | 0:0a6619901f2e | 34 | void write(char byte, bool cmd = false); |
medvdv | 0:0a6619901f2e | 35 | |
medvdv | 0:0a6619901f2e | 36 | public: |
medvdv | 0:0a6619901f2e | 37 | |
medvdv | 0:0a6619901f2e | 38 | lcd5110(PinName mosi= p11, PinName sclk = p13, PinName dc = p10, PinName sce = p8, PinName rst = p9); |
medvdv | 0:0a6619901f2e | 39 | |
medvdv | 0:0a6619901f2e | 40 | void Init(); |
medvdv | 0:0a6619901f2e | 41 | void Reset(); |
medvdv | 0:0a6619901f2e | 42 | void Clear(char pattern = 0); |
medvdv | 0:0a6619901f2e | 43 | void Contrast(char contrast = DEFAULT_CONTRAST ); |
medvdv | 0:0a6619901f2e | 44 | void PowerOff(); |
medvdv | 0:0a6619901f2e | 45 | |
medvdv | 0:0a6619901f2e | 46 | void Invert(bool invert = true); |
medvdv | 0:0a6619901f2e | 47 | void Bold(bool bold = true); |
medvdv | 0:0a6619901f2e | 48 | |
medvdv | 0:0a6619901f2e | 49 | void XY(int x = 0, int y = 0); |
medvdv | 0:0a6619901f2e | 50 | |
medvdv | 0:0a6619901f2e | 51 | void Write(char byte); |
medvdv | 0:0a6619901f2e | 52 | void Write(char byte, int count); |
medvdv | 0:0a6619901f2e | 53 | void Write(char* data, int size); |
medvdv | 0:0a6619901f2e | 54 | void Write2(char* data, int size); |
medvdv | 0:0a6619901f2e | 55 | |
medvdv | 0:0a6619901f2e | 56 | void Character(char chr); |
medvdv | 0:0a6619901f2e | 57 | int CharacterWidth(char chr); |
medvdv | 0:0a6619901f2e | 58 | |
medvdv | 0:0a6619901f2e | 59 | void String(char* str); |
medvdv | 0:0a6619901f2e | 60 | int StringWidth(char* str); |
medvdv | 0:0a6619901f2e | 61 | |
medvdv | 0:0a6619901f2e | 62 | void Row(int Y, char* str = ""); |
medvdv | 0:0a6619901f2e | 63 | |
medvdv | 0:0a6619901f2e | 64 | ~lcd5110(); |
medvdv | 0:0a6619901f2e | 65 | |
medvdv | 0:0a6619901f2e | 66 | }; |
medvdv | 0:0a6619901f2e | 67 |