NoRefresh enabler

Search This thread

bardo8430

Member
Feb 17, 2012
14
14
Hi,

I am trying to put a code together to control the refresh behavior of the e-ink screen. The final goal is to have a drop-in library for app developers to help making their app more e-ink friendly.

The code works already for the PRS-T1, but needs a different driver for the Nook Touch (N2EpdController included).

My one and only beta tester gets the famous "There is a problem parsing the package" error. Pls find enclosed the sources.

I would be grateful if someone could fix possible Eclipse setting or other errors.
 

Attachments

  • NoRefresh.zip
    64.1 KB · Views: 7,374

marspeople

Senior Member
Jul 7, 2011
70
100
Hi,

I have some interest in adapting apps to the eink screen, so I will try to help with this. Unfortunately, I cannot post in the dev forums yet.

When you get error installing apps via android UI, it is useful to do via "adb install" to be able to know the error cause. The message was "INSTALL_FAILED_OLDER_SDK", which I solved by lowering the android:minSdkVersion parameter in Manifest. Then, the app installed and ran fine, but didn't do the desired effect yet. I will check the code now...

---------- Post added at 02:41 AM ---------- Previous post was at 01:53 AM ----------

I see that you're trying to use enterA2Mode() for the nook (btw, there is a typo at NoRefreshEnablerActivity.java:29, it should read EINK_NOOK). I've been playing around with this some time ago when I started developing a fast e-ink drawing app for the NST, you can see it here: https://github.com/marspeople/E-Paper (WIP).

With few testing I've done, I guess the 1-bit mode (A2) setting is not applied globally: it should take effect only in the View from which it is called. I haven't investigated further to try to use it globally.
 
  • Like
Reactions: hereusethis

bardo8430

Member
Feb 17, 2012
14
14
Hi marspeople,

Thanks for pointing out the type, it should read
} else if (DeviceInfo.EINK_NOOK)

Regarding the global value of mode setting. From what I understand, A2 is a permanent mode, so whatever function or app is setting the updatemode, it is kept. With the PRS-T1, it is reset by calling any stock (Sony) app. For the Nook I don't know..

Good luck in compiling, hopefully we come to a version which works on both devices. Then I can proceed to dynamically change the updatemode within an app.
 

marspeople

Senior Member
Jul 7, 2011
70
100
Yes, the A2 mode is kept until any process resets the EPD. Using logcat, I noticed several epd_reset_region messages appearing automatically when I close your app to go back to the launcher. It seems the system overrides the EPD setting, making impossible to use A2 system-wide (at least by this method).

However, if you want A2 just for an app, calling enterA2mode() will probably work, as I used in my own app above.
 

bardo8430

Member
Feb 17, 2012
14
14
Hi marspeople,

I would be most interested to know why the initial source code does compile ok, works on the PRS-T1 and does not install on the Nook Touch + the fixes.

With this knowledge I can write either an app to set refresh modes or within apps.

Did you succeed to compile and install on Nook?
 

bardo8430

Member
Feb 17, 2012
14
14
Hi again,

in your N2EpdController.java

Code:
83: mtSetRegion.invoke(null, "aarddict", enumsRegion[region], regionParams, enumsMode[mode]);

I would like to replace the hardcoded "aarddict" by something dynamic.
What would be the correct function to infer the wanted name?
Code:
activity.class.getName() 
this.getClass().toString()
.. ?
 

marspeople

Senior Member
Jul 7, 2011
70
100
Hi marspeople,

I would be most interested to know why the initial source code does compile ok, works on the PRS-T1 and does not install on the Nook Touch + the fixes.

With this knowledge I can write either an app to set refresh modes or within apps.

Did you succeed to compile and install on Nook?

Yes, sorry about the confusion, but I managed to do it, despite the A2 mode didn't work. What I did was just edit the AndroidManifest.xml, changing the android:minSdkVersion parameter to 7 (since the NST runs Android 2.1).

Good luck finding out how to set A2 mode permanently. I guess you don't have a Nook, so feel free to ask me for testing purposes.
 

marspeople

Senior Member
Jul 7, 2011
70
100
Since the Nook A2 mode seems to be overridden when switching foreground activity, I've tried another approach with a background service which toggles A2 mode when requested by user. This way, the foreground activity isn't switched and "fast refreshing" mode works (until you change activity).

This fast refresh mode (called A2) is only possible because it uses only 1-bit depth, i.e, just black on white, meaning you can't see grayscale pictures but it's good enough for black text on white background and scrolling. I have not "created it", it is built-in from the device (you can test using the stock reader, it is activated when holding a page button). What I implemented is a way to activate and deactivate it at user will from inside any app.

Thanks to dairyknight for his N2EpdController class, which made this possible.
Thanks to bardo8430 for bringing the idea.
Thanks to AndroSS source code for screenshots used in automatic contrast.

Changelog:
01/Mar: Now when you launch the app and it is already running, it will activate NoRefresh mode. So you can also use an activation shortcut to the app using NookTouchTools (i.e. B&N's book icon at top left corner).
02/Mar: Improve activation shortcut to perform toggle between modes. Tap gestures aren't needed anymore (use "-noGestures" apk version if you don't want them).
04/Mar: Got rid of initial ghosting by redrawing the screen after activating A2.
04/Mar (2): Minor improvement of removing ghosting at screen edges.
12/Mar (Beta): Now you can adjust contrast in A2 mode. Images shouldn't be dark or black anymore if you raise the contrast a bit.

22/May: Completely redesigned version 2.0:
- Several options can be customized via settings screen.
- NoRefresh can be toggled by manual app shortcut, tap gestures or automatically according to screen animation (new).
- New App Whitelist to avoid unwanted activation in specific apps (except for manual mode).
- Background service can be launched at boot.
- Small improvements and tweaks.
- Custom app icon (finally :D)

06/Jun: Fix crash on empty whitelist

08/Jul: (Version 2.1)
- Automatic contrast when activating NoRefresh, according to total "brightness" of the screen (simple algorithm). This should ask you for root permission.
- Also supports manual setting in specific situations (customizable).
- Fix possible crash at startup.

26/Jul: (Version 2.2)
- Fix contrast setting behaviour

06/Dec:
- Alternative version with fixed compatibility for FW 1.2.0 available at https://github.com/marspeople/NoRefreshToggle/downloads

First Video: http://youtu.be/6pBPsyno5PY
Other Video: http://youtu.be/kBbl6egyPsQ
Another demo: http://youtu.be/5b7JjllImjM

Repository: https://github.com/marspeople/NoRefreshToggle
 

Attachments

  • NoRefreshToggle.apk
    67.8 KB · Views: 17,629
Last edited:

bardo8430

Member
Feb 17, 2012
14
14
Great to see that it works on the Nook! Good job.

When I try to compile on Eclipse, I have to remove the below Override:

//@Override
public boolean onTouch(View v, MotionEvent event) {

otherwise I get an error: The method onTouch(View, MotionEvent) of type A2Service must override a superclass method

When I compile with this mod and run the app, nothing happens after using your gestures. Except that I tap on other icons which then try to launch other apps.
Should NoRefreshToggle keep the focus?
 
Last edited:

bardo8430

Member
Feb 17, 2012
14
14
I have a suspicion: The PRS-T1 needs to call a function of the Sony library with extended parameters to pass the updatemode. ANY function carrying the mUpdateMode parameter would do - but it must be called. Which might be the problem here. In the used EinkListView.java, a lot of "injection" functions like below are defined.

Code:
@Override
	public void scrollTo(int x, int y) {
		try {
			Method invalidateMethod = super.getClass().getMethod("scrollTo", 
					int.class, int.class, int.class);
			invalidateMethod.invoke(this, x, y , mUpdateMode); 
		} catch(Exception e) {
			e.printStackTrace();
		}

But your code has neither a Listview, nor would any injection function trigger. I am afraid you would have to make the app use a ListView (or WebView).
Can you?
 

marspeople

Senior Member
Jul 7, 2011
70
100
Great to see that it works on the Nook! Good job.

When I try to compile on Eclipse, I have to remove the below Override:

//@Override
public boolean onTouch(View v, MotionEvent event) {

otherwise I get an error: The method onTouch(View, MotionEvent) of type A2Service must override a superclass method

When I compile with this mod and run the app, nothing happens after using your gestures. Except that I tap on other icons which then try to launch other apps.
Should NoRefreshToggle keep the focus?

Well, I noticed that problem of accidentally tapping unwanted widgets, I would recommend tapping on a free area of the screen. I could use an overlay button, but it would occasionally get in the way too. What do you mean by "keep the focus"?

---------- Post added at 09:13 PM ---------- Previous post was at 09:05 PM ----------

I have a suspicion: The PRS-T1 needs to call a function of the Sony library with extended parameters to pass the updatemode. ANY function carrying the mUpdateMode parameter would do - but it must be called. Which might be the problem here. In the used EinkListView.java, a lot of "injection" functions like below are defined.

Code:
@Override
	public void scrollTo(int x, int y) {
		try {
			Method invalidateMethod = super.getClass().getMethod("scrollTo", 
					int.class, int.class, int.class);
			invalidateMethod.invoke(this, x, y , mUpdateMode); 
		} catch(Exception e) {
			e.printStackTrace();
		}

But your code has neither a Listview, nor would any injection function trigger. I am afraid you would have to make the app use a ListView (or WebView).
Can you?

Well, to capture touch events I've used a dummy View which is added to an overlay (see A2Service.java:43). Despite being an android Service instead of Activity, maybe you can instantiate your ListView there and hopefully it will work. :rolleyes:
 

bardo8430

Member
Feb 17, 2012
14
14
Thanks for the hint on the dummy view, will try.

"keep the focus"?: window manager speak, I mean that a tap stays within your app and does not act on the icons below.
 

marspeople

Senior Member
Jul 7, 2011
70
100
Thanks for the hint on the dummy view, will try.

"keep the focus"?: window manager speak, I mean that a tap stays within your app and does not act on the icons below.

Since I'm using a transparent overlay, I have to let touch events pass through, otherwise only my app would see them.

PS: I've added a demo video at a previous post.
 
  • Like
Reactions: raulnayak

marspeople

Senior Member
Jul 7, 2011
70
100
I've been trying to improve the functionality of the app by changing from this manual toggle approach to something like: fast mode is triggered (a bit after) when user starts dragging his finger on the screen and restored when released.

However, I've been searching how to do this with no success so far. The invisible overlay that detects touch events currently is only able to capture MotionEvent.ACTION_OUTSIDE event type, which is useful to detect a tap, but can't deal with a drag. I also need that the drag is passed normally to the app below (to perform scrolling or whatever).

I've found this page (http://stackoverflow.com/questions/8073803/android-multi-touch-and-type-system-overlay) in which is proposed a solution that can detect a drag but can't pass it to the app below.

The code is now here: https://github.com/marspeople/NoRefreshToggle . I would appreciate any help from developers.
 

bardo8430

Member
Feb 17, 2012
14
14
Hi marspeople,

thanks again for taking this. My initial intention was to help app developers with no e-ink experience to easily adapt their code. Doing these things inside an app is much easier but needs access to the source.
See the related question on stackoverflow:
http://stackoverflow.com/questions/9391710/adapt-scrolling-swiping-to-e-ink-screens
The external app was used as a mere demonstrator to have it work on the NST and PRS-T1. Good to have a repository for it now.
 

dark_hawk

Senior Member
May 31, 2004
168
57
Ok, I think I've got it. :D

Since the Nook A2 mode seems to be overridden when switching foreground activity, I've tried another approach with a background service which toggles A2 mode when requested by user via a touch gesture. This way, the foreground activity isn't switched and "fast refreshing" mode works (until you change activity).

The activation gestures I'm currently using (unfortunately, it seems you can't use hardware keys using this approach) are:
- 4 "downward-right" taps (each tap must be done to the right and below the previous one) to activate (A2 mode)
- 4 "upward-left" taps to deactivate (Normal mode)

Video: http://youtu.be/6pBPsyno5PY

Here is the source code and a apk. bardo8430, I believe it would be easy to port this to the PRS-T1.

Noob question.
So I just install the apk and run it and I have Norefresh.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 42
    Since the Nook A2 mode seems to be overridden when switching foreground activity, I've tried another approach with a background service which toggles A2 mode when requested by user. This way, the foreground activity isn't switched and "fast refreshing" mode works (until you change activity).

    This fast refresh mode (called A2) is only possible because it uses only 1-bit depth, i.e, just black on white, meaning you can't see grayscale pictures but it's good enough for black text on white background and scrolling. I have not "created it", it is built-in from the device (you can test using the stock reader, it is activated when holding a page button). What I implemented is a way to activate and deactivate it at user will from inside any app.

    Thanks to dairyknight for his N2EpdController class, which made this possible.
    Thanks to bardo8430 for bringing the idea.
    Thanks to AndroSS source code for screenshots used in automatic contrast.

    Changelog:
    01/Mar: Now when you launch the app and it is already running, it will activate NoRefresh mode. So you can also use an activation shortcut to the app using NookTouchTools (i.e. B&N's book icon at top left corner).
    02/Mar: Improve activation shortcut to perform toggle between modes. Tap gestures aren't needed anymore (use "-noGestures" apk version if you don't want them).
    04/Mar: Got rid of initial ghosting by redrawing the screen after activating A2.
    04/Mar (2): Minor improvement of removing ghosting at screen edges.
    12/Mar (Beta): Now you can adjust contrast in A2 mode. Images shouldn't be dark or black anymore if you raise the contrast a bit.

    22/May: Completely redesigned version 2.0:
    - Several options can be customized via settings screen.
    - NoRefresh can be toggled by manual app shortcut, tap gestures or automatically according to screen animation (new).
    - New App Whitelist to avoid unwanted activation in specific apps (except for manual mode).
    - Background service can be launched at boot.
    - Small improvements and tweaks.
    - Custom app icon (finally :D)

    06/Jun: Fix crash on empty whitelist

    08/Jul: (Version 2.1)
    - Automatic contrast when activating NoRefresh, according to total "brightness" of the screen (simple algorithm). This should ask you for root permission.
    - Also supports manual setting in specific situations (customizable).
    - Fix possible crash at startup.

    26/Jul: (Version 2.2)
    - Fix contrast setting behaviour

    06/Dec:
    - Alternative version with fixed compatibility for FW 1.2.0 available at https://github.com/marspeople/NoRefreshToggle/downloads

    First Video: http://youtu.be/6pBPsyno5PY
    Other Video: http://youtu.be/kBbl6egyPsQ
    Another demo: http://youtu.be/5b7JjllImjM

    Repository: https://github.com/marspeople/NoRefreshToggle
    14
    Hi,

    I am trying to put a code together to control the refresh behavior of the e-ink screen. The final goal is to have a drop-in library for app developers to help making their app more e-ink friendly.

    The code works already for the PRS-T1, but needs a different driver for the Nook Touch (N2EpdController included).

    My one and only beta tester gets the famous "There is a problem parsing the package" error. Pls find enclosed the sources.

    I would be grateful if someone could fix possible Eclipse setting or other errors.
    4
    Hi,

    I finally surpassed all my laziness and improved NoRefresh app as I been wanting to do for a long time. Check it out at the first page.
    3
    I've just implemented a new feature I think you'll enjoy.

    Now you can adjust contrast setting for the NoRefresh/1-bit/A2 mode. Images shouldn't be dark or black anymore if you raise the contrast a bit. Actually, thanks to the B&W dithering to imitate grey, they may look nice too! (see video)

    This is a more "beta" version, you can download at first page post.

    Now let's hope someone can make this thing also play videos. :p
    2
    Hi!
    -your app is nice!
    -however i have sometimes problem with unexpected deactivation of norefresh. is there any chance of using nook touch tools of color tools to map for example small book icon on the top-left to start your app and toggle the no-refresh?

    thx

    Since I cannot avoid those automatic deactivations of NoRefresh by the system, this may be useful.

    I've just implemented it, so now when you launch the app and it is already running, it will activate NoRefresh mode. So you can just use a shortcut to the app using NookTouchTools to activate.

    I will add it to the first page post.