Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 11-25-2011, 01:05 PM   #1
asdfffdsa
Junior Member
asdfffdsa began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Nov 2011
Device: Kindle 3 WiFi
Vertical margins / Change resolution / Letterbox?

Hello, I just bought a cheap Kindle 3 WiFi on ebay. The only problem with it is that a small portion of the upper left corner of the screen is cracked (this is why it was so cheap). Most of the time, this is not an issue, but some ebooks have the first word or two cut off. Rotating the display sideways helps, but I'm not very fond of this orientation.

Is there any way that I can change the vertical margins, change the resolution, or letterbox the output on the e-ink screen? I have installed usbnetwork and I have access to root. I've been rummaging through the init scripts but I don't really understand much of what I see (I'm only accustomed to basic X stuff).

Any pointers in the right direction are welcome.
asdfffdsa is offline   Reply With Quote
Old 11-25-2011, 07:09 PM   #2
hawhill
Wizard
hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.
 
hawhill's Avatar
 
Posts: 1,085
Karma: 2114647
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
It *might* be that the Java framework, which is responsible for the UI, is fully agnostic to the resolution (but in fact, I'm a bit sceptical about this). If this was the case, you could try to create a modified Linux kernel that offers a framebuffer device with a resolution set to fix your problem. But it would be a hacky mess to get there, admittedly.

As I said, the other part would be the Java framework. You can decompile it, but it has the names mangled. So this is a hacky mess, too.

Last option might be ebook settings. Maybe you can use Calibre or another tool to modify the ebooks instead of the device. However, I don't know if the Mobi format allows for individual settings of vertical margins. Maybe some format-guru knows more?
hawhill is offline   Reply With Quote
Old 11-25-2011, 08:41 PM   #3
yifanlu
Kindle Dissector
yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.
 
Posts: 662
Karma: 170717
Join Date: Jul 2010
Device: Amazon Kindle 3
You might want to take a look at /etc/fb.modes Don't know if it does anything, but it looks interesting.
yifanlu is offline   Reply With Quote
Old 11-27-2011, 04:56 AM   #4
ryran
Connoisseur
ryran plays well with othersryran plays well with othersryran plays well with othersryran plays well with othersryran plays well with othersryran plays well with othersryran plays well with othersryran plays well with othersryran plays well with othersryran plays well with othersryran plays well with others
 
Posts: 79
Karma: 2718
Join Date: Aug 2011
Device: Kindle 3G
Lightbulb

I can't offer any help with margins, but with launchpad there's a way to much more quickly rotate the screen--if you're having to do it a lot, you might as well have a shortcut for it like Shift R. If you've got launchpad installed and set up, just add this to one of your ini files:

Code:
R = !if [ "$(cat /sys/module/eink_fb_hal_broads/parameters/bs_orientation)" == "1" ]; then lipc-send-event -r 3 com.lab126.hal orientationUp & else lipc-send-event -r 3 com.lab126.hal orientationLeft & fi
PS: That is from dsmid in the launchpad thread. Here's his original post.

Last edited by ryran; 11-27-2011 at 05:03 AM.
ryran is offline   Reply With Quote
Old 11-29-2011, 04:02 PM   #5
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
Or *somebody* could write a quick C program to "scroll" the framebuffer contents down 10% (using memcpy()).

I might do a quick one later today if nobody beats me to it. Or, the "scroller" could "shrink" the framebuffer height a little (resizing the existing contents).

I am a little new at Kindle coding -- is the framebuffer always in 4 bpp mode?
geekmaster is offline   Reply With Quote
Old 11-29-2011, 06:11 PM   #6
hawhill
Wizard
hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.
 
hawhill's Avatar
 
Posts: 1,085
Karma: 2114647
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
I've not yet seen it in a different mode. So I'd say this would be a safe bet. However, for scrolling down, you can always rely on finfo.line_length, which will hold the line length in bytes.

Besides that: great idea. Would be simple to implement (but I have to go to sleep now).
hawhill is offline   Reply With Quote
Old 11-29-2011, 06:23 PM   #7
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
Quote:
Originally Posted by hawhill View Post
... for scrolling down, you can always rely on finfo.line_length, which will hold the line length in bytes.
I have been using screeninfo.xres / 2, but your way saves a division.

I am thinking of using the arrow keys to roll the screen up/down/left/right, so that pixels wrap around the screen edges. This means that no off-screen buffer is needed, and after the hack is installed, even a small portion of working screen could be used to view anything on the screen.

I got a broken-screen kindle 3 wi-fi from eBay for free, plus $6 shipping. After I got "Voice Guide" turned on, it is actually somewhat useful even without a screen, but having even a portion of the screen active would be better...

It would be tempting to add more features, such as squeezing whitespace (folding multiple white lines between rows of text into a single white line), and maybe add an on-screen magnifier that is easier to use than the magnify-thingy in the web browser.

It should be easy to activate while reading, perhaps by pressing Next Page (Right>) and Previous Page (Right<) at the same time, and it should probably remember how far the previous page was rolled and start there for the next page too.

Also, I would like to add a GUI shell to launchpad. Not enough time though.

One problem with direct mmap to /dev/fb0 is that the framework sometimes overwrites it. Is there a way to pause the framework without a full "framework stop" and "framework start"?

And for that matter, is it useful to do a "framework startx" instead of "framework start" to start the framework in running in xorg instead of framebuffer mode?

Last edited by geekmaster; 11-29-2011 at 06:44 PM.
geekmaster is offline   Reply With Quote
Old 11-30-2011, 12:39 AM   #8
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
Okay, I wrote a program to do the framebuffer scrolling with wraparound. It *was* thoroughly tested and working from a USB ssh command line. It also worked from launchpad (Shift S S), but launchpad wrote status info on the display AFTER it had scrolled.

Then I decided to publish the source code too, so I "cleaned" it. I was very tired when I did that, and I (unwisely) did the code cleanup in the mobileread online comment editor. The code is *simpler* now -- I removed "inotify" code that attempted to detect framebuffer changes but only saw open/close events, and other "dead" test code. Inotify does not see kindle framework activity, but I am tempted to put it back in to detect when launchpad messes up the display so I can clean it (probably running as a daemon). Now that I cleaned the code. it only works from my kindle debian environment (chroot from a loop mounted ext3 image).

EDIT: It works in native jailbreak environment too, now that I initialized the unused buffer pointer.

The (repaired) source code is below in this message.

-----
This program accepts up to two parameters.

The first optional parameter is percent of display height to scroll (value 0 to 100, default = 10).

The second optional parameter is display update type (value 0 to 2, default = 1).
Display update types are:
0 = no flash (fast, but slight ghosting)
1 = quality (full flash update, cleanest display)
2 = speed (very fast, black and white only)
21 = negative (readability aid?)


This program can be mapped with various parameters to hotkeys using launchpad, but it scrolls launchpad residue onto the screen. It works much better from the command line. I may need to add my own hotkey processing to this program so the launchpad feed back does not pollute the screen. Does launchpad have a "quiet" parameter for silent operation? It would probably be faster without the visual feedback too.

Anyway, 'scroll' works [worked] fine when run from a USB telnet or ssh command line, but needs a better way to launch it. I was thinking perhaps if both the Prev(Right<) and Next(Right>) keys were down, we could do the default scroll.

To install this (preliminary) version, copy 'scroll' to the USB Drive (/mnt/us/bin), and copy scroll.ini to the launchpad folder.

Here is scroll.ini:
Spoiler:
Code:
[Actions]
;; run framebuffer scroller with default parameters (scroll 10 1)
S S = !/mnt/us/bin/scroll &
;; run framebuffer scroller with 5% scroll
S X = !/mnt/us/bin/scroll 5 &
;; run framebuffer scroller , 10% scroll, no flash update
S A = !/mnt/us/bin/scroll 10 0 &
;; run framebuffer scroller , 10% scroll, fastest update (black and white only)
S D = !/mnt/us/bin/scroll 10 2 &

Here is the C source code:
Spoiler:
Code:
// scroll.c - simple framebuffer scroller for kindle with (partially)
//            broken eink display
//
// usage:
//    scroll [percent] [type]
//
// percent: optional percent of display height to scroll (0 to 100, default = 10).
// type : optional display update type (value 0 to 2, default = 1):
//    0 = no flash (fast, but slight ghosting)
//    1 = quality (full flash update, cleanest display)
//    2 = speed (very fast, black and white only)
//
// *** Disclaimers and whatnot:
//
// This is just a simple quick-and-dirty hack.
// It could use some error checking, and more features.
//
// There is no "secret sauce" here (such as intellectual "Property",
// whatever that is), nothing to protect, no license needed.
//
// As always, please do not sue me if you poke your eye out with
// this code, or somehow manage to injure your brain or otherwise
// maim yourself, your stuff, or your loved ones with it.
//
// Enjoy, compliments of geekmaster...
//
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/ioctl.h>

#define FB_UPDATE_AREA 0x46dd

int main(int argc, char** argv) {
    int pct = 10;
    int fx = 1; // full flash update
    int y, height, width, width_bytes, fb_bytes;
    struct fb_var_screeninfo screeninfo;
    unsigned char *pfb = NULL, *psave = NULL;
    struct update_area_t
    {
        int x1, y1, x2, y2, fx;
        __u8 *buffer;
    } ua;

    // get optional command-line params
    if (argc > 1) pct = atoi(argv[1]);  // scroll percent (0-100)
    if (argc > 2) fx = atoi(argv[2]);   // update type (0-2)

    // open framebuffer and get screen size (assume 4 bpp)
    int fdFB = open("/dev/fb0", O_RDWR);
    ioctl(fdFB, FBIOGET_VSCREENINFO, &screeninfo);
    height = screeninfo.yres;
    width = screeninfo.xres;
    width_bytes = width / 2;
    fb_bytes = height * width_bytes;

    // map and copy framebuffer
    pfb = (unsigned char*)mmap(0, fb_bytes, PROT_READ|PROT_WRITE,
        MAP_SHARED, fdFB, 0);
    psave = malloc(fb_bytes);
    memcpy(psave, pfb, fb_bytes);

    // copy swapped slices back to framebuffer
    y = height * pct / 100;
    memcpy(pfb + y * width_bytes, psave, (height - y) * width_bytes);
    memcpy(pfb, psave + (height - y) * width_bytes, y * width_bytes);

    // trigger framebuffer update
    ua.x1 = 0;
    ua.y1 = 0;
    ua.x2 = width;
    ua.y2 = height;
    ua.buffer = NULL;
    ua.fx = fx;  // update type
    ioctl(fdFB, FB_UPDATE_AREA, &ua);

    // cleanup
    free (psave);
    munmap(pfb, fb_bytes);
    close(fdFB);
}

Downloadable archive with executable, source and .ini files:
NOTE: the above code has been fixed to set ua.buffer = NULL, which got lost in the cleanup. The .gz file below still contains the old broken code.
Attached Files
File Type: gz scroll.tar.gz (4.3 KB, 153 views)

Last edited by geekmaster; 12-04-2011 at 02:28 PM.
geekmaster is offline   Reply With Quote
Old 12-08-2011, 05:49 PM   #9
asdfffdsa
Junior Member
asdfffdsa began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Nov 2011
Device: Kindle 3 WiFi
Geekmaster and the rest of you guys, thanks a lot for the help.

I've cross compiled that C program and it works great when run from root. I wasn't aware one could directly mess with the framebuffer like that. I'll mess around with that API and see if I can translate and rescale things.
asdfffdsa is offline   Reply With Quote
Old 12-08-2011, 06:07 PM   #10
geekmaster
Всё гениальное просто.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 5,066
Karma: 6789001
Join Date: Nov 2011
Location: Щедрость не имеет пределов.
Device: *.*
asdfffdsa: feel free to expand on my code and use it however you wish. Giving me credit is welcome but not required. I do not like software licensing, as you can probably tell from my embedded "disclaimer". Users should exercise responsibility and not expect others to pay for their mistakes. You can use whatever license you feel comfortable with. A lot of people here seem to prefer GPL for some reason. To me, GPL seems a little like clapping your hands in applause after dipping them in cyanoacrylate adhesive.

One useful feature to add would be hotkey monitoring. I was thinking that reposition and/or resize could be done using the last adjusted settings, when the "next page" key is released. That gives time for a PDF (or other ebook format) to render the page and finish updating the framebuffer, controlled by how long the user holds the key. Also, it would be nice to have a continuous adjustment mode using the 5-way pad, using the "fast" mode while pressed, with full flash draw on release. And the ability to move and resize horizontally would be useful too. But most importantly, have fun with it!

In another recent thread (here), a new program was provided that also directly reads the framebuffer. What is special about it is that it does OCR to convert the currently selected (underlined) book title back to text. I think this is the beginning of something great.

Last edited by geekmaster; 12-08-2011 at 06:25 PM.
geekmaster is offline   Reply With Quote
Old 01-02-2013, 06:07 PM   #11
japhann
Junior Member
japhann began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jan 2013
Device: Kindle
C Program

Quote:
Originally Posted by asdfffdsa View Post
Geekmaster and the rest of you guys, thanks a lot for the help.

I've cross compiled that C program and it works great when run from root. I wasn't aware one could directly mess with the framebuffer like that. I'll mess around with that API and see if I can translate and rescale things.
Hey, I'm wondering whether you can share the program with me. A small portion of the top half of my kindle cracked and it would be great if I'm able to scroll.

Thanks!
japhann is offline   Reply With Quote
Old 01-04-2013, 05:55 AM   #12
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
attached below. updated build with new code

Spoiler:
you dont say what kindle...

http://www.mobileread.com/forums/att...4&d=1322660066

seems to CONTAIN an executable...

Look in that...

(I just built another one before I noticed, duh!)


EDIT: Tested - works fine... (added screenie - default scroll pictured - you can see the padding at the top...)
Attached Thumbnails
Click image for larger version

Name:	demo-scroll.png
Views:	108
Size:	24.2 KB
ID:	98732  

Last edited by twobob; 01-04-2013 at 11:12 AM.
twobob is offline   Reply With Quote
Old 01-04-2013, 11:08 AM   #13
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
FROM GM: That binary still has a bug. Read the post.


okay... well this one is with the amended code (above)

enjoy

EDIT: THE FULL VERSION IS NOW HERE: http://www.mobileread.com/forums/sho...2&postcount=31

Last edited by twobob; 03-29-2013 at 11:25 AM.
twobob is offline   Reply With Quote
Old 01-06-2013, 12:12 AM   #14
japhann
Junior Member
japhann began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Jan 2013
Device: Kindle
Quote:
Originally Posted by twobob View Post
FROM GM: That binary still has a bug. Read the post.


okay... well this one is with the amended code (above)

enjoy
Works perfectly! Thank you very much, you're a lifesaver!
japhann is offline   Reply With Quote
Old 01-06-2013, 08:06 AM   #15
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Welcome. it was Geekies work really. Happy to help splatter it together
twobob is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't seem to change epub margins Desertway Calibre 7 01-19-2012 04:28 AM
change margins holterzoff Amazon Kindle 3 05-21-2011 03:42 PM
Change Margins With Calibre Jafo Conversion 19 04-19-2011 08:39 PM
unwanted table-change (vertical align) by calibre NASCARaddicted Calibre 2 01-27-2010 03:35 AM
PDF scaling gets lost when margins change dna2z Sony Reader 5 11-29-2006 10:20 PM


All times are GMT -4. The time now is 02:43 AM.


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