Wednesday, 31 January 2007

HP48 Skin for M3100 / Hermes

Here is horizontal (landscape) skin for Christoph Gießelink’s PPC HP48 emulator.
See: http://privat.swol.de/ChristophGiesselink/emu48.htm

The skin is for the HTC Hermes model phone running WM5 in keyboard-open mode, to support use without the need to touch the screen at all.

Installation

Just download the zipfile and unzip in your emu48 directory and start a new emulator session with HP48-m3100-horizontal.kml

The bitmap and layout is based on the PPC skin done by Dave / Murray.

This is landscape but not in the same sense as Dave / Murray landscape which is landscape on a portrait screen. Hermes keyboard-open mode is a landscape screen.  When the keyboard is closed and the Hermes resizes the screen to be portrait, it all goes skewy. Really we need to be able to switch between two different skins when they keyboard is opened or closed.

I had to take a few pixel rows out of their layout to make it fit.

Anyway….

I also fixed up the scan-code conversions to deal with the Hermes keyboard, so some Hermes specific keystrokes work as expected, like ! and - and _.

Some new mappings

The TAB key is mapped as the ALPHA key.
The SYMBOL-UP is mapped as SHIFT-R
The SYMBOL-DOWN is mapped as SHIFT-L
(Symbol is the key with a round DOT).

Sadly I could not map SYMBOL-LEFT or RIGHT, because the emulator does not intercept these and probably can’t unless it is signed as a privileged application.

BONUS

Included is an XML based build system to make skin building easier.

I used kimagemapeditor to add hotspot rectangles to my bitmap and then my build-system created the button and annunciator layout file for me. This greatly speeds up the process when modifying or designing new skins.

Note that the kml file Includes a a kmp file which includes all the button positional information, and also a kmi file containing scan-code mappings and fixups.

I generated the kml file like this:

xsltproc HP48-generate.xslt HP48-m3100-horizontal.htm > HP48-m3100-horizontal.kmp

xsltproc comes with gnome on my Ubuntu linux. Maybe there is a windows xslt processor that could do this too??

Of course that htm file has to be valid xml too, I had to make the img tag self-closing.

The xslt relies on HP48-attributes.xml, that defines the annunciators and keys that the emulator expects.

The id attributes refer to the numbers in the Annunciator or Button statements, and the name attributes refer to the anchors in the html.

Annunciator anchoes begin with #~- to show where the annunciator should be displayed, and #~+ to show where they should be copied from.

Buttons, of course have only one imagemap entry.

TO-DO

Add scan-code conversions for a lot of the accented characters.

I intend to make this fun by having an HP48 specific xml which defines HP48 button sequences needed to generate each ascii character. I then intend to have a host-specific xml which specifies the scan-codes generated during the entry of each ascii character.  I shall spot multi-scan-code sequences, and automatically allocate flags and generate IfFlag code.

Thus, with a fixed calculator specific button-code-map, a per-skin bitmap and imagemap, and a per-platform scan-code specification, I can generate any skin for any calculator emulator on any platform. Hurrah!

Find out or write IfAnnunciator for the kml scripts.

Thursday, 19 October 2006

Counting nodes

I had a problem where I needed to assign a unique integer to each node in a tree, as it was processed; using XSLT 1.0

XSLT 1.0 doesn’t have user definable functions, the only way to return values is as output which can be captured in an

<xsl:variable name="captured"><xsl:call-template name="generate-output"/></xsl:variable>

And, naturally, the tree recursion was already generating output and could not easily be used to return a count of nodes processed so far as well.

After a couple of hours of struggling and some syntax checking with my brother Ben (for things like $node/ancestors::* - thanks bro) we have a fragment that does the trick in one line!

count($node/preceding::rule[ancestor::*[generate-id()=$ancestorid]])

This is more clearly excodessed as:

count($node/preceding::rule[count(ancestor::*[generate-id()=$ancestorid])])

and in english reads as: to find the sequence number for $node, count all preceding nodes who are contained by the common ancestor identified by $ancestorid. Without the codedicate, it would count all preceding nodes in the entire document, instead of those with a certain ancestor.

However this is not complete. preceding does not take into account open nodes, i.e. the node to which it is being applied, nor any of it’s ancestors; so this correction is added:

+ count($node/ancestor::rule) - count($ancestor/ancestor::rule)

as the number of non-counted nodes is clearly the difference between the number of ancestors of $node, and the number of ancestors of $ancestor.

The full statement is:

count($node/preceding::rule[ancestor::*[generate-id()=$ancestorid]])

+ count($node/ancestor::rule) - count($ancestor/ancestor::rule)

I leave it to the reader to produce a version that reports the total number "rule" nodes under the current ancestor.

Finally I used this recipe:


  <xsl:template name="rule-number">
    <xsl:param name="name"><xsl:message terminate="yes">rule-number called without name</xsl:message></xsl:param>
    <xsl:param name="rules-node" select="//dbam-bandwidth-rules"/>
    <!– take the first occurance of each rule (no preceding of same ancestor) –>
    <xsl:variable name="all_rules" select="$rules-node//rule[not(@name = preceding::rule[count(ancestor::*[generate-id()=generate-id($rules-node)]) &gt; 0]/@name)]"/>
    <xsl:for-each select="$all_rules">
      <xsl:if test="@name=$name"><xsl:value-of select="position()"/></xsl:if>
    </xsl:for-each>
  </xsl:template> 

Tuesday, 3 October 2006

Kenneth Cope

Greater Than us All is a great album.

I just shelled out some dosh (hard earned cash) to buy the CD version having played my casstte album to oblivion.

I was interested to see some tracks were re-recorded; and it comes to this:

Do you have an original CD album you could send me?

I don’t like the new recordings. They are not what my mind has become adjusted to, and even worse it starts to follow a trend set by the mormon tabernacle choir which seems to be to put inappropriate expression into the performance.

I probably should explain this last accusation a bit more, and I’ll use the tabernacle choir to explain.

I think the choir get bored singing the same old hymns and such so they try and jazz them up and put a bit more emotion into it, but that doesn’t make it better, it only makes it weird. Oh, but its probably more fun to sing.

(Did I mention I’m finding it hard to get decent mo-tab music lately? I’m thinking of downloading all the conferences and ripping the choir out of the middle ot build up a new compilation).

I want "Mo-tab: The same boring old hymns" type stuff, you know, "like momma used to bake" so to speak.

Now you haven’t done a bad job on the new cut of Greater Than Us All, but you are following the trend; a bit more unexpected desparation or wonder in the voice, delay the vocalists entry slightly by half a beat, drag out a middle phrase note for no good reason, it drives me mad. Not every phrase of the song needs to sound like some kind of epiphany or revelation; the song has to do that as a whole, but these days each phrase is trying to compete with the whole song.

It ends up sounding like the emotional expression of some other song overlayed onto this one. (Its nice variety for folk who have sung the song to death no doubt)

Please, be a nice man and send me what you hooked me on, not this slghtly freaky stuff. I like my music straight: A CD of your original cut of Greater Than Us All.

Thursday, 31 August 2006

ASCII character conversion

The od command can be used after a fashion to convert from a character to its character code:

 echo -ne "A" | od -t u1 | sed -e "s/^[0-9]* *//"

But more awkward is converting from a decimal character code back to the character, but this does the trick, and took about 3 minutes to come up with:

$ X=65
$ HEX=(0 1 2 3 4 5 6 7 8 9 a b c d e f)
$ echo -e "x${HEX[$(( $X / 16))]}${HEX[$(( $X % 16 ))]}"


It works by converting which is less than 255 to hexadecimal, and then making use of echo -e which interprets \x as indicating an 8 bit character expressed in hexadecimal.

Tuesday, 1 August 2006

Online Textbooks


Like many geeks I collect knowledge so that I will be able to do things if the need comes up, whatever things they are. Here’s a good list of refererences books supplied by nTensify who wrote:

There are a lot of free textbooks out there, some of them are better than others, but a lot are quickly becoming very good.

Plain and simple, everyone should have access to education, money shouldn’t dictate how educated someone can become.

Some other free books:
http://www.physicsforfree.com/ (three physics books from beginning physics to general relativity).
http://www.lightandmatter.com/area1.html (six physics books, variety of topics)
http://www.motionmountain.net/ (notably one of the best free physics books ever "published").
http://www.math.wisc.edu/~keisler/calc.html (intro to calc book under Creative Commons)
http://www.allaboutcircuits.com/ (a really cool free circuit design book I ran across a few years ago when I was leaving college).
http://www.gutenberg.org/ (obligatory gutenburg link, aggrigator of books out of copyright or otherwise set free).

(there are plenty more, but to spare you the boredom of a huge list here… go to google and search for digital library books, you’ll have a few million hits to look through ;) )

Thursday, 29 June 2006

Smart Programmer, Smart Doctor


A smart programmer who can’t sleep and is told by his doctor to count sheep, will write a small shell script to do it for him.

The smart doctor will write a shell script to tell programmers who can’t sleep to count sheep.

A colleague pointed out that if I were a smart programmer I would have written a shell script to tell the joke. Instead I write it up on my blog, what does that say?

Of dweebs, nerds and geeks

munpfazy posted on slashdot, an excellent precis on the hierachy of dweebs, nerds and geeks.

Because I’m slack, I copy it here as well; read on:

Re:Clasic anti Nerd Propiganda


by munpfazy (694689) on Wednesday June 28, @01:40AM (#15618760)

Nonsense, I say. Worse still - blasphemy! To place the nerds above the geeks is an offense of the worst kind.

There *is* a clear distinction and a value hierarchy among geeks, nerds, and dweebs, but you’ve got it all wrong.

What follows, I claim, is the one true classification of geekdom. It has stood up to rigorous peer review (loud arguments amongst drunken physics students) for years, and I stand by it.

A dweeb is someone without social skills who either doesn’t recognize or is unable to accept that they are unusual. They constantly *try* to fit in, with disastrous results, and dedicate a significant portion of their daily lives to obsessing over how to pass as normal.

A nerd is someone without social skills or popular interests who recognizes that he or she is unlike most people and feels no shame in it.

A geek is a nerd with technical skills and passionate interests; in particular one who has a myopic dedication to a particular specialty. (This is the subspecies *true geek,* distinct from but related to the *common geek,* or nerd who is generally technically savvy and useful to have around.)

To summarize, the dweeb is the guy wearing a slightly out of fashion hipster shirt who generally creates embarrassing silences at parties by saying awkward things about pop stars or sports teams.

The nerd is the guy who skips the party in order to achieve moderately high scores on a popular video game while eating unheated canned peas with a spoon and listening to recordings of experimental music.

The geek is the guy who skips the party in order to code a popular video game, figure out the angle of repose one might expect for a pile of canned peas, or compose and record some experimental music.

On the college campus, geeks make up virtually the entire population of physics and math majors (as well as a majority in classics, many of the less trendy engineering sub-disciplines, linguistics, physical anthropology, and some of the more obscure languages.)

The nerds are the guys who drop out of school after one semester but stay in a college town working in a bookstore, where they get great discounts on whatever genre books they happen to like and talk to their geek friends about writing their own books yet never seem to actually finish any of them.

The dweebs largely end up in engineering or the quantitative business disciplines, in the hopes that they can earn enough money to buy the respect of powerful and attractive people. Those in engineering have a tough time of it, as they are publicly ignored by the normals whom they so admire while simultaneously earning the scorn and contempt of the geeks in their departments. Those in business do rather well, since they have a good chance at fooling their colleagues into thinking that they are geeks. (Normals may not invite geeks to parties, but they do like to hire them.)