Where to enable user interface encoder in Marlin?
It seems that ULTIPANEL must be defined. The code for the encoder was included long ago with the Ultipanel (display and encoder) and does not exist on its own.

#define LCD_SAINSMART_I2C_2004   //  I2C LCD

#define ULTIPANEL                // enable code for encoder.

//encoder pins
#define BTN_EN1 37
#define BTN_EN2 35
#define BTN_ENC 31