The invention discloses a method for detecting and displaying the electric quantity of an earphone, which relates to the technical field of
electronic equipment and comprises the following steps of: acquiring an
analog signal of
battery voltage through an ADC (analog-to-
digital converter) channel, converting the
analog signal into a
digital signal, performing digital filtering
processing on the acquired
signal, matching a preset
voltage-electric quantity mapping table according to an updated
battery voltage value, and displaying the electric quantity of the earphone according to the preset
voltage-electric quantity mapping table. According to the method for detecting and displaying the electric quantity of the earphone, the
voltage of a
lithium battery of 0-4.2 V is detected through an ADC differential input mode, the sampling frequency is 100-500 Hz, the precision is 10-12 bits, and
signal stability is ensured through low-pass filtering. A sliding window mean filtering
algorithm is adopted to process signals, fluctuation and
noise are effectively eliminated, and voltage changes are dynamically tracked. A deviation comparison mechanism avoids misjudgment and ensures accurate electric quantity detection. The electric quantity mapping table is dynamically adjusted according to the voltage, the battery use duration and the environment temperature, the earphone electric quantity state is accurately reflected, the user experience is improved, and the electric quantity detection stability and accuracy are improved.