One caveat, the above assumes it’s wired around the same direction each time, and not zigzag. That bit me too, working on a similar mapping.
See Manually adjusting spin in mapper?
But I need to shift 1 for the zags, to get it right. This week, next time I get time to play. (It’s also top down, as well as zigzag). Hopefully between the two, we can have a good example. I’ll recraft mine to have variables for up/down and zigzag/continuous.