FIX "endstops hit" error with Auto Leveling G29 command on Marlin 1.0.2
There are a lot of guyz out there who, like me, decided to try Auto Levelling with their 3D printer, using Marlin firmware, and many have been getting the error "endstops hit" at the very end of the Auto Levelling check. I wasted several hours looking at the (mostly) BS promulgated via google, and was getting a bit pissed off erally. Nut, having been a programmer for over 20 years I thought "how hard can it be" (apologies to Jeremy Clarkeson). The answer was, luckily, not very. I checked through the code and got a feel for exactly what happens in Marlin, specifically with the Auto levelling additions. Looking at other places where the endstop is hit, I found the intriguingly named Function "endstops_hit_on_purpose()", hmm, this looks promising I thought - and it was indeed. I found the end of the G29 Auto Levelling code in "Marlin_main.cpp", added this line - AND IT ALL WORKS.
It's very easy to fix - open "Marlin_main.cpp" in a text editor, and search for "#endif // AUTO_BED_LEVELING_GRID" then add the line "endstops_hit_on_purpose()" directly after - that's it folks.

"Marlin_main.cpp"
#endif // AUTO_BED_LEVELING_GRID // original code
endstops_hit_on_purpose(); // line added by Geoff_Cohen - FIXES "endstops hit" error with Auto Leveling G29 command on Marlin 1.0.2
st_synchronize(); // original code

Plus, it's really VERY EASY TO LEVEL my 3D Solidoodle 2 printer. First Manually Home the printer - either press the Home button or enter a G28 command. Then enter G29 for auto levelling - the 3D printer software (Repetier in my case) status display shows how level the bed is - then just tweak the adjustment screws and run G29 & G29 again, until it's level - it is no longer necessary to be both level and at the correct height - just being level is enough, with the auto levelling software/hardware doing the rest. This is what a level bed will look like (the "Z" numbers on the right side)
14:06:55.795 : Bed x: 20.00 y: 20.00 z: 0.09
14:07:01.427 : Bed x: 142.00 y: 20.00 z: 0.08
14:07:07.073 : Bed x: 142.00 y: 150.00 z: 0.08
14:07:12.800 : Bed x: 20.00 y: 150.00 z: 0.07
14:07:12.818 : Eqn coefficients: a: 0.00 b: -0.00 d: 0.08
14:07:12.818 : planeNormal x: -0.00 y: 0.00 z: 1.00
So my printer is level within .02mm, pretty damn impressive IMHO - plus, it doesn't matter if the Z zero position varies slightly, the Auto Levelling will compensate every time. It's best to run the Auto level test with the Bed at operating temperature - as it may expand or even warp to some degree.