olikraus / u8g2

U8glib library for monochrome displays, version 2
Other
4.95k stars 1.04k forks source link

SSD1363 module display error #2298

Open JamesHahaho opened 8 months ago

JamesHahaho commented 8 months ago

Hello Olikraus,

I tried an SSD1363 module (i2cinterfaced, 256x128). The panel always shows the random pattern. e98649d600bf8d49ee6e7b6daa2d674

Based on SSD1362 codes, what I have changed in the codes are as follow:

  1. The base init sequence: U8X8_CA(0xfd, 0x12), / unlock / //U8X8_C(0xAE), / display off /

    U8X8_CAA(0xA0, 0x20, 0x00), U8X8_CA(0xA2, 0x80),
    U8X8_CA(0xC1, 0xFF), U8X8_CA(0xCA, 0x7F), U8X8_CA(0xAD, 0x90), U8X8_CA(0xB3, 0x61),

  2. Normal display mode command: from 0xA4 to 0xA6 (according to the datasheet) SSD1363.pdf

  3. add the write RAM command in the function u8x8_d_ssd1362_common() before write data. u8x8_cad_SendCmd(u8x8, 0x05C);

It seems that the control command could work properly, but the data could not write into the display RAM.

Could you kindly help on the issue? Thanks!

James

JamesHahaho commented 8 months ago

I find the significant difference between SSD1362 and SSD1363 .... all the commands are changed... SSD1363: image SSD1362: image I will change the codes accordingly.

olikraus commented 8 months ago

I think the issue is the missing 0x05c command, which you pointed out in 3.

https://github.com/olikraus/u8g2/blob/fc312699ac4ae105ab94ad9ba9402c1cd84ffe6f/csrc/u8x8_d_ssd1362.c#L190-L193

Depending on which constructor your have used, we probably need to send the byte 0x05c as a command byte prior to line 193. I mean we need to call u8x8_cad_SendCmd(u8x8, 0x05c ); between lines 192 and 193.

olikraus commented 8 months ago

Moreover the SSD1363 seems to use a different configuration for the DC flag. It must be high during argument sending, but must be low for SSD1362: https://github.com/olikraus/u8g2/blob/fc312699ac4ae105ab94ad9ba9402c1cd84ffe6f/tools/codebuild/codebuild.c#L2056

The "cad_001" is the specification in u8g2 for this, it means for the SSD1362: [C]ommand: DC=0 [A]rg: DC = 0 [D]ata: DC = 1

However for the SSD1363 it sould be (according to your datasheet): [C]ommand: DC=0 [A]rg: DC = 1 [D]ata: DC = 1

All in all the SSD1363 seems to be more similar to the SSD1322, which uses the same CAD layout and also reqires the 0x5c command for data write:

https://github.com/olikraus/u8g2/blob/fc312699ac4ae105ab94ad9ba9402c1cd84ffe6f/tools/codebuild/codebuild.c#L2031

I suggest to use an SSD1322 constructor for your display. It is worth a try.

JamesHahaho commented 8 months ago

Dear Olikraus, After somedays debug, I have solved the issue.

e2cf21812906d861654cacc9dd706ca

Here are the notes on the main changes:

  1. to meet the requirement of D/C, I copied your U8X_CA series macro as U8X8_CD, and use them in init sequence
  2. still use the u8x8_cad_ssd13xx_fast_i2c() as the CAD, but made changes to function u8x8_d_ssd1363_256x128_common() of case U8X8_MSG_DISPLAY_DRAW_TILE
  3. adjust the 8to32 to match the data sequence to display RAM

the .c/.h file are attached here: ssd1363.zip

I‘m not very familiar to the structure of U8G2, so the codes are not in u8g2 style... just for your reference.

Thanks for your hints. I'll try to rewrite the codes as your suggestions. James

olikraus commented 8 months ago

Thanks for the code. I will look into that once I have some time for it. I still wonder whether the ssd1322 will work...

JamesHahaho commented 8 months ago

I tried u8x8_cad_011 . Due to the origin u8x8_cad_011 dose not contain the code linked to i2c, I constructed a new function u8x8_cad_H011() :

uint8_t u8x8_cad_H011(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{ 
  switch(msg)
  {
    case U8X8_MSG_CAD_SEND_CMD:
    printf("c");
      u8x8_byte_SetDC(u8x8, 0);
      u8x8_byte_SendByte(u8x8, arg_int);
      break;
    case U8X8_MSG_CAD_SEND_ARG:
    printf("a");
      u8x8_byte_SetDC(u8x8, 1);
      u8x8_byte_SendByte(u8x8, arg_int);
      break;
    case U8X8_MSG_CAD_SEND_DATA:
    printf("d");
      u8x8_byte_SetDC(u8x8, 1);
      u8x8_byte_SendBytes(u8x8, arg_int, arg_ptr);
      break;
      /* fall through */
    case U8X8_MSG_CAD_INIT:        /*added codes here*/
          if ( u8x8->i2c_address == 255 )
          u8x8->i2c_address = 0x078;
        break;
    case U8X8_MSG_CAD_START_TRANSFER:
    case U8X8_MSG_CAD_END_TRANSFER:
      return u8x8->byte_cb(u8x8, msg, arg_int, arg_ptr);
    default:
      return 0;
  }
  return 1;
}

The data transmit on i2c bus looks like : 1 It does not work.

Compare to the worked codes, the transmitted data look like: 2

It seems the command+arg series could not be transmitted in one i2c package.

The logic_analyzer data is attached for your reference. You can use DSView to view them. logic_analizer_data.zip

olikraus commented 8 months ago

The cad_001 / cad011 are indeed only for SPI interface. Maybe i was confused here, but the u8x8_cad_ssd13xx_fast_i2c() should be correct for I2C.

neuralmax commented 3 months ago

Can you please post the logic_analyzer data for write to RAM sequence? I has been weeks and I still cannot get it to work.

JamesHahaho commented 3 months ago

la_data.zip Here I re-attached the logic analyzer data for accessing SDD1363 with I2C. You may use DSLogic software (https://dreamsourcelab.cn/download/) to open it.

neuralmax commented 3 months ago

Thank you so much. I managed to run it at last. For now just using the Wire library and sending the codes I copied from your logic analysis files. Although it works its seems very slow, despite that I run I2C at 1HMz clock speed and managed to send whole line in one communication burst I get only about 2 fps and frame tearing. Is it slow like this for you also? Link to video of result I got: https://youtu.be/XztWQ6t6XSM