olikraus / u8g2

U8glib library for monochrome displays, version 2
Other
5.16k stars 1.05k forks source link

SSD0323 / OSRAM Pictiva support #720

Closed deepfryed closed 6 years ago

deepfryed commented 6 years ago

Hi I recently bought a few OSRAM Pictiva 128x64 OLEDs and was thinking about adding support for it in u8g2. Are there any development guides I should follow before I start hacking at it to send you a PR ?

I have some standalone code based on the documentation here [1] and it seems to work but I'd love to use it with u8g2.

Thanks

[1] http://www.ka7oei.com/programming_pictiva.html

olikraus commented 6 years ago

The controller SSD0323 seems to be very similar to the SSD1325. Can you test your display with the U8G2_SSD1325_NHD_128X64 constructor? It might already work.

deepfryed commented 6 years ago

Thanks I'll give that a go!

deepfryed commented 6 years ago

0

mostly works out of the box, getting some display offset issues (flipmode 1). I'll take a look and see what's going on.

olikraus commented 6 years ago

I have created a new release with a new constructor for this, example U8G2_SSD0323_OS128064_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);

I also fixed the 8 pixel offset. Will it work better?

You can download the latest U8g2 beta release from here: https://github.com/olikraus/U8g2_Arduino/archive/master.zip

  1. Remove the existing U8g2_Arduino library (https://stackoverflow.com/questions/16752806/how-do-i-remove-a-library-from-the-arduino-environment)
  2. Install the U8g2_Arduino Zip file via Arduino IDE, add zip library menu (https://www.arduino.cc/en/Guide/Libraries).
deepfryed commented 6 years ago

Thanks for the quick response, I feel guilty making you do all the work - staring at OLEDs with a migraine's not great unfortunately.

I've got a patch to make this work but it looks like might have to be a separate module file.

diff --git a/src/clib/u8x8_d_ssd1325.c b/src/clib/u8x8_d_ssd1325.c
index cf0a82a..ecacd7c 100644
--- a/src/clib/u8x8_d_ssd1325.c
+++ b/src/clib/u8x8_d_ssd1325.c
@@ -53,7 +53,7 @@ static const uint8_t u8x8_d_ssd1325_128x64_nhd_init_seq[] = {
   U8X8_C(0x0ae),                                /* display off */
   U8X8_CA(0x0b3, 0x091),                /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
   U8X8_CA(0x0a8, 0x03f),                /* multiplex ratio: 0x03f * 1/64 duty */
-  U8X8_CA(0x0a2, 0x04c),               /* display offset, shift mapping ram counter */
+  U8X8_CA(0x0a2, 0x040),                /* display offset, shift mapping ram counter */
   U8X8_CA(0x0a1, 0x000),                /* display start line */
   U8X8_CA(0x0ad, 0x002),                /* master configuration: disable embedded DC-DC, enable internal VCOMH */
   U8X8_CA(0x0a0, 0x052),                /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1) */
@@ -101,6 +101,7 @@ static const uint8_t u8x8_d_ssd1325_128x64_nhd_powersave1_seq[] = {
 static const uint8_t u8x8_d_ssd1325_128x64_nhd_flip0_seq[] = {
   U8X8_START_TRANSFER(),                     /* enable chip, delay is part of the transfer start */
   U8X8_CA(0x0a0, 0x052),                /* remap */
+  U8X8_CA(0x0a2, 0x040),                /* display offset, shift mapping ram counter */
   U8X8_END_TRANSFER(),                     /* disable chip */
   U8X8_END()                                     /* end of sequence */
 };
@@ -108,6 +109,7 @@ static const uint8_t u8x8_d_ssd1325_128x64_nhd_flip0_seq[] = {
 static const uint8_t u8x8_d_ssd1325_128x64_nhd_flip1_seq[] = {
   U8X8_START_TRANSFER(),                     /* enable chip, delay is part of the transfer start */
   U8X8_CA(0x0a0, 0x041),                /* remap */
+  U8X8_CA(0x0a2, 0x050),                /* display offset, shift mapping ram counter */
   U8X8_END_TRANSFER(),                     /* disable chip */
   U8X8_END()                                     /* end of sequence */
 };
@@ -247,6 +249,8 @@ static uint8_t u8x8_d_ssd1325_128x64_generic(u8x8_t *u8x8, uint8_t msg, uint8_t
         arg_int--;
       } while( arg_int > 0 );

+      u8x8_cad_SendCmd(u8x8, 0xe3); // no-op needs to be sent after last byte before cs is toggled.
+
       u8x8_cad_EndTransfer(u8x8);
       break;
     default:
deepfryed commented 6 years ago

test

olikraus commented 6 years ago

Looks good. Can you attach the modified c source also?

deepfryed commented 6 years ago

u8x8_d_ssd1325.c.txt

olikraus commented 6 years ago

Thanks... Code restructure...

I have created a new beta release 2.24.1, which should include your updates. Will it still work?

====

You can download the latest U8g2 beta release from here: https://github.com/olikraus/U8g2_Arduino/archive/master.zip

  1. Remove the existing U8g2_Arduino library (https://stackoverflow.com/questions/16752806/how-do-i-remove-a-library-from-the-arduino-environment)
  2. Install the U8g2_Arduino Zip file via Arduino IDE, add zip library menu (https://www.arduino.cc/en/Guide/Libraries).
deepfryed commented 6 years ago

yes works, thanks heaps!!!

olikraus commented 6 years ago

:-)