Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a power consumption control method and device, a storage medium and electronic equipment.
A power consumption control method is applied to electronic equipment and comprises the following steps: acquiring a power consumption detection instruction; starting a timer to time according to the power consumption detection instruction; in the timing process, acquiring the current value of the electronic equipment at each sampling moment; determining a target power saving strategy according to the current value and the timing duration; and executing the target power saving strategy to control the power consumption of the electronic equipment.
As shown in fig. 1, fig. 1 is a schematic flow chart of a power consumption control method provided in the embodiment of the present application, and a specific flow may be as follows:
101. and acquiring a power consumption detection instruction.
In this embodiment, the power consumption detection instruction may be automatically generated, for example, when the electronic device is turned on, or a screen is turned on for the first time, or the electric quantity is lower than a certain value, the power consumption detection instruction is automatically triggered and generated, or may be manually triggered and generated by a user, for example, the user may manually click a certain key to generate the power consumption detection instruction when the operating speed of the electronic device is slow.
102. And starting a timer for timing according to the power consumption detection instruction.
103. And in the timing process, acquiring the current value of the electronic equipment at each sampling moment.
In this embodiment, the sampling time is mainly determined according to a sampling frequency, and the sampling frequency may be set manually once in 2s, once per second, and the like, for example, when the sampling frequency is set once in 2s, the sampling time may be a 2s timing time, a 4s timing time, a 6s timing time, and the like. The current value mainly refers to output current, the power consumption of a battery of the electronic equipment can be accurately measured, and generally, the brightness of a screen, running application and the like can affect the magnitude of the output current.
104. And determining a target power saving strategy according to the current value and the timing duration.
For example, the step 104 may specifically include:
1-1, determining the sampling duration range to which the current timing duration belongs.
In this embodiment, the sampling duration range may be set manually, and may have the same time starting point, such as 0-1 min, 0-5 min, 0-10 min, and the like, or may have different time starting points, such as 0-1 min, 1-5 min, 5-10 min, and the like, and the specific setting form may be determined according to actual requirements.
And 1-2, acquiring a preset power consumption value corresponding to the sampling duration range.
In this embodiment, the preset power consumption value may be set in advance according to characteristics of the electronic device (e.g., the number of cores of the CPU and the size of the display screen), such as 1000mA/h, 600mA/h or 300mA/h, and the preset power consumption values of different electronic devices may be different, such as the larger the number of cores of the CPU of the electronic device is, or the larger the size of the display screen is, the larger the preset power consumption value thereof may be. It should be noted that the preset power consumption value and the sampling duration range should be stored in the electronic device in advance in a one-to-one correspondence manner.
1-3, judging whether power saving operation is needed or not according to the current value and a preset power consumption value;
if so, acquiring a preset power saving strategy corresponding to the sampling duration range as a target power saving strategy;
if not, returning to execute the operation of determining the sampling duration range to which the current timing duration belongs, and stopping until the current timing duration reaches a preset threshold value.
In this embodiment, the preset power saving policy may relate to multiple aspects, such as brightness adjustment of a display screen, background application cleaning, and the like, a user may set a preset power saving policy of a required level in the electronic device in advance, the preset power saving policies of different levels may correspond to different sampling duration ranges, so as to achieve different power saving strengths, the number of specific levels may be determined according to characteristics of the electronic device itself (such as the number of cores of a CPU and the size of the display screen), for example, the electronic device a may divide three levels, and the electronic device B may divide four levels. Generally, the power saving operation is performed only when it is determined that the preset power saving policy of the current level needs to be executed, and if it is determined that the preset power saving policy of the current level does not need to be executed, it is continuously detected whether the preset power saving policy of the next level needs to be executed until it is determined that all the preset power saving policies do not need to be executed.
The determining result mainly depends on whether the actual power consumption value of the electronic device exceeds the preset power consumption value, that is, the step of determining whether the power saving operation is required according to the current value and the preset power consumption value may specifically include:
calculating the product of the current value and the corresponding sampling moment;
determining an actual power consumption value according to the product and the current timing duration;
and when the actual power consumption value is not less than the preset power consumption value, judging that power-saving operation is required.
In this embodiment, the actual power consumption may be calculated by a current value, the average power consumption value may be calculated according to the actual power consumption, and the average power consumption value is compared with the preset power consumption value as the actual power consumption value, that is, the step of "determining the actual power consumption value according to the product and the current timing duration" may further include:
accumulating the product to obtain an accumulated value;
and calculating the ratio of the accumulated value to the current timing duration, and taking the ratio as an actual power consumption value.
In this embodiment, the product of each current value and the corresponding sampling time may be accumulated to be used as the power consumption in the period of time duration, and then the product is divided by the whole time duration to obtain an average power consumption value, which is used as the actual power consumption value.
105. And executing the target power saving strategy to control the power consumption of the electronic equipment.
For example, the step 105 may specifically include:
counting the running number of the background applications;
judging whether the running number exceeds a preset number or not;
if so, calculating a difference value between the running number and a preset number, and acquiring the background running time length and/or a preset priority of the background application;
and selecting the target application with the difference quantity from the background applications according to the background running time length and/or the preset priority to close.
In this embodiment, the preset number may be 5 or 6, and the preset numbers corresponding to the preset power saving policies of different levels may be different. When the number of the background running applications is larger than the preset number corresponding to the current level, the background applications exceeding the number need to be selected for closing so as to reduce the power consumption of the electronic equipment. The specific selection mode may be selected according to actual requirements, for example, according to factors such as a background application running time length, a preset priority level, and/or a CPU occupancy rate, and generally, a longer background running time length represents a longer idle time, a lower priority level represents a lower importance, a higher CPU occupancy rate represents a greater influence on power consumption, and the applications may be preferentially closed.
Of course, the target power saving policy may also relate to the aspects of adjusting the brightness of the display screen, updating the application version, and the like, such as reducing the brightness of the display screen to a certain value, updating the background application that consumes more power to the latest version, and the like. And when the target power saving strategy is executed, the electronic equipment can also generate a current oscillogram according to the current value and the sampling moment, so that when a user wants to check the power consumption details, the power consumption details can be directly displayed to the user, the user can intuitively feel the change of the system power consumption, and the user experience effect is enhanced.
As can be seen from the above, the power consumption control method provided in this embodiment is applied to an electronic device, and is implemented by obtaining a power consumption detection instruction, starting a timer according to the power consumption detection instruction, obtaining a current value of the electronic device at each sampling time in the timing process, determining a target power saving policy according to the current value and a timing duration, and then executing the target power saving policy to control the power consumption of the electronic device, so that different power saving schemes can be started according to the power consumption condition of the electronic device in real time, and the power consumption control method effectively reduces the power consumption of the electronic device.
In the present embodiment, a description will be made from the viewpoint of the power consumption control device, and in particular, a detailed description will be given taking an example in which the power consumption control device is integrated in an electronic apparatus.
Referring to fig. 2 and fig. 3, a power consumption control method applied to an electronic device may include the following specific processes:
201. the electronic device obtains a power consumption detection instruction.
For example, when the electronic device is turned on, or the screen is turned on for the first time, or the power consumption is lower than a certain value, the power consumption detection command is automatically triggered and generated.
202. And the electronic equipment starts a timer to time according to the power consumption detection instruction.
203. In the timing process, the electronic device obtains a current value at each sampling instant.
For example, when the sampling frequency is artificially set once per second, each timing time is a sampling time, such as 1 st s, 2 nd s, etc., and the current value mainly refers to the output current.
204. The electronic equipment determines a sampling duration range to which the current timing duration belongs, and acquires a preset power consumption value corresponding to the sampling duration range.
For example, a user may set a plurality of power saving levels in advance according to characteristics of the electronic device, such as the number of cores of a CPU, the size of a display screen, and the like, for example, n power saving levels S1 is divided into 1, S2 is divided into 3, S3 is divided into 3.. Sn is divided into n, each power saving level sets a sampling duration range, such as 0 to T1, 0 to T2, and 0 to T3.. 0 to Tn, each sampling duration range sets a preset power consumption value, such as W1, W2, and W3... Wn, and specific mapping relationships may be referred to in table 1 below.
Class of power saving
|
S1
|
S2
|
S3
|
.......
|
Sn
|
Preset power consumption value corresponding to power saving grade
|
W1
|
W2
|
W3
|
.......
|
Wn
|
Sampling duration range corresponding to power saving level
|
0~T1
|
0~T2
|
0~T3
|
.......
|
0~Tn
|
Actual power consumption value of power saving class pair
|
w1
|
w2
|
w3
|
.......
|
wn |
TABLE 1
205. The electronic equipment calculates the product of the current value and the corresponding sampling moment, and accumulates the product to obtain an accumulated value.
206. The electronic device calculates a ratio of the accumulated value to the current timing duration, and uses the ratio as an actual power consumption value, and then determines whether the actual power consumption value is not less than a preset power consumption value, if so, the following step 207 is executed, and if not, the following step 208 is executed.
For example, the product of each current value and the corresponding sampling time may be accumulated to obtain the power consumption amount in the time period, and then divided by the whole time period to obtain the average power consumption value, which is used as the actual power consumption value, for example, the actual power consumption value in the sampling time period range from 0 to Ti may be Wi, and the magnitudes of Wi and Wi need to be compared at this time.
207. The electronic equipment acquires a preset power saving strategy corresponding to the sampling duration range, and the preset power saving strategy is used as a target power saving strategy, and the target power saving strategy is executed so as to control the power consumption of the electronic equipment.
For example, referring to fig. 4, the step 207 may further include:
2071. the electronic equipment counts the running number of background applications;
2072. the electronic equipment judges whether the running number exceeds a preset number or not;
2073. if so, the electronic equipment calculates the difference between the running number and the preset number, and acquires the background running time length and/or the preset priority of the background application;
and selecting the target application with the difference quantity from the background applications according to the background running time length and/or the preset priority to close.
For example, the predetermined number may be 5 which is set manually. If Wi is larger than or equal to Wi, it is indicated that the current actual power consumption exceeds the ideal range, power saving operation needs to be performed, at this time, whether the total number of background applications exceeds a preset number or not can be detected, and if the total number exceeds the preset number, the background running time is too long, or the background applications with lower preset priority are closed, so that the number of the background applications is controlled within the preset number.
208. The electronic device determines whether the current timing duration reaches a preset threshold, if so, the timing is cleared, and the step 202 is returned to be executed, and if not, the step 204 is returned to be executed.
For example, when Wi < Wi, it indicates that the current actual power consumption is within the ideal range, the power saving operation of the current power saving level is not needed, but it needs to continuously determine whether the power saving operation of the next level needs to be performed, that is, it needs to return to the operation of determining the sampling duration range again according to the timing duration t until the current timing duration t reaches Tn.
As can be seen from the above, the power consumption control method provided in this embodiment is applied to an electronic device, where the electronic device can obtain a power consumption detection instruction, start a timer to time according to the power consumption detection instruction, then obtain a current value at each sampling time in the timing process, determine a sampling time range to which a current timing time belongs, then obtain a preset power consumption value corresponding to the sampling time range, calculate a product of the current value and the corresponding sampling time, then accumulate the product to obtain an accumulated value, then calculate a ratio of the accumulated value to the current timing time, and use the ratio as an actual power consumption value, then determine whether the actual power consumption value is not less than the preset power consumption value, if so, obtain a preset power saving policy corresponding to the sampling time range, as a target power saving policy, and execute the target power saving policy, the power consumption of the electronic equipment is controlled, so that different power saving schemes can be started in real time according to the power consumption condition of the electronic equipment, the power consumption of the electronic equipment is effectively reduced, and the method is simple, high in flexibility and good in power saving effect.
According to the method described in the foregoing embodiment, the embodiment will be further described from the perspective of a power consumption control device, which may be specifically implemented as a stand-alone entity, or may be implemented by being integrated in an electronic device, such as a terminal, where the terminal may include a mobile phone, a tablet computer, a personal computer, and the like.
Referring to fig. 5, fig. 5 specifically describes a power consumption control apparatus provided in an embodiment of the present application, which is applied to an electronic device, and the power consumption control apparatus may include: a first obtaining module 10, a starting module 20, a second obtaining module 30, a determining module 40 and an executing module 50, wherein:
(1) first acquisition module 10
The first obtaining module 10 is configured to obtain a power consumption detection instruction.
In this embodiment, the power consumption detection instruction may be automatically generated, for example, when the electronic device is turned on, or a screen is turned on for the first time, or the electric quantity is lower than a certain value, the power consumption detection instruction is automatically triggered to be generated, or may be manually triggered to be generated by a user, for example, the user may click a certain key to generate the power consumption detection instruction when the operating speed of the electronic device is relatively low.
(2) Start module 20
And a starting module 20, configured to start a timer to time according to the power consumption detection instruction.
(3) Second acquisition module 30
And the second obtaining module 30 is configured to obtain a current value of the electronic device at each sampling time in the timing process.
In this embodiment, the sampling time is mainly determined according to a sampling frequency, and the sampling frequency may be set manually once in 2s, once per second, and the like, for example, when the sampling frequency is set once in 2s, the sampling time may be a 2s timing time, a 4s timing time, a 6s timing time, and the like. The current value mainly refers to output current, the power consumption of a battery of the electronic equipment can be accurately measured, and generally, the brightness of a screen, running application and the like can affect the magnitude of the output current.
(4) Determination module 40
And the determining module 40 is used for determining a target power saving strategy according to the current value and the timing duration.
For example, referring to fig. 6, the determining module 40 may specifically include a determining sub-module 41, an obtaining sub-module 42, and a determining sub-module 43, where:
and the determining submodule 41 is used for determining the sampling duration range to which the current timing duration belongs.
In this embodiment, the sampling duration range may be set manually, and may have the same time starting point, such as 0-1 min, 0-5 min, 0-10 min, and the like, or may have different time starting points, such as 0-1 min, 1-5 min, 5-10 min, and the like, and the specific setting form may be determined according to actual requirements.
And the obtaining submodule 42 is configured to obtain a preset power consumption value corresponding to the sampling duration range.
In this embodiment, the preset power consumption value may be set in advance according to characteristics of the electronic device (e.g., the number of cores of the CPU and the size of the display screen), such as 1000mA/h, 600mA/h or 300mA/h, and the preset power consumption values of different electronic devices may be different, such as the larger the number of cores of the CPU of the electronic device is, or the larger the size of the display screen is, the larger the preset power consumption value thereof may be. It should be noted that the preset power consumption value and the sampling duration range should be stored in the electronic device in advance in a one-to-one correspondence manner.
A judging submodule 43, configured to judge whether a power saving operation is required according to the current value and a preset power consumption value;
if so, acquiring a preset power saving strategy corresponding to the sampling duration range as a target power saving strategy;
if not, returning to execute the operation of determining the sampling duration range to which the current timing duration belongs, and stopping until the current timing duration reaches a preset threshold value.
In this embodiment, the preset power saving policy may relate to multiple aspects, such as brightness adjustment of a display screen, background application cleaning, and the like, a user may set a preset power saving policy of a required level in the electronic device in advance, the preset power saving policies of different levels may correspond to different sampling duration ranges, so as to achieve different power saving strengths, the number of specific levels may be determined according to characteristics of the electronic device itself (such as the number of cores of a CPU and the size of the display screen), for example, the electronic device a may divide three levels, and the electronic device B may divide four levels. Generally, the power saving operation is performed only when it is determined that the preset power saving policy of the current level needs to be executed, and if it is determined that the preset power saving policy of the current level does not need to be executed, it is continuously detected whether the preset power saving policy of the next level needs to be executed until it is determined that all the preset power saving policies do not need to be executed.
Wherein, the determination result mainly depends on whether the actual power consumption value of the electronic device exceeds the preset power consumption value, that is, the determining submodule 43 is further configured to:
calculating the product of the current value and the corresponding sampling moment;
determining an actual power consumption value according to the product and the current timing duration;
and when the actual power consumption value is not less than the preset power consumption value, judging that power-saving operation is required.
In this embodiment, the actual power consumption may be calculated by the current value, the average power consumption value may be calculated according to the actual power consumption, and the average power consumption value is compared with the preset power consumption value as the actual power consumption value, that is, the determining submodule 43 may be further configured to:
accumulating the product to obtain an accumulated value;
and calculating the ratio of the accumulated value to the current timing duration, and taking the ratio as an actual power consumption value.
In this embodiment, the determining submodule 43 may accumulate the product of each current value and the corresponding sampling time to obtain the power consumption in the period of time duration, then divide the power consumption by the whole time duration to obtain an average power consumption value, and use the average power consumption value as the actual power consumption value.
(5) Execution module 50
And an executing module 50, configured to execute the target power saving policy to control power consumption of the electronic device.
For example, the execution module 50 may specifically be configured to:
counting the running number of the background applications;
judging whether the running number exceeds a preset number or not;
if so, calculating a difference value between the running number and a preset number, and acquiring the background running time length and/or a preset priority of the background application;
and selecting the target application with the difference quantity from the background applications according to the background running time length and/or the preset priority to close.
In this embodiment, the preset number may be 5 or 6, and the preset numbers corresponding to the preset power saving policies of different levels may be different. When the number of the background running applications is greater than the preset number corresponding to the current level, the execution module 50 needs to select an excess portion of the background applications to close, so as to reduce the power consumption of the electronic device. The specific selection mode may be selected according to actual requirements, for example, according to factors such as a background application running time length, a preset priority level, and/or a CPU occupancy rate, and generally, a longer background running time length represents a longer idle time, a lower priority level represents a lower importance, a higher CPU occupancy rate represents a greater influence on power consumption, and the applications may be preferentially closed.
Of course, the target power saving policy may also relate to the adjustment of the brightness of the display screen, the update of the application version, and so on, for example, the execution module 50 reduces the brightness of the display screen to a certain value, updates the background application that consumes more power to the latest version, and so on. In addition, while executing the target power saving policy, the execution module 50 may also generate a current waveform according to the current value and the sampling time, so that when a user wants to check the power consumption details, the current waveform can be directly displayed to the user, so that the user can intuitively feel the change of the system power consumption, and the user experience effect is enhanced.
In a specific implementation, the above units may be implemented as independent entities, or may be combined arbitrarily to be implemented as the same or several entities, and the specific implementation of the above units may refer to the foregoing method embodiments, which are not described herein again.
As can be seen from the above, the power consumption control method provided in this embodiment is applied to an electronic device, a power consumption detection instruction is obtained by the first obtaining module 10, the starting module 20 starts a timer to time according to the power consumption detection instruction, during the time counting, the second obtaining module 30 obtains a current value of the electronic device at each sampling time, the determining module 40 determines a target power saving policy according to the current value and a time duration, and then the executing module 50 executes the target power saving policy to control the power consumption of the electronic device, so that different power saving schemes can be started according to the power consumption condition of the electronic device in real time, and the power consumption of the electronic device is effectively reduced.
In addition, the embodiment of the application also provides electronic equipment which can be equipment such as a smart phone and a tablet computer. As shown in fig. 7, the electronic device 900 includes a processor 901, a memory 902, a display 903, and a control circuit 904. The processor 901 is electrically connected to the memory 902, the display 903, and the control circuit 904.
The processor 901 is a control center of the electronic device 900, connects various parts of the whole electronic device by using various interfaces and lines, executes various functions of the electronic device and processes data by running or loading an application program stored in the memory 902 and calling the data stored in the memory 902, thereby performing overall monitoring of the electronic device.
In this embodiment, the processor 901 in the electronic device 900 loads instructions corresponding to processes of one or more application programs into the memory 902 according to the following steps, and the processor 901 runs the application programs stored in the memory 902, so as to implement various functions:
acquiring a power consumption detection instruction;
starting a timer to time according to the power consumption detection instruction;
in the timing process, acquiring the current value of the electronic equipment at each sampling moment;
determining a target power saving strategy according to the current value and the timing duration;
and executing the target power saving strategy to control the power consumption of the electronic equipment.
Memory 902 may be used to store applications and data. The memory 902 stores applications containing instructions executable in the processor. The application programs may constitute various functional modules. The processor 901 executes various functional applications and data processing by running an application program stored in the memory 902.
The display 903 may be used to display information input by or provided to the user as well as various graphical user interfaces of the terminal, which may be comprised of images, text, icons, video, and any combination thereof.
The control circuit 904 is electrically connected to the display 903, and is configured to control the display 903 to display information.
In some embodiments, as shown in fig. 7, electronic device 900 further comprises: a radio frequency circuit 905, an input unit 906, an audio circuit 907, a sensor 908, and a power supply 909. The processor 901 is electrically connected to the rf circuit 905, the input unit 906, the audio circuit 907, the sensor 908, and the power source 909.
The radio frequency circuit 905 is configured to receive and transmit radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and receive and transmit signals with the network device or other electronic devices.
The input unit 906 may be used to receive input numbers, character information, or user characteristic information (e.g., a fingerprint), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control. The input unit 906 may include a fingerprint recognition module.
The audio circuit 907 may provide an audio interface between the user and the terminal through a speaker, microphone, or the like.
The electronic device 900 may also include at least one sensor 908, such as light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel according to the brightness of ambient light, and a proximity sensor that may turn off the display panel and/or the backlight when the terminal is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured in the terminal, detailed description is omitted here.
The power supply 909 is used to supply power to the various components of the electronic device 900. In some embodiments, the power source 909 may be logically connected to the processor 901 through a power management system, so that functions of managing charging, discharging, and power consumption management are realized through the power management system.
Although not shown in fig. 7, the electronic device 900 may further include a camera, a bluetooth module, etc., which are not described in detail herein.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions or by associated hardware controlled by the instructions, which may be stored in a computer readable storage medium and loaded and executed by a processor. To this end, embodiments of the present invention provide a storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute steps in any one of the power consumption control methods provided by the embodiments of the present invention.
Wherein the storage medium may include: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium may execute the steps in any power consumption control method provided in the embodiments of the present invention, beneficial effects that can be achieved by any power consumption control method provided in the embodiments of the present invention may be achieved, which are detailed in the foregoing embodiments and will not be described herein again.
The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
In summary, although the present application has been described with reference to the preferred embodiments, the above-described preferred embodiments are not intended to limit the present application, and those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present application, so that the scope of the present application shall be determined by the appended claims.