This archive contains the source code, make files, etc for "peggy-serial"
Copyright 2008 by Jay Clegg.  All rights reserved.  Released under 
GPl license.

//////////////////////////////////////////////////////////////////////////////
DO NOT USE THIS CODE ON A PEGGY2 THAT HAS NOT BEEN MODIFIED TO SUPPORT IT!!!

This code is designed for a *modified* version of the Peggy 2.0 board sold by 
evilmadscience.com.  If you use this on a normal Peggy 2.0, you may destroy 
something, start a fire, etc.
If you're not prepared to take the time to understand the modifications, 
or to responsibility for ensuring that everything is set up properly, 
you should not use this code, nor modify your Peggy2.  

Sorry, but this is not meant to be an out-of-the-box type of thing.

I am releasing this code and the information for how it works 'as-is' and 
make *NO* guarantees that it will not cause damage to your peggy2, your 
computer, your immediate surroundings, your health, or your sanity.
//////////////////////////////////////////////////////////////////////////////

More information about this project, and an explanation of how to
modify a Peggy 2.0 so that it can run this code can be found here:

http://www.planetclegg.com/projects/QC-Peggy.html

In brief: The modification requires disconnecting the TX/RX AVR pins from the
LED driver chips and connects the SDA/SDL pins in their place.  The web site 
explains the details.

You should be aware that one of the buttons on the right side of the
board may be wired to the SDA pin, so you will *not* want to press that button
after making the modifications.   Bad Things May Happen if you do.  Also,
the two serial headers on the Peggy 2.0 will no longer be wired correct, so 
don't try to use them.

Makefile is included.  you will need avr-gcc to build this project, and you 
will need a AVR programmer that is compatible with AVRDUDE and that supports 
a 6-pin ISP header to load the code.   Sorry, but I couldnt do this with the 
Ardiuno IDE, since it apparently does not support interrupt code.

You should modify the makefile to match the AVR programmer you intend to use.
The values are at the top of the makefile.  You should then be able to do a
'make' followed by a 'make install' to load the code on the chip.

Also included:  A python script that will send a test pattern to a serial 
port, so that you can see if everything is working. You'll need PySerial 
installed, and you'll need to modify the script to match whatever serial 
port you are using.

The Quartz Composer Patch and samples are included in a separate archive.

TROUBLESHOOTING:

A) if the intial test pattern on the Peggy is corrupt:

    1) you may have modified the board incorrectly.  Check your wiring.
    2) your avr-gcc may be different than mine.  This code is very timing 
       sensitive.  I've included a hex of one of my builds, you can try 
       loading it manually and see if that helps. 

B) If the test pattern works, but it won't receive frames (or drops frames 
	sporatically) 
	
	1) try the suggestions 1 & 2 above  as well.  
	    You may have the RX/TX pins reversed,  or the display interrupt may be 
		taking too long, which can cause the serial buffer to 
		overflow, loosing data.  
	2) If it's neither of those things, it may be a problem on the PC/MAC side.  
		Make sure your cabling is good,	and that you're sending the data to 
		the proper port.
	

