Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unhandled exception: Error: display brightness value is invalid

ANSWERED

I've built a clockface back in the 2019 and now I'm trying to make some updates but it seems like in SDK v4.3 I can't control the brightness of display anymore:

var  flashlightToggle = function() {
  if (flash.style.opacity == 0) {
    flashlightOn();
  } else {
    flashlightOff();
  }
};
var  flashlightOn = function() {
  flash.style.opacity = 1;
  display.autoOff = false;
  display.brightnessOverride = 1.0;
};
var  flashlightOff = function() {
  flash.style.opacity = 0;
  display.autoOff = true;
  display.brightnessOverride = undefined;
};

In this context, flash is a white rectangle that takes the whole screen, and when triggered, acts like a flashlight and helps me find my way to bed every evening.

Using auto-brightness in situations where you need a flashlight doesn't make sense. 
How can I get this functionality back?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

The API has changed for .autoOff and brighnessOverride (see here). autoOff will be a problem because of AOD.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
4 REPLIES 4

The API has changed for .autoOff and brighnessOverride (see here). autoOff will be a problem because of AOD.

Peter McLennan
Gondwana Software
Best Answer

Thanks, this was really helpful! Maybe putting display to be always on isn't the best solution. I'll try to set the timer instead.

Best Answer

I've made an update and even though it doesn't trow an error anymore, it does not work in practice. My "flashlight" is now almost useless 😞

var  flashlightToggle = function() {
  if (flash.style.opacity == 0) {
    flashlightOn();
  } else {
    flashlightOff();
  }
};
var  flashlightOn = function() {
  flash.style.opacity = 1;
  display.autoOff = false;
  //display.brightnessOverride = 1.0;
  display.DisplayBrightnessValue = "max";
};
var  flashlightOff = function() {
  flash.style.opacity = 0;
  display.autoOff = true;
  // display.brightnessOverride = undefined;
  display.DisplayBrightnessValue = "normal";
};

How can I fix it?!?

Best Answer
0 Votes

Hi @1GR3 - what doesn't it do that it should?

 

You may want to look at the Display API and detect if the display goes off.

Author | ch, passion for improvement.

Best Answer
0 Votes