// The display container PContainer theScreen; // The time display label PLabel theTime; // The Strings for showing the time String theHour = "00"; String theMinute = "00"; String theSecond = "00"; // The time the alarm is set for int alarmHour = 0; int alarmMinute = 51; int alarmSecond = 0; // A boolean that tells the app whether or not it should be going off boolean alarming = false; void setup() { // Instantiate the container theScreen = new PContainer(); // Instantiate the label theTime = new PLabel("00:00:00"); theTime.setBounds(5,5,width,50); // Add the label to the screen theScreen.add(theTime); // Initalize the screen theScreen.initialize(); } void draw() { // If our alarm is going off, change the background color if (!alarming) { background(200); } else { background(255,0,0); } // Get the time // If the hour/minute/second are less than 10, add a zero in front for display if (hour() < 10) { theHour = "0" + hour(); } else { theHour = "" + hour(); } if (minute() < 10) { theMinute = "0" + minute(); } else { theMinute = "" + minute(); } if (second() < 10) { theSecond = "0" + second(); } else { theSecond = "" + second(); } // Check the hour and minute, see if we should be running the alarm if (hour() == alarmHour && minute() == alarmMinute) { alarming = true; } // Set the time label for display theTime.text = theHour + ":" + theMinute + ":" + theSecond; // Draw the screen theScreen.draw(); } void keyPressed() { theScreen.keyPressed(); } void keyReleased() { theScreen.keyReleased(); } void libraryEvent(Object library, int event, Object data) { }