Esempio n. 1
0
  /**
   * LCDディスプレイの表示
   *
   * @param mcu
   * @param rs
   * @param ee
   * @param d0
   * @param d1
   * @param d2
   * @param d3
   * @param type LCD機種
   */
  public TextLCD(Mcu mcu, int rs, int ee, int d0, int d1, int d2, int d3, LCDType type) {
    _type = type;
    _mcu = mcu;
    try {
      _rs = new DigitalOut(_mcu, rs);
      _e = new DigitalOut(_mcu, ee);
      _d = new BusOut(_mcu, d0, d1, d2, d3);

      _e.write(1);
      _rs.write(0);

      Thread.sleep(15);

      for (int i = 0; i < 3; i++) {
        writeByte(0x3);
        Thread.sleep(2);
      }
      writeByte(0x2);
      Thread.sleep(1);

      writeCommand(0x28);
      writeCommand(0x0C);
      writeCommand(0x6);
      cls();

    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    } catch (MbedJsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Esempio n. 2
0
 /**
  * コマンドを送る
  *
  * @param command
  */
 void writeCommand(int command) {
   try {
     _rs.write(0);
   } catch (MbedJsException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   writeByte(command);
 }
Esempio n. 3
0
 /**
  * データを送る
  *
  * @param data
  */
 void writeData(int data) {
   try {
     _rs.write(1);
   } catch (MbedJsException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   writeByte(data);
 }
Esempio n. 4
0
 /**
  * 1バイト書き込み
  *
  * @param value
  */
 void writeByte(int value) {
   try {
     _d.write(value >> 4);
     Thread.sleep(1);
     _e.write(0);
     Thread.sleep(1);
     _e.write(1);
     _d.write(value >> 0);
     Thread.sleep(1);
     _e.write(0);
     Thread.sleep(1);
     _e.write(1);
   } catch (MbedJsException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (InterruptedException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }