wuhanstudio / u8g2-arm-linux

U8g2 for arm linux - a monochrome graphics library
https://github.com/wuhanstudio/u8g2-arm-linux/wiki
Other
51 stars 24 forks source link

Origin not on right place #4

Closed ricbrue closed 3 years ago

ricbrue commented 3 years ago

I've a SH1107 display controller with a 128x128 pixels display (UG-2828TSWIG01). The communication of the driver seems to work on a custom Linux distribution (arm64 device). The only issue that I encounter is that the origin of the coordinates is not in the right place as you can see in the following picture. photo_2021-06-18_10-59-01 I attach also a portion of the code that I am using.

u8g2_t u8g2;
u8g2_Setup_sh1107_i2c_128x128_f(&u8g2, U8G2_R0, u8x8_byte_arm_linux_hw_i2c, u8x8_arm_linux_gpio_and_delay);
u8x8_SetPin(u8g2_GetU8x8(&u8g2), U8X8_PIN_RESET, GPIO_DISPLAY_RESET_PIN_NO);
u8g2_SetI2CAddress(&u8g2, (0x3C<<1));
u8g2_InitDisplay(&u8g2);
u8g2_SetPowerSave(&u8g2, 0);

u8g2_ClearBuffer(u8g2);
u8g2_SetFont(u8g2, u8g2_font_ncenB08_tr);
//This creates two lines composed by numbers in order to identify the real origin (1,1)
for(int i = 0; i <16; i++){
   char tmp[2];
   sprintf(tmp,"%d",(i%10));
   u8g2_DrawStr(u8g2, (i*8), 8, tmp);
   u8g2_DrawStr(u8g2, 1, 8+(i*8), tmp);
}   

u8g2_SendBuffer(u8g2);

What am I missing?

ricbrue commented 3 years ago

Here a better test code:

for(int i=0;i<128;i++){
  u8g2_DrawPixel(u8g2, i,i); //diagonal -> dx bottom
  u8g2_DrawPixel(u8g2, i,127-i); //diagonal -> dx top
  u8g2_DrawPixel(u8g2, i,0); //line top
  u8g2_DrawPixel(u8g2, i,7); //line top
  u8g2_DrawPixel(u8g2, i,127); //line bottom
  u8g2_DrawPixel(u8g2, i,120); //line bottom
  u8g2_DrawPixel(u8g2, 0,i); //line left
  u8g2_DrawPixel(u8g2, 7,i); //line left
  u8g2_DrawPixel(u8g2, 127,i); //line right
  u8g2_DrawPixel(u8g2, 120,i); //line right
}

Result: photo_2021-06-18_12-02-31

wuhanstudio commented 3 years ago

Hi, I'm wondering is this happening for multiple display controllers or just SH1107?

Currently, I use SSD1306 for the testing purpose, maybe I'll get a SH1107 to reproduce the error.

ricbrue commented 3 years ago

Hi, I'm wondering is this happening for multiple display controllers or just SH1107?

Currently, I use SSD1306 for the testing purpose, maybe I'll get a SH1107 to reproduce the error.

Hi, we have only such display so far, we cannot test with other displays.

wuhanstudio commented 3 years ago

Is this the one you are using (IIC), I'll place the order and test it out soon.

1.12 inch 22P/7P/5P SPI White OLED Square Screen (Board/No Board) SH1107 Drive IC 128*128 Parallel/IIC Interface 3.3V https://a.aliexpress.com/_mOunvk1

wuhanstudio commented 3 years ago

BTW, I saw a similar problem and a quick fix:

https://github.com/olikraus/u8g2/issues/44

https://github.com/olikraus/u8g2/commit/bb19b64e2d87a217e1e2aa41d38b746825e13cff#diff-74e8434bb42473a155d5c67d24d068588b66b999bdc0ddd95b522121e64aa5f6L460

By changing:

u8x8_i2c_data_transfer(u8x8, arg_int, arg_ptr); 

to:

u8x8_i2c_data_transfer(u8x8, arg_int, p)
ricbrue commented 3 years ago

Ok I've finally solved applying u8g2_Setup_sh1107_pimoroni_128x128_f configuration (here). Indeed I think that the issue was the default_x_offset and the flipmode_x_offset which were 96 instead of 0. Thank you anyway for your help.