In the present work, for X a Banach space, the notion of piecewise continuous Z-almost automorphic functions with values in finite dimensional spaces is extended to piecewise continuous Z-almost automorphic functions with values in X. Several properties of this class of functions are provided, in particular it is shown that if X is a Banach algebra, then this class of functions constitute also a Banach algebra; furthermore, using the theory of Z-almost automorphic functions, a new characterization of compact almost automorphic functions is given. As consequences, with the help of Z-almost automorphic functions, it is presented a simple proof of the characterization of almost automorphic sequences by compact almost automorphic functions; the method permits us to give explicit examples of compact almost automorphic functions which are not almost periodic. Also, using the theory developed here, it is shown that almost automorphic solutions of differential equations with piecewise constant argument are in fact compact almost automorphic. Finally, it is proved that the classical solution of the 1D heat equation with continuous Z-almost automorphic source is also continuous Z-almost automorphic; furthermore, we comment applications to the existence and uniqueness of the asymptotically continuous Z-almost automorphic mild solution to abstract integro-differential equations with nonlocal initial conditions.