A non-transitory storage medium having stored thereon instructions that, when executed by at least one processor of a portable electronic device, cause the processor to perform a method for controlling a screen protection function of the portable electronic device, the portable electronic device comprising a gravity sensor and a display screen, the method comprising:
- setting a tilt angle range for placement of the portable electronic device, and storing the tilt angle range in a storage system of the portable electronic device;
- detecting a horizontal vector and a vertical vector of a gravitational acceleration of the portable electronic device using the gravity sensor;
- calculating a tilt angle of the portable electronic device according to the horizontal vector and the vertical vector;
- determining whether the tilt angle exceeds the preset tilt angle range;
- and
- activating a screen protection program of the portable electronic device to control the display screen to enter into a power saving mode if the tilt angle exceeds the preset tilt angle range;
- or
- terminating the screen protection program to control the display screen to enter into a normal display mode if the tilt angle does not exceed the preset tilt angle range.