Duty cycle detection circuit for square wave
Detecting the duty cycle of a square wave of Known peak amplitude is easy if you are not in a hurry.

Say if your peak is 5VDC then just average this with a lowpass filter. For non critical stuff one or two passive RC sections will do. Make your cut frequency a small fraction of your square wave frequency so the output will be low ripple DC.

Feed the DC through a simple comparetor like say LM393. 1V is 20%, 2.5V is 50% 4V is 80% etc.