A method and system for adaptive ambient light sensing based on polling LRADC
By using polling LRADC and piecewise linear interpolation nonlinear compensation, the reporting blind zone and nonlinear mapping problems of LRADC in ambient light detection are solved, realizing low-cost, high-linearity adaptive ambient light sensing and improving the user experience of automatic brightness adjustment.
Patent Information
- Application Number
- CN202611283112.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-24
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2046-08-24
AI Technical Summary
Existing LRADCs suffer from problems in ambient light detection, such as reporting blind spots caused by interruption thresholds, brightness jumps caused by discrete reporting, and distortion due to nonlinear mapping of photoresistors, leading to increased hardware costs.
Hardware interrupts are disabled by polling the LRADC. Combined with timer polling and piecewise linear interpolation nonlinear compensation, data is uploaded through the Linux standardized sensor reporting interface, and nonlinear correction of light sensing data is performed to achieve ambient light adaptive sensing.
It eliminates the reporting blind spot caused by the interrupt threshold, realizes smooth continuity and non-linear correction of illumination response, reduces hardware costs, and improves the user experience of automatic brightness adjustment.
Smart Images

Figure CN122821896B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of embedded systems and terminal display control technology, specifically involving a software improvement scheme for ambient light detection using a low-resolution analog-to-digital converter (LRADC) in conjunction with a photoresistor. In particular, for smart terminals with screens, by changing the LRADC acquisition mode from interrupt-driven to timer polling, and coordinating with nonlinear compensation of the system framework layer, low-cost, high-linearity adaptive ambient light sensing is achieved. Background Technology
[0002] In embedded system design, low-resolution analog-to-digital converters (LRADCs) are commonly used to convert analog voltage signals into digital values. These modules have low power consumption and low resource consumption, making them widely used in low-speed signal acquisition scenarios such as key scanning and battery voltage monitoring. LRADCs themselves do not rely on a high-precision reference source, have extremely low hardware overhead, and are suitable for integration as general-purpose peripherals into various SoCs.
[0003] In some embedded platforms, LRADCs typically operate via hardware interrupts. The basic process is as follows: when the input voltage crosses a preset threshold, the LRADC triggers an interrupt. The interrupt service routine reads and decodes the converted value, and then reports the value to user space as a key press event via the Linux INPUT subsystem. This design is naturally suited for acquiring discrete events such as key presses.
[0004] The interrupt triggering mode of the aforementioned LRADC is configured for button detection. When terminal manufacturers attempt to reuse this solution to implement a simple light sensor—by connecting a photoresistor and a fixed resistor to the input of the LRADC to form a voltage divider circuit, and reflecting changes in ambient light through the fluctuation of the voltage divider—this interrupt mode exposes three independent but superimposed problems.
[0005] One issue is the reporting blind zone caused by the interrupt threshold. In interrupt mode, the LRADC must detect that the input voltage crosses a preset threshold to trigger a report. The change in the resistance of the photoresistor caused by changes in illumination is continuous and gradual. When the change is small, the fluctuation of the voltage divider is insufficient to reach the threshold, and the system cannot detect the change at all, resulting in a dead zone in brightness adjustment.
[0006] Secondly, there's the brightness jump caused by discrete reporting. Button detection is a discrete event, naturally suited to interrupt methods, resulting in a rapid response. However, ambient light signals are continuously changing analog quantities. Using discrete interrupt events to represent a continuous physical quantity inherently results in information loss, inevitably leading to jumps or stutters in upper-level brightness adjustment.
[0007] Thirdly, the nonlinearity of the photoresistor leads to mapping distortion. The relationship between the photoresistor resistance and the light intensity is a power function, not a nonlinear one. Existing solutions do not perform any correction and directly map the raw ADC value to the brightness value, causing the adjustment curve to deviate from the actual light intensity. As a result, the brightness change perceived by the user is inconsistent with the actual ambient light change.
[0008] The above problems have not been effectively solved in the existing technology, and can usually only be avoided by replacing the dedicated photosensitive IC, which significantly increases the hardware cost. Summary of the Invention
[0009] To address the problems of reporting dead zone, response jump, and nonlinear distortion of photoresistors caused by interrupt mechanisms when existing LRADCs are multiplexed for photosensing, this invention provides an ambient light adaptive sensing method and system based on polling LRADCs. The aim is to enable low-cost photoresistors to achieve sensing effects close to those of dedicated photosensing ICs through acquisition method reconstruction and software nonlinear compensation, while keeping the hardware unchanged and the cost unaffected.
[0010] To achieve the above objectives, the present invention adopts the following technical solution:
[0011] An ambient light adaptive sensing method based on polling LRADC is proposed for automatic adjustment of screen backlight in smart terminals with screens. The terminal uses a photoresistor instead of a dedicated ambient light sensing IC.
[0012] Hardware acquisition configuration: The embedded platform's LRADC input pin is connected to a voltage divider circuit consisting of a photoresistor and a fixed resistor. The power supply voltage is fed into the LRADC after being divided by the photoresistor and the fixed resistor. As the ambient light changes, the resistance of the photoresistor changes, and the voltage at the voltage divider node changes accordingly. The LRADC completes the analog-to-digital conversion to obtain the original digital signal.
[0013] Driver-level polling configuration: In the LRADC driver, the original hardware interrupt triggering mechanism of the LRADC is disabled—specifically, all interrupt registration code is masked to prevent hardware interrupts from triggering. Simultaneously, a kernel timer is created with a polling period set. After the timer expires, a callback function actively reads the LRADC data register. This allows for continuous acquisition of real-time LRADC conversion values without any threshold conditions, fundamentally eliminating the reporting blind spot caused by interrupt thresholds. The polling period is configurable; actual testing has verified that 4 seconds is the optimal value balancing system load and response speed.
[0014] Data reporting interface configuration: The read LRADC conversion values are uploaded to the system framework layer via the Linux standardized sensor reporting interface—including the device file interface of the IIO subsystem or the sensor event interface of Sensor HAL. Both interfaces support multi-platform reuse without requiring modification of the upper-layer logic.
[0015] Nonlinear compensation configuration for light-sensing data: The system framework layer corrects the original ADC value based on a pre-calibrated nonlinear mapping relationship of the photoresistor. The calibration method is as follows: Multiple calibration points are selected within the target illumination range, and the ADC value corresponding to each calibration point is measured. A piecewise linear interpolation mapping curve is established with illuminance as the horizontal axis and ADC value as the vertical axis. This curve is used to convert any original ADC value into linearized ambient illuminance data.
[0016] The method for constructing piecewise linear interpolation mapping curves is as follows:
[0017] (a) Calibration point selection: Select at least 7 calibration points within the target illumination range (e.g., 0~10000 Lux). The calibration points should be evenly distributed on a logarithmic coordinate system, for example, 0 Lux (complete darkness), 1 Lux, 10 Lux, 100 Lux, 1000 Lux, 5000 Lux, and 10000 Lux. The more calibration points there are, the higher the interpolation accuracy, but the workload also increases accordingly. Experiments have shown that 7~11 calibration points can achieve a good balance between accuracy and workload.
[0018] (b) Calibration data recording: At each calibration point, the actual illuminance value Lux_i is measured using a standard lux meter, and the original digital value ADC_i output by the LRADC is recorded to form a calibration data pair (Lux_i, ADC_i).
[0019] (c) Piecewise linear interpolation formula: For any input LRADC raw value ADC_x, first determine its calibration interval [ADC_i, ADC_{i+1}], and then calculate the corresponding illuminance value Lux_x according to the following formula:
[0020] Lux_x=Lux_i+(Lux_{i+1}-Lux_i)×(ADC_x-ADC_i) / (ADC_{i+1}-ADC_i)
[0021] (d) Boundary handling: When ADC_x is less than the minimum calibration point ADC_0, linear extrapolation or Lux_0 is used directly; when ADC_x is greater than the maximum calibration point ADC_n, linear extrapolation or Lux_n is used directly. Preferably, a truncation method is used to handle boundary values, that is, when the value exceeds the calibration range, the calibration value of the nearest endpoint is taken.
[0022] (e) Curve update: The calibration data is stored in the configuration file of the system framework layer and can be replaced and optimized through OTA remote upgrade or system update to adapt to the individual differences of different batches of photoresistors.
[0023] Smoothing Filtering and Brightness Mapping Configuration: The linearized illuminance data is denoised by moving average or first-order low-pass filtering, and then the final backlight adjustment command is generated through a two-layer mapping of "illuminance → nit brightness → backlight PWM". The first layer of mapping determines the target brightness (nits) based on the illuminance, and the second layer converts the nit value into PWM duty cycle or register value according to the screen backlight characteristics.
[0024] The specific implementation of the brightness two-layer mapping logic is as follows:
[0025] The first layer of mapping (Lux→Nits): Based on the filtered linearized ambient light perception data Lux, the target screen brightness L_nits (unit: nits) is determined through a preset illuminance-brightness mapping curve. This mapping curve can be implemented using a lookup table combined with linear interpolation. The mapping table is pre-configured according to the characteristics of human vision (Weber-Fechner law) to ensure that brightness changes conform to the non-linear characteristics of human eye perception. The mapping table is stored in the configuration file of the system framework layer, such as the config_autoBrightnessLevels and config_autoBrightnessLcdBacklightValues arrays in the Android system.
[0026] The second layer of mapping (Nits→Backlight): Based on the brightness-backlight drive characteristics of the display, the target nit brightness L_nits is converted into the corresponding backlight control value. For PWM dimming displays, the conversion formula is:
[0027] PWM=(L_nits / L_max)^(1 / γ)×PWM_max
[0028] Where L_max is the maximum brightness of the screen (nits), γ is the gamma value of the screen (usually 2.2), and PWM_max is the maximum PWM duty cycle (usually 255 or 100%). For displays that use registers to control the backlight, the PWM value is mapped to the corresponding backlight register value.
[0029] The combination of the above-mentioned technical features, namely "interrupt-to-polling conversion + 4-second cycle optimization + piecewise linear interpolation nonlinear compensation + dual-layer mapping", synergistically solves the technical problem of achieving near-dedicated photosensitive IC effects with low-cost photoresistors, making the actual changes in screen brightness match the user's perception of ambient light and significantly improving the user experience of automatic brightness adjustment.
[0030] The present invention also provides an ambient light adaptive sensing system based on polling LRADC, including the above-mentioned voltage divider circuit, LRADC module, timer polling module, data reporting module, nonlinear compensation module, filtering module and brightness adjustment module. Each module is connected in sequence to work together to complete the complete processing link from light signal to backlight command.
[0031] The present invention also provides a computer-readable storage medium storing a computer program, the computer program comprising program code for implementing the steps of the above-described method, and / or program code for implementing the functions of the modules of the above-described system. The storage medium includes, but is not limited to, non-volatile storage media such as ROM, RAM, EEPROM, flash memory, solid-state drives, and SD cards.
[0032] Compared with the prior art, the beneficial effects of the present invention include:
[0033] 1. The reporting dead zone has been completely eliminated. Because the polling method does not depend on any voltage threshold, it can capture and report even the smallest changes in illumination in the next sampling cycle, and brightness adjustment covers the entire illumination range.
[0034] 2. Smooth and continuous light response. Timed polling generates a stable data stream, transforming automatic brightness from abrupt jumps to continuous and smooth adjustments, significantly improving the visual experience.
[0035] 3. Nonlinearity is accurately compensated. Piecewise linear interpolation is used to correct the inherent nonlinearity of the photoresistor, making the output illuminance approximately linear with the actual illuminance, achieving the linearity level of a dedicated photosensitive IC.
[0036] 4. Zero increase in hardware costs. The entire process involves software-driven and framework-level modifications without altering the PCB design. Furthermore, it can be remotely upgraded and deployed to already sold equipment via OTA, resulting in significant economic benefits in large-scale production.
[0037] 5. Cross-platform portability. The solution is based on the Linux kernel standard interface and the Android framework layer, and can be easily ported to other embedded platforms with LRADC peripherals. Attached Figure Description
[0038] Figure 1 This is a schematic diagram of the hardware connection between the photoresistor and the LRADC of the present invention.
[0039] Figure 2 This is a software flowchart of the interrupt-to-polling mechanism of the LRADC driver layer in this invention.
[0040] Figure 3 This is a schematic diagram of the overall system architecture and data flow of the present invention. Detailed Implementation
[0041] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments, but the implementation of the present invention is not limited thereto.
[0042] [General Explanation with Reference to Attached Figures]
[0043] Figure 1In this context, VCC is the power supply voltage, and R... s The resistor is a photoresistor, and R0 is a fixed resistor; the power supply voltage VCC and the photoresistor R... s One end is connected to the photoresistor R s The other end is connected in series with a fixed resistor R0, and the voltage divider node is also connected to the LRADC analog input channel; the LRADC has a built-in 12-bit successive approximation analog-to-digital converter, which converts the analog voltage into a digital value for the CPU to read.
[0044] Figure 2 In the process, after the driver is loaded, step S101 is executed first to disable the hardware interrupts originally configured for LRADC; then step S102 is executed to initialize and start the kernel timer; each time the timer expires, step S103 is executed to read the LRADC data register in the callback function; step S104 is executed to report the conversion value through the IIO subsystem or Sensor HAL; then step S105 is executed to reset the timer and wait for the next cycle.
[0045] Figure 3 In the diagram, 10 represents the photoresistor voltage divider circuit, 20 the LRADC module, 30 the timer polling module, 40 the data reporting module, 50 the nonlinear compensation module, 60 the filtering module, and 70 the brightness adjustment module. Data flows from the photoresistor voltage divider circuit 10 → LRADC module 20 → timer polling module 30 in the driver layer → data reporting module 40 → nonlinear compensation module 50 in the system framework layer → filtering module 60 → brightness adjustment module 70, completely demonstrating the entire signal conversion and software processing chain.
[0046] Example 1: Specific Implementation Based on the First Embedded Platform
[0047] Step 1: Hardware Connection
[0048] like Figure 1 As shown, an external photoresistor R is connected to the LRADC channel of the first embedded platform. s Together with the fixed resistor R0, they form a voltage divider circuit. One end of the fixed resistor R0 is grounded, and the other end is connected to the LRADC input pin and the photoresistor R. s One end, photoresistor R s The other end is connected to the power supply voltage VCC. The photoresistor is connected in series with the fixed resistor, and its voltage divider node is connected to the LRADC input pin. s Choose a type where the light and dark resistances differ significantly. The value of the fixed resistor R0 is based on the photoresistor R. s The ratio of the light resistor to the dark resistor is selected so that the output voltage of the voltage divider node falls within the optimal range of the LRADC.
[0049] The LRADC module is preferably a 12-bit successive approximation (SAR) analog-to-digital converter. Successive approximation ADCs use a binary search algorithm to progressively approximate the digital encoding of the analog input voltage. They offer advantages such as simple structure, low power consumption, low cost, and moderate accuracy, and are widely used in sensor data acquisition and other scenarios. The LRADC module operates on a 1.8V power supply. The 12-bit resolution divides the 1.8V analog input range into 2^12 = 4096 quantization levels, with each quantization level corresponding to a voltage resolution of 1.8V / 4096 ≈ 0.44mV. For ambient light detection applications, the resistance of the photoresistor changes continuously and slowly with illumination, requiring no extremely high sampling rate but demanding a certain level of measurement accuracy. The 0.44mV voltage resolution provided by the 12-bit resolution is sufficient to accurately capture subtle changes in ambient light. Furthermore, the low power consumption of the successive approximation architecture meets the stringent energy requirements of embedded terminals. The aforementioned hardware characteristics enable the LRADC module, as a 12-bit successive approximation analog-to-digital converter, to achieve a good balance between power consumption, cost, and detection accuracy, making it a preferred analog-to-digital conversion solution for ambient light detection of photoresistors.
[0050] Step 2: Kernel driver modification
[0051] Locate the LRADC driver file within the kernel path of the first embedded platform system source code. This driver file is typically located in the input subsystem directory, and its filename usually contains identifiers such as LRADC or gpadc.
[0052] Step S101 – Disable the original hardware interrupts configured for LRADC:
[0053] First, delete or comment out the interrupt configuration attribute of the LRADC node in the device tree file. The LRADC node in the device tree typically contains an `interrupts` attribute, which specifies the interrupt number and interrupt trigger type—this attribute is the core identifier of the interrupt mode configured for LRADC for key detection purposes. By deleting or commenting out this attribute, the LRADC will no longer respond to hardware interrupt signals.
[0054] Secondly, disable interrupt registration logic in the driver initialization function. Driver initialization functions typically contain calls to interrupt registration functions, such as the `request_irq` function. By commenting out or removing this function call, the driver will no longer register interrupt handlers with the kernel.
[0055] Step S102 – Initialize and start the kernel timer:
[0056] Define a timer structure variable; initialize the timer in the driver initialization function, set the callback function pointer when the timer times out; set the timer timeout to 4 seconds, and start the timer to begin the first polling cycle.
[0057] Step S103 – Read the LRADC data register in the callback function:
[0058] The following operations are performed in the timer callback function: read the current value of the LRADC data register through memory-mapped I / O, and convert the value from the register's raw format to a standardized numerical representation.
[0059] Step S104 – Report the converted value via the IIO subsystem or Sensor HAL:
[0060] The conversion value read in step S103 is reported to the user space through the IIO subsystem interface, or to the Android sensor framework through the SensorHAL interface.
[0061] Step S105 – Reset the timer and wait for the next cycle:
[0062] At the end of the timer callback function, the mod_timer() function is called to reset the timer's timeout, so that the timer will trigger again in the next 4-second cycle, thus achieving continuous polling and data collection.
[0063] In the driver unload function, delete the timer to release resources.
[0064] The steps S101 to S105 above correspond to the following steps in sequence: S101 disables the original hardware interrupt configuration of LRADC, S102 initializes and starts the kernel timer, S103 reads the LRADC register in the callback function, S104 reports the conversion value through IIO / SensorHAL, and S105 resets the timer to wait for the next cycle. These steps correspond to the aforementioned steps of disabling the original hardware interrupt triggering mechanism and registering the kernel timer in the LRADC driver, triggering the reading of the real-time conversion value by the timer at a 4-second cycle, and uploading the conversion value to the driver layer of the system framework layer through the Linux standardized sensor reporting interface.
[0065] Step 3: IIO Device Registration
[0066] In the driver, the LRADC is registered as an IIO device through the IIO device registration interface. Specific operations include: populating the IIO device descriptor structure, setting fields such as device name, number of channels, and data read callback function; calling the IIO device registration function to register the device to the IIO subsystem; and creating a property file in the IIO device directory of the file system to expose the raw ADC values for user space to read. User space can obtain the latest LRADC conversion values by reading this property file.
[0067] Step 4: Sensor HAL layer adaptation
[0068] In Sensor HAL, a separate polling thread is created. This thread runs continuously, performing the following operations in each loop: opening and reading the IIO device property file to obtain the latest raw ADC value; converting the read value from string format to integer format; converting the raw ADC value to the corresponding voltage value or directly using it as the raw light sensor value based on the LRADC's reference voltage and resolution; filling the converted data into a standard sensor event structure, setting the sensor type to ambient light sensor, and setting fields such as timestamp and accuracy; and reporting the event to Sensor Service through Sensor HAL's standard reporting interface.
[0069] Step 5: Configure framework layer parameters
[0070] In the system framework's automatic brightness policy configuration file, modify the automatic brightness mapping array. This configuration file is typically located at frameworks / base / core / res / res / values / config.xml. The mapping array uses a piecewise linear interpolation mapping table to map ambient light illuminance values to corresponding screen backlight brightness values. The calibration points of the mapping table are filled in based on the actual calibration data of the photoresistor.
[0071] The calibration process for the piecewise linear interpolation mapping curve is as follows:
[0072] First, place the device to be calibrated in a dark room and provide a stable lighting environment using an adjustable standard light source (such as a halogen tungsten lamp with an attenuation filter). At the same time, use a calibrated standard illuminance meter to monitor the actual illuminance value.
[0073] Next, 11 calibration points were selected within the target illumination range: 0 Lux (completely blocked), 1 Lux, 3 Lux, 10 Lux, 30 Lux, 100 Lux, 300 Lux, 1000 Lux, 3000 Lux, 5000 Lux, and 10000 Lux. At each calibration point, after the illumination stabilized, the LRADC value was read 10 times consecutively, and the arithmetic mean was taken as the calibration ADC value for that point. The calibration data pair (Lux_i, ADC_i) was recorded.
[0074] Next, the calibration data is written to the configuration file in the system framework layer. In the Android system, the calibration data can be configured through the config_autoBrightnessLevels array (which stores the illuminance calibration points) and the config_autoBrightnessLcdBacklightValues array (which stores the corresponding backlight values), or stored in a custom configuration file as key-value pairs.
[0075] Finally, in actual operation, the system framework layer reads the calibration data, performs real-time conversion on any input LRADC raw value according to the piecewise linear interpolation formula, and outputs a linearized ambient light illuminance value.
[0076] Add a moving average filtering logic to the automatic brightness strategy class. Specifically, maintain a fixed-length data queue with a window size of 5 sampling points. Each time new light sensor data is received, add it to the tail of the queue, remove the old data from the head of the queue, and calculate the arithmetic mean of all data in the queue as the filtered light sensor value. This filtering process eliminates brightness fluctuations caused by sampling noise, photoresistor thermal noise, and other factors.
[0077] Step 6: Luminance Dual-Layer Mapping
[0078] The brightness adjustment module 70 implements two layers of mapping logic. The first layer of mapping determines the target screen brightness, measured in nits, based on filtered linearized ambient light sensing data and a preset mapping curve. The second layer of mapping converts the target nit brightness into the corresponding backlight PWM duty cycle or backlight register value based on the screen's brightness-backlight drive characteristics, generating the final screen brightness adjustment command and sending it to the display driver.
[0079] like Figure 3 As shown, the overall system architecture of this embodiment includes: a photoresistor voltage divider circuit 10 outputs an analog voltage signal to an LRADC module 20; the LRADC module 20 outputs a digitally converted value and transmits it to a timer polling module 30 in the driver layer; the timer polling module 30 periodically collects data and then sends it to a data reporting module 40; the data reporting module 40 uploads the data to a nonlinear compensation module 50 in the system framework layer through a Linux standardized sensor reporting interface; the nonlinear compensation module 50 outputs corrected light sensing data to a filtering module 60; and the filtered data is input to a brightness adjustment module 70 to generate a backlight driving command.
[0080] Example 2: Specific Implementation Based on the Second Embedded Platform
[0081] The implementation of this invention is not limited to the first embedded platform, but is also applicable to other embedded platforms that include an LRADC module. The main differences between the second and first embedded platforms are: the directory path of the driver files may be different, the interrupt configuration attribute name of the LRADC node in the device tree may be different, and the default reporting path may be different. These differences are common between different chip manufacturers and different kernel versions.
[0082] An external photoresistor and a fixed resistor are connected to the LRADC channel of the second embedded platform to form a voltage divider circuit. The circuit connection method is exactly the same as in Embodiment 1. Figure 1 As shown.
[0083] Regarding driver file location, the LRADC driver file is located in the corresponding directory based on the kernel source code structure of the second platform. If the LRADC driver of the second platform is located in the IIO subsystem directory instead of the input subsystem directory, the driver initialization process and interrupt registration method may differ slightly, but the core logic for disabling interrupts and registering timers is exactly the same as in Example 1. Figure 2 As shown (S101 disables interrupts in the original configuration, S102 initializes timers).
[0084] Regarding device tree configuration, based on the device tree binding document of the second platform, the interrupt configuration attributes of the LRADC node are located and commented out or deleted. The names of the interrupt configuration attributes may differ between different platforms, such as different fields like interrupts or interrupt-parent, but the purpose and effect of the operation are exactly the same as in Example 1 (corresponding to S101).
[0085] Regarding the timer polling logic, the implementation method is exactly the same as in Example 1: define a timer structure, register the timer and set a callback function in the driver initialization function (corresponding to S102), read the register and report in the callback function (corresponding to S103 and S104), reset the timer at the end of the callback function (corresponding to S105), and delete the timer in the driver unload function.
[0086] Regarding the reporting path, if the second platform uses the IIO subsystem by default, the IIO device registration steps in Embodiment 1 can be directly reused; if the Sensor HAL method is required, the HAL layer adaptation should be performed in the same manner as in Embodiment 1. Both reporting paths have been described in detail in Embodiment 1 and will not be repeated here.
[0087] At the system framework layer, the same piecewise linear interpolation nonlinear compensation method and brightness dual-layer physical mapping strategy as in Embodiment 1 are adopted.
[0088] Experimental results show that the technical solution of the present invention can achieve an ambient light adaptive sensing effect close to that of a dedicated photosensitive IC on a second embedded platform, proving that the present invention has good platform portability.
[0089] Example 3: Polling Cycle Comparison Experiment
[0090] The inventors conducted comparative tests with polling cycles of 2 seconds, 4 seconds, 6 seconds, and 8 seconds respectively. The test environment was the first embedded platform, and the test conditions were moving from an indoor environment (about 200 lux) to an outdoor sunlight environment (about 10,000 lux). The CPU load and light-sensing response smoothness were recorded for each cycle.
[0091] Test results show that:
[0092] With a 2-second polling cycle, the CPU load increases by about 3%, the light sensor response is smooth, and the brightness adjustment is continuous, but the system overhead is slightly higher, which may affect the real-time performance of other background tasks in resource-constrained embedded platforms.
[0093] With a 4-second polling cycle, the CPU load increases by about 1.5%, the light sensor response is smooth, the brightness adjustment is continuous and without any lag, and the overall performance is optimal. It ensures the timeliness of brightness adjustment without causing significant additional burden on the system.
[0094] With a 6-second polling cycle, the CPU load increases by about 1%, but a noticeable lag appears in brightness adjustment. Users will clearly feel the screen brightness response delay when the ambient light changes rapidly (such as when moving from indoors to outdoors).
[0095] With an 8-second polling cycle, the CPU load increases by about 0.8%, but the lag in brightness adjustment becomes more noticeable, resulting in a poor user experience.
[0096] Based on the above experimental results, a 4-second polling period achieves the optimal balance between system load and response timeliness, making it the preferred polling period. This preferred period is suitable for most application scenarios with gradually changing ambient light.
[0097] Example 4: Photoresistor selection and voltage divider circuit design
[0098] like Figure 1 As shown, the photoresistor R s The following factors should be considered when selecting a light source: the higher the ratio of light resistance to dark resistance, the higher the detection sensitivity; the shorter the response time, the stronger the ability to track changes in illumination; and the spectral response characteristics should match the spectrum of the target light source, such as natural light or LED light.
[0099] The method for determining the value of the fixed resistor R0 is as follows: Determine the optimal measurement range based on the reference voltage and resolution of the LRADC. Select a value for the fixed resistor R0 such that the output voltage of the voltage divider node falls within the middle region of the LRADC range at the center point of the target illumination range, thereby obtaining optimal linearity and detection accuracy.
[0100] In actual debugging, the following steps can be taken: First, based on the photoresistor R... s The datasheet specifies the typical values for the light and dark resistances; then, the output voltage of the voltage divider node is calculated under different lighting conditions according to the voltage divider formula; it is checked whether the voltage range covers the optimal range of the LRADC; if the voltage range is too high or too low, the resistance value of the fixed resistor R0 is adjusted and the calculation is repeated; the above steps are repeated until the voltage range meets the requirements; finally, the test is conducted under actual lighting conditions, and the resistance value of the fixed resistor R0 is finely adjusted according to the measurement results to cover the lighting range of the actual application scenario.
[0101] The above steps correspond sequentially to disabling interrupts in the driver, initializing the timer, reading the callback, reporting the data, and resetting the timer. These steps correspond to the driver layer improvement steps of disabling the hardware interrupt triggering mechanism and registering the kernel timer in the LRADC driver, triggering the reading of the real-time conversion value by the timer at a 4-second cycle, and uploading the conversion value to the system framework layer through the Linux standardized sensor reporting interface.
[0102] Industrial applicability
[0103] This invention can be directly applied to various smart terminals with screens, including tablets, mobile phones, vehicle central control systems, and smart home panels. A high-performance, cost-effective light-sensing solution can be achieved simply through software upgrades. Compared to traditional dedicated light-sensing IC solutions, this invention uses a photoresistor instead, significantly reducing BOM costs. Furthermore, changes to the driver layer can be completed via OTA updates, eliminating the need for hardware recalls or redesigns. Its cost advantages in mass production and flexibility in deployment have been validated, demonstrating clear prospects for industrial applications.
[0104] The method and system of this invention can be implemented by software, hardware, or a combination of both. The computer program can be stored in various computer-readable storage media, including but not limited to non-volatile storage media such as ROM, RAM, EEPROM, flash memory, solid-state drives, and SD cards. When the computer program stored in the storage medium is executed by a processor, it can implement all or part of the functions of the ambient light adaptive sensing method and system provided by this invention.
Claims
1. An ambient light adaptive sensing method based on polling LRADC, applied to a smart terminal with a screen, characterized in that, include: The conversion signal of the low-resolution analog-to-digital converter (LRADC) in the embedded platform is obtained, and the ambient light intensity is converted into an analog voltage by a photoresistor voltage divider circuit. The photoresistor voltage divider circuit is composed of a photoresistor and a fixed resistor connected in series, and the voltage divider node is connected to the LRADC input pin. In the LRADC driver, the original hardware interrupt triggering mechanism of the LRADC is disabled, and a kernel timer is registered to trigger the reading of the real-time conversion value of the LRADC at a 4-second cycle. The read LRADC conversion value is uploaded to the system framework layer through the Linux standardized sensor reporting interface, which includes the IIO subsystem or the Sensor HAL hardware abstraction layer. The system framework layer corrects the original value of LRADC based on the pre-calibrated nonlinear mapping relationship of photoresistors and outputs linearized ambient light sensing data. The nonlinear mapping relationship is constructed using a piecewise linear interpolation method. The linearized ambient light sensing data is smoothed and noise-reduced, and then screen backlight adjustment instructions are generated through a dual-layer brightness mapping logic.
2. The method according to claim 1, characterized in that, The nonlinear mapping relationship of the photoresistor is constructed as follows: Multiple sets of calibration sampling points were selected in the full illumination test range, and the illumination intensity and LRADC conversion value corresponding to each set of sampling points were recorded. A piecewise linear interpolation mapping curve is constructed with illuminance as the horizontal axis and LRADC conversion value as the vertical axis. The piecewise linear interpolation mapping curve is used to complete the nonlinear correction of the original ADC value and output linear ambient light sensing data.
3. The method according to claim 1, characterized in that, After the kernel timer times out, a callback function is triggered to perform an LRADC register read operation, with no hardware interrupts involved in the data acquisition process.
4. The method according to claim 1, characterized in that, The smoothing and noise reduction process uses a moving average filter or a first-order low-pass filter algorithm to eliminate random noise from the samples.
5. The method according to claim 1, characterized in that, The brightness dual-layer mapping logic specifically includes: a first mapping step, determining the target screen brightness based on linearized ambient light sensing data, wherein the unit of the target screen brightness is nits; and a second mapping step, converting the target screen brightness into a backlight PWM drive value or a backlight register value based on the display backlight hardware characteristics.
6. An ambient light adaptive sensing system based on polling LRADC, applied to a smart terminal with a screen, characterized in that, include: Photoresistor voltage divider circuit, LRADC module, brightness adjustment module, timer polling module, data reporting module, nonlinear compensation module and filtering module; The photoresistor voltage divider circuit is composed of a photoresistor and a fixed resistor connected in series, and the voltage divider node is connected to the LRADC input pin. The photoresistor voltage divider circuit outputs an analog voltage signal to the LRADC module, the LRADC module outputs a digital conversion value and transmits it to the timer polling module, the timer polling module collects data at 4-second intervals and then sends it to the data reporting module; The data reporting module uploads data to the nonlinear compensation module through the Linux standardized sensor reporting interface; The nonlinear compensation module uses a piecewise linear interpolation method to perform nonlinear correction on the original value of LRADC and outputs the corrected light sensing data to the filtering module. The filtered data is input into the brightness adjustment module to generate backlight driving instructions.
7. The system according to claim 6, characterized in that, The timer polling module includes an interrupt disabling unit, a timer registration unit, and a data reading unit; The interrupt disabling unit is used to disable the hardware interrupt registration logic within the LRADC driver. The timer registration unit is used to create kernel timers, with the timer timeout period configured to be 4 seconds. The data reading unit triggers a callback function to read the original conversion value of the LRADC register when the timer times out.
8. The system according to claim 6, characterized in that, The nonlinear compensation module includes a calibration storage unit and an interpolation calculation unit; The calibration storage unit stores multiple sets of illumination intensity and corresponding LRADC conversion calibration data; The interpolation calculation unit calls the calibration data to generate a piecewise linear interpolation mapping curve to complete the ADC numerical nonlinear correction.
9. The system according to claim 6, characterized in that, The brightness adjustment module includes two layers of mapping units: First mapping unit: Calculates the target screen brightness based on linear light sensing data, with the brightness unit being nits; The second mapping unit: combines the hardware characteristics of the display backlight, converts the nit brightness into PWM backlight drive value, and outputs the screen brightness adjustment command.
10. A computer-readable storage medium storing a computer program, characterized in that, The computer program includes program code that implements the method as described in any one of claims 1 to 5, and / or program code that implements the functions of each module of the system as described in any one of claims 6 to 9. When the computer program is executed by a processor, it implements the ambient light adaptive sensing method as described in any one of claims 1 to 5, and / or implements the functions of each module of the system as described in any one of claims 6 to 9.
Citation Information
Patent Citations
Liquid crystal display brightness adjusting system and method based on ambient light perception
CN120580963A
Self-adaptive dimming method and indoor illuminating lamp
CN122421150A
