Adding rotary encoder with I2C OLED display
I've been tinkering with the firmware and now have an OLED display working via I2C.
Now I'd like to add a way to use the menus. Hopefully with a rotary encoder. I can connect this in the same pinout as used for the "Smart" controllers. What changes in the firmware configuration do I need to make for the encoder to work?
Now I'd like to add a way to use the menus. Hopefully with a rotary encoder. I can connect this in the same pinout as used for the "Smart" controllers. What changes in the firmware configuration do I need to make for the encoder to work?
Comments
I read both the ui.h and displaylist.h files and see no obvious place for this.
RAMPS 1.4 board, The encoder is connected as follows:
Button A 33
Button B 35
Click button 37
Thanks again.
did you use the uiconfig.h?
#define UI_DISPLAY_TYPE 5
#define U8GLIB_SSD1306_I2C
so it´s simple to add Encoder.
in configuration.h
set #define FEATURE_UI_KEYS 1
in uiconfig.h
uncomment // UI_KEYS_INIT_CLICKENCODER_LOW(33,31); and replace the pin numbers by yours
do the same for //UI_KEYS_CLICKENCODER_LOW_REV(33,31)
similar for button , assign pin number/function
so at least the part in your uiconfig.h should be
void uiInitKeys() {
#if UI_HAS_KEYS!=0
UI_KEYS_INIT_CLICKENCODER_LOW(33,35);
UI_KEYS_INIT_BUTTON_LOW(37); // push button, connects gnd to pin
#endif
}
void uiCheckKeys(uint16_t &action) {
#if UI_HAS_KEYS!=0
UI_KEYS_CLICKENCODER_LOW_REV(33,35);
UI_KEYS_BUTTON_LOW(37,UI_ACTION_OK); // push button, connects gnd to pin
#endif
}
think that should work for you, if Encoder direction is wrong, just swap the pin numbers
(Note to self -- This works better if you actually connect to pins 33, 35, and 37. Not 31, 33, 35.... )