Display

Dependents:   Termocamera_ironblack

Committer:
gia95
Date:
Fri Sep 27 12:50:22 2019 +0000
Revision:
35:ebad2ec6f903
Parent:
21:ae0a4eedfc90
unigraphic;

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 21:ae0a4eedfc90 31 ST7565::ST7565(proto_t displayproto, PinName* buspins, PinName CS, PinName reset, PinName DC, PinName WR, PinName RD, const char *name, unsigned int LCDSIZE_X, unsigned int LCDSIZE_Y)
Geremia 21:ae0a4eedfc90 32 : LCD(displayproto, buspins, CS, reset, DC, WR, RD, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
Geremia 21:ae0a4eedfc90 33 {
Geremia 21:ae0a4eedfc90 34 hw_reset();
Geremia 21:ae0a4eedfc90 35 BusEnable(true);
Geremia 21:ae0a4eedfc90 36 init();
Geremia 21:ae0a4eedfc90 37 cls();
Geremia 21:ae0a4eedfc90 38 set_orientation(1);
Geremia 21:ae0a4eedfc90 39 locate(0,0);
Geremia 21:ae0a4eedfc90 40 }
Geremia 18:ffa58f1a680a 41 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 42 : LCD(displayproto, Hz, mosi, miso, sclk, CS, reset, DC, LCDSIZE_X, LCDSIZE_Y, IC_X_SEGS, IC_Y_COMS, name)
Geremia 18:ffa58f1a680a 43 {
Geremia 18:ffa58f1a680a 44 hw_reset();
Geremia 18:ffa58f1a680a 45 BusEnable(true);
Geremia 18:ffa58f1a680a 46 init();
Geremia 18:ffa58f1a680a 47 cls();
Geremia 18:ffa58f1a680a 48 set_orientation(1);
Geremia 18:ffa58f1a680a 49 locate(0,0);
Geremia 18:ffa58f1a680a 50 }
Geremia 18:ffa58f1a680a 51 // reset and init the lcd controller
Geremia 18:ffa58f1a680a 52 // init sequence is manufacturer specific
Geremia 18:ffa58f1a680a 53 void ST7565::init()
Geremia 18:ffa58f1a680a 54 {
Geremia 18:ffa58f1a680a 55 /* Start Initial Sequence ----------------------------------------------------*/
Geremia 18:ffa58f1a680a 56
Geremia 18:ffa58f1a680a 57 wr_cmd8(0xE2); // sw reset
Geremia 18:ffa58f1a680a 58 wait_ms(10);
Geremia 18:ffa58f1a680a 59
Geremia 18:ffa58f1a680a 60 wr_cmd8(0xAE); // display off
Geremia 18:ffa58f1a680a 61
Geremia 18:ffa58f1a680a 62 wr_cmd8(0xA2); // bias voltage (1/9)
Geremia 18:ffa58f1a680a 63 // wr_cmd8(0xA3); // bias voltage (1/7)
Geremia 18:ffa58f1a680a 64
Geremia 18:ffa58f1a680a 65 //wr_cmd8(0xA0); // ADC select seg0-seg131
Geremia 18:ffa58f1a680a 66 wr_cmd8(0xA1); // ADC select seg223-seg0
Geremia 18:ffa58f1a680a 67 //wr_cmd8(0xC8); // SHL select com63-com0
Geremia 18:ffa58f1a680a 68 wr_cmd8(0xC0); // SHL select com0-com63
Geremia 18:ffa58f1a680a 69
Geremia 18:ffa58f1a680a 70 wr_cmd8(0x2C); // Boost ON
Geremia 18:ffa58f1a680a 71 wait_ms(10);
Geremia 18:ffa58f1a680a 72 wr_cmd8(0x2E); // Voltage Regulator ON
Geremia 18:ffa58f1a680a 73 wait_ms(10);
Geremia 18:ffa58f1a680a 74 wr_cmd8(0x2F); // Voltage Follower ON
Geremia 18:ffa58f1a680a 75 wait_ms(10);
Geremia 18:ffa58f1a680a 76 wr_cmd8(0x20|0x05); // Regulor_Resistor_Select resistor ratio 20-27, look at your display specific init code
Geremia 18:ffa58f1a680a 77 set_contrast(0x20);
Geremia 18:ffa58f1a680a 78 //wr_cmd8(0x81); // set contrast (reference voltage register set)
Geremia 18:ffa58f1a680a 79 //wr_cmd8(0x15); // contrast 00-3F
Geremia 18:ffa58f1a680a 80
Geremia 18:ffa58f1a680a 81 wr_cmd8(0xA4); // LCD display ram (EntireDisplayOn disable)
Geremia 18:ffa58f1a680a 82 wr_cmd8(0x40); // start line = 0
Geremia 18:ffa58f1a680a 83 wr_cmd8(0xA6); // display normal (1 = illuminated)
Geremia 18:ffa58f1a680a 84 wr_cmd8(0xAF); // display ON
Geremia 18:ffa58f1a680a 85
Geremia 18:ffa58f1a680a 86 }