📄 seriallcd.java
字号:
package etaai.lcd.comm;import etaai.comunicatii.comm.Serial;import etaai.lcd.LCDPort;import javax.comm.*;import java.io.IOException;import etaai.lcd.comm.SerialLCDException;/** * Title: Serial LCD * Description: Comnada display lcd pe seriala * Copyright: Copyright (c) 2001 * Company: ETA AI * @author Mircea Pop * @version 1.0 */public class SerialLCD extends Serial implements LCDPort{ /** * Clasa SerialLCD implementeaza comunicarea cu afisajul LCD Cristalfontz * * @param String portName Numele portului serial la care este legat LCD-ul * @param int baudRate Rata de transfer * @param int bufferSize Dimensiunea stivei de I/O * @throws PortInUseException Portul este folosit de alata aplicatie * @throws NoSuchPortException Numele portului nu e valid * @throws IOException Eroare setare parametrii * @thrwos UnsupportedCommOperationException eroare setare parametrii(parametrii invalizi) * @throws SerialLCDException Eroare LCD */ public SerialLCD(String portName, int baudRate, int bufferSize) throws PortInUseException,NoSuchPortException,IOException,UnsupportedCommOperationException,SerialLCDException { super(portName, bufferSize); initPortSerial(baudRate); } /** * Trimitere la LCD comenzi * @param String lcdData Datele ce se trimit la lcd * @throws SerialLCDException Daca nu s-a reusit trimiterea datelor */ public void sendLCDData(String lcdData) throws SerialLCDException { try { sendSerialData(lcdData); } catch(Exception e) {throw new SerialLCDException("SerialLCD : " + e);} } /** * Trimitere la LCD comenzi * @param int lcdData Datele ce se trimit la lcd * @throws SerialLCDException Daca nu s-a reusit trimiterea datelor */ public void sendLCDData(int lcdData) throws SerialLCDException { try { sendSerialData(lcdData); } catch(Exception e) {throw new SerialLCDException("SerialLCD : " + e);} } /** * Trimitere la LCD comenzi * @param byte[] lcdData Datele ce se trimit la lcd * @throws SerialLCDException Daca nu s-a reusit trimiterea datelor */ public void sendLCDData(byte[] lcdData) throws SerialLCDException { try { sendSerialData(lcdData); } catch(Exception e) {throw new SerialLCDException("SerialLCD : " + e);} } /** * Initializare port serial pentru comunicarea cu afisajul * * @param int baudRate Rata de transfer * @throws SerialLCDException Daca nu s-a putut seta rata de transfer */ private void initPortSerial(int baudRate) throws SerialLCDException { try { setSerialPortParam(baudRate , SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); setFlowControl(0); /*Resetare display*/ resetDisplay(); } catch(Exception e){throw new SerialLCDException("initPortSerial : " + e.toString());} } /** * Resetare display */ public void resetDisplay() { setDTR(false); setRTS(false); try{Thread.currentThread().sleep(1000);}catch(InterruptedException _){} setDTR(true); setRTS(true); } /** * Inchidere port serial */ public void close() { close(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -