<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://hades.mech.northwestern.edu//index.php?action=history&amp;feed=atom&amp;title=AP_KS_GM-POVInput.java</id>
	<title>AP KS GM-POVInput.java - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://hades.mech.northwestern.edu//index.php?action=history&amp;feed=atom&amp;title=AP_KS_GM-POVInput.java"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=AP_KS_GM-POVInput.java&amp;action=history"/>
	<updated>2026-05-14T23:25:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=AP_KS_GM-POVInput.java&amp;diff=11795&amp;oldid=prev</id>
		<title>Kwang Sim at 09:26, 19 March 2009</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=AP_KS_GM-POVInput.java&amp;diff=11795&amp;oldid=prev"/>
		<updated>2009-03-19T09:26:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:26, 19 March 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;/**********************************************&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;pre&amp;gt;/**********************************************&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * POVController.java&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * pov.c&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * Author:Greg McGlynn&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * Author:Greg McGlynn&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * Persistence-of-Vision Display project&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * Persistence-of-Vision Display project&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * Alexander Park, Kwang Xiong Sim, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Grag&lt;/del&gt; McGlynn&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * Alexander Park, Kwang Xiong Sim, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Greg&lt;/ins&gt; McGlynn&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * ME 333 Mechatronics - Winter 2008&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * ME 333 Mechatronics - Winter 2008&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * Northwestern University&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; * Northwestern University&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kwang Sim</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=AP_KS_GM-POVInput.java&amp;diff=11794&amp;oldid=prev</id>
		<title>Kwang Sim at 09:26, 19 March 2009</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=AP_KS_GM-POVInput.java&amp;diff=11794&amp;oldid=prev"/>
		<updated>2009-03-19T09:26:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;/**********************************************&lt;br /&gt;
 * pov.c&lt;br /&gt;
 * Author:Greg McGlynn&lt;br /&gt;
 * Persistence-of-Vision Display project&lt;br /&gt;
 * Alexander Park, Kwang Xiong Sim, Grag McGlynn&lt;br /&gt;
 * ME 333 Mechatronics - Winter 2008&lt;br /&gt;
 * Northwestern University&lt;br /&gt;
 *&lt;br /&gt;
 *    This code uses the SimpleSerial code found at&lt;br /&gt;
 * http://alumni.media.mit.edu/~benres/simpleserial/&lt;br /&gt;
 * It lets you talk serial from a Java program on a Windows PC.&lt;br /&gt;
 * Java programmers may find this useful for a project.&lt;br /&gt;
 *&lt;br /&gt;
 *    This code runs on a PC and talks through a serial port to&lt;br /&gt;
 * the POV. This code is hacked together, ugly, and uncommented!&lt;br /&gt;
 * Read at your own risk!&lt;br /&gt;
 **********************************************/&lt;br /&gt;
&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.awt.image.*;&lt;br /&gt;
import java.awt.event.*;&lt;br /&gt;
import javax.swing.event.*;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
&lt;br /&gt;
public class POVController extends MouseInputAdapter implements ActionListener, KeyListener, WindowListener&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
	public static void main(String[] args)&lt;br /&gt;
	{&lt;br /&gt;
                //initialization necessary to accept keyboard input (very long functions), not shown&lt;br /&gt;
		init();&lt;br /&gt;
		init2();&lt;br /&gt;
		init3();&lt;br /&gt;
		init4();&lt;br /&gt;
&lt;br /&gt;
		new POVController().run();&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	InputStream serIn;&lt;br /&gt;
	OutputStream serOut; //we talk to the display with this&lt;br /&gt;
&lt;br /&gt;
        //the image:&lt;br /&gt;
        boolean[][] leds = new boolean[width][height];&lt;br /&gt;
&lt;br /&gt;
        //user interface stuff:&lt;br /&gt;
	final int px = 6;&lt;br /&gt;
	final int width = 193;&lt;br /&gt;
	final int height = 14;&lt;br /&gt;
&lt;br /&gt;
	final int offX = 10;&lt;br /&gt;
	final int offY = 100;&lt;br /&gt;
&lt;br /&gt;
	Checkbox eraseCheckbox;&lt;br /&gt;
	Button clearButton;&lt;br /&gt;
	Button refreshButton;&lt;br /&gt;
	Button dumpButton;&lt;br /&gt;
	Button invertButton;&lt;br /&gt;
&lt;br /&gt;
	static int[][][] ascii = new int[255][][];&lt;br /&gt;
&lt;br /&gt;
	public void run()&lt;br /&gt;
	{&lt;br /&gt;
&lt;br /&gt;
		setupComPort();&lt;br /&gt;
&lt;br /&gt;
		Frame f = new Frame(&amp;quot;POV Display Controller&amp;quot;);&lt;br /&gt;
		f.setSize(width*px+offX*2, height*px + offY + 20);&lt;br /&gt;
		f.setLayout(new FlowLayout());&lt;br /&gt;
&lt;br /&gt;
		f.addMouseListener(this);&lt;br /&gt;
		f.addMouseMotionListener(this);&lt;br /&gt;
		f.addKeyListener(this);&lt;br /&gt;
&lt;br /&gt;
                eraseCheckbox = new Checkbox(&amp;quot;Erase?&amp;quot;);&lt;br /&gt;
		f.add(eraseCheckbox);&lt;br /&gt;
&lt;br /&gt;
		clearButton = new Button(&amp;quot;Clear Display&amp;quot;);&lt;br /&gt;
		clearButton.addActionListener(this);&lt;br /&gt;
		f.add(clearButton);&lt;br /&gt;
&lt;br /&gt;
		refreshButton = new Button(&amp;quot;Refresh (if the image isn&amp;#039;t appearing)&amp;quot;);&lt;br /&gt;
		refreshButton.addActionListener(this);&lt;br /&gt;
		f.add(refreshButton);&lt;br /&gt;
&lt;br /&gt;
                dumpButton = new Button(&amp;quot;Dump code&amp;quot;);&lt;br /&gt;
		dumpButton.addActionListener(this);&lt;br /&gt;
		//f.add(dumpButton);&lt;br /&gt;
&lt;br /&gt;
		invertButton = new Button(&amp;quot;Invert pixels&amp;quot;);&lt;br /&gt;
		invertButton.addActionListener(this);&lt;br /&gt;
		f.add(invertButton);&lt;br /&gt;
&lt;br /&gt;
		f.setVisible(true);&lt;br /&gt;
		f.addWindowListener(this);&lt;br /&gt;
		f.requestFocus();&lt;br /&gt;
&lt;br /&gt;
		BufferedImage im = new BufferedImage(width*px+1, height*px+1, BufferedImage.TYPE_INT_RGB);&lt;br /&gt;
		Graphics g = im.getGraphics();&lt;br /&gt;
		g.setColor(Color.white);&lt;br /&gt;
		g.fillRect(0, 0, width*px, height*px);&lt;br /&gt;
		g.setColor(Color.black);&lt;br /&gt;
		for(int x = 0; x &amp;lt;=  width*px; x += px) g.drawLine(x, 0, x, height*px);&lt;br /&gt;
		for(int y = 0; y &amp;lt;= height*px; y += px) g.drawLine(0, y,  width*px, y);&lt;br /&gt;
&lt;br /&gt;
		while(true)&lt;br /&gt;
		{&lt;br /&gt;
&lt;br /&gt;
			for(int x = 0; x &amp;lt; width; x += 1)&lt;br /&gt;
			{&lt;br /&gt;
				for(int y = 0; y &amp;lt; height; y += 1)&lt;br /&gt;
				{&lt;br /&gt;
					if(leds[x][y]) g.setColor(Color.red);&lt;br /&gt;
					else           g.setColor(Color.white);&lt;br /&gt;
&lt;br /&gt;
					g.fillRect(x*px+2, y*px+2, px-3, px-3);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			f.getGraphics().drawImage(im, offX, offY, f);&lt;br /&gt;
			f.requestFocus();&lt;br /&gt;
			try { Thread.sleep(20); }&lt;br /&gt;
			catch(Exception e) {}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
        void setupComPort() {&lt;br /&gt;
                System.out.print(&amp;quot;PLEASE ENTER A COM PORT NUMBER: &amp;quot;);&lt;br /&gt;
                try {&lt;br /&gt;
                    int com = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in)).readLine());&lt;br /&gt;
                    if(tryComPort(com)) return;&lt;br /&gt;
                    else System.out.println(&amp;quot;That com port doesn&amp;#039;t seem to work! :(&amp;quot;);&lt;br /&gt;
                } catch(Exception e) {&lt;br /&gt;
                    e.printStackTrace();&lt;br /&gt;
                    System.out.println(&amp;quot;Sorry, there was some kind of error! :(&amp;quot;);&lt;br /&gt;
                }&lt;br /&gt;
                System.out.println(&amp;quot;Press any key to exit...&amp;quot;);&lt;br /&gt;
                try {&lt;br /&gt;
                    System.in.read();&lt;br /&gt;
                    System.in.read();&lt;br /&gt;
                } catch(Exception e) {}&lt;br /&gt;
                System.exit(0);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        boolean tryComPort(int com) {&lt;br /&gt;
                SimpleSerial ss = new SimpleSerialNative(com /*com port!*/);&lt;br /&gt;
                serIn = ss.getInputStream();&lt;br /&gt;
		serOut = ss.getOutputStream();&lt;br /&gt;
&lt;br /&gt;
		return (serIn != null &amp;amp;&amp;amp; serOut != null);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	int lastX, lastY;&lt;br /&gt;
&lt;br /&gt;
	int ledX(int mouseX)&lt;br /&gt;
	{&lt;br /&gt;
		return (mouseX - offX)/px;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int ledY(int mouseY)&lt;br /&gt;
	{&lt;br /&gt;
		return (mouseY - offY)/px;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	boolean inBounds(int x, int y)&lt;br /&gt;
	{&lt;br /&gt;
		return (x &amp;gt;= 0 &amp;amp;&amp;amp; y &amp;gt;= 0 &amp;amp;&amp;amp; x &amp;lt; width &amp;amp;&amp;amp; y &amp;lt; height);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	void set(int x, int y, boolean state)&lt;br /&gt;
	{&lt;br /&gt;
		if(inBounds(x, y)) leds[x][y] = state;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	public void mousePressed(MouseEvent e)&lt;br /&gt;
	{&lt;br /&gt;
		lastX = ledX(e.getX());&lt;br /&gt;
		lastY = ledY(e.getY());&lt;br /&gt;
		boolean state = !eraseCheckbox.getState();&lt;br /&gt;
		set(lastX, lastY, state);&lt;br /&gt;
		updateColumn(lastX);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public void mouseDragged(MouseEvent e)&lt;br /&gt;
	{&lt;br /&gt;
		int newX = ledX(e.getX());&lt;br /&gt;
		int newY = ledY(e.getY());&lt;br /&gt;
&lt;br /&gt;
		if(newX == lastX &amp;amp;&amp;amp; newY == lastY) return;&lt;br /&gt;
&lt;br /&gt;
		boolean state = !eraseCheckbox.getState();&lt;br /&gt;
		double dist = Math.sqrt((newX-lastX)*(newX-lastX) + (newY-lastY)*(newY-lastY));&lt;br /&gt;
		double dx = (newX - lastX)/dist/10;&lt;br /&gt;
		double dy = (newY - lastY)/dist/10;&lt;br /&gt;
		for(int i = 0; i &amp;lt; dist*10; i++)&lt;br /&gt;
		{&lt;br /&gt;
			int x = (int)(lastX + dx*i);&lt;br /&gt;
			int y = (int)(lastY + dy*i);&lt;br /&gt;
			set(x, y, state);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		int startCol = (newX &amp;lt; lastX ? newX : lastX);&lt;br /&gt;
		int endCol   = (newX &amp;gt; lastX ? newX : lastX);&lt;br /&gt;
		for(int col = startCol; col &amp;lt;= endCol; col += 1)&lt;br /&gt;
		{&lt;br /&gt;
			updateColumn(col);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		lastX = newX;&lt;br /&gt;
		lastY = newY;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	void updateColumn(int x)&lt;br /&gt;
	{&lt;br /&gt;
		byte byte1 = (byte)(x &amp;gt;&amp;gt; 8);&lt;br /&gt;
		byte byte2 = (byte)(x &amp;amp; 255);&lt;br /&gt;
		byte byte3 = 0, byte4 = 0;&lt;br /&gt;
&lt;br /&gt;
		//here we assume height = 14&lt;br /&gt;
		for(int y = 0; y &amp;lt; 7; y += 1)&lt;br /&gt;
		{&lt;br /&gt;
			if(leds[x][y]) byte4 |= (1 &amp;lt;&amp;lt; y);&lt;br /&gt;
		}&lt;br /&gt;
		for(int y = 7; y &amp;lt; 14; y += 1)&lt;br /&gt;
		{&lt;br /&gt;
			if(leds[x][y]) byte3 |= (1 &amp;lt;&amp;lt; (y-7));&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
			serOut.write(byte1);&lt;br /&gt;
			serOut.write(byte2);&lt;br /&gt;
			serOut.write(byte3);&lt;br /&gt;
			serOut.write(byte4);&lt;br /&gt;
			try { Thread.sleep(5); }&lt;br /&gt;
			catch(Exception e) {}&lt;br /&gt;
		}&lt;br /&gt;
		catch(Exception e)&lt;br /&gt;
		{&lt;br /&gt;
			e.printStackTrace();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	final byte CLEAR = 0x00;&lt;br /&gt;
&lt;br /&gt;
	void sendCommand(byte command)&lt;br /&gt;
	{&lt;br /&gt;
		try&lt;br /&gt;
		{&lt;br /&gt;
			serOut.write(0xff);&lt;br /&gt;
			serOut.write(0xff);&lt;br /&gt;
			serOut.write(0x00);&lt;br /&gt;
			serOut.write(command);&lt;br /&gt;
		}&lt;br /&gt;
		catch(Exception e)&lt;br /&gt;
		{&lt;br /&gt;
			e.printStackTrace();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public void actionPerformed(ActionEvent e)&lt;br /&gt;
	{&lt;br /&gt;
		if(e.getSource() == clearButton)&lt;br /&gt;
		{&lt;br /&gt;
			for(int x = 0; x &amp;lt; width; x += 1)&lt;br /&gt;
			{&lt;br /&gt;
				for(int y = 0; y &amp;lt; height; y += 1)&lt;br /&gt;
				{&lt;br /&gt;
					leds[x][y] = false;&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
			sendCommand(CLEAR);&lt;br /&gt;
		}&lt;br /&gt;
		else if(e.getSource() == refreshButton)&lt;br /&gt;
		{&lt;br /&gt;
			for(int x = 0; x &amp;lt; width; x++)&lt;br /&gt;
			{&lt;br /&gt;
				updateColumn(x);&lt;br /&gt;
				try { Thread.sleep(5); } &lt;br /&gt;
				catch(Exception ex) {}&lt;br /&gt;
			}&lt;br /&gt;
		} &lt;br /&gt;
		else if(e.getSource() == dumpButton) &lt;br /&gt;
		{&lt;br /&gt;
			try &lt;br /&gt;
			{ &lt;br /&gt;
				FileWriter fw = new FileWriter(new File(&amp;quot;dump.txt&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
				for(int x = 0; x &amp;lt; width; x++) &lt;br /&gt;
				{&lt;br /&gt;
					fw.write(&amp;quot;pixels[&amp;quot; + x + &amp;quot;][1] = 0b0&amp;quot;);&lt;br /&gt;
					for(int y = 6; y &amp;gt;= 0; y--) fw.write(leds[x][y] ? &amp;quot;1&amp;quot; : &amp;quot;0&amp;quot;); &lt;br /&gt;
					fw.write(&amp;quot;;\r\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
					fw.write(&amp;quot;pixels[&amp;quot; + x + &amp;quot;][0] = 0b0&amp;quot;);&lt;br /&gt;
					for(int y = 13; y &amp;gt;= 7; y--) fw.write(leds[x][y] ? &amp;quot;1&amp;quot; : &amp;quot;0&amp;quot;);&lt;br /&gt;
					fw.write(&amp;quot;;\r\n&amp;quot;);&lt;br /&gt;
				}&lt;br /&gt;
&lt;br /&gt;
				fw.flush();&lt;br /&gt;
				fw.close();&lt;br /&gt;
			} &lt;br /&gt;
			catch(Exception ex) {}&lt;br /&gt;
		} &lt;br /&gt;
		else if(e.getSource() == invertButton) {&lt;br /&gt;
			for(int x = 0; x &amp;lt; width; x++) &lt;br /&gt;
			{&lt;br /&gt;
				for(int y = 0; y &amp;lt; 14; y++) &lt;br /&gt;
				{&lt;br /&gt;
					leds[x][y] = !leds[x][y];&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	int asciiCursor = 0;&lt;br /&gt;
	int asciiWidth = 10, asciiHeight = 14;&lt;br /&gt;
	public void keyPressed(KeyEvent e) &lt;br /&gt;
	{&lt;br /&gt;
		&lt;br /&gt;
		char c = e.getKeyChar();&lt;br /&gt;
		if(c &amp;gt;= &amp;#039; &amp;#039; &amp;amp;&amp;amp; c &amp;lt;= &amp;#039;~&amp;#039; &amp;amp;&amp;amp; asciiCursor + asciiWidth &amp;lt; width) &lt;br /&gt;
		{&lt;br /&gt;
			for(int x = 0; x &amp;lt; asciiWidth; x++)&lt;br /&gt;
			{&lt;br /&gt;
				for(int y = 0; y &amp;lt; asciiHeight; y++) &lt;br /&gt;
				{&lt;br /&gt;
					leds[asciiCursor + x][y] |= (ascii[c][y][x] == 1);&lt;br /&gt;
				}&lt;br /&gt;
				updateColumn(x);&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			asciiCursor += asciiWidth;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		if(e.getKeyCode() == KeyEvent.VK_BACK_SPACE) &lt;br /&gt;
		{&lt;br /&gt;
			if(asciiCursor &amp;gt;= asciiWidth) &lt;br /&gt;
			{&lt;br /&gt;
				asciiCursor -= asciiWidth;&lt;br /&gt;
				for(int x = 0; x &amp;lt; asciiWidth; x++)&lt;br /&gt;
				{&lt;br /&gt;
					for(int y = 0; y &amp;lt; asciiHeight; y++) &lt;br /&gt;
					{&lt;br /&gt;
						leds[asciiCursor + x][y] = false;&lt;br /&gt;
					}&lt;br /&gt;
					updateColumn(x);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	public void keyReleased(KeyEvent e) {}&lt;br /&gt;
	public void keyTyped(KeyEvent e) {}&lt;br /&gt;
&lt;br /&gt;
	public void windowActivated(WindowEvent e) {}&lt;br /&gt;
	public void windowClosed(WindowEvent e) {}&lt;br /&gt;
	public void windowClosing(WindowEvent e) { System.exit(0); }&lt;br /&gt;
	public void windowDeactivated(WindowEvent e) {}&lt;br /&gt;
	public void windowDeiconified(WindowEvent e) {}&lt;br /&gt;
	public void windowIconified(WindowEvent e) {}&lt;br /&gt;
	public void windowOpened(WindowEvent e) {}&lt;br /&gt;
																																																	  &lt;br /&gt;
&lt;br /&gt;
//...init# functions omitted (these just initialize ascii[][][])&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwang Sim</name></author>
	</entry>
</feed>