Parallax 5 position switch

From RepRap
Revision as of 20:02, 27 December 2014 by Glenn (talk | contribs) (+cat +link)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

this wiki is to show how to wire a direction pad to ramps, in case the scroll pad is not to liking, or not available. these direction controlled 5 position switches, left right, up, down and push are common at radio shack in the USA. part is this online http://www.radioshack.com/product/index.jsp?productId=12296089&locale=en_US


5positionswitch.jpg


<videoflash>lgVPS5aL_FM</videoflash>



    pins.h define pins used
   #define BTN_EN1 37 up
   #define BTN_EN2 35 down
   #define BTN_ENC 31  //the click or the push



you will want the modified ultralcd.cpp file. changes will be made later on to include it with the main files as an optional change.

the idea behind the coding is to allow for direction pad to change settings, if pressed for more than a few seconds items advance faster so settings like temp and fan speed don't take to long, also holding down changes menu option automatically after a second of holding down.
here is the spec file of the controller joypad
here is an image of the diagram of the part:

5pos.jpg
this wiki is being edited currently. errors may be in wiki info, and code may not be for your specific build for example my configuration.h file is different.

my configuration.h
enable the following in configuration.h file by unmarking and defining the following

  1. define LCD_I2C_SAINSMART_YWROBOT (for i2c display that i will be adding later to reference)
  1. define ULTRA_LCD //general lcd support, also 16x2
  2. define SDSUPPORT // Enable SD Card Support in Hardware Console


you may have other hardware to enable depending on lcd display type.
here is the important code change for the 5 position switch to work ultralcd.ggp replace the one in the marlin firmware directory with this one. the code for it is essentially this:

   
if(READ(BTN_EN1)==0) {enc=EN_A; encoderDiff=1; EN_A_TEMP++;EN_B_TEMP==0;if (EN_A_TEMP>200){encoderDiff=5;};}//newbutton|=EN_A;
else {EN_A_TEMP==0; }
if(READ(BTN_EN2)==0) {enc=EN_B ;encoderDiff=-1;EN_B_TEMP++;EN_A_TEMP==0;if (EN_B_TEMP>200){encoderDiff=-5;};} // newbutton|=EN_B;
else {EN_B_TEMP==0;}
if (encoderDiff==0) {EN_B_TEMP==0;EN_A_TEMP==0;}
//if (cnt_button>5 ) encoderDiff=encoderDiff *10;
//speed up menu
lastEncoderBits = enc;
//}//end cnt



it still needs a little work and clean up. but it works at least good enough to show people how.