Mechanical AGN feedback: controlling the thermodynamical evolution of elliptical galaxies