This is something I've wanted to do on my knee mill as well. Finding the correct table height to run a program using both jobber twist drills and short end mills can be a pain. If you do decide to run such programs in one program it leads to a loss in rigidity from doing some cutting with the quill almost fully extended.
How I was thinking of accomplishing this is by changing the tool length offset when the height of the knee changes. What would be nice is a prompt after a tool change that requests a knee height adjustment to target minimum quill length extension. I was thinking you could do this with a Python script that processes an ngc. The script would look at the minimum Z height for a given tool, then replace the M6 with an O code routine. The O code routine would prompt the user 'Adjust Knee Height X Length, Press Resume After Adjustment' then check the new knee position and if within range, issue a G10 L10 (set tool table) for the entire tool table.
This solution would be a bit clunky, as you'd have to run the script on every file you post to the machine, unless you can integrate this feature into your post processor. Also, adjusting the entire tool table can be slow - I have 12 in mine, and rewriting all of them from a script takes ~20 seconds (from memory). It would probably be quicker to do a G10 L2 (set coordinate system) instead, but the problem with this (I think) is that your tool length offsets would be invalid after exiting an ngc.
Can you provide details and/or pictures on how you mounted your linear encoder and wired it to your controller?