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 05-14-2012, 08:10 PM   #1
geekmaster
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Arrow geekmaster touchscreen signature capture script

If you watched my "newtrix" demo through to the end, you saw the animated "geekmaster signature". It was stored as a vector display list in the sv[] array.

In this thread, I present a useful tool to teach you a very simple way to use the K5 touchscreen. It does not support advanced features like multitouch pinch and stretch, but it is simple and easy to understand.

When you run it, you can draw a trail of dots on the screen with your finger, each dot is stored as a touchscreen capture point. When you press the exit button in the lower-right corner, this script exits and outputs the contents of the display list in a C structure, ready to copy into a C program (like newtrix). You can either pipe this program to a file (./gmsigcap.sh >mysig.h), or you can copy its output from your ssh terminal scrollback buffer.

You might even be tempted to replace the geekmaster signature with your own signature or vector art. Go ahead, but before distributing my code with your signature (with my MIT license intact) please change it to do some cool new stuff.

Here is the script source code:
PHP Code:
#!/bin/sh
#====================================================
# gmsigcap 1.0b - geekmaster vector signature capture
# Copyright (C) 2012 by geekmaster, with MIT license:
# http://www.opensource.org/licenses/mit-license.php
#----------------------------------------------------
# Tested on K5main,K5diags, uses touchscreen.
#----------------------------------------------------

#===========================
# initvar - init global vars
#---------------------------
initvar() {
  
gs=12 # granularity size (distance per capture point)
  
DN=/dev/nullDZ=/dev/zeroDF=/dev/fb0
  DT
=$(for i in /dev/input/event*;do evtest info $i|grep zforce>$DN&&echo $i&&break;done)
  
set $(eips -i|grep line_length); VX=$4
  W
='\xff';W=$W$W$W$W$W$W;W=$W$W$W$W$W;W=$W$W$W$W$W;W=$W$W$W$W # 600px white
  
eips --# flash clear
  
x=0 y=0 xs=0 ys0=0 B=0 Q=0 n=0 H="" R='\x0d' GG=$((gs*gs))
  
eips 44 38 '+~~~~~'
  
eips 44 39 '| Exit'
}

#=================================
# abortsh - abort subprocess shell
#---------------------------------
abortsh() {
  
set $(ps a|grep "sh -c hexdump $DT")
  
kill -HUP $# abort shell
  
Q=# signal quit
}

#==================================
# sigcap - signature vector capture
#----------------------------------
sigcap() {
  
script -"hexdump $DT$DN|while [[ $Q -eq 0 ]]; do
    
read L; [[ ${#L} -ne 48 ]]&& break # rare script exit output
    
set $Llocal T=$((0x$6)) C=$((0x$7)) V=$((0x$8))
    case 
$T in
    0
) if [[ $B -eq 9 ]]; then
        H
="$H 0 };$R\x0a"n=$((n+1))
        echo -
"unsigned short int sigvec[$n]={$R"; echo -e "$H$R"
        abortsh # abort subprocess shell
        Q=1 # signal quit
      elif [[ 
$x -ge 540 && $y -ge 750 ]]; then # on exit button
        if [[ 
$B -ne 1 ]]; then # was not pressed
          eips -v 44 38 '+~~~~~'
          eips -v 44 39 '| Exit'
        fi; B=1
      else # off exit button
        if [[ 
$B -ne 2 ]]; then # was not released
          eips 44 38 '+~~~~~'
          eips 44 39 '| Exit'
        fi; B=2
      fi
      Dx=$((x-xs)); [[ 
$Dx -lt 0 ]]&& Dx=$((0-Dx))
      Dy=$((y-ys)); [[ 
$Dy -lt 0 ]]&& Dy=$((0-Dy))
      RR=$((Dx*Dx+Dy*Dy))
      if [[ 
$RR -ge $GG ]];then
        H="
$H $((y*256/800*256+x*256/600)),$R\x0a"; n=$((n+1))
        dd if=
$DZ of=$DF bs=1 count=5 seek=$((y*VX+x-4)) 2>$DN # black
        xs=
$x ys=$y; eips '';
      fi ;;
    3) case 
$C in
      53) x=$((V*600/4096)) ;;
      54) y=$((V*800/4096)) ;;
      57) case 
$V in
        0) xs=0 ys=0 ;;
        65535) [[ 
$B -eq 1 ]]&& B=9 # signal exit button pressed
          H="
$H $((y*256/800*256+x*256/600)),$R\x0a"
          H="
$H 0,$R\x0a"; n=$((n+2)) ;;
        esac ;;
      esac ;;
    esac
  done
  eips 44 38 '      '
  eips 44 39 '      '
}

killall -STOP Xorg cvm # pause framework
initvar # init global vars
sigcap # signature vector capture
killall -CONT cvm Xorg # resume framework 
P.S. You can even draw "happy face" smilies with this, and animate them using code from my newtrix demo.

Here is the output from this script after I drew a large smiley icon with my finger, then pressed the "exit" button:
Spoiler:
Code:
unsigned short int sigvec[125]={
 23228,
 21944,
 20916,
 19886,
 19110,
 18333,
 17555,
 17549,
 17543,
 17538,
 17533,
 18036,
 18540,
 19302,
 20064,
 21083,
 22614,
 24401,
 25422,
 26443,
 27209,
 28231,
 29253,
 30533,
 31557,
 32581,
 33606,
 34632,
 35403,
 36430,
 37202,
 38230,
 39258,
 40032,
 40549,
 41065,
 41326,
 41587,
 41848,
 42110,
 42119,
 41869,
 41618,
 41371,
 40356,
 39848,
 39085,
 38577,
 37556,
 37048,
 36284,
 35010,
 33221,
 32455,
 30920,
 29641,
 28360,
 26823,
 25541,
 24002,
 22973,
 21687,
 20657,
 20392,
 20129,
 20129,
 0,
 22408,
 22402,
 22908,
 23674,
 24954,
 26236,
 25730,
 24965,
 23944,
 22919,
 22148,
 21890,
 0,
 29084,
 28822,
 29328,
 30348,
 31116,
 32399,
 32916,
 32921,
 32413,
 31650,
 30885,
 29858,
 29856,
 0,
 29281,
 30303,
 31328,
 32352,
 33378,
 34404,
 35175,
 35691,
 36464,
 36981,
 37243,
 37504,
 37254,
 37001,
 0,
 24958,
 25722,
 25472,
 24707,
 24704,
 0,
 31634,
 32150,
 31128,
 31379,
 32404,
 0,
 63727,
 63469,
 0,
 0 };

When adding this to a program, I suggest reformatting it to multiple numbers per line, using a source code style formatter such as AStyle.

Enjoy!
Attached Files
File Type: gz gmsigcap-1.0b.tar.gz (1.3 KB, 382 views)

Last edited by geekmaster; 05-16-2012 at 02:57 PM.
geekmaster is offline   Reply With Quote
Old 05-14-2012, 09:47 PM   #2
geekmaster
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
FYI: In the signature vector display list, the number 0 means "pen up" in this case. The other numbers all are connected by lines between the capture points. In the sample data above, the first group of numbers forms the large circle for the face. The second two groups are each a circle for the eyes. The third group is the smile. The fourth and fifth groups are fill-ins for the pupils of the eyes. The last group of numbers is the exit button touch and release -- you probably want to delete that group from your saved vector signature and artwork. The script ends with two zeros telling the program to stop drawing and go do other stuff.

The raw touchscreen data has values of 0-4095 for width and 0-4095 for height. Typical vector graphics that I plan to use can be represented with 0-255 values for width and height, so I rescale them so they can both pack into a 16-bit number (y*256+x).

You can look at the code in the "goodbye" function in the newtrix demo, to see how to use this data.

You can of course change the output to be more script friendly by removing the commas, if you prefer using this in variations on my "algorithmic art" scripts instead of my C demos.

Again, I hope you enjoy this and learn something new from it.

Comments are not only welcome -- they are required!


Last edited by geekmaster; 05-14-2012 at 09:53 PM.
geekmaster is offline   Reply With Quote
Old 05-15-2012, 02:29 AM   #3
Alexander Turcic
Fully Converged
Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.
 
Alexander Turcic's Avatar
 
Posts: 18,163
Karma: 14021202
Join Date: Oct 2002
Location: Switzerland
Device: Too many to count here.
Quote:
Originally Posted by geekmaster View Post
NOTE: Since mobileread upgraded their website software, code boxes and php boxes now insert extra garbage into the code when you click the save button. In the code listed below, please ignore that "amp;" in the "DT=" line. If I remove it, mobileread will just stick in more new ones when I save it. Very annoying new problem for mobileread. Unfortunately, I copied code from this editbox and those "amp;" things got into the sigcap-1.0a.tar.gz file too. New upload soon. EDIT: after I added the above paragraph, the one "amp;" in the code turned into THREE (and I did not even change the php box contents). Grrr. Bad mobileread website software! This was not a problem in the past.
Definitely going to look into that today!
Alexander Turcic is offline   Reply With Quote
Old 05-15-2012, 08:54 AM   #4
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by Alexander Turcic View Post
Definitely going to look into that today!
While fixing things - the login form is not international:
Quote:
Originally Posted by wed-dev
--
[07:51:51.159] A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element. @ https://www.mobileread.com/forums/forumdisplay.php?f=150
That's "forumdisplay.php" if you can't read the entire name.
EDIT 1:
Same problem with "new reply" -
Quote:
Originally Posted by web-dev
--
[07:54:26.491] A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element. @ https://www.mobileread.com/forums/new...eply&p=2081612
And this one is "newreply.php"
Edit 2:
Ah, but the "quick edit reply" does not use the windows-1252 character set - web-dev did not report the character set, so I assume the "quick edit reply" is using UTF-8.

Edit 3:
And then, if you choose the "go advanced" in the "quick edit reply" then you are back to windows-1252 character set.
Quote:
Originally Posted by web-dev
--
[08:02:20.348] A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element. @ https://www.mobileread.com/forums/edi...postid=2081839
This one is "editpost.php"
These differences may be part of the stray characters problem(s).

Last edited by knc1; 05-15-2012 at 09:10 AM.
knc1 is offline   Reply With Quote
Old 05-15-2012, 09:10 AM   #5
Alexander Turcic
Fully Converged
Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.
 
Alexander Turcic's Avatar
 
Posts: 18,163
Karma: 14021202
Join Date: Oct 2002
Location: Switzerland
Device: Too many to count here.
knc1, the forum software we're still using is not UTF-8 aware. It is not enough to simply convert the underlying database to UTF-8 and to change the HTML headers accordingly; all string-related operations need to be replaced too when byte count matters. We did a sandbox in the past doing all the changes ourselves, and it seemed to have worked, but honestly, since we are planning to switch the forum software as soon as a adequate candidate is in sight, we don't want to apply any more custom changes than necessary. It might get harder to upgrade to the other forum software otherwise. Finding the right forum software we could migrate to is a real nightmare.

I don't think the ampersand issue described here by geekmaster is related to character-set issues as the ampersand should be part of either character-set.
Alexander Turcic is offline   Reply With Quote
Old 05-15-2012, 09:18 AM   #6
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by Alexander Turcic View Post
I don't think the ampersand issue described here by geekmaster is related to character-set issues as the ampersand should be part of either character-set.
Since you have your hands on the code today anyway -
Then why not just make the quick edit reply use windows-1252 like the rest of the site?
That should only require adding the missing character set def to the form.
knc1 is offline   Reply With Quote
Old 05-15-2012, 09:49 AM   #7
Alexander Turcic
Fully Converged
Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.
 
Alexander Turcic's Avatar
 
Posts: 18,163
Karma: 14021202
Join Date: Oct 2002
Location: Switzerland
Device: Too many to count here.
Thanks knc1, it seems to be you are totally right. I was able to replicate the issue by posting above script via the quick reply form.
Alexander Turcic is offline   Reply With Quote
Old 05-15-2012, 09:55 AM   #8
geekmaster
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
I just removed all the "amp;" using firefox in linux, and the save button added one back again, so it appears to not be browser related, and it appears that you were able to reproduce the bug.

In my experience, reproducing a bug is critical to finding it, fixing it, and testing the fix. It will be nice to see this fixed. It is odd that I did not see this until I posted other toushscreen support code recently, and it seems to only affect that single line of code (which is common initialization code used in many of my scripts).

Thanks for looking into this. Looking forward to a fix.
geekmaster is offline   Reply With Quote
Old 05-15-2012, 11:40 AM   #9
geekmaster
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
I guess the easy workaround in my code to avoid this "amp;" problem is to remove the "break" from the loop, so it scans all events, instead of quitting when it finds the zforce (touchscreen) device.

The reason I scan for the zforce device is because it is a different device number depending on whether you booted from main or diags when using the touchscreen.

I wonder if the name "zforce" implies that it can read how much force is applied to the screen...

When pressing the screen with a soft fingertip, more "pixels" are covered as the fingertip flattens out. You can see this effect when you run the "zforcediag" program on the diags partition. Unfortunately, you have to boot to diags using mmcblk0p2_ssh, because zforcediag looks for the touchscreen input device in the wrong location when booting from main. From diags, run "/usr/local/bin/zforcediag", and you will see that if you read the touchscreen LED and photodiodes directly instead of using the input device I am using, you could even measure the diameter of a coin or other object laid (carefully) on the screen.

EDIT: Because the zforcediag program resides in the same directory as the dropbear files needed by SSH, the new 5.1.0 OTA updates probably delete this very useful diagnostic tool when they delete dropbear. Bad amazon! I plan to copy my /usr/local file to my usb drive to hide them from amazon.


Last edited by geekmaster; 10-09-2012 at 07:05 PM.
geekmaster is offline   Reply With Quote
Old 05-15-2012, 11:57 AM   #10
geekmaster
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
I decided to show you how zforcediag works. I want to use its low-level direct access to the touchscreen LEDs and photodiodes in my own code (I love getting closer to the "bare metal").

I rebooted to diags, and I started SSH from menu items N) U) Z) X), then I ran /usr/local/bin/zforcediag. Here is the output of zforcediag when I touch one finger, then two fingers, then release the first and then the second finger:
Spoiler:
Code:
# ./zforcediag
05/15/12 03:52:28 PM
*** X Leds ***
[0] 4 4   83 77
[1] 4 5   81 87
[2] 4 5   89 87
[3] 4 5   78 80
[4] 4 5   76 80
[5] 4 5   94 80
[6] 4 5   110 80
[7] 4 6   101 73
[8] 5 8   82 84
[9] 5 5   84 80
[10] 4 4   107 78
*** Y Leds ***
[0] 2 1   88 91
[1] 2 1   96 94
[2] 2 4   86 120
[3] 4 2   114 70
[4] 4 4   100 77
[5] 4 5   83 81
[6] 6 4   80 107
[7] 4 2   77 97
[8] 1 4   92 94
[9] 4 4   92 112
[10] 3 1   82 90
[11] 1 1   105 87
[12] 1 1   108 117
[13] 1 1   107 100
[14] 3 4   82 105
*** ***
05/15/12 03:52:31 PM
*** X Leds ***
[0] 4 5   81 77
[1] 15 15   37 4
[2] 15 8   7 75
[3] 5 5   91 81
[4] 5 5   78 76
[5] 4 5   95 78
[6] 4 5   114 75
[7] 4 6   81 75
[8] 5 8   78 88
[9] 5 5   80 82
[10] 4 4   104 81
*** Y Leds ***
[0] 2 1   77 89
[1] 2 1   90 92
[2] 2 4   86 117
[3] 4 2   110 74
[4] 4 4   96 82
[5] 4 5   80 85
[6] 6 4   78 107
[7] 4 1   76 81
[8] 1 4   91 96
[9] 4 4   98 115
[10] 2 1   83 98
[11] 1 2   110 88
[12] 15 15   0 1
[13] 4 1   60 95
[14] 3 4   75 104
*** ***
05/15/12 03:52:34 PM
*** X Leds ***
[0] 4 5   82 77
[1] 15 15   57 3
[2] 15 15   2 28
[3] 7 5   74 80
[4] 4 5   75 76
[5] 4 5   94 95
[6] 4 6   108 73
[7] 4 12   94 85
[8] 15 15   1 3
[9] 8 5   68 72
[10] 4 4   103 80
*** Y Leds ***
[0] 2 1   92 93
[1] 2 1   83 95
[2] 2 15   78 103
[3] 15 15   3 63
[4] 4 4   90 79
[5] 4 5   83 84
[6] 5 4   76 110
[7] 4 1   77 82
[8] 1 4   91 97
[9] 4 3   98 70
[10] 2 1   80 102
[11] 1 4   87 99
[12] 15 15   0 0
[13] 4 1   79 97
[14] 3 4   82 106
*** ***
05/15/12 03:52:37 PM
*** X Leds ***
[0] 4 4   82 77
[1] 4 5   81 88
[2] 4 5   85 79
[3] 4 5   80 81
[4] 4 5   76 82
[5] 4 5   88 88
[6] 4 6   107 74
[7] 4 9   94 85
[8] 15 15   1 2
[9] 9 5   73 72
[10] 4 4   102 78
*** Y Leds ***
[0] 2 1   86 91
[1] 2 1   83 93
[2] 3 15   70 89
[3] 15 6   10 80
[4] 4 4   90 79
[5] 4 5   85 82
[6] 5 4   74 115
[7] 4 2   76 85
[8] 1 4   85 95
[9] 4 4   99 111
[10] 3 1   89 97
[11] 1 1   103 92
[12] 1 1   98 71
[13] 1 1   110 97
[14] 3 4   72 108
*** ***
05/15/12 03:52:40 PM
*** X Leds ***
[0] 4 4   84 78
[1] 4 5   81 75
[2] 4 5   93 84
[3] 4 5   81 82
[4] 4 5   77 82
[5] 4 5   94 86
[6] 4 5   111 82
[7] 4 6   103 80
[8] 5 8   81 83
[9] 5 5   78 81
[10] 4 4   105 77
*** Y Leds ***
[0] 2 1   82 90
[1] 2 1   85 94
[2] 2 4   86 72
[3] 4 2   111 78
[4] 4 4   104 79
[5] 4 5   80 81
[6] 6 4   74 105
[7] 4 1   76 79
[8] 1 4   87 95
[9] 4 4   97 112
[10] 2 1   76 91
[11] 1 1   100 80
[12] 1 1   95 108
[13] 1 1   99 101
[14] 3 4   76 108
*** ***
^C

Here is the output of "strace zforcediags", while I touch the screen two times:
Spoiler:
Code:
# /mnt/us/strace zforcediag
execve("/usr/local/bin/zforcediag", ["zforcediag"], [/* 18 vars */]) = 0
restart_syscall(<... resuming interrupted call ...>pid 1451 stray syscall entry
 <unfinished ...>
brk(0)                                  = 0x12000
uname({sys="Linux", node="[192_168_15_244]", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40017000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=37047, ...}) = 0
mmap2(NULL, 37047, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40021000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\301V\1\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=988620, ...}) = 0
mmap2(NULL, 1025308, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x4002b000
mprotect(0x40118000, 32768, PROT_NONE)  = 0
mmap2(0x40120000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xed) = 0x40120000
mmap2(0x40123000, 9500, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40123000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40019000
syscall_983045(0x40019570, 0x4002091c, 0x40019c48, 0x40019570, 0x40020000, 0x40018eb0, 0x40020050, 0xf0005, 0x11, 0x50, 0x1, 0x87c, 0, 0xbefa4968, 0x40001c45, 0x40010d56, 0x30, 0x40019570, 0, 0, 0xc764, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) = 0
mprotect(0x40120000, 8192, PROT_READ)   = 0
mprotect(0x4001f000, 4096, PROT_READ)   = 0
munmap(0x40021000, 37047)               = 0
open("/dev/zforce", O_RDWR)             = 3
setitimer(ITIMER_REAL, {it_interval={3, 0}, it_value={3, 0}}, NULL) = 0
rt_sigaction(SIGALRM, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGALRM, {0x8868, [], 0x4000000 /* SA_??? */}, NULL, 8) = 0
pause()                                 = ? ERESTARTNOHAND (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
sigreturn()                             = ? (mask now [QUIT TRAP BUS KILL ALRM TERM STKFLT CONT SYS])
ioctl(3, 0x5a07, 0)                     = 0
ioctl(3, ITE_GPIO_OUT, 0xbefa4b14)      = 0
gettimeofday({1337096929, 402478}, NULL) = 0
brk(0)                                  = 0x12000
brk(0x33000)                            = 0x33000
open("/etc/localtime", O_RDONLY)        = -1 ENOENT (No such file or directory)
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001a000
write(1, "05/15/12 03:48:49 PM\n", 2105/15/12 03:48:49 PM
)  = 21
write(1, "*** X Leds ***\n", 15*** X Leds ***
)        = 15
write(1, "[0] 4 4   82 78\n", 16[0] 4 4   82 78
)       = 16
write(1, "[1] 4 5   82 80\n", 16[1] 4 5   82 80
)       = 16
write(1, "[2] 4 5   90 80\n", 16[2] 4 5   90 80
)       = 16
write(1, "[3] 4 5   82 82\n", 16[3] 4 5   82 82
)       = 16
write(1, "[4] 4 5   79 82\n", 16[4] 4 5   79 82
)       = 16
write(1, "[5] 4 8   98 72\n", 16[5] 4 8   98 72
)       = 16
write(1, "[6] 15 15   5 4\n", 16[6] 15 15   5 4
)       = 16
write(1, "[7] 15 8   32 76\n", 17[7] 15 8   32 76
)      = 17
write(1, "[8] 5 8   80 86\n", 16[8] 5 8   80 86
)       = 16
write(1, "[9] 5 5   79 85\n", 16[9] 5 5   79 85
)       = 16
write(1, "[10] 4 4   107 84\n", 18[10] 4 4   107 84
)     = 18
write(1, "*** Y Leds ***\n", 15*** Y Leds ***
)        = 15
write(1, "[0] 2 1   77 94\n", 16[0] 2 1   77 94
)       = 16
write(1, "[1] 2 1   82 89\n", 16[1] 2 1   82 89
)       = 16
write(1, "[2] 2 4   78 120\n", 17[2] 2 4   78 120
)      = 17
write(1, "[3] 4 2   108 83\n", 17[3] 4 2   108 83
)      = 17
write(1, "[4] 4 4   109 82\n", 17[4] 4 4   109 82
)      = 17
write(1, "[5] 4 5   85 85\n", 16[5] 4 5   85 85
)       = 16
write(1, "[6] 5 4   80 102\n", 17[6] 5 4   80 102
)      = 17
write(1, "[7] 9 15   82 7\n", 16[7] 9 15   82 7
)       = 16
write(1, "[8] 15 15   0 1\n", 16[8] 15 15   0 1
)       = 16
write(1, "[9] 15 4   39 97\n", 17[9] 15 4   39 97
)      = 17
write(1, "[10] 3 1   73 90\n", 17[10] 3 1   73 90
)      = 17
write(1, "[11] 1 1   100 91\n", 18[11] 1 1   100 91
)     = 18
write(1, "[12] 1 1   90 74\n", 17[12] 1 1   90 74
)      = 17
write(1, "[13] 1 1   68 70\n", 17[13] 1 1   68 70
)      = 17
write(1, "[14] 3 4   71 106\n", 18[14] 3 4   71 106
)     = 18
write(1, "*** ***\n", 8*** ***
)                = 8
pause()                                 = ? ERESTARTNOHAND (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
sigreturn()                             = ? (mask now [QUIT TRAP BUS KILL ALRM TERM STKFLT CONT SYS])
ioctl(3, 0x5a07, 0)                     = 0
ioctl(3, ITE_GPIO_OUT, 0xbefa4b14)      = 0
gettimeofday({1337096932, 396310}, NULL) = 0
open("/etc/localtime", O_RDONLY)        = -1 ENOENT (No such file or directory)
write(1, "05/15/12 03:48:52 PM\n", 2105/15/12 03:48:52 PM
)  = 21
write(1, "*** X Leds ***\n", 15*** X Leds ***
)        = 15
write(1, "[0] 4 4   85 78\n", 16[0] 4 4   85 78
)       = 16
write(1, "[1] 4 5   80 73\n", 16[1] 4 5   80 73
)       = 16
write(1, "[2] 8 15   79 11\n", 17[2] 8 15   79 11
)      = 17
write(1, "[3] 15 9   5 82\n", 16[3] 15 9   5 82
)       = 16
write(1, "[4] 5 5   80 73\n", 16[4] 5 5   80 73
)       = 16
write(1, "[5] 4 5   95 90\n", 16[5] 4 5   95 90
)       = 16
write(1, "[6] 4 5   108 76\n", 17[6] 4 5   108 76
)      = 17
write(1, "[7] 4 6   100 75\n", 17[7] 4 6   100 75
)      = 17
write(1, "[8] 5 8   72 83\n", 16[8] 5 8   72 83
)       = 16
write(1, "[9] 5 5   80 81\n", 16[9] 5 5   80 81
)       = 16
write(1, "[10] 4 4   106 78\n", 18[10] 4 4   106 78
)     = 18
write(1, "*** Y Leds ***\n", 15*** Y Leds ***
)        = 15
write(1, "[0] 2 1   86 93\n", 16[0] 2 1   86 93
)       = 16
write(1, "[1] 2 1   78 85\n", 16[1] 2 1   78 85
)       = 16
write(1, "[2] 2 3   83 70\n", 16[2] 2 3   83 70
)       = 16
write(1, "[3] 4 2   110 75\n", 17[3] 4 2   110 75
)      = 17
write(1, "[4] 4 4   100 83\n", 17[4] 4 4   100 83
)      = 17
write(1, "[5] 4 5   83 85\n", 16[5] 4 5   83 85
)       = 16
write(1, "[6] 6 4   77 107\n", 17[6] 6 4   77 107
)      = 17
write(1, "[7] 4 2   75 96\n", 16[7] 4 2   75 96
)       = 16
write(1, "[8] 1 4   92 95\n", 16[8] 1 4   92 95
)       = 16
write(1, "[9] 4 3   102 68\n", 17[9] 4 3   102 68
)      = 17
write(1, "[10] 2 1   77 92\n", 17[10] 2 1   77 92
)      = 17
write(1, "[11] 1 4   96 91\n", 17[11] 1 4   96 91
)      = 17
write(1, "[12] 15 15   1 0\n", 17[12] 15 15   1 0
)      = 17
write(1, "[13] 15 15   2 72\n", 18[13] 15 15   2 72
)     = 18
write(1, "[14] 4 4   99 109\n", 18[14] 4 4   99 109
)     = 18
write(1, "*** ***\n", 8*** ***
)                = 8
pause(^[^C <unfinished ...>

Being able to determine what coin is (gently) placed on the screen by measuring its diameter would be a cool hack.

EDIT: By comparing the output of zforcediags to the 0-4095 outputs from the zforce event input device, you can see that they interpolate the touch centroid from the proportional "blocked light" values of the outermost blocked sensors. From my testing, it appears that they really DO get 4K pixel accuracy this way (which is why they patented it). You can roll your fingertip on the screen to see subpixel movements. I am curious why amazon is switching to capacitive touchscreens on future kindles -- perhaps to use a thinner bezel so the K5 can be as thin as the K4 (but more likely for cost savings).

EDIT 2: You can see in the first output listing how two finger touches cast shadows forming a rectangle, making it difficult to determine where the two fingers really are without tracking movement history. In fact, the finger positions returned by the event device driver DO get confused and swap half the coordinate pair between fingers when you rotate two fingers on the screen across a common X or Y coordinate. This makes the finger positions reported suddenly jump to the "other" corners of the rectangle. I know how to compensate for this by using velocity tracking instead of position tracking (and in fact it does appear to be fixed in a recent update to the main code trunk for the linux touchscreen driver, but not in the version used in the kindle). Even though the coordinates reported may be for the wrong corners of the rectangle, they are still useful for pinch and stretch gestures, because both diagonals of a rectangle are the same length. I can resize an animated vector object (such as my signature vector) easily enough, but rotating it past a horizontal or vertical axis is difficult unless I add two-finger velocity tracking and "corner swap" correction (and that hack could break if they ever DO fix this problem, and preventing unwanted future behavior adds to the code complexity).


Last edited by geekmaster; 05-15-2012 at 02:42 PM.
geekmaster is offline   Reply With Quote
Old 05-15-2012, 01:47 PM   #11
deep
Enthusiast
deep began at the beginning.
 
Posts: 29
Karma: 10
Join Date: May 2012
Device: Kindle Touch
Just registered to say how awesome you are geekamaster (I admit I'm not the first !).
Appreciate the way you do your stuff man
Been downloading all your kindle touch codes lately. I would definitely love to work on them, unfortunately I'm always outta time.
Expecting better touch interaction and finger gestures for kindlets from your findings !
Keep rocking geekmaster !
deep is offline   Reply With Quote
Old 05-16-2012, 07:28 AM   #12
Alexander Turcic
Fully Converged
Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.Alexander Turcic ought to be getting tired of karma fortunes by now.
 
Alexander Turcic's Avatar
 
Posts: 18,163
Karma: 14021202
Join Date: Oct 2002
Location: Switzerland
Device: Too many to count here.
Quote:
Originally Posted by Alexander Turcic View Post
Definitely going to look into that today!
I believe the issue has been fixed. It was triggered by the &&break; in geekmaster's code. An over-simplified regular expression in our Ajax handling code considered this piece a valid HTML entity and therefore decided to encode it into &&amp;break;. We replaced the regular expression with something more robust.
Alexander Turcic is offline   Reply With Quote
Old 05-16-2012, 09:24 AM   #13
geekmaster
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by Alexander Turcic View Post
I believe the issue has been fixed. It was triggered by the &&break; in geekmaster's code. An over-simplified regular expression in our Ajax handling code considered this piece a valid HTML entity and therefore decided to encode it into &&amp;break;. We replaced the regular expression with something more robust.
Thank you.
geekmaster is offline   Reply With Quote
Old 10-06-2012, 05:02 PM   #14
geekmaster
Carpe diem, c'est la vie.
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: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
This program partially works on the Paperwhite, but has some issues that need fixing. The name of the touchscreen device changed from zforce to cyttsp, so I need to change the code that searches for it in the input devices:

I needed to change this:
DT=$(for i in /dev/input/event*;do evtest info $i|grep zforce>$DN&&echo $i&&break;done)

to this:
DT=$(for i in /dev/input/event*;do evtest info $i|grep -w "zforce\|cyttsp">$DN&&echo $i&&break;done)

Also, the eips text output needs to be reformatted. On the K5 and earlier you had 40 lines of 50 characters. But on the Paperwhite, you havee 42 lines of 48 characters. Not only is the line 2 characters narrower, but you can only see the left half of the last character on the line. So practically speaking, in text mode, the new higher resolution eink screen cannot display the rightmost 3 characters of lines that displayed fine on earlier kindles.

Here are the screen dimensions reported by eips:
Code:
[root@kindle root]# eips -i

Fixed framebuffer info
    id:              mxc_epdc_fb    smem_start:       0x75800000
    smem_len:            4718592    type:          PACKED_PIXELS
    type_aux:                  0    visual:   STATIC_PSEUDOCOLOR
    xpanstep:                  1    ypanstep:                  1
    ywrapstep:                 0    line_length:             768
    mmio_start:       0x00000000    mmio_len:                  0
    accel:                     0

Variable framebuffer info
    xres:                    758    yres:                   1024
    xres_virtual:            768    yres_virtual:           6144
    xoffset:                   0    yoffset:                   0
    bits_per_pixel:            8    grayscale:                 1
    red.offset:                0    green.offset:              0
    red.length:                8    green.length:              8
    red.msb_right:             0    green.msb_right:           0
    blue.offset:               0    transp.offset:             0
    blue.length:               8    transp.length:             0
    blue.msb_right:            0    transp.msb_right:          0
    nonstd:                    0    activate:                128
    width:                    -1    height:                   -1
    accel_flags:               0    pixclock:           40000000
    left_margin:              12    right_margin:             76
    upper_margin:              4    lower_margin:              5
    hsync_len:                12    vsync_len:                 2
    sync:                      0    vmode:                     0
    rotate:                    3
[root@kindle root]# 
As you can see, it is 8 bits-per-pixel, just like the K4 and K5. It is not 4bpp as reported in another thread.

Last edited by geekmaster; 10-09-2012 at 10:12 PM.
geekmaster is offline   Reply With Quote
Old 10-06-2012, 05:13 PM   #15
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
I think you can fix that 1/2 character if you make a change that solves:
xres = xres_virtual - left_margin
But that may be hardcoded in the driver, I have not looked at the code.
I.E: left_margin = 10 dot clocks not 12 dot clocks might work.

If I had one in front of me, the first thing I would do is try a: modinfo command on that driver module to see what can be passed to it as options at load time.

- - - -

If the above does not help,
Take another look at that report - the math there does not look right, but I may have missed the exact point of the problem.

For the purpose of reading that report, think of it as trying to describe the components of a video scan line. (left over from when the drivers/hardware did generate scan lines)

Last edited by knc1; 10-06-2012 at 05:18 PM.
knc1 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
geekmaster simple touchscreen script support hack geekmaster Kindle Developer's Corner 12 04-21-2021 11:38 PM
I'd help HER capture Moose and Squirrel! ardeegee Lounge 2 06-29-2010 12:17 PM
Trying to Capture Rebecca andavane Calibre 4 10-26-2009 01:47 PM


All times are GMT -4. The time now is 05:04 PM.


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