Hello, I create widget where i set text to show me screen brightness (auto mode or value). When i set brightness to 50 % widget show me 130, max is 255. As source i use screen_brightness from system settings.
It is possible to widget show me brightness value in % from 0-100?
Brightness value convert
Moderator: Martin
Re: Brightness value convert
Hi,
You could divide the value by 2.5 to get into the range from 0 to 100.
Assuming the value is stored in variable setting, you could use an action Notification on Screen with following expression:
{setting/2.5,numberformat,0}
numberformat,0 formats the number without decimal places, e.g. 50 instead of 50.3.
Regards,
Martin
You could divide the value by 2.5 to get into the range from 0 to 100.
Assuming the value is stored in variable setting, you could use an action Notification on Screen with following expression:
{setting/2.5,numberformat,0}
numberformat,0 formats the number without decimal places, e.g. 50 instead of 50.3.
Regards,
Martin
Re: Brightness value convert
There's a very slight chance that the operation - a so called "scaling operation" - may consume a tad less power by sticking to integers: arithmetically it makes no appreciable difference if, instead of dividing by brightness/2.55 - forcing a floating point operation - the operation consisted of brightness*100/255 (sticking to integers). Languages exists which even provide a 3 argument operation for this kind of integer scaling, using a longer intermediate result for the product to avoid integer overflow.
Automagic scripts language distinguishes between integers and floating point numbers, and does integer or floating point calculation depending on the type of number fed to the calculation, but I haven't done any measuring how performance or power consumption are affected. It should also depend on the microprocessor the code runs on.
Automagic scripts language distinguishes between integers and floating point numbers, and does integer or floating point calculation depending on the type of number fed to the calculation, but I haven't done any measuring how performance or power consumption are affected. It should also depend on the microprocessor the code runs on.