bj.1. GLCD I2C slave functionality

Touchscreen has three 16-bit registers: pressure, x and y. The registers are accessible on address 0x30 (default setting) as registers 5,6 and 7. Register 5 holds current register number:

Touchscreen support

PIC.SWI2C_WriteReg(0x34,0,1) .. clears display and displays registers contents

PIC.SWI2C_WriteReg(0x31,2,0x41) .. writes double sized letter A to current display (x,y) position and increases y by 2, if y<14

PIC.SWI2C_WriteReg(0x33,0,0) .. clears display

PIC.SWI2C_WriteReg(0x31,0,0x41) .. writes normal letter A to current display (x,y) position and increases y by 1, if

y<15

PIC.SWI2C_WriteReg(0x30,1,2) .. sets current display x position to 2

PIC.SWI2C_WriteReg(0x30,0,1) .. sets current display x position to 1

Examples:

SWI2C_ReadReg(address as Byte, register number as Byte) function can optionally be used to read back a register content.

SWI2C_WriteReg(address as Byte, register number as Byte, value as Byte) function is used to send text data to the GLCD. See the table on the right hand side.

PIC18F4550 firmware 2.7.2 (for GLCD) supports I2C slave functionality. Any I2C master device that supports I2C clock stretching can use GLCD functionality via I2C interface. PIC18F4550 firmware 2.7.2 (for GLCD) has a default I2C address range from 0x30 to 0x37. The range may be moved with PC USB HEX Editor v3.0.

0x33 1 0 .. 1 Turns GLCD on (1) or off (0).

0x33 2 0 .. 1 Turns GLCD backlight on (1) or off (0)

0x31 Style ASCII code Displays an ASCII character on (x,y) display position*

0x32 Style byte Displays a byte in HEX on (x,y) display position*

0x33 0 0 .. 255 Fills the display with an arbitrary byte value.

0 clears the display.

0x30 9 0 ... 63 Pixel graphics: current x2 position (vertical)

0x30 10 0 ... 127 Pixel graphics: current y2 position (horizontal)

PIC18F4550 firmware v2.7.2 for GLCD I2C slave registers:

Address: Register: Value: Description:

0x30 0 0 ... 7 GLCD current x position (vertical, line number)

0x30 1 0 ... 15 GLCD current y position (horizontal)

0x30 2 0 ... 16 character buffer counter

0x30 3 0 ... 63 Pixel graphics: current x1 position (vertical)

0x30 4 0 ... 127 Pixel graphics: current y1 position (horizontal)

0x30 5 0 .. 2 Touchscreen register selection (0 = pressure, 1 = x, 2 = y)

0x30 6 0 .. 255 Touchscreen register register high byte

0x30 7 0 .. 255 Touchscreen register register low byte

0x30 8 0 .. 4 Current character fonts

Both x and y positions are absolute and have to be calibrated in accordance with the GLCD useful display area. The default threshold is 100 and it can be altered with PC USB Projects HEX Editor v3.0.

Each register holds a 10-bit value obtained by A/D conversion. Pressure value indicates the amount of pressure that is applied to the touch screen. If the amount of pressure is lower than threshold pressure, all the registers reset to 0. x position register holds a 10-bit value that corresponds to horizontal position of the point where pressure is applied to the touchscreen. y position register holds a 10-bit value that corresponds to vertical position of the point where pressure is applied to the touchscreen.

0 - pressure register

1 - x position register

2 - y position register

0x37 Row number (0..7) Style Prints buffered characters to a selected display row

Styles are: Character fonts are:

0 - normal 0 - Normal1 (X1250)

1 - inverted normal 1 - Normal2 (CP850)

2 - double 2 - Normal3 (CP850)

3 - inverted double 3 - Italic (X850)

4 - Space (CP437)

*The characters may be printed to display, if there is enough space available in the selected display line. The current y display position is automatically increased by 1 for styles 0 and 1 and by 2 for styles 2 and 3 and when a HEX value is displayed.

ALSO READ:

- Graphics LCD with touchscreen

- Modular Weather Station Project

- Basic circuit for PIC18F4550 to work over USB 2.0

0x36 1 0 .. 1 (colour) Pixel graphics: Draw line from (x1,y1) to (x2,y2)

0x36 2 0 .. 1 Pixel graphics: Draw rectangle from (x1,y1) to (x2,y2) position

0x36 3 0 .. 1 Pixel graphics: Draw box from (x1,y1) to (x2,y2) position

0x34 don't care don't care Display registers contents

0x35 don't care ASCII code Enter a character to the character buffer

0x36 0 0 .. 1 (colour) Pixel graphics: Draw point at (x1,y1) position