Display uc1701 x_offset cannot be added

Basic Information:

Printer Model: Alfawise EX8 modified
MCU / Printerboard: BTT Skr Pro 1.2
klippy.log
klippy (3).log (11.9 KB)

Describe your issue:

My LCD display based on uc1701 has 4 pixel shift. I read about x_offset for this lcd (https://github.com/Klipper3d/klipper/pull/3284)
but when I’ve added that option I received error “Option ‘x_offset’ is not valid in section ‘display’”
Help me please.

Only applicable to LCDs with the sh1106 controller chip. In this case, you need to set

lcd_type: sh1106

But is it possible just replace u1701 (LCD) to sh1106 (OLED) and get system work?

Just try it?
Since I do not know your display, I cannot give you a meaningful answer. As a matter of fact, only the sh1106 supports this setting.

Thank you for attention!
My display is Alfawise Ex8 custom display. It has label on plate WYH L12864 COG.
This is u1701 based LCD with a single 10-pin connector. It uses only cs_pin, a0_pin, spi_software_mosi_pin and spi_software_sclk_pin. And also encoder_pins and click_pin of course. Even spi_software_miso_pin is not used but I’ve set it to dummy value (EXP2_2).
When I tried set sh1106 i’ve received error “Option ‘dc_pin’ in section ‘display’ must be specified”. then when I’ve defined dc_pin to some value (EXP2_4) I received next error “Option ‘a0_pin’ is not valid in section ‘display’”/ After that I’ve decided that sh1106 is not compatible with u1701 and stopped experiments.
Is it possible to add x_offset section to u1701 type as that already was made according link in the starting message?

This would have to be answered by a developer.

IMO, this does not really fit together:

  • The offsetting for the SSD1306/SH1106 is needed because they have 132 segments instead of 128
  • Your LCD has, as its name already suggests, the standard 128 segments

→ Some offsets should not be needed

As a more general remark: Klipper is heavily focused on the displays that can be connected via Moonraker / KlipperScreen. There is only very limited interest in working on such “old” displays

In the marlin x offset 4 px fixed picture :slight_smile:

Same with me.

UC1701? I don’t know u1701!

There is an example how to instantiate your display.

More info Configuration reference - Klipper documentation
… you may search for uc1701 display

According to

x_offset shouldn’t be a problem.

You could share your printer.cfg with us.

Good luck, hcet14

Thank you for answer.

UC1701? I don’t know u1701!

Yes, of course, uc1701. My typo. I’ve checked marlin code. According macro names chip is ST7565. But it works in Klipper as type uc1701 except these 4 pixels.

x_offset shouldn’t be a problem.

May be problem in the checker which generate error for type uc1701 not in the handler itelf. Unfortunately I have not any idea where that checker can be. I play with Klipper for one week only.

You could share your printer.cfg with us.

Sure. Attachment is archive with my config files.
config-20230805-104205.zip (6.0 KB)

PS marlin code which handles this X_OFFSET:

#define ST7565_COLUMN_ADR(N) (0x10 | (((N) >> 4) & 0xF)), ((N) & 0xF)

N = 4 in the case of the my LCD.

If you had read my previous answer, you would have noticed that it is not implemented for this type of controller.
An interested developer would need to pick this up and implement it.

Please don’t thank me. You might hit the like knob, if there is a solution.

I guess, you were on the right path to solution.
Did you replaced your klipper/klippy/extras/display/uc1701.py?
Your printer.cfg looks good concerning the display.

Replace “klipper/klippy/extras/display/uc1701.py” with one from config: Add x_offset (Used to add horizontal offset on SSD1306/SH1106 displays) by rjpatawaran · Pull Request #3284 · Klipper3d/klipper · GitHub

The files from dmbutyugin and tntclaus are the same. When you compare those with the current official uc1701.py you’ll see the difference. Of course uncomment “#x_offset: 4” back in your printer.cfg.

@hcet14 please be so kind to discuss only topics you actually understand and to which you can add value:

Problem is fixed. Thank you both hcet14 and Sineos merge of your advices give me a solution.
In the file
klippy/extras/display/uc1701.py
I’ve replace line 170 in the class UC1701(DisplayBase):
from

        DisplayBase.__init__(self, io)

to

        x_offset = config.getint('x_offset', 0, minval=0, maxval=4)
        columns = config.getint('columns', 128)
        DisplayBase.__init__(self, io, columns=columns, x_offset=x_offset)

This allows to set x_offset and columns in the [display] section of the printer.cfg

x_offset: 4

heals starting offset

columns: 132

removes points at the end of lines.

Thank you!

3 Likes

Yes, this is a proper solution :+1:

Is it needed to make pull request to klipper branch?

Cool, i would pull a request.

I did it. https://github.com/Klipper3d/klipper/pull/6323