Keep a secondary counter for revolutions, reset it if a counter had not changed after x ticks of the pot not moving?
timer = timer + 1;
if(revolution = max_revolution) {
revolutions = revolutions + 1;
}
length = (revolutions * max revolution) + revolution - prev_revolution;
if(revolution == past_revolution && timer >= x) {
revolutions = 0;
prev_revolution = revolution;
}