Welcome! Log In Create A New Profile

Advanced

[SOLVED] Getting 2004a LCD and rotary encoder to work

Posted by Killi 
[SOLVED] Getting 2004a LCD and rotary encoder to work
November 29, 2015 10:58AM
Hi,

I'm using Marlin 1.0.2 on an Arduino Mega with Ramps 1.4 and bought a 2004a LCD and a rotary encoder (no controller board).
I can't get the rotary encoder to work, just the LCD....I soldered everything like the RepRapDiscount Smart Controller. If I look in pins.h, there is:


  #ifdef ULTRA_LCD

    #ifdef NEWPANEL
      #define LCD_PINS_RS 16
      #define LCD_PINS_ENABLE 17
      #define LCD_PINS_D4 23
      #define LCD_PINS_D5 25
      #define LCD_PINS_D6 27
      #define LCD_PINS_D7 29

      #ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
        #define BEEPER 37

        #define BTN_EN1 31
        #define BTN_EN2 33
        #define BTN_ENC 35

        #define SDCARDDETECT 49
...
...

So it is not enough to comment out the
// The RepRapDiscount Smart Controller (white PCcool smiley
// [reprap.org]
#define REPRAP_DISCOUNT_SMART_CONTROLLER
because there is an if on "NEWPANEL".

But when I set
#define NEWPANEL
I'm getting the following compile errors:

ultralcd.cpp: In function 'void lcd_goto_menu(menuFunc_t, uint32_t, bool)':
ultralcd.cpp:198: error: 'encoderPosition' was not declared in this scope
       encoderPosition = encoder;
       ^
ultralcd.cpp:199: error: 'lcd_quick_feedback' was not declared in this scope
       if (feedback) lcd_quick_feedback();
                                        ^
ultralcd.cpp: In function 'void lcd_update()':
ultralcd.cpp:1202: error: 'IS_SD_INSERTED' was not declared in this scope
     if((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected()))
         ^
ultralcd.cpp:1202: error: 'lcd_oldcardstatus' was not declared in this scope
     if((IS_SD_INSERTED != lcd_oldcardstatus && lcd_detected()))
                           ^
ultralcd.cpp:1214: error: 'card' was not declared in this scope
             card.initsd();
             ^
ultralcd.cpp:1219: error: 'card' was not declared in this scope
             card.release();
             ^
'encoderPosition' was not declared in this scope

In ultralcd.cpp the encoderPosition is only declared if you define ULTIPANEL....???

To get my LCD to work, this is my config:


#define ULTRA_LCD  //general LCD support, also 16x2
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#define ENCODER_PULSES_PER_STEP 1 // Increase if you have a high resolution encoder
#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
#define LCD_FEEDBACK_FREQUENCY_HZ 700         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
                    
// The RepRapDiscount Smart Controller (white PCcool smiley
// [reprap.org]
#define REPRAP_DISCOUNT_SMART_CONTROLLER

What do I have to do to enable my rotary encoder? A LCD is pretty but useless without user input....

Edited 3 time(s). Last edit at 11/29/2015 02:15PM by Killi.
Re: Getting LCD and rotary encoder to work
November 29, 2015 02:14PM
I got it!!!!!!!!! After 1 week of google and reverse engineering the marlin code I've got it!

If you want to enable your selfmade LCD with rotary encoder you have to:

- enable ULTRA_LCD
- enable NEWPANEL
- enable SDSUPPORT
- enable ULTIPANEL
- enable REPRAP_DISCOUNT_SMART_CONTROLLER

=> This makes absolutely no sense to me but these settings have dependencies on each other. Even if you don't have an SD card you have to enable it for compiling the firmware...

And now my rotary encoder works like charm :-)
Sorry, only registered users may post in this forum.

Click here to login