Lyapunov-type characterisation of exponential dichotomies with applications to the heat and Klein–Gordon equations