I can't set the contrast with U8glib

I changed the display from my project from LCD128x64 with ST7920 to EA dogXL240B-7 with UC1611s. I connected the display to my Arduino Mega in SPI 4 wire configuration: SCK to Pin 52, SI to Pin 51, CS to Pin 53 and CD to Pin 48. I’m using the library U8glib and everyting is working perfect except one thing. I can’t set the contrast. I use ‘u8g.setContrast(xxx);’ and that doesn’t work for me; it makes no difference if I put 0 or 255 at the xxx. I’ve put this line in the Setup and tried it in the pictureloop but nothing is working.
What am I doing wrong, can someone help me please.

Thanks for reporting this. It seems to be a bug.

Please locate this file/code in your folder structure:
https://code.google.com/p/u8glib/source/browse/csrc/u8g_dev_uc1611_dogxl240.c
Setting of the contrast is done in lines 102

The wrong code is this:

case U8G_DEV_MSG_CONTRAST:
u8g_SetChipSelect(u8g, dev, 0);
u8g_SetAddress(u8g, dev, 0); /* instruction mode /
u8g_WriteByte(u8g, dev, 0x81);
u8g_WriteByte(u8g, dev, (
(uint8_t )arg) >> 2); / set contrast from, keep gain at 0 */
u8g_SetChipSelect(u8g, dev, 1);
return 1;

Correct code sould be:

case U8G_DEV_MSG_CONTRAST:
u8g_SetChipSelect(u8g, dev, 1);
u8g_SetAddress(u8g, dev, 0); /* instruction mode /
u8g_WriteByte(u8g, dev, 0x81);
u8g_WriteByte(u8g, dev, (
(uint8_t )arg) >> 2); / set contrast from, keep gain at 0 */
u8g_SetChipSelect(u8g, dev, 0);
return 1;

Maybe you can fix this and let me know whether this will work

Thanks, Oliver

Thanks for looking at this Oliver.

I changed the code but it makes no difference!

hmmm... ok, it has been contributed (i do not own the display). From the datasheet it should be:

   case U8G_DEV_MSG_CONTRAST:
     u8g_SetChipSelect(u8g, dev, 1);
     u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
     u8g_WriteByte(u8g, dev, 0x81);
     u8g_WriteByte(u8g, dev, (*(uint8_t *)arg));  /* set contrast from, keep gain at 0 */
     u8g_SetChipSelect(u8g, dev, 0);
     return 1;

The division by 4 is wrong.

Also, updating library is tricky. There might be multiply locations of the library code on your hard disk. Ensure you have updated the correct c code and always check in your log window of the arduino IDE that the code is recompiled.

Oliver

Thanks Oliver.

I changed the code and I'm sure that I did it in the correct c code but without success.

Dirk.

Best Oliver, I will excuse me for my previous post.

I've searched with Windows Explorer for 'u8g_dev_uc1611_dogxl240.c' and changed the code in all the files it found... NOW IT'S WORKING!!!!

Thanks a lot Oliver, you're the genius.

Dirk.

Well, yes, looks like the Arduino IDE puts several copies of lib files everywhere around in the system...

Oliver