u8glib icon indicating copy to clipboard operation
u8glib copied to clipboard

Missing setContrast()

Open delinend opened this issue 8 years ago • 15 comments

Hi.

I missing the setContrast() funktion for my ssd1306 I2C display, in the NODEmcu build. Is it possible that you can support the setContrast() funktion in the u8glib for NODEmcu ?

Thanks and best regards.

delinend avatar Jun 01 '16 19:06 delinend

it should be there. Which version do you use?

olikraus avatar Jun 01 '16 20:06 olikraus

I just see under "Unimplemented Functions" http://nodemcu.readthedocs.io/en/dev/en/modules/u8g/#unimplemented-functions and normaly use the http://nodemcu-build.com/ builder (master or dev)

delinend avatar Jun 02 '16 03:06 delinend

Maybe nodemcu uses an older version of u8glib. Contrast is implemented here in line 244: https://github.com/olikraus/u8glib/blob/master/csrc/u8g_dev_ssd1306_128x64.c

olikraus avatar Jun 02 '16 04:06 olikraus

Maybe nodemcu uses an older version of u8glib.

Correct, we integrate release 1.18.1 and I postponed binding setContrast() for the time being. @delinend it will be included with the next update from upstream release 1.19.1.

devsaurus avatar Jun 02 '16 18:06 devsaurus

thanks for the clarification.

olikraus avatar Jun 02 '16 19:06 olikraus

Thanks. I'm looking forward to use the u8glib build 1.19.1 on NodeMCU, when it's ready there.

delinend avatar Jun 03 '16 15:06 delinend

Do anyone knows, when the upstream release 1.19.1 is comming ?

delinend avatar Jul 09 '16 15:07 delinend

Can't you select 1.19.1 from the library manager?

olikraus avatar Jul 10 '16 08:07 olikraus

@delinend I've started PR nodemcu/nodemcu-firmware#1385. Feel free to test drive the update and feed back any issues over there.

devsaurus avatar Jul 10 '16 15:07 devsaurus

@devsaurus Thanks. How do we get it over to nodemcu/nodemcu-firmware (dev), so that I can test it, via http://nodemcu-build.com/ ?

delinend avatar Jul 27 '16 03:07 delinend

@delinend The update won't be available from nodemcu-build before it's merged into the official firmware repo. Thus I've prepared images with a snapshot of the PR branch at https://github.com/devsaurus/nodemcu-firmware/releases/tag/u8g_1.19.1 It contains the default modules plus the upgraded u8g.

Feel free to try them and feed back your results over at https://github.com/nodemcu/nodemcu-firmware/pull/1385.

devsaurus avatar Jul 27 '16 05:07 devsaurus

@delinend the update was merged to nodemcu upstream in the meantime.

devsaurus avatar Aug 02 '16 20:08 devsaurus

Thanks @devsaurus . I have tested it now, and have a small question. I'm using a small 0.96" oled (ssd1306_128x64) from Ebay via I2C and tryed setContrast(255) vs setContrast(0). There is a differency (it's working), but it is small. When using setContrast(0), it still bright my room up in the night. Is this an issue in the oled 0.96" display, or mayby in the code ? I want to Dim it more, but maybe the display can't do that?

delinend avatar Aug 08 '16 14:08 delinend

When using setContrast(0), it still bright my room up in the night. Is this an issue in the oled 0.96" display, or mayby in the code ?

The code itself is pretty simple, thus I don't expect issues there. But you could measure the supply current of the display and compare it with the ISEG spec of the datasheet for different contrast settings. You'd need a quite precise current meter that's able to detect a delta of 50-80 µA.

devsaurus avatar Aug 08 '16 17:08 devsaurus

Have a look at this file: https://github.com/olikraus/u8glib/blob/master/csrc/u8g_dev_ssd1306_128x64.c It contains the init sequence for the OLED, which looks like this:

static const uint8_t u8g_dev_ssd1306_128x64_adafruit3_init_seq[] PROGMEM = {

  U8G_ESC_CS(0),             /* disable chip */
  U8G_ESC_ADR(0),           /* instruction mode */
  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
  U8G_ESC_CS(1),             /* enable chip */

  0x0ae,                /* display off, sleep mode */
  0x0d5, 0x080,     /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
  0x0a8, 0x03f,     /* */

  0x0d3, 0x000,     /*  */

  0x040,                /* start line */

  0x08d, 0x014,     /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */

  0x020, 0x002,     /* 2012-05-27: page addressing mode */
  0x0a1,                /* segment remap a0/a1*/
  0x0c8,                /* c0: scan dir normal, c8: reverse */
  0x0da, 0x012,     /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
  0x081, 0x0cf,     /* [2] set contrast control */
  0x0d9, 0x0f1,     /* [2] pre-charge period 0x022/f1*/
  0x0db, 0x040,     /* vcomh deselect level */

You could play around with some parameters. For example you could disable the charge pump ( use 0x08d, 0x010) or you can redurce the vcomh deselet level, e.g. try 0x0db, 0x030 or 0x0db,0x020

olikraus avatar Aug 09 '16 09:08 olikraus