Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.
Inits/IST3020.cpp@34:67b3634507da, 2022-01-07 (annotated)
- Committer:
- dswood
- Date:
- Fri Jan 07 12:05:27 2022 +0000
- Revision:
- 34:67b3634507da
- Parent:
- 18:ffa58f1a680a
The libraries used would not output %. I tried escaping it but nothing worked. So I changed the & in the font and used that. Not cleaver I know. I don't recommend this to anyone.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Geremia | 4:12ba0ecc2c1f | 1 | /* mbed UniGraphic library - Device specific class |
Geremia | 4:12ba0ecc2c1f | 2 | * Copyright (c) 2015 Giuliano Dianda |
Geremia | 4:12ba0ecc2c1f | 3 | * Released under the MIT License: http://mbed.org/license/mit |
Geremia | 4:12ba0ecc2c1f | 4 | */ |
Geremia | 0:75ec1b3cde17 | 5 | #include "Protocols.h" |
Geremia | 0:75ec1b3cde17 | 6 | #include "IST3020.h" |
Geremia | 0:75ec1b3cde17 | 7 | |
Geremia | 18:ffa58f1a680a | 8 | /*this is a quite standard config, similar to ST7565, except bigger screen and diff resistor ratio value*/ |
Geremia | 3:48f3282c2be8 | 9 | |
Geremia | 0:75ec1b3cde17 | 10 | ////////////////////////////////////////////////////////////////////////////////// |
Geremia | 0:75ec1b3cde17 | 11 | // display settings /////////////////////////////////////////////////////// |
Geremia | 0:75ec1b3cde17 | 12 | ///////////////////////////////////////////////////////////////////////// |
Geremia | 0:75ec1b3cde17 | 13 | #define IC_X_SEGS 256 // IST3020 SEG has range 0-255 (255-0 if ADC=1), check your datasheet, important for the orientation |
Geremia | 0:75ec1b3cde17 | 14 | #define IC_Y_COMS 64 // IST3020 COM has range 0-63 (63-0 if SHL=1), check your datasheet, important for the orientation |
dreschpe | 9:1749ae993cfe | 15 | // put in constructor |
dreschpe | 9:1749ae993cfe | 16 | //#define LCDSIZE_X 192 // display X pixels, IST3020 is advertised as 224x65 but display size could be smaller |
dreschpe | 9:1749ae993cfe | 17 | //#define LCDSIZE_Y 64 // display Y pixels, the 65th is for accessing "icons" |
Geremia | 0:75ec1b3cde17 | 18 | |
Geremia | 0:75ec1b3cde17 | 19 | |
Geremia | 0:75ec1b3cde17 | 20 | |
dreschpe | 9:1749ae993cfe | 21 | IST3020::IST3020(proto_t displayproto, PortName port, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name, unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) |
Geremia | 0:75ec1b3cde17 | 22 | : LCD(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name) |
Geremia | 0:75ec1b3cde17 | 23 | { |
Geremia | 0:75ec1b3cde17 | 24 | hw_reset(); |
Geremia | 0:75ec1b3cde17 | 25 | BusEnable(true); |
Geremia | 2:713844a55c4e | 26 | init(); |
Geremia | 2:713844a55c4e | 27 | cls(); |
Geremia | 2:713844a55c4e | 28 | set_orientation(1); |
Geremia | 2:713844a55c4e | 29 | locate(0,0); |
Geremia | 0:75ec1b3cde17 | 30 | } |
dreschpe | 9:1749ae993cfe | 31 | IST3020::IST3020(proto_t displayproto, int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC, const char *name, unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y) |
Geremia | 1:ff019d22b275 | 32 | : LCD(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name) |
Geremia | 0:75ec1b3cde17 | 33 | { |
Geremia | 0:75ec1b3cde17 | 34 | hw_reset(); |
Geremia | 2:713844a55c4e | 35 | BusEnable(true); |
Geremia | 2:713844a55c4e | 36 | init(); |
Geremia | 2:713844a55c4e | 37 | cls(); |
Geremia | 2:713844a55c4e | 38 | set_orientation(1); |
Geremia | 2:713844a55c4e | 39 | locate(0,0); |
Geremia | 0:75ec1b3cde17 | 40 | } |
Geremia | 0:75ec1b3cde17 | 41 | // reset and init the lcd controller |
Geremia | 3:48f3282c2be8 | 42 | // init sequence is manufacturer specific |
Geremia | 0:75ec1b3cde17 | 43 | void IST3020::init() |
Geremia | 0:75ec1b3cde17 | 44 | { |
Geremia | 0:75ec1b3cde17 | 45 | /* Start Initial Sequence ----------------------------------------------------*/ |
Geremia | 0:75ec1b3cde17 | 46 | |
Geremia | 1:ff019d22b275 | 47 | wr_cmd8(0xE2); // sw reset |
Geremia | 0:75ec1b3cde17 | 48 | wait_ms(10); |
Geremia | 0:75ec1b3cde17 | 49 | |
Geremia | 1:ff019d22b275 | 50 | wr_cmd8(0xAE); // display off |
Geremia | 1:ff019d22b275 | 51 | wr_cmd8(0xAB); // built-in OSC on |
Geremia | 1:ff019d22b275 | 52 | wr_cmd8(0xA2); // bias voltage (1/9) |
Geremia | 1:ff019d22b275 | 53 | // wr_cmd8(0xA3); // bias voltage (1/7) |
Geremia | 0:75ec1b3cde17 | 54 | |
Geremia | 1:ff019d22b275 | 55 | wr_cmd8(0xA0); // ADC select seg0-seg223 |
Geremia | 1:ff019d22b275 | 56 | //wr_cmd8(0xA1); // ADC select seg223-seg0 |
Geremia | 1:ff019d22b275 | 57 | wr_cmd8(0xC8); // SHL select com63-com0 |
Geremia | 1:ff019d22b275 | 58 | //wr_cmd8(0xC0); // SHL select com0-com63 |
Geremia | 0:75ec1b3cde17 | 59 | |
Geremia | 1:ff019d22b275 | 60 | wr_cmd8(0x2C); // Internal Voltage Converter ON |
Geremia | 0:75ec1b3cde17 | 61 | wait_ms(10); |
Geremia | 1:ff019d22b275 | 62 | wr_cmd8(0x2E); // Internal Voltage Regulator ON |
Geremia | 0:75ec1b3cde17 | 63 | wait_ms(10); |
Geremia | 1:ff019d22b275 | 64 | wr_cmd8(0x2F); // Internal Voltage Follower ON |
Geremia | 0:75ec1b3cde17 | 65 | wait_ms(10); |
Geremia | 1:ff019d22b275 | 66 | wr_cmd8(0x20); // Regulor_Resistor_Select resistor ratio 20-27 20=4.5(default) 27=8.0, 0.5 steps |
Geremia | 3:48f3282c2be8 | 67 | set_contrast(46); |
Geremia | 1:ff019d22b275 | 68 | //wr_cmd8(0x81); // set contrast (reference voltage register set) |
Geremia | 1:ff019d22b275 | 69 | //wr_cmd8(0x20); // contrast 00-3F default 20 |
Geremia | 0:75ec1b3cde17 | 70 | |
Geremia | 1:ff019d22b275 | 71 | wr_cmd8(0xA4); // LCD display ram (EntireDisplayOn disable) |
Geremia | 1:ff019d22b275 | 72 | //wr_cmd8(0x70); // External Capacitors Discharge function enable (should be enabled by default) |
Geremia | 1:ff019d22b275 | 73 | //wr_cmd8(0x77); // External Capacitors Discharge function disable |
Geremia | 1:ff019d22b275 | 74 | wr_cmd8(0x40); // start line = 0 |
Geremia | 1:ff019d22b275 | 75 | wr_cmd8(0xA6); // display normal (1 = illuminated) |
Geremia | 1:ff019d22b275 | 76 | wr_cmd8(0xAF); // display ON |
Geremia | 0:75ec1b3cde17 | 77 | |
Geremia | 0:75ec1b3cde17 | 78 | } |