Use the actual display resolution to figure out the device type.
Use the device type to decide rotation.
Moved device type and rotation decisions to functions.
Renamed constants, because I don't really like Hungarian notation.