TFT and Rotary Encoder conflict

@ David Prentice

[Mod edit @david_prentice ]

Good evening David, I have a problem with an ESP32 design.
I have configured the TFT (8 bit) as follows:

***********************
#define LCD_RD 2  
#define LCD_WR 4
#define LCD_RS 15  
#define LCD_CS 35 
#define LCD_RST 32 
#define LCD_D0 12
#define LCD_D1 13
#define LCD_D2 26
#define LCD_D3 25
#define LCD_D4 17
#define LCD_D5 16
#define LCD_D6 27
#define LCD_D7 14 
************************

In the same project there is an optical rotary encoder that uses the GPO16 and GPO17 pins with the interrupt, which are also used by the TFT (D4 and D5).

***********************
       //--------- Set up Interrupt Timer -------------------------------
    timer = timerBegin(0, 80, true); //use Timer0, div80 for 1us clock
    timerAttachInterrupt(timer, &onTimer, true);
    timerAlarmWrite(timer, 10000, true); // T=10000us
    timerAlarmEnable(timer); // Start Timer


    //--- Counter setup for Rotary Encoder ---------------------
    pcnt_config_t pcnt_config_A;// structure for A   
    pcnt_config_t pcnt_config_B;// structure for B
    //
    pcnt_config_A.pulse_gpio_num = PULSE_INPUT_PIN; 
    pcnt_config_A.ctrl_gpio_num = PULSE_CTRL_PIN;
    pcnt_config_A.lctrl_mode = PCNT_MODE_REVERSE;
    pcnt_config_A.hctrl_mode = PCNT_MODE_KEEP;
    pcnt_config_A.channel = PCNT_CHANNEL_0;
    pcnt_config_A.unit = PCNT_UNIT_0;
    pcnt_config_A.pos_mode = PCNT_COUNT_INC;
    pcnt_config_A.neg_mode = PCNT_COUNT_DEC;
    pcnt_config_A.counter_h_lim = 10000;
    pcnt_config_A.counter_l_lim = -10000;
    //
    pcnt_config_B.pulse_gpio_num = PULSE_CTRL_PIN;
    pcnt_config_B.ctrl_gpio_num = PULSE_INPUT_PIN;
    pcnt_config_B.lctrl_mode = PCNT_MODE_KEEP;
    pcnt_config_B.hctrl_mode = PCNT_MODE_REVERSE;
    pcnt_config_B.channel = PCNT_CHANNEL_1;
    pcnt_config_B.unit = PCNT_UNIT_0;
    pcnt_config_B.pos_mode = PCNT_COUNT_INC;
    pcnt_config_B.neg_mode = PCNT_COUNT_DEC;
    pcnt_config_B.counter_h_lim = 10000;
    pcnt_config_B.counter_l_lim = -10000;
    //
    pcnt_unit_config(&pcnt_config_A);//Initialize A
    pcnt_unit_config(&pcnt_config_B);//Initialize B
    pcnt_counter_pause(PCNT_UNIT_0);
    pcnt_counter_clear(PCNT_UNIT_0);
    pcnt_counter_resume(PCNT_UNIT_0); //Start
**********************

Reading your mail, I found the reference to your mcufriend_shiek.h which I installed by modifying pins D4 and D5 of the TFT respectively on pins GPO5 and GPO23.
As you guessed, to no success!
By changing the TFT addresses, it remains blank and by changing the addresses of the rotary encoder, it causes no effect.
Can you help me?
Thanks in advance, Roberto

Take IO34 and IO36 for the rotary encoder and use the AiEsp32RotaryEncoder.h

An optical rotary don't need debouncing and don't need pullup or pulldown. Debouncing is in the encoder. An optical rotary isn't tristate the output is always 0 or 1.

Hello Buckfast,
thank you for your contribution and suggestions.
I had no doubts about identifying pin IO35, but would be pleased to confirm if pin IO36 is the same as I find on the ESP32 datasheets listed as SVP.
Thanks again, Roberto

(ps. sorry for my english... :wink:)

Your English is good enough.

I use this configuration but you don't need the pull-up and the GND is the GND from the encoder.

IO36 and IO 39 are input only without pull-up. IO is in this case bad. It should be I36 and I39.

Thanks a lot for your precious suggestion.
Bye, Roberto

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.