Welcome! Log In Create A New Profile

Advanced

Marlin forgets about the rotary encoder

Posted by BlackDragon 
Marlin forgets about the rotary encoder
February 06, 2014 12:57AM
So, I have an Arduino Mega/RAMPS 1.4, with a 20x4 LCD panel and a rotary encoder. I am using Marlin for the code.
Everything is hooked up, code modified and compiled without any errors.

When I first start the rig, the encoder will control the flow rate. I turn it clockwise, the flow rate drops. I turn it counter-clockwise, the flow rate increases. If I click, the screen switches to the menu. All of this tells me that the electronics and wiring are solid.

Now for the problem.
Once I click into the menu, the rotary stops working. I can click back to the monitor, but the rotary no longer works there either.

I'm thinking that when the screen is changed, the focus for the encoder is not being set. However, I am having trouble finding where the code calls the encoder controls and what happens when screens change.

Any assistance that might point me in the right direction would be appreciated.
Re: Marlin forgets about the rotary encoder
February 12, 2014 10:11AM
ok... finally figured it out.

So, in the pins.h, under ULTRA_LCD, there are several sets of pin definitions, sitting in an IF...ELSEIF...THEN structure.
Since I was only using the NEWPANEL part of the code, that was the only place I had set the pin definitions for the LCD, the encoder and buzzer (note: the buzzer is not hooked up. This will be important in a moment).

Now, I have a touch of OCD, so, just to keep everything looking good, I went through the rest of the ULTRA_LCD and set the pin definitions to the same values for each board type. While doing this, I noticed that under one section (LCD_I2C_PANELOLU2) the buzzer was set to pin 33. Will, as I said, I have a bit of OCD. Having pins spread across AUX-4 drove me crazy, so I moved everything down by the +5 and GND pins. This put one of the encoder pins on 33. Hmmm....

I recompiled and uploaded. Low and behold, that darned thing is now working correctly. Apparently, when you pull up the menu, the program changes the panel being used. *shakes head*

So, when changing pin definitions, change it for every section of code in the pins.h.

Once I have this bugger working, I may see about making a new control code module. Less repetition, less chance to miss something. Then make a document that would give all of the correct values to put in, based on what board you are using.
Sorry, only registered users may post in this forum.

Click here to login