Keypads

From Hackspire
Revision as of 11:18, 17 August 2012 by ExtendeD (talk | contribs) (Replace caps with shift)
Jump to navigation Jump to search

Key maps

Each bit in the 900E0010-900E001F registers represents a key. If the bit is cleared, the key is being pressed. Only bits 0 to 10 are used in each halfword. The mapping depends on the currently used keypad.

Clickpad keypad map:

offset bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10
0010 ret enter space (-) Z . Y 0 X on theta
0012 , + W 3 V 2 U 1 T e^x pi
0014 ? - S 6 R 5 Q 4 P 10^x EE
0016 : * O 9 N 8 M 7 L x^2 i
0018 " / K tan J cos I sin H ^ >
001A ' cat G ) F ( E var D shift <
001C flag click C home B menu A esc | tab
001E up u+r right r+d down d+l left l+u del ctrl =

TI-84+ keypad map:

offset bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10
0010 down left right up
0012 enter + - * / ^ clear
0014 (-) 3 6 9 ) tan vars
0016 . 2 5 8 ( cos prgm stat
0018 0 1 4 7 , sin apps X
001A on sto ln log x^2 x^-1 math alpha
001C graph trace zoom wind y= 2nd mode del
001E

Touchpad keypad map:

offset bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 8 bit 9 bit 10
0010 ret enter (-) space Z Y 0 ?!
0012 X W V 3 U T S 1 pi trig 10^x
0014 R Q P 6 O N M 4 EE x^2
0016 L K J 9 I H G 7 / e^x
0018 F E D C B A = * ^
001A var - ) . ( 5 cat frac del scratch
001C flag + doc 2 menu 8 esc tab
001E shift ctrl ,

Touchpad I²C

Communication with the actual touchpad is done with the I²C protocol: GPIO 1 is the Serial Clock (SCL) and GPIO 3 is the Serial Data Line (SDA). The touchpad responds to messages with address 0x20. A write message consists of the first port to write to, followed by the values to write: the port number auto-increments, so a message of 00 de ad writes de to port 00 and ad to port 01. A read message reads from whatever port was set by the previous write message, so it generally has to be preceded by an empty write to set the port.

A list of the touchpad's ports follows. All 16-bit numbers are big-endian.

  • Any page:
    • FF: Page number
  • Page 04 (default):
    • 00: Contact (usually is 01 if proximity >= 0x2F, 00 otherwise)
    • 01: Proximity
    • 02-03: X position
    • 04-05: Y position
    • 06: X velocity
    • 07: Y velocity
    • 0A: 1 if touchpad pressed down, 0 if not
    • 0B: Status (reading this clears the low bits)
      • Bit 0 (0x01): Set when proximity is nonzero
      • Bit 1 (0x02): Set when velocity bytes are nonzero
      • Bit 2 (0x04): Set when unknown byte at 08 is nonzero
      • Bit 3 (0x08): Set when pressed byte has changed
      • Bit 6 (0x40): Always set? (If it's not set, the OS's interrupt handler overflows the stack and crashes)
    • E4-E7: Firmware version
  • Page 10:
    • 04-05: Maximum X coordinate (0x0918)
    • 06-07: Maximum Y coordinate (0x069B)

Keypad Connector

The Connector joining the keypads to the nspire itself has a very basic design concept: There are a bunch of GPIO pins, VCC, and GND. The OS memory-maps the pins to the bit chart seen above, using half as input, half as output. The same pins the touchpad uses for its I2C connection are used for buttons on the clickpad.

The pins are as follows: 1. Ground 2. Vcc 3-30. GPIO pins, alternating Column-Row-Column-Row

On the 84+ Pad: Pin 23 = Link port wire 1 Pin 25 = Link port wire 2


The OS is constantly doing iskeypressed() on all the keys, so the pins end up looking like a square wave if read by a 'scope. Input pins only show the wave if one of their buttons is pressed, but output pins show the whole wave regardless.

If you can't envision how the keys actually work yet, this might help: All the buttons have 2 connectors, that get shorted when they are pressed. The bits in the table above represent columns of buttons. It's not layed out perfectly because it has more than 8 buttons per column, so it gets offset strangely. The bits in the offsets (the rows) represent rows of buttons.

The columns are each hooked to one Input pin. The rows are each hooked to one output pin. The calculator turns on One output pin, and looks for any signals on the inputs. If there are any, it records the button that matches the input pin and that column. It then repeats this process for all the other columns, and the iskeypressed() process is complete.

If this doesn't make any sense still, email me (willrandship at gmail dot com) and I'll see if I can help. --William Shipley 05:38, 16 September 2011 (CEST)