From: Nathael Pajani Date: Sun, 19 Mar 2017 18:35:18 +0000 (+0100) Subject: Add support for displays without an external VCC (use internal charge pump) X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=7361a13180e1ad867e8dc06dd0763da409641eaa;p=soft%2Flpc122x%2Fcore Add support for displays without an external VCC (use internal charge pump) --- diff --git a/extdrv/ssd130x_oled_driver.c b/extdrv/ssd130x_oled_driver.c index f8b2d20..06c0d68 100644 --- a/extdrv/ssd130x_oled_driver.c +++ b/extdrv/ssd130x_oled_driver.c @@ -261,16 +261,23 @@ int ssd130x_display_off(struct oled_display* conf) int ssd130x_display_on(struct oled_display* conf) { int ret = 0; + uint8_t val = 0; /* Display OFF */ - ret = ssd130x_display_power(conf, SSD130x_DISP_OFF); + ret = ssd130x_display_power(conf, SSD130x_DISP_OFF); /* 0xAE */ if (ret != 0) { return ret; } + if (conf->charge_pump == SSD130x_INTERNAL_PUMP) { + val = SSD130x_CMD_CHARGE_INTERN; + ssd130x_send_command(conf, SSD130x_CMD_CHARGE_PUMP, &val, 1); /* 0x8D */ + } + ret = ssd130x_set_mem_addressing_mode(conf, SSD130x_ADDR_TYPE_HORIZONTAL); if (ret != 0) { return ret; } + ret = ssd130x_set_scan_direction(conf); if (ret != 0) { return ret; @@ -279,6 +286,14 @@ int ssd130x_display_on(struct oled_display* conf) if (ret != 0) { return ret; } + + if (conf->charge_pump == SSD130x_INTERNAL_PUMP) { + val = 0xF1; + ssd130x_send_command(conf, SSD130x_CMD_SET_PRECHARGE, &val, 1); /* 0xD9 */ + val = SSD130x_VCOM_083; + ssd130x_send_command(conf, SSD130x_CMD_VCOM_LEVEL, &val, 1); /* 0xDB */ + } + ret = ssd130x_set_display_on(conf, SSD130x_DISP_RAM); if (ret != 0) { return ret; diff --git a/include/extdrv/ssd130x_oled_driver.h b/include/extdrv/ssd130x_oled_driver.h index 19f055d..8552c39 100644 --- a/include/extdrv/ssd130x_oled_driver.h +++ b/include/extdrv/ssd130x_oled_driver.h @@ -33,6 +33,7 @@ struct oled_display { uint8_t address; /* 8 bits address */ uint8_t bus_num; /* I2C bus number */ uint8_t probe_ok; + uint8_t charge_pump; uint8_t video_mode; uint8_t contrast; uint8_t scan_dir; @@ -121,6 +122,13 @@ enum ssd130x_defs { #define SSD130x_ADDR_COL(x) ((x) & 0x7F) #define SSD130x_ADDR_PAGE(x) ((x) & 0x07) +/* Charge pump */ +#define SSD130x_EXT_VCC 0x01 +#define SSD130x_INTERNAL_PUMP 0x00 +#define SSD130x_CMD_CHARGE_PUMP 0x8D +#define SSD130x_CMD_CHARGE_EXT 0x10 +#define SSD130x_CMD_CHARGE_INTERN 0x14 + /* Hardware configuration */ #define SSD130x_CMD_START_LINE(x) (0x40 + ((x) & 0x3F)) #define SSD130x_CMD_SEG0_MAP_RIGHT 0xA1