First of all, thanks for your very quick response! I found out what seems to be the problem;
I was using the M5Atom.h to control the leds, and somewhere in the M5.Update() the flickering sometimes occurred. The problem was indeed solved using the fastled library. The device works exactly as I was hoping now.
For this I needed to remove M5Atom.h, because indeed some functions and variables overlap.
Thanks again for pointing me in the right direction.
Greetings from a very happy Geert :-)