﻿ABOUT THE LCDDISPLAY MODULE

The LCDDisplay module provides an interface to the Matrix Orbital emulation mode 
implemented in the #Twatch, the LCD Twitter appliance designed by Dangerous Prototypes 
(http://dangerousprototypes.com/docs/Twatch_networked_LCD).  The #Twatch is based on a Microchip 
PIC 18F67J60 microcontroller with full Ethernet support connected to an HD44780-based
4 line by 20 character display.

David Moisan's SNTPDisplay project is also designed to work with this module.

The #Twatch LCD display connects to an ordinary Ethernet connection and the PowerShell
module connects to the LCD display through the network by running a discovery routine 
based on the MCHP Microchip Discovery Protocol to find the #twatch.  From then on, a set of 
functions is used to enter LCD mode, write characters to the screen, move the cursor and
perform other functions, including custom character definition.

RUNNING THE DEMO

The module comes with a demo routine that exercises all of the functions of the #twatch.  In PowerShell, enter:
Start-LCDDemo

The demo program will run and perform all of the LCD functions.

BASIC PROGRAM FLOW

You’ll perform these basic functions to send text and formatting to the LCD:
    1.	Get the address of the device using find-mchpipdevice
    2.	Connect to the device and get a connection object by using Connect-LCD.
    3.	Stop the clock (or #twatch) display using enter-lcdmode.
    4.	Send text to the LCD with write-lcd.
    5.	Position the cursor with set-lcdposition.
    6.	Resume the clock (or #twatch) display using Exit-LCDmode.
    7.	Finally, close the LCD connection with Close-LCD.

------------“HELLO, WORLD” EXAMPLE---------------
This is a simple example of the canonical “Hello, World” program implemented with the module.

# Hello, World Example
#
Import-module LCDDisplay –erroraction silentlycontinue

# Discover the #twatch’s address.

$display = Find-MCHPIPDevice

# If not found (no #twatch), exit

If ($display –eq $null) {
	Write-error “No #twatch found!”
	Exit
	}
# Otherwise, continue
Else {
	$lcd = Connect-LCD –ipaddress $display.IPAddress
	
	Enter-LCDMode –connection $lcd

    Clear-LCD –connection $lcd

    Set-LCDhome -connection $lcd

	Set-LCDPosition –connection $lcd –row 2 –column 5

	Write-LCD –connection $lcd –textstring “Hello, World!”

	# Pause for 30 seconds

    Sleep 30
	# Exit LCD mode and reenter clock (or #twatch) mode.

	Exit-LCDMode –connection $lcd

	Close-LCD –connection $lcd
	}
# Done!
exit
