Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 03-25-2014, 06:41 PM   #1
peterson
Connoisseur
peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.
 
Posts: 74
Karma: 889004
Join Date: Mar 2014
Device: Kindle PW2
Front Light Master extension


Front Light Master
v0.2 (2014-04-14)

The "Front Light Master" is an extension for the Kindle Paperwhite 1 and 2 models (i.e. the ones that have a front light). Based on the idea of the FLToggle extension by DuckieTigger (a copy of which you can download at https://www.mobileread.com/forums/sho...&postcount=116) it adds multiple more features.

Same features as FLToggle:
  • turns off LED if brightness is below a certain value at power-on

Additional features:
  • works with Paperwhite 2 (needs verification for Paperwhite 1)
  • turns off LED if you change the brightness below this value at any time, not only at power-on
  • at power-on, makes sure that the LED has a minimum brightness for some time, so you have a chance to change it before it turns off (very helpful if you lie in bed and want to read a book with the lights off)
  • define which brightness to use depending on the time of day

After power-on, if you change the brightness manually, no auto-changes will be made to the brightness until you turn the Kindle off again. Auto-changes
will only happen when you set a schedule for the current time. This gives you full control over your Kindle's frontlight brightness.

Disclaimer

As of version 0.2, this extension has only been tested on a Kindle Paperwhite 2.

If you get this extension to run on your device, please provide feedback here.

It is recommended to test the extension manually prior to activating auto control. To do so, select "Test auto-control" from the Front Light menu in KUAL. This will run the controller in the background. It can be stopped via "Kill test auto-control" or by rebooting your Kindle. If you notice any unwanted side effects, simply restart your Kindle.

Either way, as usual please be advised that you are using this extension on your own risk.


Prerequisites
  • You need a Paperwhite 1 (not tested yet) or Paperwhite 2 (tested).
  • KUAL is recommended.


Installation

Unzip the downloaded file into the extensions folder (/mnt/us/extensions when using SSH, otherwise the extensions folder at root of the Kindle volume when connected to your PC).


Configuration

Edit frontlightmaster/bin/config.sh, all available options are described here. Note that you MUST use an editor that supports Unix line endings. On Windows, use e.g. the free notepad++ application.


Use

Run KUAL and enter the "Front Light" section. You will see the following options:
  • "Turn off front light" - This will turn the front light LED off until you set a new brightness.
  • "Test auto-control" - Run the auto control in the background. Will only run until you stop it or reboot the device.
  • "Kill test auto-control" - Kill a running test.
  • "Auto-Control - enable" - Enable auto-control permanently, including after a reboot of your Kindle. Strongly recommended to only do this once you have tried the test auto-control.

When auto-control is active, the menu items will disappear and be replaced by "Auto-Control - disable", which will disable the auto-control.

All these functions can be done also on a terminal on your Kindle (e.g. via ssh). Just go to /mnt/us/extensions/frontlightmaster/bin where you will find the following scripts:
  • checkschedule.sh - checks whether your configured schedule makes sense
  • config.sh - your configuration
  • disable.sh - disable auto-control
  • enable.sh - enable auto-control
  • frontlightmaster.sh - the auto-control, run manually to test and see debug output (depending on your config)
  • turnoff.sh - turn off the front light


Uninstalling

It is recommended to disable auto-control via KUAL or the disable.sh script prior to deleting the folder from the extensions directory.
Attached Files
File Type: zip frontlightmaster-v0.2.zip (9.8 KB, 1573 views)

Last edited by peterson; 04-14-2014 at 03:43 PM. Reason: v0.2
peterson is offline   Reply With Quote
Old 03-25-2014, 06:44 PM   #2
peterson
Connoisseur
peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.
 
Posts: 74
Karma: 889004
Join Date: Mar 2014
Device: Kindle PW2
This is a very first version. I tested it the last couple of hours and it seems to work fine. Please let me know if you miss a feature or find a bug.
peterson is offline   Reply With Quote
Advert
Old 03-29-2014, 11:02 AM   #3
Elmer
Junior Member
Elmer began at the beginning.
 
Elmer's Avatar
 
Posts: 2
Karma: 10
Join Date: Mar 2014
Device: K3, K4, KPW2
Hi,
I've downloaded it, I will test it on my pw2 (v5.4.2).
I'm intrested on the auto control function, with the schedule !

Thanks !
Elmer is offline   Reply With Quote
Old 03-30-2014, 01:32 PM   #4
Belenos
Connoisseur
Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.Belenos got an A in P-Chem.
 
Posts: 58
Karma: 6090
Join Date: Oct 2013
Device: PW
Thanks!
Belenos is offline   Reply With Quote
Old 04-08-2014, 09:22 AM   #5
Elmer
Junior Member
Elmer began at the beginning.
 
Elmer's Avatar
 
Posts: 2
Karma: 10
Join Date: Mar 2014
Device: K3, K4, KPW2
Hi,

I'm using it on my PW2 for one week, I have no problems. Tonight, I've changed some settings, I will test it tomorrow.
Elmer is offline   Reply With Quote
Advert
Old 04-10-2014, 03:17 PM   #6
phoenix_pl
Junior Member
phoenix_pl began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Apr 2014
Device: Kindle PW2
Hi,
I would like to use your extension but I don't want to use the scheduler - is it enough to comment out the section in config.sh in order to disable scheduler?
phoenix_pl is offline   Reply With Quote
Old 04-10-2014, 04:15 PM   #7
arcadesdude
Lexically Impaired
arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.
 
arcadesdude's Avatar
 
Posts: 28
Karma: 200518
Join Date: May 2008
Device: PW2
Quote:
Originally Posted by phoenix_pl View Post
Hi,
I would like to use your extension but I don't want to use the scheduler - is it enough to comment out the section in config.sh in order to disable scheduler?
@phoenix_pl, agreed, +1, me too!

@peterson,

I too would also like to use this extension without the scheduler.
The scheduler basically doesn't save my current light setting in between turning it off an back on...it just overrides it. Here's the ideal if it is possible thank you in advance!

Basically I want the extension to

1) When turning on PW2, have FL be ON for X seconds (X is configurable and that currently works). and then AFTER X seconds

2) Restore PREVIOUS light setting (which is saved when turning OFF PW2 (Screensaver mode).

3) Check in Background if I set light below minimum Y amount (Y is configurable and that currently works) to turn OFF the FL.

4) Whenever SS mode is activated, save current FL setting.

5) option for scheduler to override above options is current (as of 4/10/2014) operation but option to turn off scheduler

Then go back to 1) and repeat

Maybe I have the logic wrong and there isn't a need to save the current setting. Just not have the scheduler override it perhaps?

Last edited by arcadesdude; 04-10-2014 at 04:20 PM.
arcadesdude is offline   Reply With Quote
Old 04-13-2014, 05:01 PM   #8
peterson
Connoisseur
peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.
 
Posts: 74
Karma: 889004
Join Date: Mar 2014
Device: Kindle PW2
@arcadesdude / @phoenix_pl : To not use the scheduler, just don't define a schedule. I.e. set

Code:
SCHEDULE=""
or just comment it out. I believe this should cover what you intend.
peterson is offline   Reply With Quote
Old 04-14-2014, 08:58 AM   #9
arcadesdude
Lexically Impaired
arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.
 
arcadesdude's Avatar
 
Posts: 28
Karma: 200518
Join Date: May 2008
Device: PW2
Quote:
Originally Posted by peterson View Post
@arcadesdude / @phoenix_pl : To not use the scheduler, just don't define a schedule. I.e. set

Code:
SCHEDULE=""
or just comment it out. I believe this should cover what you intend.
After turning on the pw2 and after the initial 10 seconds where I have the light set in level 5, the light never gets reset to the level it was when the pw2 was turned off (ss mode). It stays on level 5.

That happens with schedule both commented out and with it set to an empty string value.
arcadesdude is offline   Reply With Quote
Old 04-14-2014, 03:44 PM   #10
peterson
Connoisseur
peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.
 
Posts: 74
Karma: 889004
Join Date: Mar 2014
Device: Kindle PW2
You are right. I've uploaded a new version that should fix this issue (it also has the SCHEDULE disabled by default).

Anybody updating, please make a backup of your config.sh.
peterson is offline   Reply With Quote
Old 04-14-2014, 05:27 PM   #11
arcadesdude
Lexically Impaired
arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.
 
arcadesdude's Avatar
 
Posts: 28
Karma: 200518
Join Date: May 2008
Device: PW2
New version is working perfectly! I tested on various light levels then turning off and back on and waiting out the delay. It works as you intended now and is exactly how I like it -- better than 'stock/amazon' because it can go off and I can use the default slider to turn it off/on without having to go into KUAL once autocontrol is enabled. It even survives a reboot. Thanks again!
arcadesdude is offline   Reply With Quote
Old 04-14-2014, 08:45 PM   #12
arcadesdude
Lexically Impaired
arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.
 
arcadesdude's Avatar
 
Posts: 28
Karma: 200518
Join Date: May 2008
Device: PW2
The only UI or possible bug in this new 0.2 version is that if you have the light off then turn off the pw2, then turn it on, you'll have your 10 seconds of light to adjust the backlight...but after the 10 seconds the light will go off again.

You can't change the light level when first turning it on since it gets reset to what the level was before it was turned off (including off).

Maybe something that checks if the current light level setting is not equal to the remembered (when turning off) light level setting test would allow that to be overridden. I guess it would also have to be not equal to the initial (when turning on) light setting value. Hrm....
arcadesdude is offline   Reply With Quote
Old 04-15-2014, 12:20 AM   #13
arcadesdude
Lexically Impaired
arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.
 
arcadesdude's Avatar
 
Posts: 28
Karma: 200518
Join Date: May 2008
Device: PW2
I managed to modify your script in a way that gives the UI that I want from this to be perfect now.

So when I turn it on, the minimum brightness I set it to 6 (since I read on 5 usually and lower). It will turn on to 6 for 10 seconds and then it will either restore the original brightness (or screen off) OR, if the brightness was changed after first turning it on (anything other than 'level 6') it will keep that new brightness setting.

This allows me to change the brightness level without having to wait 10 seconds for it to first to restore the old level and then set the new level. So if the light was off, for example, and I'm in a dark room, it will now be set to level 6 and then if I change it (say to 5 or 4) it will not turn off after 10 seconds and then require me to set the level as it would have before without my small modification. This way if the level is set other than 6 (minimumbrightnesslevel) then it will stay that way.

Here's what I changed to acheive this in frontlightmaster.sh:

Code:
# if brightness to use is really low, set the minimum brightness and wait a bit
		if [ $(get_brightness_to_use) -lt $MINIMUMBRIGHTNESSONSTART ]; then
			# remember brightness
			BRIGHTNESSONSTART=$(get_brightness_to_use)

			logger "Set minimum brightness to $MINIMUMBRIGHTNESSONSTART for $MINIMUMBRIGHTNESSONSTARTTIME seconds"
			set_brightness $MINIMUMBRIGHTNESSONSTART
			lipc-wait-event -s $MINIMUMBRIGHTNESSONSTARTTIME com.lab126.powerd goingToScreenSaver || true
		
			
			if [ $(get_current_brightness) -eq $MINIMUMBRIGHTNESSONSTART ]; then
				# reset brightness
				set_brightness $BRIGHTNESSONSTART
			fi

			LASTBRIGHTNESS=$(get_current_brightness)

		else
			# we start with the brightness that is currently set, this will update in a bit
			LASTBRIGHTNESS=$(get_current_brightness)
						
			
		fi
The part that is different is:

Code:
if [ $(get_current_brightness) -eq $MINIMUMBRIGHTNESSONSTART ]; then
				# reset brightness
				set_brightness $BRIGHTNESSONSTART
			fi
Thanks again, it's perfect now!
arcadesdude is offline   Reply With Quote
Old 04-15-2014, 01:41 PM   #14
arcadesdude
Lexically Impaired
arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.arcadesdude ought to be getting tired of karma fortunes by now.
 
arcadesdude's Avatar
 
Posts: 28
Karma: 200518
Join Date: May 2008
Device: PW2
Cool

The only improvement I could suggest at this point would be reguarding this line of code in frontlightmaster.sh:

Code:
lipc-wait-event -s $MINIMUMBRIGHTNESSONSTARTTIME com.lab126.powerd goingToScreenSaver || true
which is after awakening from SS mode to and setting the minimum brightness.

If I'm correct, then that line of code waits until the $MINIMUMBRIGHTNESSONSTARTTIME has elapsed before continuing to process the next line of code. This means if the brightness is changed during that $MINIMUMBRIGHTNESSONSTARTTIME (10 seconds say) then there isn't any way of knowing if the brightness slider was changed and then set back to the $MINIMUMBRIGHTNESSONSTART level. So if you have the light off, and min brightness set to 5, when you turn it on the PW2 will be at brightness level 5 for 10 seconds during which if you increase and then decrease the brightness + 1 - 1 so it remains at 5 (or whatever $MINIMUMBRIGHTNESSONSTART is set to) then the light would go off since it didn't detect a change in brightness (manually changing the slider).

If that line of code was a do while loop of some sort that executed for $MINIMUMBRIGHTNESSONSTARTTIME then it could detect current brightness being different from $MINIMUMBRIGHTNESSONSTART at any point within the 10 seconds (MINIMUMBRIGHTNESSONSTARTTIME) and then chose not to reset the light to the former saved off value (off in my example above).

Any ideas on the above?
arcadesdude is offline   Reply With Quote
Old 04-16-2014, 03:58 AM   #15
peterson
Connoisseur
peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.peterson ought to be getting tired of karma fortunes by now.
 
Posts: 74
Karma: 889004
Join Date: Mar 2014
Device: Kindle PW2
Your first code change should be sufficient. The only case your first code change does not cover is when the user changes the brightness, and then changes it back to the $MINIMUMBRIGHTNESSONSTART. This should be such a rare event that I believe we can ignore it.
peterson is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Front light on PB Touch Lux walan PocketBook 1 11-23-2013 08:52 AM
What is your main use for your front light speakingtohe General Discussions 43 09-15-2013 11:45 AM
Kindle PW front light... freezer2k Amazon Kindle 52 09-09-2013 09:37 AM
I'm annoyed - Extension/angle cords don't activate Vox charge light TonyToews Kobo Tablets 12 12-09-2011 02:37 PM
Front Light Idea drgnbear Sony Reader 10 02-13-2007 06:27 PM


All times are GMT -4. The time now is 04:15 AM.


MobileRead.com is a privately owned, operated and funded community.