Checking if the backlight is active

by Mark Milec 4/7/2008 8:54:00 AM

When the backlight is inactive on a Symbol 9090G, a keypress activates the backlight, but it also acts as a regular keypress.  This was causing a problem for the users of my application so I needed to check if the backlight was active so I can ignore the keypress if it's inactive.  The solution was easy with the help of the Symbol SDK.

using Symbol.Display; 
public class ScreenHandler {
  public static bool IsBacklightOn {
    get {
      bool returnValue;
      StandardDisplay display = null;
      foreach (Device device in Device.AvailableDevices) {
        if (device.DisplayType == DisplayType.StandardDisplay) {
          display = new StandardDisplay(device);
        }
      }
      if (display == null) {
        returnValue = false;
      } else {
        returnValue = display.BacklightState == BacklightState.ON;
        display.Dispose();
      }
      return returnValue;
    }
  } 
}

 

Update: In the previous version of this code, I wasn't disposing the display object.  That caused me far too many hours of frustration, because after around 25 calls to this method, the barcode scanner would stop scanning.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

8/20/2008 2:17:48 PM

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen

About the author

Name of author Mark Milec
Senior Application Developer at Atlas Tube

View Mark Milec's profile on LinkedIn E-mail me Send mail

Calendar

<<  August 2008  >>
MoTuWeThFrSaSu
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

View posts in large calendar

Pages

    Recent posts

    Recent comments

    Don't show

    Archive

    Authors

    Categories

    None


    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in