import stamp.core.*; /** * Put a one line description of your class here. *
* This comment should contain a description of the class. What it * is for, what it does and how to use it. * * You should rename the class and then save it in a file with * exactly the same name as the class. * * @version 1.0 Date * @author Your Name Here */ public class PocketWatch { static int ss; static int mm; static int hh; static int dd; static int mo; static int yl; static int yh; static Uart rxUart; static Uart txUart; public static void main() { StringBuffer msg = new StringBuffer(512); CPU.setInput(CPU.pin15); CPU.setOutput(CPU.pin14); CPU.setInput(CPU.pin13); rxUart = new Uart(Uart.dirReceive, CPU.pin15, Uart.dontInvert, Uart.speed9600, Uart.stop1); txUart = new Uart(Uart.dirTransmit, CPU.pin14, Uart.dontInvert, Uart.speed9600, Uart.stop1); CPU.writePin(CPU.pin14, true); CPU.delay(10000); //SetTimeCommand txUart.sendByte(0x55); txUart.sendByte(0x00); txUart.sendByte(0x00); txUart.sendByte(0x1E); txUart.sendByte(0x06); txUart.sendByte(0x03); txUart.sendByte(0x06); txUart.sendByte(0x61); //SetAlarmCommand txUart.sendByte(0x55); txUart.sendByte(0x01); txUart.sendByte(0x00); txUart.sendByte(0x1E); txUart.sendByte(0x06); txUart.sendByte(0x03); txUart.sendByte(0x06); txUart.sendByte(0x61); //ReadAlarmCommand txUart.sendByte(0x55); txUart.sendByte(0x03); ss = rxUart.receiveByte(); hh = rxUart.receiveByte(); mm = rxUart.receiveByte(); dd = rxUart.receiveByte(); mo = rxUart.receiveByte(); yl = rxUart.receiveByte(); msg.clear(); msg.append("Alarm: "); msg.append(hh); msg.append(":"); msg.append(mm); msg.append(":"); msg.append(ss); msg.append(" "); msg.append(mo); msg.append("/"); msg.append(dd); msg.append("/"); msg.append(yl); System.out.println(msg.toString()); System.out.println("\n\nDone with AN-501"); } }