Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 736878a6 authored by Jonas Larsson's avatar Jonas Larsson
Browse files

Pimp automatic backlight.

Moving average filter for light sensor, support for custom levels, battery stats fix and dim fix.
parent 41066ed5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -38,4 +38,11 @@ interface IPowerManager
    // sets the brightness of the backlights (screen, keyboard, button) 0-255
    void setBacklightBrightness(int brightness);
    void setAttentionLight(boolean on, int color);

    // custom backlight things
    int getLightSensorValue();
    int getRawLightSensorValue();
    int getLightSensorScreenBrightness();
    int getLightSensorButtonBrightness();
    int getLightSensorKeyboardBrightness();
}
+130 −0
Original line number Diff line number Diff line
@@ -1270,6 +1270,136 @@ public final class Settings {
         */
        public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;

        /**
         * Indicates that custom light sensor settings has changed.
         * The value is random and changes reloads light settings.
         *
         * @hide
         */
        public static final String LIGHTS_CHANGED = "lights_changed";

        /**
         * Whether custom light sensor levels & values are enabled. The value is
         * boolean (1 or 0).
         *
         * @hide
         */
        public static final String LIGHT_SENSOR_CUSTOM = "light_sensor_custom";

        /**
         * Screen dim value to use if LIGHT_SENSOR_CUSTOM is set. The value is int.
         * Default is android.os.BRIGHTNESS_DIM.
         *
         * @hide
         */
        public static final String LIGHT_SCREEN_DIM = "light_screen_dim";

        /**
         * Custom light sensor levels. The value is a comma separated int array
         * with length N.
         * Example: "100,300,3000".
         *
         * @hide
         */
        public static final String LIGHT_SENSOR_LEVELS = "light_sensor_levels";

        /**
         * Custom light sensor lcd values. The value is a comma separated int array
         * with length N+1.
         * Example: "10,50,100,255".
         *
         * @hide
         */
        public static final String LIGHT_SENSOR_LCD_VALUES = "light_sensor_lcd_values";

        /**
         * Custom light sensor lcd values. The value is a comma separated int array
         * with length N+1.
         * Example: "10,50,100,255".
         *
         * @hide
         */
        public static final String LIGHT_SENSOR_BUTTON_VALUES = "light_sensor_button_values";

        /**
         * Custom light sensor lcd values. The value is a comma separated int array
         * with length N+1.
         * Example: "10,50,100,255".
         *
         * @hide
         */
        public static final String LIGHT_SENSOR_KEYBOARD_VALUES = "light_sensor_keyboard_values";

        /**
         * Whether light sensor is allowed to decrease when calculating automatic
         * backlight. The value is boolean (1 or 0).
         *
         * @hide
         */
        public static final String LIGHT_DECREASE = "light_decrease";

        /**
         * Light sensor hysteresis for decreasing backlight. The value is
         * int (0-99) representing % (0-0.99 as float). Example:
         *
         * Levels     Output
         * 0 - 100    50
         * 100 - 200  100
         * 200 - Inf  255
         *
         * Current sensor value is 150 which gives light value 100. Hysteresis is 50.
         * Current level lower bound is 100 and previous lower bound is 0.
         * Sensor value must drop below 100-(100-0)*(50/100)=50 for output to become 50
         * (corresponding to the 0 - 100 level).
         * @hide
         */
        public static final String LIGHT_HYSTERESIS = "light_hysteresis";

        /**
         * Whether light sensor used when calculating automatic backlight should
         * be filtered through an moving average filter.
         * The value is boolean (1 or 0).
         *
         * @hide
         */
        public static final String LIGHT_FILTER = "light_filter";

        /**
         * Window length of filter used when calculating automatic backlight.
         * One minute means that the average sensor value last minute is used.
         * The value is integer (milliseconds)
         *
         * @hide
         */
        public static final String LIGHT_FILTER_WINDOW = "light_filter_window";

        /**
         * Reset threshold of filter used when calculating automatic backlight.
         * Sudden large jumps in sensor value resets the filter. This is used
         * to make the filter respond quickly to large enough changes in input
         * while still filtering small changes. Example:
         *
         * Current filter value (average) is 100 and sensor value is changing to
         * 10, 150, 100, 30, 50. The filter is continously taking the average of
         * the samples. Now the user goes outside and the value jumps over 1000.
         * The difference between current average and new sample is larger than
         * the reset threshold and filter is reset. It begins calculating a new
         * average on samples around 1000 (say, 800, 1200, 1000, 1100 etc.)
         *
         * The value is integer (lux)
         *
         * @hide
         */
        public static final String LIGHT_FILTER_RESET = "light_filter_reset";

        /**
         * Sample interval of filter used when calculating automatic backlight.
         * The value is integer (milliseconds)
         *
         * @hide
         */
        public static final String LIGHT_FILTER_INTERVAL = "light_filter_interval";

        /**
         * Control whether the process CPU usage meter should be shown.
         */
+371 −15

File changed.

Preview size limit exceeded, changes collapsed.