Java source code

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
Spamzor
LCD?
Posts: 9
Joined: Sat May 24, 2003 3:58 am
Location: Brisbane Austrailia

Java source code

Post by Spamzor »

I have already emailed MO support about this, and I was emailed some C source code - useless

the java source file linked in the thread above is DEAD.

I have searched for hours and I need someone to help!!!

Spamzor
LCD?
Posts: 9
Joined: Sat May 24, 2003 3:58 am
Location: Brisbane Austrailia

Post by Spamzor »

Common, can someone supply me with some Java source code or not?

Miles
Matrix Orbital
Matrix Orbital
Posts: 1105
Joined: Mon Mar 04, 2002 4:00 pm

Post by Miles »

Hi Spamzor,

Can you please contact me at myero@matrixorbital.ca and I'll see what I can find and send it to you ASAP. I apologize for the delay... :(
Miles Y.
Head of Technical Support
Product Manager
Matrix Orbital

Spamzor
LCD?
Posts: 9
Joined: Sat May 24, 2003 3:58 am
Location: Brisbane Austrailia

Post by Spamzor »

Miles wrote:Hi Spamzor,

Can you please contact me at myero@matrixorbital.ca and I'll see what I can find and send it to you ASAP. I apologize for the delay... :(
I emailed you and I got an email back telling me to look at the javelin source,

that does not help!

I am not programming through javelin??

Tom
Matrix Orbital
Matrix Orbital
Posts: 1030
Joined: Mon Jul 19, 2004 4:43 pm
Location: Calgary
Contact:

Post by Tom »

Hi Spamzor,

Sorry for any late replies. I had to look all over for a java sample. Here it is below. This program will take keypad inputs and display them on the LCD.

/**
* LCDControl.java
*
* Author: Owen Langman (langman@cs.wisc.edu)
*
* Description:
* Basic commands to control a Matrix Orbital (we love MO!)
* LCD screen.
*
* NOTE: This requires the javax.comm package.
* Check java.sun.com
**/

import java.io.*;
import java.util.*;
import javax.comm.*;

/**
* Collection of methods to control a Matrix Orbital LCD.
*
* <p> Bugs: None known.
*
* @author Owen Langman (langman@cs.wisc.edu)
*
**/
public class LCDControl {

private CommPortIdentifier portId;
private SerialPort serialPort;
private OutputStream outputStream;

public static final char COMMAND_START = (char)254;
public static final char COMMAND_NULL = (char)0;
public static final char COMMAND_ETX = (char)3;
public static final char COMMAND_DEL = (char)253;

/**
* Constructor. Uses COM1 as the default port.
*
**/
public LCDControl() {
this(1); //uses com1 with default const.
}

/**
* Constructor. Initializes COM port and resets the LCD.
*
* @param port Interger specifying the COM port to output to.
**/
public LCDControl(int port) {

String portname = new String("COM");
portname += port;
try {
portId = CommPortIdentifier.getPortIdentifier(portname);
} catch (NoSuchPortException ex) {
System.out.println(portname + " does not exist.");
return;
}

try {
serialPort = (SerialPort)portId.open("LCDControl",2000);
} catch (PortInUseException ex) {
System.out.println("Could not open " + portname);
return;
}

try {
serialPort.setSerialPortParams(19200,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException ex) {
System.out.println("Could not set serial stuff");
}

try {
outputStream = serialPort.getOutputStream();
} catch (IOException e) {}

resetLCD();
}

/**
* Resets the lcd in every way possible.
*/
public void resetLCD() {

String resetString;
resetString = new String(COMMAND_START + "B" + COMMAND_NULL +
COMMAND_START + "~" + COMMAND_NULL + COMMAND_START +
"T" + COMMAND_START + "Y" + COMMAND_ETX +
COMMAND_START + "X");
try {
outputStream.write(resetString.getBytes());
} catch (Exception ex) {
System.out.println("Could not reset lcd");
}
}

/**
* Clears the LCD screen.
*/
public void clear() {

String clearString;
clearString = new String(COMMAND_START + "X");
try {
outputStream.write(clearString.getBytes());
} catch (Exception ex) {
System.out.println("Could not clear lcd");
}
}

/**
* Writes a string to the screen at the cursor's current
* position.
*
* @param str String to write to the screen.
*/
public void display_write(String str) {

try {
outputStream.write(str.getBytes());
} catch (Exception ex) {
System.out.println("Could not write to lcd");
}

}

/**
* Changes position of the lcd's cursor.
*
* @param x Horizontal index to move the cursor to
* @param y Line number to move the cursor to
*/
public void display_position(int x, int y) {

String displayString;
displayString = new String(COMMAND_START + "G");

try {
outputStream.write(displayString.getBytes());
outputStream.write(y);
outputStream.write(x);
} catch (Exception ex) {
System.out.println("Could not change cursor position on lcd");
}
}

/**
* Full clear then shutdown of the LCD
*/
public void display_close() {

String clearString, closeString;
clearString = new String(COMMAND_START + "X");
closeString = new String(COMMAND_START + "F");

try {
outputStream.write(clearString.getBytes());
outputStream.write(closeString.getBytes());
} catch (Exception ex) {
System.out.println("Could not close lcd");
}
}
}

Tharos
LCD?
Posts: 2
Joined: Thu Jan 10, 2013 12:52 pm

Re: Java source code

Post by Tharos »

Hi!
I'm looking for an example that send and receive commands or text from the LCD on JAVA but in Linux.
Can anybody help me?

Thanks!

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: Java source code

Post by Clark »

Hi Tharos,

Unfortunately, with so many programming languages and operating systems we don't have a demo for absolutely everything. I would recommend taking a look at our Linux Appnote to determine how to communicate to the display in a Linux environment, and then changing the required methods in the code above over to Linux.

Thanks,
Troy
Troy Clark
Design & Development
Matrix Orbital

Tharos
LCD?
Posts: 2
Joined: Thu Jan 10, 2013 12:52 pm

Re: Java source code

Post by Tharos »

Thanks for your answers Clark!

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: Java source code

Post by Clark »

My pleasure Tharos,

Once you do have your code up and running, don't hesitate to post a little snippet to guide fellow developers. And if you do have any questions, just ask.

Thanks,
Troy
Troy Clark
Design & Development
Matrix Orbital

Dave Osborne
LCD?
Posts: 2
Joined: Thu Jul 11, 2013 9:26 am
Location: Virginia, USA

GLK Java API

Post by Dave Osborne »

We developed a Java API for use with the GLK19264-7T-1U, which we've then used with a product running on Linux.
The API is now a public repo on github, and we'd like to see if other users out there find it useful, and hopefully want to contribute to refining and expanding the API. You can find it at github.com/daveosborne66/lcd
- Dave Osborne
@daveosborne66

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: Java source code

Post by Clark »

Hi Dave,

Your contribution is greatly appreciated; the code appears extensive and well written, an amazing resource for anyone starting Matrix Orbital development in Java.

If possible, we'd love to add an entry for your products in our gallery section, if you have any info/images we could use please shoot me an email.

Thanks again,
Troy
Troy Clark
Design & Development
Matrix Orbital

Post Reply