DifferentialEquations with nested functions + Callbacks

I am trying to follow the examples here and here so I thought it was common to use f1.

Everything in the code is defined and works, except for f1 which I now introduce as part of the callback. I will think about this some more and try to make my question more understandable.