Does anyone have a plan or know about Klipper working with a linear encoder for the closed-loop control?

The linear encoder normally works in the inkjet printer.
It contained a grating strip and the linear encoder,

Here is an example of how to use the linear encoder and grating strip from the old printer to make a closed-loop control 3D printer:

And the programming of knowing motion is very easy, here is an example in ESP32:

Code source, was written by Chinese

    #define GPIO_INPUT_IO_ENC_S (5)
    #define GPIO_INPUT_IO_ENC_A (4)
    #define GPIO_INPUT_IO_ENC_B (3)
    #define GPIO_INPUT_PIN_SEL ((1ULL << GPIO_INPUT_IO_ENC_S) | (1ULL << GPIO_INPUT_IO_ENC_A) | (1ULL << GPIO_INPUT_IO_ENC_B))

    void app_main(void)
    {
        gpio_config_t io_conf = {};
        io_conf.mode = GPIO_MODE_INPUT;
        io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL;
        io_conf.pull_down_en = 0;
        io_conf.pull_up_en = 1;
        gpio_config(&io_conf);
        int flag = 0;
        while (1)
        {
            if (gpio_get_level(GPIO_INPUT_IO_ENC_A) == 0)flag = 1; // 判断是否开始拨动
            if (flag)
            {
                if (gpio_get_level(GPIO_INPUT_IO_ENC_A) == 1)   // 判断一次拨动是否结束
                {
                    if (gpio_get_level(GPIO_INPUT_IO_ENC_B) == 1) // 根据B线判断正转反转
                    {
                        ESP_LOGI("TEST", "+");	// 正转逻辑
                    }
                    else
                    {
                        ESP_LOGI("TEST", "-");	// 反转逻辑
                    }
                    flag = 0;
                }
            }
            vTaskDelay(1 / portTICK_PERIOD_MS);	// 查询间隔1ms
        }
    }

And here are the documents of the encoder:
V02-1747EN-952646.pdf (592.4 KB)
av02-3654en-ds-heds-974x-21jun2012 encoder.pdf (194.4 KB)

I’m an ender3 v2 user, and the Klipper doesn’t support the screen for that motherboard, so it seems we have some extra GPIO to do that work,

[Ender3v2 motherboard schematic, Creality 4.2.2]
Creality.4.2.2.-.Schematic.28-5-22.pdf (188.1 KB)

The available pins are: PB10, PB11, PB12, PB14, PB15, PC6,