Example #1
0
        public double GetBrightness()
        {
            int    sb            = new ScreenBrightness().GetBrightness();
            double normalised_sb = sb / (100 / max_value);

            return(normalised_sb);
        }
Example #2
0
        public static float GetScreenBrightnessWithMode(Context ctx, ScreenBrightness mode)
        {
            // force current mode to manual
            var currentMode = GetScreenBrightnessMode(ctx);

            if (currentMode == ScreenBrightness.ModeAutomatic)
            {
                SetScreenBrightnessMode(ctx, ScreenBrightness.ModeManual);
            }
            var brightnes = GetManualScreenBrightnessLevel(ctx);

            if (mode == ScreenBrightness.ModeAutomatic)
            {
                SetScreenBrightnessMode(ctx, ScreenBrightness.ModeAutomatic);
            }
            return(brightnes);
        }
Example #3
0
        public static float GetScreenBrightnessWithMode(Activity act, ScreenBrightness mode)
        {
            bool canWritteSettings = Settings.System.CanWrite(act);

            // force current mode to manual
            var currentMode = (ScreenBrightness)Settings.System.GetInt(act.ContentResolver, Settings.System.ScreenBrightnessMode);

            if (currentMode == ScreenBrightness.ModeAutomatic)
            {
                Settings.System.PutInt(act.ContentResolver, Settings.System.ScreenBrightnessMode, (int)ScreenBrightness.ModeManual);
            }
            var brightnes = GetManualScreenBrightnessLevel(act);

            if (mode == ScreenBrightness.ModeAutomatic)
            {
                Settings.System.PutInt(act.ContentResolver, Settings.System.ScreenBrightnessMode, (int)ScreenBrightness.ModeAutomatic);
            }
            return(brightnes);
        }
Example #4
0
        /// <summary>
        /// Set Screen Backlight
        /// </summary>
        /// <param name="offset"></param>
        public void Set(uint offset)
        {
            uint val = 170 * offset;

            if (offset == 0)
            {
                val = 20;
            }
            bool ret;

            if (Config.IsXC2903())
            {
                ret = ScreenBrightness.SetScreenBacklight_2903(val);
            }
            else
            {
                ret = ScreenBrightness.SetScreenBacklight(val);
            }
        }
Example #5
0
        /// <summary>
        /// Get Screen Backlight
        /// </summary>
        public void Get()
        {
            int val = 0;

            if (Config.IsXC2903())
            {
                val = ScreenBrightness.GetScreenBacklight_2903();
            }
            else
            {
                val = ScreenBrightness.GetScreenBacklight();
            }
            if (val < 170)
            {
                val = 170;
            }

            tbarscreen.Value = (int)val * 6 / 1000;
            tbarscreen.Update();
        }
        public static int Main(string[] args)
        {
            //value 80,90
            var _screenBrightness = new ScreenBrightness();

            try
            {
                Console.WriteLine("ChangeScreenBrightness build 1");
                // Step 1: test for null.
                if (args.Length == 0)
                {
                    Console.WriteLine("value is null");
                    ExExitApp();
                }
                else
                {
                    string strArgument = args[0];
                    int    intValue    = 0;
                    if (int.TryParse(strArgument, out intValue))
                    {
                        if ((0 < intValue) && (intValue <= 100))
                        {
                            //Set Brightness
                            _screenBrightness.SetBrightness((byte)intValue);
                            Console.WriteLine("Set Brightness Value: " + strArgument);
                            return(0);
                        }
                    }
                }
                //
                Console.WriteLine("value is not from 1 to 100");
                ExExitApp();
                return(-1);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.ToString());
                Console.WriteLine("Exit App");
                return(-1);
            }
        }
Example #7
0
 public static void SetScreenBrightnessMode(Context ctx, ScreenBrightness mode)
 {
     Settings.System.PutInt(ctx.ContentResolver, Settings.System.ScreenBrightnessMode, (int)mode);
 }