import stamp.core.CPU; import stamp.core.ScaledTimer16; import stamp.core.Timer; import stamp.core.Uart; import stamp.peripheral.lcd.SerialLCD; import stamp.peripheral.rtc.DS1302; public class SerialLCDTest { static boolean tick=true; public static void main () { System.out.println ("SerialLCDTest.java v1.4"); System.out.println ("Starting ScaledTimer test..."); Timer clock = new Timer(); ScaledTimer16 scaledTimer = new ScaledTimer16 (400, 100); for (int i = 0; i < 1000; i++) { scaledTimer.mark(); for (clock.mark(); !clock.timeout(1000);) ; // wait for one second int ticks = scaledTimer.passedTicks(); int time = scaledTimer.passedTime(); System.out.print(ticks); System.out.print(" ticks. "); System.out.print(time); System.out.print(" ms. "); System.out.println(tick?"tick":"tock"); tick=!tick; } // end for System.out.println ("Starting DS1302 test..."); DS1302 ds1302 = new DS1302 (CPU.pin13, CPU.pin14, CPU.pin0); for (int i = 0; i < 10; i++) { System.out.println (ds1302.readTime(false)); scaledTimer.mark(); for (clock.mark(); !clock.timeout(1000);) ; // wait for one second } // end for System.out.println ("Starting SerialLCD test..."); SerialLCD screen = new SerialLCD(new Uart(Uart.dirTransmit, CPU.pin15, Uart.dontInvert, Uart.speed19200, Uart.stop1)); screen.backLightOn(); screen.blinkOff(); screen.cursorOff(); screen.clearScr(); screen.moveTo(SerialLCD.LINE2, 3); screen.write("Wow! It's working!"); // Keep this one the last test... System.out.println ("Starting CPU test..."); boolean state = true; while (true) { for (int i = 0; i < 4; i++) { switch (i) { case 0: CPU.writePin(CPU.pin1, state); break; case 1: CPU.writePin(CPU.pin2, state); break; case 2: CPU.writePin(CPU.pin3, state); break; case 3: CPU.writePin(CPU.pin4, state); break; } // emd switch scaledTimer.mark(); for (clock.mark(); !clock.timeout(1000);) ; // wait for one second } // end for state = !state; } } }