Peugeot 307 - Peugeot Folding Mirrors, or just a folding mirror. - UJU

One of the features of my Peugeot 307 is folding mirrors. More of a gimmick but can be useful. However the drivers side mirror doesn't always like to play ball. It first happened about 3 months ago. The drivers side mirror would either not fold at all or if I folded it manually then tried to open it electronically it would move fine but it wouldn't stop until the mirror had moved back so far it couldn't go any further, then click and clunk as the motor tried to push the mirror further. From this I concluded that it was a fault with the system that determines the current position of the mirror.

I took the mirror apart but couldn't find anything wrong so I just gave everything a good clean and a touch of oil. That fixed things beautifully until about a week ago when it started playing the same game again.

Does anyone know what the problem might be? Or can anyone explain how the mirror knows its current position so I have an idea of what faults to look for. The car is too clever for me, I didn't manage to work out how it knows where the mirror is.

Thanks in advance