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.

Dependents:   afero_poc15_180216 afero_poc15_180223 afero_poc15_180302 afero_poc15_180403R ... more

Fork of UniGraphic by GraphicsDisplay

UniGraphic for La Suno Version.
To go with La Suno, WatchDog Reset functions were added in ILI9341.

Committer:
Geremia
Date:
Mon Mar 02 10:35:41 2015 +0000
Revision:
18:ffa58f1a680a
Child:
21:ae0a4eedfc90
Added LCD ST7565, compatible with UC1701

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 18:ffa58f1a680a 1 /* mbed UniGraphic library - Device specific class
Geremia 18:ffa58f1a680a 2 * Copyright (c) 2015 Giuliano Dianda
Geremia 18:ffa58f1a680a 3 * Released under the MIT License: http://mbed.org/license/mit
Geremia 18:ffa58f1a680a 4 */
Geremia 18:ffa58f1a680a 5 #include "Protocols.h"
Geremia 18:ffa58f1a680a 6 #include "ST7565.h"
Geremia 18:ffa58f1a680a 7
Geremia 18:ffa58f1a680a 8 /*this is a quite standard config for ST7565 and similars, like UC1701*/
Geremia 18:ffa58f1a680a 9
Geremia 18:ffa58f1a680a 10 //////////////////////////////////////////////////////////////////////////////////
Geremia 18:ffa58f1a680a 11 // display settings ///////////////////////////////////////////////////////
Geremia 18:ffa58f1a680a 12 /////////////////////////////////////////////////////////////////////////
Geremia 18:ffa58f1a680a 13 #define IC_X_SEGS 132 // ST7565 SEG has range 0-131 (131-0 if ADC=1), check your datasheet, important for the orientation
Geremia 18:ffa58f1a680a 14 #define IC_Y_COMS 64 // ST7565 COM has range 0-63 (63-0 if SHL=1), check your datasheet, important for the orientation
Geremia 18:ffa58f1a680a 15 // put in constructor
Geremia 18:ffa58f1a680a 16 //#define LCDSIZE_X 128 // display X pixels, ST7565 is advertised as 132x65 but display size could be smaller
Geremia 18:ffa58f1a680a 17 //#define LCDSIZE_Y 64 // display Y pixels, the 65th is for accessing "icons"
Geremia 18:ffa58f1a680a 18
Geremia 18:ffa58f1a680a 19
Geremia 18:ffa58f1a680a 20
Geremia 18:ffa58f1a680a 21 ST7565::ST7565(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 18:ffa58f1a680a 22 : LCD(displayproto, port, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
Geremia 18:ffa58f1a680a 23 {
Geremia 18:ffa58f1a680a 24 hw_reset();
Geremia 18:ffa58f1a680a 25 BusEnable(true);
Geremia 18:ffa58f1a680a 26 init();
Geremia 18:ffa58f1a680a 27 cls();
Geremia 18:ffa58f1a680a 28 set_orientation(1);
Geremia 18:ffa58f1a680a 29 locate(0,0);
Geremia 18:ffa58f1a680a 30 }
Geremia 18:ffa58f1a680a 31 ST7565::ST7565(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 18:ffa58f1a680a 32 : LCD(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
Geremia 18:ffa58f1a680a 33 {
Geremia 18:ffa58f1a680a 34 hw_reset();
Geremia 18:ffa58f1a680a 35 BusEnable(true);
Geremia 18:ffa58f1a680a 36 init();
Geremia 18:ffa58f1a680a 37 cls();
Geremia 18:ffa58f1a680a 38 set_orientation(1);
Geremia 18:ffa58f1a680a 39 locate(0,0);
Geremia 18:ffa58f1a680a 40 }
Geremia 18:ffa58f1a680a 41 // reset and init the lcd controller
Geremia 18:ffa58f1a680a 42 // init sequence is manufacturer specific
Geremia 18:ffa58f1a680a 43 void ST7565::init()
Geremia 18:ffa58f1a680a 44 {
Geremia 18:ffa58f1a680a 45 /* Start Initial Sequence ----------------------------------------------------*/
Geremia 18:ffa58f1a680a 46
Geremia 18:ffa58f1a680a 47 wr_cmd8(0xE2); // sw reset
Geremia 18:ffa58f1a680a 48 wait_ms(10);
Geremia 18:ffa58f1a680a 49
Geremia 18:ffa58f1a680a 50 wr_cmd8(0xAE); // display off
Geremia 18:ffa58f1a680a 51
Geremia 18:ffa58f1a680a 52 wr_cmd8(0xA2); // bias voltage (1/9)
Geremia 18:ffa58f1a680a 53 // wr_cmd8(0xA3); // bias voltage (1/7)
Geremia 18:ffa58f1a680a 54
Geremia 18:ffa58f1a680a 55 //wr_cmd8(0xA0); // ADC select seg0-seg131
Geremia 18:ffa58f1a680a 56 wr_cmd8(0xA1); // ADC select seg223-seg0
Geremia 18:ffa58f1a680a 57 //wr_cmd8(0xC8); // SHL select com63-com0
Geremia 18:ffa58f1a680a 58 wr_cmd8(0xC0); // SHL select com0-com63
Geremia 18:ffa58f1a680a 59
Geremia 18:ffa58f1a680a 60 wr_cmd8(0x2C); // Boost ON
Geremia 18:ffa58f1a680a 61 wait_ms(10);
Geremia 18:ffa58f1a680a 62 wr_cmd8(0x2E); // Voltage Regulator ON
Geremia 18:ffa58f1a680a 63 wait_ms(10);
Geremia 18:ffa58f1a680a 64 wr_cmd8(0x2F); // Voltage Follower ON
Geremia 18:ffa58f1a680a 65 wait_ms(10);
Geremia 18:ffa58f1a680a 66 wr_cmd8(0x20|0x05); // Regulor_Resistor_Select resistor ratio 20-27, look at your display specific init code
Geremia 18:ffa58f1a680a 67 set_contrast(0x20);
Geremia 18:ffa58f1a680a 68 //wr_cmd8(0x81); // set contrast (reference voltage register set)
Geremia 18:ffa58f1a680a 69 //wr_cmd8(0x15); // contrast 00-3F
Geremia 18:ffa58f1a680a 70
Geremia 18:ffa58f1a680a 71 wr_cmd8(0xA4); // LCD display ram (EntireDisplayOn disable)
Geremia 18:ffa58f1a680a 72 wr_cmd8(0x40); // start line = 0
Geremia 18:ffa58f1a680a 73 wr_cmd8(0xA6); // display normal (1 = illuminated)
Geremia 18:ffa58f1a680a 74 wr_cmd8(0xAF); // display ON
Geremia 18:ffa58f1a680a 75
Geremia 18:ffa58f1a680a 76 }