I updated the rotate script with the following enhancements:
1. when closing the display, the display is turned off (backlight)
2. when opening the display, rotation is not run (since orientation has not changed)
3. when resuming, rotation is not run three times and hence resumes will be faster