Disclosure of Invention
The invention mainly aims to provide a gravity sensor adjusting method, a mobile terminal and a computer readable storage medium, and aims to solve the problem that in the prior art, when the height of a user changes due to the detection timing of a gravity sensor, the gravity sensor fails, and the detection of a vertical screen of a mold is inaccurate.
In order to achieve the above object, the present invention provides a gravity sensor adjusting method, including the steps of:
a corresponding relation table of detection configuration of the gravity sensor corresponding to the height value of each position is stored in the mobile terminal in advance;
setting the overtime time of a timer, and acquiring the height value of the current position of the mobile terminal when the timer reaches the overtime time;
and acquiring the corresponding gravity sensor stage number in the corresponding relation table according to the height value of the current position of the mobile terminal, and setting the stage number as the current gravity sensing stage number.
Optionally, the gravity sensor adjusting method, where the mobile terminal stores in advance a correspondence table of the detection configuration of the gravity sensor corresponding to each height value of the location, specifically includes:
setting the height value of the position of the mobile terminal as a plurality of height value grades in advance;
setting the configuration of a gravity sensor of the mobile terminal to a plurality of gravity sensor levels in advance;
corresponding each height value grade of the mobile terminal to a gravity sensor grade, and generating a corresponding relation table of detection configuration of the gravity sensor corresponding to the height value of each position;
wherein, the lower the height value grade, the higher the corresponding gravity sensor grade.
Optionally, the gravity sensor adjusting method, wherein the setting of the timeout time of the timer, and obtaining the height value of the current location of the mobile terminal when the timer reaches the timeout time specifically include:
setting the overtime time of a timer, wherein the overtime time comprises overtime time of a plurality of levels, and the overtime time is longer when the level is higher;
and when the timer reaches the overtime, acquiring the height value of the current position of the mobile terminal.
Optionally, the gravity sensor adjusting method, wherein the obtaining a height value of a current location of the mobile terminal further includes:
judging whether the height value of the current position of the mobile terminal and the height value of the last detected position of the mobile terminal are changed or not;
when the detected stage number corresponding to the height value of the position is changed, the counting value of the height change counter is increased by one;
when the detected stage number corresponding to the height value of the position is unchanged, adding one to the count value of the unchanged height counter;
when the count value of the height change counter is greater than or equal to a first preset threshold value, reducing the overtime of the timer by one level;
and when the count value of the height unchangeable counter is greater than or equal to a second preset threshold value, increasing the overtime of the timer by one step.
Optionally, the gravity sensor adjusting method, wherein the obtaining of the corresponding gravity sensor stage number in the correspondence table according to the height value of the current position of the mobile terminal and setting as the current gravity sensing stage number specifically includes:
according to the updated overtime time of the timer, the mobile terminal acquires the latest height value of the current position after the timer reaches the updated overtime time;
and searching the corresponding gravity sensor detection configuration in a pre-stored corresponding relation table of the gravity sensor detection configuration corresponding to each position height value according to the latest current position height value of the mobile terminal, and setting the gravity sensor detection configuration as the current gravity sensing stage number.
Optionally, the gravity sensor adjusting method, wherein a correspondence table of the gravity sensor detection configuration corresponding to each height value of the located position is stored in advance in the mobile terminal, and before the method, the method further includes:
presetting a height change counter and a height unchanged counter;
the height change counter is used for automatically adding one to the count value when the number of stages corresponding to the height value of the position is changed;
the height unchangeable counter is used for automatically adding one to the count value when the number of stages corresponding to the height value of the position is unchanged.
Optionally, in the gravity sensor adjustment method, the first preset threshold is 2, and the second preset threshold is 6.
In addition, to achieve the above object, the present invention also provides a gravity sensor adjustment system, wherein the gravity sensor adjustment system includes:
the timer setting module is used for setting the overtime time of the timer;
the timer is used for triggering the height detection module to detect the height value of the position at regular time, and the overtime time of the timer is dynamically set by the timer setting module;
the height detection module is used for detecting the height value of the position where the mobile terminal is located;
the height change counter is used for automatically adding one to the count value when the level number corresponding to the height value of the position is changed;
the height unchanged counter is used for automatically adding one to the count value when the number of stages corresponding to the height value of the position is not changed;
and the gravity sensor detection module is used for setting the number of stages of the gravity sensor of the mobile terminal according to the height value of the position acquired by the height detection module.
In addition, to achieve the above object, the present invention also provides a mobile terminal, wherein the mobile terminal includes: a memory, a processor and a gravity sensor adjustment program stored on the memory and executable on the processor, the gravity sensor adjustment program when executed by the processor implementing the steps of the gravity sensor adjustment method as described above.
Further, to achieve the above object, the present invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a gravity sensor adjustment program, which when executed by a processor, implements the steps of the gravity sensor adjustment method as described above.
The invention pre-stores the corresponding relation table of the detection configuration of the gravity sensor corresponding to the height value of each position in the mobile terminal; setting the overtime time of a timer, and acquiring the height value of the current position of the mobile terminal when the timer reaches the overtime time; and acquiring the corresponding gravity sensor stage number in the corresponding relation table according to the height value of the current position of the mobile terminal, and setting the stage number as the current gravity sensing stage number. The invention solves the problem that the detection of the vertical screen of the mold is inaccurate due to the failure of the gravity sensor when the height of the user is changed due to the detection timing of the gravity sensor in the prior art, and simultaneously can keep lower energy consumption and bring convenience to the user.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer and clearer, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The display of the mobile terminal is divided into horizontal screen display and vertical screen display, which are particularly commonly used on interfaces such as video watching, photographing and navigation, and the horizontal and vertical screen detection of the mobile terminal is carried out by the mobile terminal through a gravity sensor; the problems are not great when the above-mentioned use is carried out at a general position; however, at present, along with wide distribution of operator base stations, mobile terminals can be used at various altitudes, and the gravity values at different heights can be changed, particularly, the gravity changes more obviously on some devices such as elevators and aircrafts in high buildings, and when the change speed of the gravity values is higher than the gravity speed detected by the mobile terminals, the gravity detection of the mobile terminals is inaccurate.
In view of the above-mentioned drawbacks of the prior art, a gravity sensor adjusting method according to a preferred embodiment of the present invention, as shown in fig. 1, includes the following steps:
in step S10, a correspondence table of the detection arrangement of the gravity sensor corresponding to each of the positional height values is stored in advance in the mobile terminal.
Please refer to fig. 2, which is a flowchart of step S10 in the gravity sensor adjusting method according to the present invention.
As shown in fig. 2, the step S10 includes:
s11, setting the height value of the position of the mobile terminal as a plurality of height value grades in advance;
s12, setting the configuration of the gravity sensor of the mobile terminal into a plurality of gravity sensor levels in advance;
and S13, corresponding each height value grade of the mobile terminal to a gravity sensor grade, and generating a corresponding relation table of gravity sensor detection configuration corresponding to each height value of the position.
Wherein, the lower the height value grade, the higher the corresponding gravity sensor grade.
Specifically, for example, five levels of 1, 2, 3, 4, and 5 are provided for the gravity sensor detection configuration in the mobile terminal, and a higher level indicates a larger gravity sensor detection period; the height value of the position is also set to be 1, 2, 3, 4 and 5, and the higher the detected level number of the height value of the position is, the faster the height is changed; therefore, when the height value of the detected position is 1 st level, the gravity sensor detection is configured to be 5 th level; when the detected position height value is level 2, configuring the gravity sensor detection as level 4; when the height value of the detected position is 3 rd level, the gravity sensor detection is configured to be 3 rd level; when the height value of the detected position is level 4, configuring the gravity sensor detection as level 2; when the detected height value of the position is 5 th level, configuring the detection of the gravity sensor as 1 st level, which is equivalent to generating a corresponding relation table of the detection configuration of the gravity sensor corresponding to each height value of the position; i.e. a lower level of said height value corresponds to a higher level of the gravity sensor.
And step S20, setting the overtime time of the timer, and acquiring the height value of the current position of the mobile terminal when the timer reaches the overtime time.
Please refer to fig. 3, which is a flowchart of step S20 in the gravity sensor adjusting method according to the present invention.
As shown in fig. 3, the step S20 includes:
s21, setting the overtime time of the timer, wherein the overtime time comprises overtime time of a plurality of levels, and the overtime time is longer when the number of the levels is higher;
and S22, when the timer reaches the overtime, acquiring the height value of the current position of the mobile terminal.
Specifically, the mobile terminal sets the timeout time of the timer, for example, the timeout time of the timer is set to five levels, for example, 1, 2, 3, 4, and 5 levels of timeout time, where a higher level indicates a longer timeout time.
Further, as shown in fig. 4, acquiring a height value of a current position of the mobile terminal, and then:
s221, judging whether the height value of the current position of the mobile terminal and the height value of the last detected position of the mobile terminal are changed;
s222, when the number of stages corresponding to the detected height value of the position is changed, adding one to the count value of the height change counter;
s223, when the number of stages corresponding to the detected height value of the position is not changed, adding one to the count value of the height unchangeable counter;
s224, when the count value of the height change counter is greater than or equal to a first preset threshold (the first preset threshold is preferably 2), reducing the timeout time of the timer by one step;
and S225, when the count value of the height unchangeable counter is greater than or equal to a second preset threshold (the second preset threshold is preferably 6), increasing the timeout time of the timer by one step.
And detecting the height value of the current position of the mobile terminal after the timer is overtime.
Step S30, obtaining the corresponding gravity sensor stage number from the corresponding relationship table according to the height value of the current position of the mobile terminal, and setting the stage number as the specific process of the current gravity sensor stage number, please refer to fig. 5, which is a flowchart of step S30 in the gravity sensor adjusting method provided by the present invention.
As shown in fig. 5, the step S30 includes:
s31, according to the updated overtime time of the timer, the mobile terminal obtains the latest current position height value after the timer reaches the updated overtime time;
and S32, according to the latest current position height value of the mobile terminal, searching the corresponding gravity sensor detection configuration in a corresponding relation table of the gravity sensor detection configuration corresponding to each position height value stored in advance, and setting the gravity sensor detection configuration as the current gravity sensing stage number.
Specifically, the gravity sensor detection configuration of the mobile terminal is set according to the acquired height value of the position; for example, when the detected position height value is 1 st level, the gravity sensor detection is configured to be 5 th level; when the detected position height value is level 2, configuring the gravity sensor detection as level 4; when the height value of the detected position is 3 rd level, the gravity sensor detection is configured to be 3 rd level; when the height value of the detected position is level 4, configuring the gravity sensor detection as level 2; and when the detected position height value is the 5 th level, configuring the gravity sensor detection as the 1 st level.
Further, based on the gravity sensor adjusting method, as shown in fig. 6, the present invention further provides a gravity sensor adjusting system, wherein the gravity sensor adjusting system includes:
a timer setting module 100, configured to set a timeout time of the timer 200;
the timer 200 is used for triggering the height detection module 300 to detect the height value of the located position at regular time, and the timeout time of the timer 200 is dynamically set by the timer setting module 100;
the height detection module 300 is configured to detect a height value of a position where the mobile terminal is located;
a height change counter 600 for automatically incrementing a count value by one when the number of steps corresponding to the height value of the position is changed;
the height unchanged counter 500 is used for automatically adding one to the count value when the number of stages corresponding to the height value of the position is not changed;
the gravity sensor detecting module 400 is configured to set the number of gravity sensor stages of the mobile terminal according to the height value of the position obtained by the height detecting module 300.
The timer setting module 100 is configured to set the timeout time of the timer 200, where the timeout time of the timer 200 has five stages: 1. 2, 3, 4 and 5 levels of timeout time, wherein the higher the level number is, the longer the timeout time is; the timer setting module 100 sets the timeout time of the timer 200 according to the count values of the height change counter 500 and the height unchangeable counter 600: when the count value of the altitude change counter 500 is greater than or equal to 2, the timer setting module 100 performs degradation processing on the timeout time of the timer 200; when the count value of the height unchangeable counter 600 is greater than or equal to 6, the timer setting module 100 performs an upgrade process on the timeout time of the timer 200.
The timer 200 is used for triggering the height detection module 300 to detect the height value of the located position at regular time; the timeout time of the timer 200 is dynamically set by the timer setting module 100.
The height detection module 300 is configured to detect a height value of the located position, and when the height detection module 300 detects that the number of steps corresponding to the height value of the located position and the number of steps corresponding to the height of the located position detected by the height detection module 300 last time are changed, increment a count value of the height change counter 500 by one; when the height detection module 300 detects that the number of levels corresponding to the height value of the located position and the number of levels corresponding to the height of the located position detected by the height detection module 300 last time are not changed, the count value of the unchanged height counter 600 is increased by one.
The gravity sensor detection module 400 is configured to set a gravity sensor of the mobile terminal according to the height value of the position obtained by the height detection module 300; when the detected position height value is 1 st level, the gravity sensor detection is configured to be 5 th level; when the detected position height value is level 2, configuring the gravity sensor detection as level 4; when the height value of the detected position is 3 rd level, the gravity sensor detection is configured to be 3 rd level; when the height value of the detected position is level 4, configuring the gravity sensor detection as level 2; and when the detected position height value is the 5 th level, configuring the gravity sensor detection as the 1 st level.
Wherein, the height change counter 500 is used to detect whether there is a change from the last acquired height value of the located position each time the height detection module 300 acquires the height value of the located position, and if so, the height change counter 500 is incremented by 1.
Wherein, the height unchangeable counter 600 is used for detecting whether there is a change from the last acquired height value of the located position each time the height detection module 300 acquires the height value of the located position, if not, the height unchangeable counter 600 adds 1.
Further, the principle of implementing the mobile terminal gravity sensor detection and adjustment method based on the gravity sensor adjustment system is as follows:
step S1, starting the timer 200, where the timeout TIME is set to level 3 by the timer setting module 100, and a variable TIME is set to 3;
step S2, determining whether the timer 200 is overtime, if yes, performing step S3, otherwise, performing step S2;
step S3, the height detection module 300 detects the height value of the located position and assigns the height value to TIME1, and the gravity sensor detection module 400 sets a corresponding gravity sensor for detection according to the height TIME 1; then, whether the TIME1 is equal to the TIME is judged, if so, the step S4 is executed, and if not, the step S7 is executed;
step S4, adding 1 to the height unchangeable counter 600, and clearing the height changeable counter 500; then step S5 is executed;
step S5, determining whether the height invariant counter 600 is greater than or equal to 6, if so, executing step S6, otherwise, executing step S2;
step S6, the timer setting module 100 increases the timeout period of the timer 200 by one step, and clears both the height change counter 500 and the height unchanged counter 600; then, step S100 is executed;
step S7, adding 1 to the height change counter 500, and clearing the height change counter 600; then step S8 is executed;
step S8, determining whether the height change counter 500 is greater than or equal to 2, if so, executing step S9, otherwise, executing step S2;
step S9, the timer setting module 100 decreases the timeout period of the timer 200 by one step, and clears both the height change counter 500 and the height unchanged counter 600; then, step S100 is executed;
in step S100, the value of TIME1 is assigned to TIME, and then step S2 is executed.
Further, as shown in fig. 7, based on the gravity sensor adjusting method and system, the present invention also provides a mobile terminal, which includes a processor 10, a memory 20, and a display 30. Fig. 7 shows only some of the components of the mobile terminal, but it is to be understood that not all of the shown components are required to be implemented, and that more or fewer components may be implemented instead.
The memory 20 may in some embodiments be an internal storage unit of the mobile terminal, such as a hard disk or a memory of the mobile terminal. The memory 20 may also be an external storage device of the mobile terminal in other embodiments, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the mobile terminal. Further, the memory 20 may also include both an internal storage unit and an external storage device of the mobile terminal. The memory 20 is used for storing application software installed in the mobile terminal and various data, such as program codes of the installed mobile terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, the memory 20 stores a gravity sensor adjustment program 40, and the gravity sensor adjustment program 40 can be executed by the processor 10 to implement the gravity sensor adjustment method of the present application.
The processor 10 may be a Central Processing Unit (CPU), microprocessor or other data Processing chip in some embodiments, and is used for running program codes stored in the memory 20 or Processing data, such as executing the gravity sensor adjusting method.
The display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch panel, or the like in some embodiments. The display 30 is used for displaying information at the mobile terminal and for displaying a visual user interface. The components 10-30 of the mobile terminal communicate with each other via a system bus.
In one embodiment, the following steps are implemented when the processor 10 executes the gravity sensor adjustment program 40 in the memory 20:
a corresponding relation table of detection configuration of the gravity sensor corresponding to the height value of each position is stored in the mobile terminal in advance;
setting the overtime time of a timer, and acquiring the height value of the current position of the mobile terminal when the timer reaches the overtime time;
and acquiring the corresponding gravity sensor stage number in the corresponding relation table according to the height value of the current position of the mobile terminal, and setting the stage number as the current gravity sensing stage number.
The method includes that a corresponding relation table of detection configuration of the gravity sensor corresponding to the height value of each located position is stored in the mobile terminal in advance, and specifically includes:
setting the height value of the position of the mobile terminal as a plurality of height value grades in advance;
setting the configuration of a gravity sensor of the mobile terminal to a plurality of gravity sensor levels in advance;
corresponding each height value grade of the mobile terminal to a gravity sensor grade, and generating a corresponding relation table of detection configuration of the gravity sensor corresponding to the height value of each position;
wherein, the lower the height value grade, the higher the corresponding gravity sensor grade.
The setting of the timeout time of the timer, and obtaining the height value of the current position of the mobile terminal when the timer reaches the timeout time specifically include:
setting the overtime time of a timer, wherein the overtime time comprises overtime time of a plurality of levels, and the overtime time is longer when the level is higher;
and when the timer reaches the overtime, acquiring the height value of the current position of the mobile terminal.
The obtaining of the height value of the current position of the mobile terminal then further includes:
judging whether the height value of the current position of the mobile terminal and the height value of the last detected position of the mobile terminal are changed or not;
when the detected stage number corresponding to the height value of the position is changed, the counting value of the height change counter is increased by one;
when the detected stage number corresponding to the height value of the position is unchanged, adding one to the count value of the unchanged height counter;
when the count value of the height change counter is greater than or equal to a first preset threshold value, reducing the overtime of the timer by one level;
and when the count value of the height unchangeable counter is greater than or equal to a second preset threshold value, increasing the overtime of the timer by one step.
The acquiring, according to the height value of the current position of the mobile terminal, the corresponding gravity sensor stage number in the correspondence table, and setting the stage number as the current gravity sensor stage number specifically includes:
according to the updated overtime time of the timer, the mobile terminal acquires the latest height value of the current position after the timer reaches the updated overtime time;
and searching the corresponding gravity sensor detection configuration in a pre-stored corresponding relation table of the gravity sensor detection configuration corresponding to each position height value according to the latest current position height value of the mobile terminal, and setting the gravity sensor detection configuration as the current gravity sensing stage number.
The mobile terminal is pre-stored with a corresponding relationship table of the gravity sensor detection configuration corresponding to each of the height values of the located positions, and the method further includes:
presetting a height change counter and a height unchanged counter;
the height change counter is used for automatically adding one to the count value when the number of stages corresponding to the height value of the position is changed;
the height unchangeable counter is used for automatically adding one to the count value when the number of stages corresponding to the height value of the position is unchanged.
The first preset threshold is 2, and the second preset threshold is 6.
The present invention also provides a computer readable storage medium, wherein the computer readable storage medium stores a gravity sensor adjustment program, which when executed by a processor implements the steps of the gravity sensor adjustment method as described above.
In summary, the present invention provides a gravity sensor adjusting method, a mobile terminal and a computer-readable storage medium, where the method includes: a corresponding relation table of detection configuration of the gravity sensor corresponding to the height value of each position is stored in the mobile terminal in advance; setting the overtime time of a timer, and acquiring the height value of the current position of the mobile terminal when the timer reaches the overtime time; and acquiring the corresponding gravity sensor stage number in the corresponding relation table according to the height value of the current position of the mobile terminal, and setting the stage number as the current gravity sensing stage number. The invention solves the problem that the detection of the vertical screen of the mold is inaccurate due to the failure of the gravity sensor when the height of the user is changed due to the detection timing of the gravity sensor in the prior art, and simultaneously can keep lower energy consumption and bring convenience to the user.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Of course, it will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by instructing relevant hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer readable storage medium, and when executed, the program can include the processes of the embodiments of the methods described above. The computer readable storage medium may be a memory, a magnetic disk, an optical disk, etc.
It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.