Move hysteresis algorithm from ST to OS